sc/inc/tablestyle.hxx                       |  109 +++++++++++++++++++++++++++-
 sc/source/core/data/fillinfo.cxx            |    8 --
 sc/source/core/data/tablestyle.cxx          |   75 -------------------
 sc/source/filter/inc/stylesbuffer.hxx       |    7 +
 sc/source/filter/oox/defaulttablestyles.cxx |    4 +
 sc/source/filter/oox/stylesbuffer.cxx       |   29 +++++++
 6 files changed, 149 insertions(+), 83 deletions(-)

New commits:
commit cc4e613d125085ff69102821f860d3a592ff2cfa
Author:     Markus Mohrhard <[email protected]>
AuthorDate: Fri Aug 8 05:55:12 2025 +0800
Commit:     Andras Timar <[email protected]>
CommitDate: Mon Nov 17 19:00:12 2025 +0100

    support vertical and horizontal dxf borders
    
    Change-Id: I4903ec947da4545f8fe173436b904be3e0526c09
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/193670
    Tested-by: Andras Timar <[email protected]>
    Reviewed-by: Andras Timar <[email protected]>

diff --git a/sc/source/filter/inc/stylesbuffer.hxx 
b/sc/source/filter/inc/stylesbuffer.hxx
index 3f9613f8d01d..3181c80e7313 100644
--- a/sc/source/filter/inc/stylesbuffer.hxx
+++ b/sc/source/filter/inc/stylesbuffer.hxx
@@ -405,6 +405,8 @@ struct BorderModel
     BorderLineModel     maTop;              /// Top line format.
     BorderLineModel     maBottom;           /// Bottom line format.
     BorderLineModel     maDiagonal;         /// Diagonal line format.
+    BorderLineModel     maVertical;         /// Vertical line format.
+    BorderLineModel     maHorizontal;       /// Horizontal line format.
     bool                mbDiagTLtoBR;       /// True = top-left to 
bottom-right on.
     bool                mbDiagBLtoTR;       /// True = bottom-left to 
top-right on.
 
@@ -420,13 +422,18 @@ struct ApiBorderData
     ApiBorderLine       maRight;            /// Right line format
     ApiBorderLine       maTop;              /// Top line format
     ApiBorderLine       maBottom;           /// Bottom line format
+    ApiBorderLine       maVertical;         /// Vertical line format
+    ApiBorderLine       maHorizontal;           /// Horizontal line format
     model::ComplexColor maComplexColorLeft;
     model::ComplexColor maComplexColorRight;
     model::ComplexColor maComplexColorTop;
     model::ComplexColor maComplexColorBottom;
+    model::ComplexColor maComplexColorVertical;
+    model::ComplexColor maComplexColorHorizontal;
     ApiBorderLine       maTLtoBR;           /// Diagonal top-left to 
bottom-right line format.
     ApiBorderLine       maBLtoTR;           /// Diagonal bottom-left to 
top-right line format.
     bool                mbBorderUsed;       /// True = left/right/top/bottom 
line format used.
+    bool                mbVertHorz;         /// True = vert/horz line format 
used.
     bool                mbDiagUsed;         /// True = diagonal line format 
used.
 
     explicit            ApiBorderData();
diff --git a/sc/source/filter/oox/defaulttablestyles.cxx 
b/sc/source/filter/oox/defaulttablestyles.cxx
index 4bf970a0ded0..918b49549182 100644
--- a/sc/source/filter/oox/defaulttablestyles.cxx
+++ b/sc/source/filter/oox/defaulttablestyles.cxx
@@ -90,6 +90,10 @@ void DefaultOOXMLTableStyles::importBorders()
             importBorderElement(xBorder, XLS_TOKEN(left), rBorderInfo.nLeftId);
         if (rBorderInfo.nRightId >= 0)
             importBorderElement(xBorder, XLS_TOKEN(right), 
rBorderInfo.nRightId);
+        if (rBorderInfo.nVerticalId >= 0)
+            importBorderElement(xBorder, XLS_TOKEN(vertical), 
rBorderInfo.nVerticalId);
+        if (rBorderInfo.nHorizontalId >= 0)
+            importBorderElement(xBorder, XLS_TOKEN(horizontal), 
rBorderInfo.nHorizontalId);
 
         maBorders.push_back(xBorder);
     }
diff --git a/sc/source/filter/oox/stylesbuffer.cxx 
b/sc/source/filter/oox/stylesbuffer.cxx
index 8964142374df..be9c7a4aae56 100644
--- a/sc/source/filter/oox/stylesbuffer.cxx
+++ b/sc/source/filter/oox/stylesbuffer.cxx
@@ -1450,6 +1450,8 @@ BorderModel::BorderModel( bool bDxf ) :
     maTop( bDxf ),
     maBottom( bDxf ),
     maDiagonal( bDxf ),
