sc/inc/document.hxx                         |    1 
 sc/inc/fillinfo.hxx                         |    2 
 sc/inc/patattr.hxx                          |   16 +-
 sc/inc/tablestyle.hxx                       |   71 +++++-----
 sc/source/core/data/column2.cxx             |    3 
 sc/source/core/data/documen4.cxx            |   27 +++
 sc/source/core/data/fillinfo.cxx            |    6 
 sc/source/core/data/patattr.cxx             |  194 ++++++++++++++++------------
 sc/source/core/data/tablestyle.cxx          |   83 +++++++++++
 sc/source/filter/excel/xestyle.cxx          |    2 
 sc/source/filter/inc/defaulttablestyles.hxx |    2 
 sc/source/filter/inc/stylesbuffer.hxx       |    2 
 sc/source/filter/oox/defaulttablestyles.cxx |   19 ++
 sc/source/filter/oox/stylesbuffer.cxx       |    8 +
 sc/source/ui/inc/output.hxx                 |    5 
 sc/source/ui/view/cellsh1.cxx               |    4 
 sc/source/ui/view/output2.cxx               |   49 ++++---
 17 files changed, 357 insertions(+), 137 deletions(-)

New commits:
commit 365cdb242f2812292b5b2fec854b25f389d6787f
Author:     Balazs Varga <[email protected]>
AuthorDate: Wed Oct 8 08:16:38 2025 +0200
Commit:     Balazs Varga <[email protected]>
CommitDate: Thu Jan 29 09:27:35 2026 +0100

    Support Font styles in Table styles
    
    Only Font Weight and Font Color are used in the default Table styles
    Individual cells of Table Font styles can be overwritten by direct cell
    font attributes which can be overwritten by Cond formats.
    
    cherry-pick from: 2c317e5fcad18877310a0da2db710b076ef0be7a
    
    Change-Id: I7c8d78bbff8be51b136b746ac71d490bf1077601
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/192470
    Reviewed-by: Balazs Varga <[email protected]>
    Tested-by: Balazs Varga <[email protected]>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/193674
    Reviewed-by: Andras Timar <[email protected]>
    Tested-by: Andras Timar <[email protected]>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/196742
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/197968
    Tested-by: Jenkins

diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 3be6cfd1202f..f80742a0dd1e 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -1902,6 +1902,7 @@ public:
     SC_DLLPUBLIC const ScPatternAttr*       GetMostUsedPattern( SCCOL nCol, 
SCROW nStartRow, SCROW nEndRow, SCTAB nTab ) const;
     const ScPatternAttr*                    GetSelectionPattern( const 
ScMarkData& rMark );
     std::unique_ptr<ScPatternAttr>          CreateSelectionPattern( const 
ScMarkData& rMark, bool bDeep = true );
+    SC_DLLPUBLIC const SfxItemSet*          GetTableFormatSet( SCCOL nCol, 
SCROW nRow, SCTAB nTab ) const;
     SC_DLLPUBLIC void                       AddCondFormatData( const 
ScRangeList& rRange, SCTAB nTab, sal_uInt32 nIndex );
     void                                    RemoveCondFormatData( const 
ScRangeList& rRange, SCTAB nTab, sal_uInt32 nIndex );
 
diff --git a/sc/inc/fillinfo.hxx b/sc/inc/fillinfo.hxx
index de66e7a370e2..cc249c6bcafe 100644
--- a/sc/inc/fillinfo.hxx
+++ b/sc/inc/fillinfo.hxx
@@ -116,6 +116,7 @@ struct ScCellInfo
     ScCellInfo()
         : pPatternAttr(nullptr)
         , pConditionSet(nullptr)
+        , pTableFormatSet(nullptr)
         , pDataBar(nullptr)
         , pIconSet(nullptr)
         , maBackground()
@@ -151,6 +152,7 @@ struct ScCellInfo
 
     const ScPatternAttr*        pPatternAttr;
     const SfxItemSet*           pConditionSet;
+    const SfxItemSet*           pTableFormatSet;
     std::optional<Color>        mxColorScale;
     const ScDataBarInfo*        pDataBar;
     const ScIconSetInfo*        pIconSet;
diff --git a/sc/inc/patattr.hxx b/sc/inc/patattr.hxx
index cc7f6442065b..0bf555bdaa93 100644
--- a/sc/inc/patattr.hxx
+++ b/sc/inc/patattr.hxx
@@ -187,6 +187,7 @@ public:
                                         const OutputDevice* pOutDev = nullptr,
                                         const Fraction* pScale = nullptr,
                                         const SfxItemSet* pCondSet = nullptr,
+                                        const SfxItemSet* pTableSet = nullptr,
                                         SvtScriptType nScript = 
SvtScriptType::NONE);
 
     static void fillFont( vcl::Font& rFont, const SfxItemSet& rItemSet,
@@ -194,6 +195,7 @@ public:
                                         const OutputDevice* pOutDev = nullptr,
                                         const Fraction* pScale = nullptr,
                                         const SfxItemSet* pCondSet = nullptr,
+                                        const SfxItemSet* pTableSet = nullptr,
                                         SvtScriptType nScript = 
SvtScriptType::NONE, const Color* pBackConfigColor = nullptr,
                                         const Color* pTextConfigColor = 
nullptr);
 
@@ -201,6 +203,7 @@ public:
                             const SfxItemSet& rItemSet,
                             ScAutoFontColorMode eAutoMode,
                             const SfxItemSet* pCondSet = nullptr,
+                            const SfxItemSet* pTableSet = nullptr,
                             const Color* pBackConfigColor = nullptr,
                             const Color* pTextConfigColor = nullptr);
 
@@ -210,19 +213,21 @@ public:
     void fillColor(model::ComplexColor& rComplexColor,
                     ScAutoFontColorMode eAutoMode,
                     const SfxItemSet* pCondSet = nullptr,
+                    const SfxItemSet* pTableSet = nullptr,
                     const Color* pBackConfigColor = nullptr,
                     const Color* pTextConfigColor = nullptr) const
     {
-        fillColor(rComplexColor, maLocalSfxItemSet, eAutoMode, pCondSet, 
pBackConfigColor, pTextConfigColor);
+        fillColor(rComplexColor, maLocalSfxItemSet, eAutoMode, pCondSet, 
pTableSet, pBackConfigColor, pTextConfigColor);
     }
 
     void fillFontOnly(vcl::Font& rFont,
                     const OutputDevice* pOutDev = nullptr,
                     const Fraction* pScale = nullptr,
                     const SfxItemSet* pCondSet = nullptr,
+                    const SfxItemSet* pTableSet = nullptr,
                     SvtScriptType nScript = SvtScriptType::NONE) const
     {
-        fillFontOnly(rFont, maLocalSfxItemSet, pOutDev, pScale, pCondSet, 
nScript);
+        fillFontOnly(rFont, maLocalSfxItemSet, pOutDev, pScale, pCondSet, 
pTableSet, nScript);
     }
 
     /** Fills a font object from the own item set. */
@@ -230,17 +235,18 @@ public:
                     const OutputDevice* pOutDev = nullptr,
                     const Fraction* pScale = nullptr,
                     const SfxItemSet* pCondSet = nullptr,
+                    const SfxItemSet* pTableSet = nullptr,
                     SvtScriptType nScript = SvtScriptType::NONE,
                     const Color* pBackConfigColor = nullptr,
                     const Color* pTextConfigColor = nullptr) const
     {
-        fillFont(rFont, maLocalSfxItemSet, eAutoMode, pOutDev, pScale, 
pCondSet, nScript, pBackConfigColor, pTextConfigColor);
+        fillFont(rFont, maLocalSfxItemSet, eAutoMode, pOutDev, pScale, 
pCondSet, pTableSet, nScript, pBackConfigColor, pTextConfigColor);
     }
 
     /** Converts all Calc items contained in rSrcSet to edit engine items and 
puts them into rEditSet. */
-    SC_DLLPUBLIC static void             FillToEditItemSet( SfxItemSet& 
rEditSet, const SfxItemSet& rSrcSet, const SfxItemSet* pCondSet = nullptr );
+    SC_DLLPUBLIC static void             FillToEditItemSet( SfxItemSet& 
rEditSet, const SfxItemSet& rSrcSet, const SfxItemSet* pCondSet = nullptr, 
const SfxItemSet* pTableSet = nullptr );
     /** Converts all Calc items contained in the own item set to edit engine 
items and puts them into pEditSet. */
-    SC_DLLPUBLIC void                    FillEditItemSet( SfxItemSet* 
pEditSet, const SfxItemSet* pCondSet = nullptr ) const;
+    SC_DLLPUBLIC void                    FillEditItemSet( SfxItemSet* 
pEditSet, const SfxItemSet* pCondSet = nullptr, const SfxItemSet* pTableSet = 
nullptr ) const;
 
     /** Converts all edit engine items contained in rEditSet to Calc items and 
puts them into rDestSet. */
     SC_DLLPUBLIC static void             GetFromEditItemSet( SfxItemSet& 
rDestSet, const SfxItemSet& rEditSet );
diff --git a/sc/inc/tablestyle.hxx b/sc/inc/tablestyle.hxx
index fd39336e71a1..e14bbb486aaf 100644
--- a/sc/inc/tablestyle.hxx
+++ b/sc/inc/tablestyle.hxx
@@ -173,6 +173,9 @@ public:
         return nullptr;
     }
 
+    const SfxItemSet* GetTableCellItemSet(const ScDBData& rDBData, SCCOL nCol, 
SCROW nRow,
+                                          SCROW nRowIndex) const;
+
     void SetRowStripeSize(sal_Int32 nFirstRowStripeSize, sal_Int32 
nSecondRowStripeSize);
     void SetColStripeSize(sal_Int32 nFirstColStripeSize, sal_Int32 
nSecondColStripeSize);
 
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index 4347c524efa6..036b9eb3db0d 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -285,7 +285,8 @@ tools::Long ScColumn::GetNeededSize(
         vcl::Font aFont;
         aFont.SetKerning(FontKerning::NONE); // like 
ScDrawStringsVars::SetPattern
         // font color doesn't matter here
-        pPattern->fillFontOnly(aFont, pDev, &aFontZoom, pCondSet, nScript);
+        const SfxItemSet* pTableSet = rDocument.GetTableFormatSet( nCol, nRow, 
nTab );
+        pPattern->fillFontOnly(aFont, pDev, &aFontZoom, pCondSet, pTableSet, 
nScript);
         pDev->SetFont(aFont);
     }
 
diff --git a/sc/source/core/data/documen4.cxx b/sc/source/core/data/documen4.cxx
index a2d31ef7d3ed..b0664bcae0ed 100644
--- a/sc/source/core/data/documen4.cxx
+++ b/sc/source/core/data/documen4.cxx
@@ -29,6 +29,7 @@
 #include <document.hxx>
 #include <docsh.hxx>
 #include <table.hxx>
+#include <dbdata.hxx>
 #include <globstr.hrc>
 #include <scresid.hxx>
 #include <subtotal.hxx>
@@ -47,6 +48,7 @@
 #include <externalrefmgr.hxx>
 #include <attrib.hxx>
 #include <formulacell.hxx>
+#include <tablestyle.hxx>
 #include <tokenarray.hxx>
 #include <tokenstringcontext.hxx>
 #include <memory>
@@ -791,6 +793,31 @@ const SfxPoolItem* ScDocument::GetEffItem(
     return nullptr;
 }
 