+    maVertical( bDxf ),
+    maHorizontal( bDxf ),
     mbDiagTLtoBR( false ),
     mbDiagBLtoTR( false )
 {
@@ -1457,6 +1459,7 @@ BorderModel::BorderModel( bool bDxf ) :
 
 ApiBorderData::ApiBorderData() :
     mbBorderUsed( false ),
+    mbVertHorz( false ),
     mbDiagUsed( false )
 {
 }
@@ -1557,16 +1560,21 @@ void Border::finalizeImport( bool bRTL )
 
     maApiData.mbBorderUsed = maModel.maLeft.mbUsed || maModel.maRight.mbUsed 
|| maModel.maTop.mbUsed || maModel.maBottom.mbUsed;
     maApiData.mbDiagUsed   = maModel.maDiagonal.mbUsed;
+    maApiData.mbVertHorz   = maModel.maVertical.mbUsed || 
maModel.maHorizontal.mbUsed;
 
     convertBorderLine( maApiData.maLeft,   maModel.maLeft );
     convertBorderLine( maApiData.maRight,  maModel.maRight );
     convertBorderLine( maApiData.maTop,    maModel.maTop );
     convertBorderLine( maApiData.maBottom, maModel.maBottom );
+    convertBorderLine( maApiData.maVertical, maModel.maVertical );
+    convertBorderLine( maApiData.maHorizontal, maModel.maHorizontal );
 
     maApiData.maComplexColorLeft = 
maModel.maLeft.maColor.createComplexColor(getBaseFilter().getGraphicHelper(), 
-1);
     maApiData.maComplexColorRight = 
maModel.maRight.maColor.createComplexColor(getBaseFilter().getGraphicHelper(), 
-1);
     maApiData.maComplexColorTop = 
maModel.maTop.maColor.createComplexColor(getBaseFilter().getGraphicHelper(), 
-1);
     maApiData.maComplexColorBottom = 
maModel.maBottom.maColor.createComplexColor(getBaseFilter().getGraphicHelper(), 
-1);
+    maApiData.maComplexColorVertical = 
maModel.maVertical.maColor.createComplexColor(getBaseFilter().getGraphicHelper(),
 -1);
+    maApiData.maComplexColorHorizontal = 
maModel.maHorizontal.maColor.createComplexColor(getBaseFilter().getGraphicHelper(),
 -1);
 
     if( maModel.mbDiagTLtoBR )
         convertBorderLine( maApiData.maTLtoBR, maModel.maDiagonal );
@@ -1576,6 +1584,25 @@ void Border::finalizeImport( bool bRTL )
 
 void Border::fillToItemSet( SfxItemSet& rItemSet, bool bSkipPoolDefs ) const
 {
+    if (maApiData.mbVertHorz)
+    {
+        SvxBoxInfoItem aBoxInfoItem(ATTR_BORDER_INNER);
+        editeng::SvxBorderLine aLine;
+
+        if (SvxBoxItem::LineToSvxLine(maApiData.maVertical, aLine, false))
+        {
+            aLine.setComplexColor(maApiData.maComplexColorVertical);
+            aBoxInfoItem.SetLine(&aLine, SvxBoxInfoItemLine::VERT);
+        }
+        if (SvxBoxItem::LineToSvxLine(maApiData.maHorizontal, aLine, false))
+        {
+            aLine.setComplexColor(maApiData.maComplexColorHorizontal);
+            aBoxInfoItem.SetLine(&aLine, SvxBoxInfoItemLine::HORI);
+        }
+
+        ScfTools::PutItem( rItemSet, aBoxInfoItem, bSkipPoolDefs );
+
+    }
     if( maApiData.mbBorderUsed )
     {
          SvxBoxItem aBoxItem( ATTR_BORDER );
@@ -1632,6 +1659,8 @@ BorderLineModel* Border::getBorderLine( sal_Int32 
nElement )
         case XLS_TOKEN( top ):      return &maModel.maTop;
         case XLS_TOKEN( bottom ):   return &maModel.maBottom;
         case XLS_TOKEN( diagonal ): return &maModel.maDiagonal;
+        case XLS_TOKEN( vertical ): return &maModel.maVertical;
+        case XLS_TOKEN( horizontal ): return &maModel.maHorizontal;
     }
     return nullptr;
 }
commit 4697615ba84a990ae4c1c8ae1fb32f8b44b48b91
Author:     Markus Mohrhard <[email protected]>
AuthorDate: Fri Aug 8 05:31:56 2025 +0800
Commit:     Andras Timar <[email protected]>
CommitDate: Mon Nov 17 18:59:59 2025 +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]>

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 9a594352be0a..482feb3f3c5e 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)

Reply via email to