+const SfxItemSet* ScDocument::GetTableFormatSet(SCCOL nCol, SCROW nRow, SCTAB 
nTab) const
+{
+    const ScDBData* pDBData = GetDBAtCursor(nCol, nRow, nTab, 
ScDBDataPortion::AREA);
+    if (pDBData)
+    {
+        const ScTableStyleParam* pTableStyleInfo = 
pDBData->GetTableStyleInfo();
+        if (!pTableStyleInfo)
+            return nullptr;
+
+        const ScTableStyle* pTableStyle = 
mpTableStyles->GetTableStyle(pTableStyleInfo->maStyleName);
+        if (!pTableStyle)
+            return nullptr;
+
+        SCROW nNonEmptyRowsBeforePaintRange = 
-static_cast<SCROW>(pDBData->HasHeader());
+        ScRange aDBRange;
+        pDBData->GetArea(aDBRange);
+        if (aDBRange.aStart.Row() < nRow)
+        {
+            nNonEmptyRowsBeforePaintRange += 
this->CountNonFilteredRows(aDBRange.aStart.Row(), nRow - 1, nTab);
+        }
+        return pTableStyle->GetTableCellItemSet(*pDBData, nCol, nRow, 
nNonEmptyRowsBeforePaintRange);
+    }
+    return nullptr;
+}
+
 const SfxItemSet* ScDocument::GetCondResult( SCCOL nCol, SCROW nRow, SCTAB 
nTab, ScRefCellValue* pCell ) const
 {
     ScConditionalFormatList* pFormatList = GetCondFormList(nTab);
diff --git a/sc/source/core/data/fillinfo.cxx b/sc/source/core/data/fillinfo.cxx
index b86a4ac67089..6a83e242db88 100644
--- a/sc/source/core/data/fillinfo.cxx
+++ b/sc/source/core/data/fillinfo.cxx
@@ -458,6 +458,12 @@ void ScDocument::FillInfo(
                 {
                     pInfo->pLinesAttr = pLinesAttr;
                 }
+
+                const SfxItemSet* pPoolItem = 
pTableStyle->GetTableCellItemSet(*pDBData, nCol, nRow, nRowIndex);
+                if (pPoolItem)
+                {
+                    pInfo->pTableFormatSet = pPoolItem;
+                }
             }
 
             ++nRowIndex;
diff --git a/sc/source/core/data/patattr.cxx b/sc/source/core/data/patattr.cxx
index 094128fc66e0..d3532ebb7ff8 100644
--- a/sc/source/core/data/patattr.cxx
+++ b/sc/source/core/data/patattr.cxx
@@ -555,23 +555,56 @@ void getFontIDsByScriptType(SvtScriptType nScript,
 void ScPatternAttr::fillFont(
         vcl::Font& rFont, const SfxItemSet& rItemSet, ScAutoFontColorMode 
eAutoMode,
         const OutputDevice* pOutDev, const Fraction* pScale,
-        const SfxItemSet* pCondSet, SvtScriptType nScript,
+        const SfxItemSet* pCondSet, const SfxItemSet* pTableSet, SvtScriptType 
nScript,
         const Color* pBackConfigColor, const Color* pTextConfigColor)
 {
     model::ComplexColor aComplexColor;
 
     //  determine effective font color
-    ScPatternAttr::fillFontOnly(rFont, rItemSet, pOutDev, pScale, pCondSet, 
nScript);
-    ScPatternAttr::fillColor(aComplexColor, rItemSet, eAutoMode, pCondSet, 
pBackConfigColor, pTextConfigColor);
+    ScPatternAttr::fillFontOnly(rFont, rItemSet, pOutDev, pScale, pCondSet, 
pTableSet, nScript);
+    ScPatternAttr::fillColor(aComplexColor, rItemSet, eAutoMode, pCondSet, 
pTableSet, pBackConfigColor, pTextConfigColor);
 
     //  set font effects
     rFont.SetColor(aComplexColor.getFinalColor());
 }
 
+template <class T>
+static const T* lcl_populateresult( TypedWhichId<T> nWhich, const SfxItemSet& 
rSrcSet, const SfxItemSet* pCondSet, const SfxItemSet* pTableSet = nullptr )
+{
+    const T* pItem = nullptr;
+
+    if (pCondSet)
+        pItem = pCondSet->GetItemIfSet(nWhich);
+
+    if (!pItem && pTableSet)
+    {
+        const SfxPoolItem* pThisItem;
+        if (rSrcSet.GetItemState(nWhich, false, &pThisItem) == 
SfxItemState::SET
+            && *pThisItem != 
rSrcSet.GetPool()->GetUserOrPoolDefaultItem(nWhich))
+        {
+            // use the direct cell format value againts the Table style format
+            // if it not a default one (COL_BLACK is the default in case of 
Table Styles)
+            // on the cell level
+            if (sal_uInt16(nWhich) == ATTR_FONT_COLOR
+                && rSrcSet.GetItem(ATTR_FONT_COLOR)->getColor() == COL_BLACK)
+                pItem = pTableSet->GetItemIfSet(nWhich);
+            else
+                pItem = &rSrcSet.Get(nWhich);
+        }
+        else
+            pItem = pTableSet->GetItemIfSet(nWhich);
+    }
+
+    if (!pItem)
+        pItem = &rSrcSet.Get(nWhich);
+
+    return pItem;
+}
+
 void ScPatternAttr::fillFontOnly(
         vcl::Font& rFont, const SfxItemSet& rItemSet,
         const OutputDevice* pOutDev, const Fraction* pScale,
-        const SfxItemSet* pCondSet, SvtScriptType nScript)
+        const SfxItemSet* pCondSet, const SfxItemSet* pTableSet, SvtScriptType 
nScript)
 {
     // Read items
 
@@ -598,18 +631,12 @@ void ScPatternAttr::fillFontOnly(
 
     if (pCondSet)
     {
-        pFontAttr = pCondSet->GetItemIfSet( nFontId );
-        if ( !pFontAttr )
-            pFontAttr = &rItemSet.Get( nFontId );
+        pFontAttr = lcl_populateresult( nFontId, rItemSet, pCondSet, pTableSet 
);
 
-        const SvxFontHeightItem* pFontHeightItem = pCondSet->GetItemIfSet( 
nHeightId );
-        if ( !pFontHeightItem )
-            pFontHeightItem = &rItemSet.Get( nHeightId );
+        const SvxFontHeightItem* pFontHeightItem = lcl_populateresult( 
nHeightId, rItemSet, pCondSet, pTableSet );
         nFontHeight = pFontHeightItem->GetHeight();
 
-        const SvxWeightItem* pFontHWeightItem = pCondSet->GetItemIfSet( 
nWeightId );
-        if ( !pFontHWeightItem )
-            pFontHWeightItem = &rItemSet.Get( nWeightId );
+        const SvxWeightItem* pFontHWeightItem = lcl_populateresult( nWeightId, 
rItemSet, pCondSet, pTableSet );
         eWeight = pFontHWeightItem->GetValue();
 
         const SvxPostureItem* pPostureItem = pCondSet->GetItemIfSet( 
nPostureId );
@@ -664,9 +691,14 @@ void ScPatternAttr::fillFontOnly(
     }
     else    // Everything from rItemSet
     {
-        pFontAttr = &rItemSet.Get( nFontId );
-        nFontHeight = rItemSet.Get( nHeightId ).GetHeight();
-        eWeight = rItemSet.Get( nWeightId ).GetValue();
+        pFontAttr = lcl_populateresult( nFontId, rItemSet, pCondSet, pTableSet 
);
+
+        const SvxFontHeightItem* pFontHeightItem = lcl_populateresult( 
nHeightId, rItemSet, pCondSet, pTableSet );
+        nFontHeight = pFontHeightItem->GetHeight();
+
+        const SvxWeightItem* pFontHWeightItem = lcl_populateresult( nWeightId, 
rItemSet, pCondSet, pTableSet );
+        eWeight = pFontHWeightItem->GetValue();
+
         eItalic = rItemSet.Get( nPostureId ).GetValue();
         eUnder = rItemSet.Get( ATTR_FONT_UNDERLINE ).GetValue();
         eOver = rItemSet.Get( ATTR_FONT_OVERLINE ).GetValue();
@@ -737,20 +769,13 @@ void ScPatternAttr::fillFontOnly(
     rFont.SetTransparent( true );
 }
 
-void ScPatternAttr::fillColor(model::ComplexColor& rComplexColor, const 
SfxItemSet& rItemSet, ScAutoFontColorMode eAutoMode, const SfxItemSet* 
pCondSet, const Color* pBackConfigColor, const Color* pTextConfigColor)
+void ScPatternAttr::fillColor(model::ComplexColor& rComplexColor, const 
SfxItemSet& rItemSet, ScAutoFontColorMode eAutoMode, const SfxItemSet* 
pCondSet, const SfxItemSet* pTableSet, const Color* pBackConfigColor, const 
Color* pTextConfigColor)
 {
-    model::ComplexColor aComplexColor;
+    const SvxColorItem* pColorItem
+        = lcl_populateresult(ATTR_FONT_COLOR, rItemSet, pCondSet, pTableSet);
 
     Color aColor;
-
-    SvxColorItem const* pColorItem = nullptr;
-
-    if (pCondSet)
-        pColorItem = pCondSet->GetItemIfSet(ATTR_FONT_COLOR);
-
-    if (!pColorItem)
-        pColorItem = &rItemSet.Get(ATTR_FONT_COLOR);
-
+    model::ComplexColor aComplexColor;
     if (pColorItem)
     {
         aComplexColor = pColorItem->getComplexColor();
@@ -767,18 +792,12 @@ void ScPatternAttr::fillColor(model::ComplexColor& 
rComplexColor, const SfxItemS
         || eAutoMode == ScAutoFontColorMode::IgnoreAll)
     {
         //  get background color from conditional or own set
+        const SvxBrushItem* pItem
+            = lcl_populateresult(ATTR_BACKGROUND, rItemSet, pCondSet, 
pTableSet);
+
         Color aBackColor;
-        if ( pCondSet )
-        {
-            const SvxBrushItem* pItem = 
pCondSet->GetItemIfSet(ATTR_BACKGROUND);
-            if (!pItem)
-                pItem = &rItemSet.Get(ATTR_BACKGROUND);
+        if (pItem)
             aBackColor = pItem->GetColor();
-        }
-        else
-        {
-            aBackColor = rItemSet.Get(ATTR_BACKGROUND).GetColor();
-        }
 
         //  if background color attribute is transparent, use window color for 
brightness comparisons
         if (aBackColor == COL_TRANSPARENT
@@ -938,15 +957,39 @@ ScDxfFont ScPatternAttr::GetDxfFont(const SfxItemSet& 
rItemSet, SvtScriptType nS
 }
 
 template <class T>
-static void lcl_populate( std::optional<T>& rxItem, TypedWhichId<T> nWhich, 
const SfxItemSet& rSrcSet, const SfxItemSet* pCondSet )
+static void lcl_populate( std::optional<T>& rxItem, TypedWhichId<T> nWhich, 
const SfxItemSet& rSrcSet, const SfxItemSet* pCondSet, const SfxItemSet* 
pTableSet = nullptr )
 {
-    const T* pItem = pCondSet->GetItemIfSet( nWhich );
-    if ( !pItem )
-        pItem = &rSrcSet.Get( nWhich );
+    const T* pItem = nullptr;
+
+    if (pCondSet)
+        pItem = pCondSet->GetItemIfSet(nWhich);
+
+    if (!pItem && pTableSet)
+    {
+        const SfxPoolItem* pThisItem;
+        if (rSrcSet.GetItemState(nWhich, false, &pThisItem) == 
SfxItemState::SET
+            && *pThisItem != 
rSrcSet.GetPool()->GetUserOrPoolDefaultItem(nWhich))
+        {
+            // use the direct cell format value againts the Table style format
+            // if it not a default one (COL_BLACK is the default in case of 
Table Styles)
+            // on the cell level
+            if (sal_uInt16(nWhich) == ATTR_FONT_COLOR
+                && rSrcSet.GetItem(ATTR_FONT_COLOR)->getColor() == COL_BLACK)
+                pItem = pTableSet->GetItemIfSet(nWhich);
+            else
+                pItem = &rSrcSet.Get(nWhich);
+        }
+        else
+            pItem = pTableSet->GetItemIfSet(nWhich);
+    }
+
+    if (!pItem)
+        pItem = &rSrcSet.Get(nWhich);
+
     rxItem.emplace(*pItem);
 }
 
-void ScPatternAttr::FillToEditItemSet( SfxItemSet& rEditSet, const SfxItemSet& 
rSrcSet, const SfxItemSet* pCondSet )
+void ScPatternAttr::FillToEditItemSet( SfxItemSet& rEditSet, const SfxItemSet& 
rSrcSet, const SfxItemSet* pCondSet, const SfxItemSet* pTableSet )
 {
     //  Read Items
 
@@ -974,35 +1017,23 @@ void ScPatternAttr::FillToEditItemSet( SfxItemSet& 
rEditSet, const SfxItemSet& r
 
     if ( pCondSet )
     {
-        lcl_populate(oColorItem, ATTR_FONT_COLOR, rSrcSet, pCondSet);
-        lcl_populate(oFontItem, ATTR_FONT, rSrcSet, pCondSet);
-        lcl_populate(oCjkFontItem, ATTR_CJK_FONT, rSrcSet, pCondSet);
-        lcl_populate(oCtlFontItem, ATTR_CTL_FONT, rSrcSet, pCondSet);
-
-        const SvxFontHeightItem* pFontHeightItem = pCondSet->GetItemIfSet( 
ATTR_FONT_HEIGHT );
-        if (!pFontHeightItem)
-            pFontHeightItem = &rSrcSet.Get( ATTR_FONT_HEIGHT );
+        lcl_populate(oColorItem, ATTR_FONT_COLOR, rSrcSet, pCondSet, 
pTableSet);
+        lcl_populate(oFontItem, ATTR_FONT, rSrcSet, pCondSet, pTableSet);
+        lcl_populate(oCjkFontItem, ATTR_CJK_FONT, rSrcSet, pCondSet, 
pTableSet);
+        lcl_populate(oCtlFontItem, ATTR_CTL_FONT, rSrcSet, pCondSet, 
pTableSet);
+
+        const SvxFontHeightItem* pFontHeightItem = lcl_populateresult( 
ATTR_FONT_HEIGHT, rSrcSet, pCondSet, pTableSet );
         nTHeight = pFontHeightItem->GetHeight();
-        pFontHeightItem = pCondSet->GetItemIfSet( ATTR_CJK_FONT_HEIGHT );
-        if ( !pFontHeightItem )
-            pFontHeightItem = &rSrcSet.Get( ATTR_CJK_FONT_HEIGHT );
+        pFontHeightItem = lcl_populateresult( ATTR_CJK_FONT_HEIGHT, rSrcSet, 
pCondSet, pTableSet );
         nCjkTHeight = pFontHeightItem->GetHeight();
-        pFontHeightItem = pCondSet->GetItemIfSet( ATTR_CTL_FONT_HEIGHT );
-        if ( !pFontHeightItem )
-            pFontHeightItem = &rSrcSet.Get( ATTR_CTL_FONT_HEIGHT );
+        pFontHeightItem = lcl_populateresult( ATTR_CTL_FONT_HEIGHT, rSrcSet, 
pCondSet, pTableSet );
         nCtlTHeight = pFontHeightItem->GetHeight();
 
-        const SvxWeightItem* pWeightItem = pCondSet->GetItemIfSet( 
ATTR_FONT_WEIGHT );
-        if ( !pWeightItem )
-            pWeightItem = &rSrcSet.Get( ATTR_FONT_WEIGHT );
+        const SvxWeightItem* pWeightItem = lcl_populateresult( 
ATTR_FONT_WEIGHT, rSrcSet, pCondSet, pTableSet );
         eWeight = pWeightItem->GetValue();
-        pWeightItem = pCondSet->GetItemIfSet( ATTR_CJK_FONT_WEIGHT );
-        if ( !pWeightItem )
-            pWeightItem = &rSrcSet.Get( ATTR_CJK_FONT_WEIGHT );
+        pWeightItem = lcl_populateresult( ATTR_CJK_FONT_WEIGHT, rSrcSet, 
pCondSet, pTableSet );
         eCjkWeight = pWeightItem->GetValue();
-        pWeightItem = pCondSet->GetItemIfSet( ATTR_CTL_FONT_WEIGHT );
-        if ( !pWeightItem )
-            pWeightItem = &rSrcSet.Get( ATTR_CTL_FONT_WEIGHT );
+        pWeightItem = lcl_populateresult( ATTR_CTL_FONT_WEIGHT, rSrcSet, 
pCondSet, pTableSet );
         eCtlWeight = pWeightItem->GetValue();
 
         const SvxPostureItem* pPostureItem = pCondSet->GetItemIfSet( 
ATTR_FONT_POSTURE );
@@ -1080,16 +1111,25 @@ void ScPatternAttr::FillToEditItemSet( SfxItemSet& 
rEditSet, const SfxItemSet& r
     }
     else        // Everything directly from Pattern
     {
-        oColorItem.emplace(rSrcSet.Get(ATTR_FONT_COLOR));
-        oFontItem.emplace(rSrcSet.Get(ATTR_FONT));
-        oCjkFontItem.emplace(rSrcSet.Get(ATTR_CJK_FONT));
-        oCtlFontItem.emplace(rSrcSet.Get(ATTR_CTL_FONT));
-        nTHeight = rSrcSet.Get( ATTR_FONT_HEIGHT ).GetHeight();
-        nCjkTHeight = rSrcSet.Get( ATTR_CJK_FONT_HEIGHT ).GetHeight();
-        nCtlTHeight = rSrcSet.Get( ATTR_CTL_FONT_HEIGHT ).GetHeight();
-        eWeight = rSrcSet.Get( ATTR_FONT_WEIGHT ).GetValue();
-        eCjkWeight = rSrcSet.Get( ATTR_CJK_FONT_WEIGHT ).GetValue();
-        eCtlWeight = rSrcSet.Get( ATTR_CTL_FONT_WEIGHT ).GetValue();
+        lcl_populate(oColorItem, ATTR_FONT_COLOR, rSrcSet, pCondSet, 
pTableSet);
+        lcl_populate(oFontItem, ATTR_FONT, rSrcSet, pCondSet, pTableSet);
+        lcl_populate(oCjkFontItem, ATTR_CJK_FONT, rSrcSet, pCondSet, 
pTableSet);
+        lcl_populate(oCtlFontItem, ATTR_CTL_FONT, rSrcSet, pCondSet, 
pTableSet);
+
+        const SvxFontHeightItem* pFontHeightItem = 
lcl_populateresult(ATTR_FONT_HEIGHT, rSrcSet, pCondSet, pTableSet);
+        nTHeight = pFontHeightItem->GetHeight();
+        pFontHeightItem = lcl_populateresult(ATTR_CJK_FONT_HEIGHT, rSrcSet, 
pCondSet, pTableSet);
+        nCjkTHeight = pFontHeightItem->GetHeight();
+        pFontHeightItem = lcl_populateresult(ATTR_CTL_FONT_HEIGHT, rSrcSet, 
pCondSet, pTableSet);
+        nCtlTHeight = pFontHeightItem->GetHeight();
+
+        const SvxWeightItem* pWeightItem = 
lcl_populateresult(ATTR_FONT_WEIGHT, rSrcSet, pCondSet, pTableSet);
+        eWeight = pWeightItem->GetValue();
+        pWeightItem = lcl_populateresult(ATTR_CJK_FONT_WEIGHT, rSrcSet, 
pCondSet, pTableSet);
+        eCjkWeight = pWeightItem->GetValue();
+        pWeightItem = lcl_populateresult(ATTR_CTL_FONT_WEIGHT, rSrcSet, 
pCondSet, pTableSet);
+        eCtlWeight = pWeightItem->GetValue();
+
         eItalic = rSrcSet.Get( ATTR_FONT_POSTURE ).GetValue();
         eCjkItalic = rSrcSet.Get( ATTR_CJK_FONT_POSTURE ).GetValue();
         eCtlItalic = rSrcSet.Get( ATTR_CTL_FONT_POSTURE ).GetValue();
@@ -1172,10 +1212,10 @@ void ScPatternAttr::FillToEditItemSet( SfxItemSet& 
rEditSet, const SfxItemSet& r
     rEditSet.Put( SvxScriptSpaceItem( false, EE_PARA_ASIANCJKSPACING ) );
 }
 
-void ScPatternAttr::FillEditItemSet( SfxItemSet* pEditSet, const SfxItemSet* 
pCondSet ) const
+void ScPatternAttr::FillEditItemSet( SfxItemSet* pEditSet, const SfxItemSet* 
pCondSet, const SfxItemSet* pTableSet ) const
 {
     if( pEditSet )
-        FillToEditItemSet( *pEditSet, GetItemSet(), pCondSet );
+        FillToEditItemSet( *pEditSet, GetItemSet(), pCondSet, pTableSet );
 }
 
 void ScPatternAttr::GetFromEditItemSet( SfxItemSet& rDestSet, const 
SfxItemSet& rEditSet )
diff --git a/sc/source/core/data/tablestyle.cxx 
b/sc/source/core/data/tablestyle.cxx
index bb032aa06953..5ee0229c9704 100644
--- a/sc/source/core/data/tablestyle.cxx
+++ b/sc/source/core/data/tablestyle.cxx
@@ -20,6 +20,89 @@ ScTableStyle::ScTableStyle(const OUString& rName, const 
std::optional<OUString>&
 {
 }
 
+const SfxItemSet* ScTableStyle::GetTableCellItemSet(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->GetItemSet();
+    }
+
+    if (bHasHeader && mpFirstHeaderCellPattern && nRow == aRange.aStart.Row()
+        && nCol == aRange.aStart.Col())
+    {
+        return &mpFirstHeaderCellPattern->GetItemSet();
+    }
+
+    if (bHasTotal && mpTotalRowPattern && nRow == aRange.aEnd.Row())
+    {
+        return &mpTotalRowPattern->GetItemSet();
+    }
+
+    if (bHasHeader && mpHeaderRowPattern && nRow == aRange.aStart.Row())
+    {
+        return &mpHeaderRowPattern->GetItemSet();
+    }
+
+    if (pParam->mbFirstColumn && mpFirstColumnPattern && nCol == 
aRange.aStart.Col())
+    {
+        return &mpFirstColumnPattern->GetItemSet();
+    }
+
+    if (pParam->mbLastColumn && mpLastColumnPattern && nCol == 
aRange.aEnd.Col())
+    {
+        return &mpLastColumnPattern->GetItemSet();
+    }
+
+    if (!bHasTotal || aRange.aEnd.Row() != nRow)
+    {
+        if (pParam->mbRowStripes && nRowIndex >= 0)
+        {
+            sal_Int32 nTotalRowStripPattern = mnFirstRowStripeSize + 
mnSecondRowStripeSize;
+            bool bFirstRowStripe = (nRowIndex % nTotalRowStripPattern) < 
mnFirstRowStripeSize;
+            if (mpSecondRowStripePattern && !bFirstRowStripe)
+            {
+                return &mpSecondRowStripePattern->GetItemSet();
+            }
+
+            if (mpFirstRowStripePattern && bFirstRowStripe)
+            {
+                return &mpFirstRowStripePattern->GetItemSet();
+            }
+        }
+
+        if (pParam->mbColumnStripes)
+        {
+            SCCOL nRelativeCol = nCol - aRange.aStart.Col();
+            sal_Int32 nTotalColStripePattern = mnFirstColStripeSize + 
mnSecondColStripeSize;
+            bool bFirstColStripe = (nRelativeCol % nTotalColStripePattern) < 
mnFirstColStripeSize;
+            if (mpSecondColumnStripePattern && !bFirstColStripe)
+            {
+                return &mpSecondColumnStripePattern->GetItemSet();
+            }
+
+            if (mpFirstColumnStripePattern && bFirstColStripe)
+            {
+                return &mpFirstColumnStripePattern->GetItemSet();
+            }
+        }
+    }
+
+    if (mpTablePattern)
+    {
+        return &mpTablePattern->GetItemSet();
+    }
+
+    return nullptr;
+}
+
 void ScTableStyle::SetRowStripeSize(sal_Int32 nFirstRowStripeSize, sal_Int32 
nSecondRowStripeSize)
 {
     if (nFirstRowStripeSize >= 1)
diff --git a/sc/source/filter/excel/xestyle.cxx 
b/sc/source/filter/excel/xestyle.cxx
index a327e1880df5..bee635eca515 100644
--- a/sc/source/filter/excel/xestyle.cxx
+++ b/sc/source/filter/excel/xestyle.cxx
@@ -897,7 +897,7 @@ vcl::Font XclExpFontHelper::GetFontFromItemSet( const 
XclExpRoot& rRoot, const S
 
     // fill the font object
     vcl::Font aFont;
-    ScPatternAttr::fillFontOnly(aFont, rItemSet, nullptr, nullptr, nullptr, 
nScScript);
+    ScPatternAttr::fillFontOnly(aFont, rItemSet, nullptr, nullptr, nullptr, 
nullptr, nScScript);
     return aFont;
 }
 
diff --git a/sc/source/filter/inc/defaulttablestyles.hxx 
b/sc/source/filter/inc/defaulttablestyles.hxx
index f4b72549ddb4..2cd524f30249 100644
--- a/sc/source/filter/inc/defaulttablestyles.hxx
+++ b/sc/source/filter/inc/defaulttablestyles.hxx
@@ -91,7 +91,7 @@ private:
     void importBorderElement(oox::xls::BorderRef xBorder, sal_Int32 
nBorderElement,
                              sal_Int32 nBorderElementId);
     void importBorders();
-    // TODO: void importFonts();
+    void importFonts();
     void importDxfs();
     void importTableStyle(const TableStyle& rTableStyleInfo);
 
diff --git a/sc/source/filter/inc/stylesbuffer.hxx 
b/sc/source/filter/inc/stylesbuffer.hxx
index 53d3eeb43d34..862c63544c4e 100644
--- a/sc/source/filter/inc/stylesbuffer.hxx
+++ b/sc/source/filter/inc/stylesbuffer.hxx
@@ -218,6 +218,8 @@ public:
 
     /** Sets font formatting attributes for the passed element. */
     void                importAttribs( sal_Int32 nElement, const 
AttributeList& rAttribs );
+    /** Sets font formatting attributes for OOXML default table styles. */
+    void                setFontElements( const XlsColor& rColor, bool bWeight 
);
 
     /** Imports the FONT record from the passed stream. */
     void                importFont( SequenceInputStream& rStrm );
diff --git a/sc/source/filter/oox/defaulttablestyles.cxx 
b/sc/source/filter/oox/defaulttablestyles.cxx
index ccf5c9241ef5..e7698b6c1dc9 100644
--- a/sc/source/filter/oox/defaulttablestyles.cxx
+++ b/sc/source/filter/oox/defaulttablestyles.cxx
@@ -19,7 +19,7 @@ DefaultOOXMLTableStyles::DefaultOOXMLTableStyles(const 
oox::xls::WorkbookHelper&
     importColors();
     importFills();
     importBorders();
-    //importFonts();
+    importFonts();
     importDxfs();
 }
 
@@ -101,7 +101,19 @@ void DefaultOOXMLTableStyles::importBorders()
     }
 }
 
-//void DefaultOOXMLTableStyles::importFonts() {}
+void DefaultOOXMLTableStyles::importFonts()
+{
+    size_t nFonts = sizeof(aFonts) / sizeof(Font);
+    for (size_t i = 0; i < nFonts; ++i)
+    {
+        auto xFont = std::make_shared<oox::xls::Font>(*this, true);
+
+        const Font& rFontInfo = aFonts[i];
+        xFont->setFontElements(maColors[rFontInfo.nThemeColorId], 
rFontInfo.bBold);
+
+        maFonts.push_back(xFont);
+    }
+}
 
 void DefaultOOXMLTableStyles::importDxfs()
 {
@@ -117,6 +129,9 @@ void DefaultOOXMLTableStyles::importDxfs()
         if (aDxfInfo.nBorderId >= 0)
             xDxf->setBorder(maBorders[aDxfInfo.nBorderId]);
 
+        if (aDxfInfo.nFontId >= 0)
+            xDxf->setFont(maFonts[aDxfInfo.nFontId]);
+
         xDxf->finalizeImport();
         maDxfs.push_back(xDxf);
     }
diff --git a/sc/source/filter/oox/stylesbuffer.cxx 
b/sc/source/filter/oox/stylesbuffer.cxx
index c9d9de57f40c..fa906190ba5b 100644
--- a/sc/source/filter/oox/stylesbuffer.cxx
+++ b/sc/source/filter/oox/stylesbuffer.cxx
@@ -658,6 +658,14 @@ void Font::importAttribs( sal_Int32 nElement, const 
AttributeList& rAttribs )
     }
 }
 
+void Font::setFontElements(const XlsColor& rColor, bool bWeight)
+{
+    maModel.maColor = rColor;
+    maUsedFlags.mbColorUsed = true;
+    maModel.mbBold = bWeight;
+    maUsedFlags.mbWeightUsed = true;
+}
+
 void Font::importFont( SequenceInputStream& rStrm )
 {
     SAL_WARN_IF( mbDxf, "sc", "Font::importFont - unexpected conditional 
formatting flag" );
diff --git a/sc/source/ui/inc/output.hxx b/sc/source/ui/inc/output.hxx
index 50ffa1f0b99d..27dddb82cc14 100644
--- a/sc/source/ui/inc/output.hxx
+++ b/sc/source/ui/inc/output.hxx
@@ -150,14 +150,16 @@ private:
         ScRefCellValue          maCell;
         const ScPatternAttr*    mpPattern;
         const SfxItemSet*       mpCondSet;
+        const SfxItemSet*       mpTableSet;
         const SfxItemSet*       mpPreviewFontSet;
         const ScPatternAttr*    mpOldPattern;
         const SfxItemSet*       mpOldCondSet;
+        const SfxItemSet*       mpOldTableSet;
         const SfxItemSet*       mpOldPreviewFontSet;
         RowInfo*                mpThisRowInfo;
         sc::MisspellRangeResult maMisspellRanges;
 
-        explicit DrawEditParam(const ScPatternAttr* pPattern, const 
SfxItemSet* pCondSet, bool bCellIsValue);
+        explicit DrawEditParam(const ScPatternAttr* pPattern, const 
SfxItemSet* pCondSet, const SfxItemSet* pTableSet, bool bCellIsValue);
 
         bool readCellContent(const ScDocument* pDoc, bool bShowNullValues, 
bool bShowFormulas, bool bSyntaxMode, bool bUseStyleColor, bool 
bForceAutoColor, bool& rWrapFields);
         void setPatternToEngine(bool bUseStyleColor);
@@ -322,6 +324,7 @@ private:
                            std::vector<std::unique_ptr<ScPatternAttr> >& 
aAltPatterns,
                            const ScPatternAttr*& pOldPattern,
                            const SfxItemSet*& pOldCondSet,
+                           const SfxItemSet*& pOldTableSet,
                            SvtScriptType& nOldScript,
                            ScDrawStringsVars& aVars,
                            bool& bProgress, tools::Long nPosX, tools::Long 
nPosY, bool bTaggedPDF,
diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx
index 0af2287af08f..02d5239fbd37 100644
--- a/sc/source/ui/view/cellsh1.cxx
+++ b/sc/source/ui/view/cellsh1.cxx
@@ -2915,7 +2915,7 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
                 if ( !aChars.isEmpty() )
                 {
                     vcl::Font aFont;
-                    pTabViewShell->GetSelectionPattern()->fillFontOnly(aFont, 
nullptr, nullptr, nullptr,
+                    pTabViewShell->GetSelectionPattern()->fillFontOnly(aFont, 
nullptr, nullptr, nullptr, nullptr,
                                                                 
pTabViewShell->GetSelectionScriptType() );
                     if ( !aFontName.isEmpty() )
                         aFont = vcl::Font( aFontName, Size(1,1) );
@@ -2930,7 +2930,7 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
 
                 // font color doesn't matter here
                 vcl::Font aCurFont;
-                pTabViewShell->GetSelectionPattern()->fillFontOnly(aCurFont, 
nullptr, nullptr, nullptr,
+                pTabViewShell->GetSelectionPattern()->fillFontOnly(aCurFont, 
nullptr, nullptr, nullptr, nullptr,
                                                                 
pTabViewShell->GetSelectionScriptType());
 
                 SfxAllItemSet aSet( GetPool() );
diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx
index ce0a481a5c33..942672d2a27e 100644
--- a/sc/source/ui/view/output2.cxx
+++ b/sc/source/ui/view/output2.cxx
@@ -99,6 +99,7 @@ class ScDrawStringsVars
 
     const ScPatternAttr* pPattern;              // attribute
     const SfxItemSet*   pCondSet;               // from conditional formatting
+    const SfxItemSet*   pTableSet;              // from table formatting
 
     vcl::Font           aFont;                  // created from attributes
     FontMetric          aMetric;
@@ -140,7 +141,7 @@ public:
                 //  SetPatternSimple: without Font
 
     void SetPattern(
-        const ScPatternAttr* pNew, const SfxItemSet* pSet, const 
ScRefCellValue& rCell,
+        const ScPatternAttr* pNew, const SfxItemSet* pSet, const SfxItemSet* 
pTSet, const ScRefCellValue& rCell,
         SvtScriptType nScript );
 
     void        SetPatternSimple( const ScPatternAttr* pNew, const SfxItemSet* 
pSet );
@@ -202,6 +203,7 @@ ScDrawStringsVars::ScDrawStringsVars(ScOutputData* pData, 
bool bPTL) :
     pOutput     ( pData ),
     pPattern    ( nullptr ),
     pCondSet    ( nullptr ),
+    pTableSet   ( nullptr ),
     nAscentPixel(0),
     eAttrOrient ( SvxCellOrientation::Standard ),
     eAttrHorJust( SvxCellHorJustify::Standard ),
@@ -245,7 +247,7 @@ void ScDrawStringsVars::SetShrinkScale( tools::Long nScale, 
SvtScriptType nScrip
     if ( !bPixelToLogic )
         aFraction *= pOutput->maZoomY;
     vcl::Font aTmpFont;
-    pPattern->fillFontOnly(aTmpFont, pFmtDevice, &aFraction, pCondSet, 
nScript);
+    pPattern->fillFontOnly(aTmpFont, pFmtDevice, &aFraction, pCondSet, 
pTableSet, nScript);
     // only need font height
     tools::Long nNewHeight = aTmpFont.GetFontHeight();
     if ( nNewHeight > 0 )
@@ -297,9 +299,7 @@ static bool lcl_isNumberFormatText(const ScDocument* pDoc, 
SCCOL nCellX, SCROW n
     return pNumberFormatter->GetType( nCurrentNumberFormat ) == 
SvNumFormatType::TEXT;
 }
 
-void ScDrawStringsVars::SetPattern(
-    const ScPatternAttr* pNew, const SfxItemSet* pSet, const ScRefCellValue& 
rCell,
-    SvtScriptType nScript )
+void ScDrawStringsVars::SetPattern( const ScPatternAttr* pNew, const 
SfxItemSet* pSet, const SfxItemSet* pTSet, const ScRefCellValue& rCell, 
SvtScriptType nScript )
 {
     nMaxDigitWidth = 0;
     nSignWidth     = 0;
@@ -308,6 +308,7 @@ void ScDrawStringsVars::SetPattern(
 
     pPattern = pNew;
     pCondSet = pSet;
+    pTableSet = pTSet;
 
     // evaluate pPattern
 
@@ -329,9 +330,9 @@ void ScDrawStringsVars::SetPattern(
         eColorMode = ScAutoFontColorMode::Print;
 
     if (bPixelToLogic)
-        pPattern->fillFont(aFont, eColorMode, pFmtDevice, nullptr, pCondSet, 
nScript, &aBackConfigColor, &aTextConfigColor);
+        pPattern->fillFont(aFont, eColorMode, pFmtDevice, nullptr, pCondSet, 
pTableSet, nScript, &aBackConfigColor, &aTextConfigColor);
     else
-        pPattern->fillFont(aFont, eColorMode, pFmtDevice, &pOutput->maZoomY, 
pCondSet, nScript, &aBackConfigColor, &aTextConfigColor );
+        pPattern->fillFont(aFont, eColorMode, pFmtDevice, &pOutput->maZoomY, 
pCondSet, pTableSet, nScript, &aBackConfigColor, &aTextConfigColor );
 
     aFont.SetAlignment(ALIGN_BASELINE);
 
@@ -1540,6 +1541,7 @@ void ScOutputData::LayoutStrings(bool bPixelToLogic)
     // variables for GetOutputArea
     const ScPatternAttr* pOldPattern = nullptr;
     const SfxItemSet* pOldCondSet = nullptr;
+    const SfxItemSet* pOldTableSet = nullptr;
     SvtScriptType nOldScript = SvtScriptType::NONE;
 
     // alternative pattern instances in case we need to modify the pattern
@@ -1563,7 +1565,7 @@ void ScOutputData::LayoutStrings(bool bPixelToLogic)
             for (SCCOL nX=nLoopStartX; nX<=mnX2; nX++)
             {
                 LayoutStringsImpl(bPixelToLogic, pThisRowInfo, nX, nY, nArrY, 
oFirstNonEmptyCellX, oLastEmptyCellX, nLastContentCol,
-                                  aAltPatterns, pOldPattern, pOldCondSet, 
nOldScript, aVars,
+                                  aAltPatterns, pOldPattern, pOldCondSet, 
pOldTableSet, nOldScript, aVars,
                                   bProgress, nPosX, nPosY, bTaggedPDF, 
bReopenRowTag, pPDF, nLayoutSign, aDX);
                 nPosX += mpRowInfo[0].basicCellInfo(nX).nWidth * nLayoutSign;
             }
@@ -1586,6 +1588,7 @@ void ScOutputData::LayoutStringsImpl(bool const 
bPixelToLogic, RowInfo* const pT
             std::vector<std::unique_ptr<ScPatternAttr> >& aAltPatterns,
             const ScPatternAttr*& pOldPattern,
             const SfxItemSet*& pOldCondSet,
+            const SfxItemSet*& pOldTableSet,
             SvtScriptType& nOldScript,
             ScDrawStringsVars& aVars,
             bool& bProgress, tools::Long const nPosX, tools::Long const nPosY,
@@ -1594,6 +1597,7 @@ void ScOutputData::LayoutStringsImpl(bool const 
bPixelToLogic, RowInfo* const pT
 {
     const ScPatternAttr* pPattern = nullptr;
     const SfxItemSet* pCondSet = nullptr;
+    const SfxItemSet* pTableSet = nullptr;
     bool bCellIsValue = false;
     tools::Long nNeededWidth = 0;
     OutputAreaParam aAreaParam;
@@ -1717,6 +1721,7 @@ void ScOutputData::LayoutStringsImpl(bool const 
bPixelToLogic, RowInfo* const pT
             ScCellInfo& rCellInfo = pThisRowInfo->cellInfo(nCellX);
             pPattern = rCellInfo.pPatternAttr;
             pCondSet = rCellInfo.pConditionSet;
+            pTableSet = rCellInfo.pTableFormatSet;
 
             if ( !pPattern )
             {
@@ -1724,12 +1729,14 @@ void ScOutputData::LayoutStringsImpl(bool const 
bPixelToLogic, RowInfo* const pT
                 // test for null is quicker than using column flags
                 pPattern = mpDoc->GetPattern( nCellX, nCellY, mnTab );
                 pCondSet = mpDoc->GetCondResult( nCellX, nCellY, mnTab );
+                pTableSet = mpDoc->GetTableFormatSet( nCellX, nCellY, mnTab );
             }
         }
         else        // get from document
         {
             pPattern = mpDoc->GetPattern( nCellX, nCellY, mnTab );
             pCondSet = mpDoc->GetCondResult( nCellX, nCellY, mnTab );
+            pTableSet = mpDoc->GetTableFormatSet( nCellX, nCellY, mnTab );
         }
         if ( mpDoc->GetPreviewFont() || mpDoc->GetPreviewCellStyle() )
         {
@@ -1770,17 +1777,18 @@ void ScOutputData::LayoutStringsImpl(bool const 
bPixelToLogic, RowInfo* const pT
             nScript = ScGlobal::GetDefaultScriptType();
 
         if ( !ScPatternAttr::areSame(pPattern, pOldPattern) || pCondSet != 
pOldCondSet ||
-             nScript != nOldScript || mbSyntaxMode )
+             pTableSet != pOldTableSet || nScript != nOldScript || 
mbSyntaxMode )
         {
-            if ( StringDiffer(pOldPattern,pPattern) ||
-                 pCondSet != pOldCondSet || nScript != nOldScript || 
mbSyntaxMode )
+            if ( StringDiffer(pOldPattern,pPattern) || pCondSet != pOldCondSet 
||
+                 pTableSet != pOldTableSet || nScript != nOldScript || 
mbSyntaxMode )
             {
-                aVars.SetPattern(pPattern, pCondSet, aCell, nScript);
+                aVars.SetPattern(pPattern, pCondSet, pTableSet, aCell, 
nScript);
             }
             else
                 aVars.SetPatternSimple( pPattern, pCondSet );
             pOldPattern = pPattern;
             pOldCondSet = pCondSet;
+            pOldTableSet = pTableSet;
             nOldScript = nScript;
         }
 
@@ -2506,7 +2514,7 @@ void ScOutputData::ShrinkEditEngine( EditEngine& rEngine, 
const tools::Rectangle
     }
 }
 
-ScOutputData::DrawEditParam::DrawEditParam(const ScPatternAttr* pPattern, 
const SfxItemSet* pCondSet, bool bCellIsValue) :
+ScOutputData::DrawEditParam::DrawEditParam(const ScPatternAttr* pPattern, 
const SfxItemSet* pCondSet, const SfxItemSet* pTableSet, bool bCellIsValue) :
     meHorJustAttr( lcl_GetValue<SvxHorJustifyItem, 
SvxCellHorJustify>(*pPattern, ATTR_HOR_JUSTIFY, pCondSet) ),
     meHorJustContext( meHorJustAttr ),
     meHorJustResult( meHorJustAttr ),
@@ -2525,9 +2533,11 @@ ScOutputData::DrawEditParam::DrawEditParam(const 
ScPatternAttr* pPattern, const
     mpEngine(nullptr),
     mpPattern(pPattern),
     mpCondSet(pCondSet),
+    mpTableSet(pTableSet),
     mpPreviewFontSet(nullptr),
     mpOldPattern(nullptr),
     mpOldCondSet(nullptr),
+    mpOldTableSet(nullptr),
     mpOldPreviewFontSet(nullptr),
     mpThisRowInfo(nullptr)
 {}
@@ -2591,7 +2601,7 @@ void ScOutputData::DrawEditParam::setPatternToEngine(bool 
bUseStyleColor)
     // syntax highlighting mode is ignored here
     // StringDiffer doesn't look at hyphenate, language items
 
-    if (ScPatternAttr::areSame(mpPattern, mpOldPattern) && mpCondSet == 
mpOldCondSet && mpPreviewFontSet == mpOldPreviewFontSet )
+    if (ScPatternAttr::areSame(mpPattern, mpOldPattern) && mpCondSet == 
mpOldCondSet && mpTableSet == mpOldTableSet && mpPreviewFontSet == 
mpOldPreviewFontSet )
         return;
 
     Color nConfBackColor = GetConfBackgroundColor();
@@ -2599,7 +2609,7 @@ void ScOutputData::DrawEditParam::setPatternToEngine(bool 
bUseStyleColor)
             
Application::GetSettings().GetStyleSettings().GetHighContrastMode();
 
     SfxItemSet aSet( mpEngine->GetEmptyItemSet() );
-    mpPattern->FillEditItemSet( &aSet, mpCondSet );
+    mpPattern->FillEditItemSet( &aSet, mpCondSet, mpTableSet );
     if ( mpPreviewFontSet )
     {
         if ( const SvxFontItem* pItem = mpPreviewFontSet->GetItemIfSet( 
ATTR_FONT ) )
@@ -2622,6 +2632,7 @@ void ScOutputData::DrawEditParam::setPatternToEngine(bool 
bUseStyleColor)
     mpEngine->SetDefaults( std::move(aSet) );
     mpOldPattern = mpPattern;
     mpOldCondSet = mpCondSet;
+    mpOldTableSet = mpTableSet;
     mpOldPreviewFontSet = mpPreviewFontSet;
 
     EEControlBits nControl = mpEngine->GetControlWord();
@@ -4493,6 +4504,7 @@ void ScOutputData::DrawEdit(bool bPixelToLogic)
     bool bHyphenatorSet = false;
     const ScPatternAttr* pOldPattern = nullptr;
     const SfxItemSet*    pOldCondSet = nullptr;
+    const SfxItemSet*    pOldTableSet = nullptr;
     const SfxItemSet*    pOldPreviewFontSet = nullptr;
     ScRefCellValue aCell;
 
@@ -4580,6 +4592,7 @@ void ScOutputData::DrawEdit(bool bPixelToLogic)
 
                     const ScPatternAttr* pPattern = nullptr;
                     const SfxItemSet* pCondSet = nullptr;
+                    const SfxItemSet* pTableSet = nullptr;
                     if (bDoCell)
                     {
                         if ( nCellY == nY && nCellX >= mnX1 && nCellX <= mnX2 
&&
@@ -4588,12 +4601,14 @@ void ScOutputData::DrawEdit(bool bPixelToLogic)
                             ScCellInfo& rCellInfo = 
pThisRowInfo->cellInfo(nCellX);
                             pPattern = rCellInfo.pPatternAttr;
                             pCondSet = rCellInfo.pConditionSet;
+                            pTableSet = rCellInfo.pTableFormatSet;
                             aCell = rCellInfo.maCell;
                         }
                         else        // get from document
                         {
                             pPattern = mpDoc->GetPattern( nCellX, nCellY, 
mnTab );
                             pCondSet = mpDoc->GetCondResult( nCellX, nCellY, 
mnTab );
+                            pTableSet = mpDoc->GetTableFormatSet( nCellX, 
nCellY, mnTab );
                             GetVisibleCell( nCellX, nCellY, mnTab, aCell );
                         }
                         if (aCell.isEmpty())
@@ -4616,7 +4631,7 @@ void ScOutputData::DrawEdit(bool bPixelToLogic)
                         // fdo#32530: Check if the first character is RTL.
                         OUString aStr = mpDoc->GetString(nCellX, nCellY, 
mnTab);
 
-                        DrawEditParam aParam(pPattern, pCondSet, 
lcl_SafeIsValue(aCell));
+                        DrawEditParam aParam(pPattern, pCondSet, pTableSet, 
lcl_SafeIsValue(aCell));
                         const bool bNumberFormatIsText = 
lcl_isNumberFormatText( mpDoc, nCellX, nCellY, mnTab );
                         aParam.meHorJustContext = getAlignmentFromContext( 
aParam.meHorJustAttr,
                                 aParam.mbCellIsValue, aStr, *pPattern, 
pCondSet, mpDoc, mnTab, bNumberFormatIsText);
@@ -4636,6 +4651,7 @@ void ScOutputData::DrawEdit(bool bPixelToLogic)
                         aParam.mpPreviewFontSet = pPreviewFontSet;
                         aParam.mpOldPattern = pOldPattern;
                         aParam.mpOldCondSet = pOldCondSet;
+                        aParam.mpOldTableSet = pOldTableSet;
                         aParam.mpOldPreviewFontSet = pOldPreviewFontSet;
                         aParam.mpThisRowInfo = pThisRowInfo;
                         if (mpSpellCheckCxt)
@@ -4665,6 +4681,7 @@ void ScOutputData::DrawEdit(bool bPixelToLogic)
                         // Retrieve parameters for next iteration.
                         pOldPattern = aParam.mpOldPattern;
                         pOldCondSet = aParam.mpOldCondSet;
+                        pOldTableSet = aParam.mpOldTableSet;
                         pOldPreviewFontSet = aParam.mpOldPreviewFontSet;
                         bHyphenatorSet = aParam.mbHyphenatorSet;
                     }
commit 145d17585b69d5b55255916a609c13a2c6adac09
Author:     Markus Mohrhard <[email protected]>
AuthorDate: Mon Aug 11 01:21:08 2025 +0800
Commit:     Balazs Varga <[email protected]>
CommitDate: Thu Jan 29 09:27:21 2026 +0100

    don't apply banded row/col formatting to subtotal row
    
    Change-Id: Id82036246e808e9e556c5f2d04ff6611716dc9c8
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/193671
    Reviewed-by: Andras Timar <[email protected]>
    Tested-by: Andras Timar <[email protected]>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/196739
    Reviewed-by: Balazs Varga <[email protected]>
    Tested-by: Balazs Varga <[email protected]>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/197967
    Tested-by: Jenkins

diff --git a/sc/inc/tablestyle.hxx b/sc/inc/tablestyle.hxx
index 7ef1d87382ee..fd39336e71a1 100644
--- a/sc/inc/tablestyle.hxx
+++ b/sc/inc/tablestyle.hxx
@@ -118,42 +118,48 @@ public:
                 return pPoolItem;
         }
 
-        if (pParam->mbRowStripes && nRowIndex >= 0)
+        if (!bHasTotal || aRange.aEnd.Row() != nRow)
         {
-            sal_Int32 nTotalRowStripPattern = mnFirstRowStripeSize + 
mnSecondRowStripeSize;
-            bool bFirstRowStripe = (nRowIndex % nTotalRowStripPattern) < 
mnFirstRowStripeSize;
-            if (mpSecondRowStripePattern && !bFirstRowStripe)
+            if (pParam->mbRowStripes && nRowIndex >= 0)
             {
-                const T* pPoolItem = 
GetItemFromPattern(mpSecondRowStripePattern.get(), nWhich);
-                if (pPoolItem)
-                    return pPoolItem;
+                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 (mpFirstRowStripePattern && bFirstRowStripe)
+            if (pParam->mbColumnStripes)
             {
-                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;
+                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;
+                }
             }
         }
 

Reply via email to