sc/inc/tablestyle.hxx | 5 ++- sc/source/core/data/documen4.cxx | 2 - sc/source/core/data/fillinfo.cxx | 2 - sc/source/core/data/tablestyle.cxx | 52 +++++++++++++++++++++++++++---------- sc/source/ui/drawfunc/drawsh2.cxx | 26 ++++++++++++++++-- sc/source/ui/view/tabvwsh4.cxx | 2 - 6 files changed, 68 insertions(+), 21 deletions(-)
New commits: commit b6a7169872e5ca85e6611ce2317f8928021dcafb Author: Balazs Varga <[email protected]> AuthorDate: Thu Nov 13 10:39:52 2025 +0100 Commit: Andras Timar <[email protected]> CommitDate: Mon Nov 17 19:05:10 2025 +0100 Table styles: fix wrong font colors after we applied an empty font attr set for FirstColumnStripePattern, which didn't have any font attr but TablePattern has. Change-Id: Ib125432b3d34311348f864005f97a2eeeac92ea1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/193985 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-by: Andras Timar <[email protected]> diff --git a/sc/inc/tablestyle.hxx b/sc/inc/tablestyle.hxx index 04b9c36d56e4..514f23d7ecce 100644 --- a/sc/inc/tablestyle.hxx +++ b/sc/inc/tablestyle.hxx @@ -71,8 +71,9 @@ private: public: ScTableStyle(const OUString& rName, const std::optional<OUString>& rUIName); - const SfxItemSet* GetTableCellItemSet(const ScDBData& rDBData, SCCOL nCol, SCROW nRow, - SCROW nRowIndex) const; + static bool HasFontAttrSet(ScPatternAttr* pPattern); + const SfxItemSet* GetFontItemSet(const ScDBData& rDBData, SCCOL nCol, SCROW nRow, + SCROW nRowIndex) const; const SvxBrushItem* GetFillItem(const ScDBData& rDBData, SCCOL nCol, SCROW nRow, SCROW nRowIndex) const; std::unique_ptr<SvxBoxItem> GetBoxItem(const ScDBData& rDBData, SCCOL nCol, SCROW nRow, diff --git a/sc/source/core/data/documen4.cxx b/sc/source/core/data/documen4.cxx index 9fa423eee0fa..352779393fa9 100644 --- a/sc/source/core/data/documen4.cxx +++ b/sc/source/core/data/documen4.cxx @@ -813,7 +813,7 @@ const SfxItemSet* ScDocument::GetTableFormatSet(SCCOL nCol, SCROW nRow, SCTAB nT { nNonEmptyRowsBeforePaintRange += this->CountNonFilteredRows(aDBRange.aStart.Row(), nRow - 1, nTab); } - return pTableStyle->GetTableCellItemSet(*pDBData, nCol, nRow, nNonEmptyRowsBeforePaintRange); + return pTableStyle->GetFontItemSet(*pDBData, nCol, nRow, nNonEmptyRowsBeforePaintRange); } return nullptr; } diff --git a/sc/source/core/data/fillinfo.cxx b/sc/source/core/data/fillinfo.cxx index 9ff8c501e0f2..c509cd5926b7 100644 --- a/sc/source/core/data/fillinfo.cxx +++ b/sc/source/core/data/fillinfo.cxx @@ -458,7 +458,7 @@ void ScDocument::FillInfo( pInfo->maLinesAttr = SfxPoolItemHolder(*pPool, pLinesAttr.get()); } - const SfxItemSet* pPoolItem = pTableStyle->GetTableCellItemSet(*pDBData, nCol, nRow, nRowIndex); + const SfxItemSet* pPoolItem = pTableStyle->GetFontItemSet(*pDBData, nCol, nRow, nRowIndex); if (pPoolItem) { pInfo->pTableFormatSet = pPoolItem; diff --git a/sc/source/core/data/tablestyle.cxx b/sc/source/core/data/tablestyle.cxx index d7d3ff02a330..9d930e888e90 100644 --- a/sc/source/core/data/tablestyle.cxx +++ b/sc/source/core/data/tablestyle.cxx @@ -20,8 +20,23 @@ ScTableStyle::ScTableStyle(const OUString& rName, const std::optional<OUString>& { } -const SfxItemSet* ScTableStyle::GetTableCellItemSet(const ScDBData& rDBData, SCCOL nCol, SCROW nRow, - SCROW nRowIndex) const +bool ScTableStyle::HasFontAttrSet(ScPatternAttr* pPattern) +{ + // TODO: maybe different pPatterns can have different font attributes, and + // now we only check if any font attribute is set on a pattern. + // e.g.: mpFirstRowStripePattern only has ATTR_FONT_WEIGHT set and we will retirn that one, + // but mpTablePattern also can have ATTR_FONT_COLOR set (need to merge them and return that + // one for custom styles, but now it is enough for the ooxml default styles). + for (sal_Int16 nWhich = ATTR_FONT; nWhich <= ATTR_FONT_RELIEF; nWhich++) + { + if (pPattern->GetItemSet().GetItemState(nWhich) == SfxItemState::SET) + return true; + } + return false; +} + +const SfxItemSet* ScTableStyle::GetFontItemSet(const ScDBData& rDBData, SCCOL nCol, SCROW nRow, + SCROW nRowIndex) const { const ScTableStyleParam* pParam = rDBData.GetTableStyleInfo(); ScRange aRange; @@ -32,33 +47,39 @@ const SfxItemSet* ScTableStyle::GetTableCellItemSet(const ScDBData& rDBData, SCC if (bHasHeader && mpLastHeaderCellPattern && nRow == aRange.aStart.Row() && nCol == aRange.aEnd.Col()) { - return &mpLastHeaderCellPattern->GetItemSet(); + if (HasFontAttrSet(mpLastHeaderCellPattern.get())) + return &mpLastHeaderCellPattern->GetItemSet(); } if (bHasHeader && mpFirstHeaderCellPattern && nRow == aRange.aStart.Row() && nCol == aRange.aStart.Col()) { - return &mpFirstHeaderCellPattern->GetItemSet(); + if (HasFontAttrSet(mpFirstHeaderCellPattern.get())) + return &mpFirstHeaderCellPattern->GetItemSet(); } if (bHasTotal && mpTotalRowPattern && nRow == aRange.aEnd.Row()) { - return &mpTotalRowPattern->GetItemSet(); + if (HasFontAttrSet(mpTotalRowPattern.get())) + return &mpTotalRowPattern->GetItemSet(); } if (bHasHeader && mpHeaderRowPattern && nRow == aRange.aStart.Row()) { - return &mpHeaderRowPattern->GetItemSet(); + if (HasFontAttrSet(mpHeaderRowPattern.get())) + return &mpHeaderRowPattern->GetItemSet(); } if (pParam->mbFirstColumn && mpFirstColumnPattern && nCol == aRange.aStart.Col()) { - return &mpFirstColumnPattern->GetItemSet(); + if (HasFontAttrSet(mpFirstColumnPattern.get())) + return &mpFirstColumnPattern->GetItemSet(); } if (pParam->mbLastColumn && mpLastColumnPattern && nCol == aRange.aEnd.Col()) { - return &mpLastColumnPattern->GetItemSet(); + if (HasFontAttrSet(mpLastColumnPattern.get())) + return &mpLastColumnPattern->GetItemSet(); } if (!bHasTotal || aRange.aEnd.Row() != nRow) @@ -69,12 +90,14 @@ const SfxItemSet* ScTableStyle::GetTableCellItemSet(const ScDBData& rDBData, SCC bool bFirstRowStripe = (nRowIndex % nTotalRowStripPattern) < mnFirstRowStripeSize; if (mpSecondRowStripePattern && !bFirstRowStripe) { - return &mpSecondRowStripePattern->GetItemSet(); + if (HasFontAttrSet(mpSecondRowStripePattern.get())) + return &mpSecondRowStripePattern->GetItemSet(); } if (mpFirstRowStripePattern && bFirstRowStripe) { - return &mpFirstRowStripePattern->GetItemSet(); + if (HasFontAttrSet(mpFirstRowStripePattern.get())) + return &mpFirstRowStripePattern->GetItemSet(); } } @@ -85,19 +108,22 @@ const SfxItemSet* ScTableStyle::GetTableCellItemSet(const ScDBData& rDBData, SCC bool bFirstColStripe = (nRelativeCol % nTotalColStripePattern) < mnFirstColStripeSize; if (mpSecondColumnStripePattern && !bFirstColStripe) { - return &mpSecondColumnStripePattern->GetItemSet(); + if (HasFontAttrSet(mpSecondColumnStripePattern.get())) + return &mpSecondColumnStripePattern->GetItemSet(); } if (mpFirstColumnStripePattern && bFirstColStripe) { - return &mpFirstColumnStripePattern->GetItemSet(); + if (HasFontAttrSet(mpFirstColumnStripePattern.get())) + return &mpFirstColumnStripePattern->GetItemSet(); } } } if (mpTablePattern) { - return &mpTablePattern->GetItemSet(); + if (HasFontAttrSet(mpTablePattern.get())) + return &mpTablePattern->GetItemSet(); } return nullptr; commit 29ec160a9dd8b3f45c387c1ad10f5ebf20c96bf6 Author: Balazs Varga <[email protected]> AuthorDate: Sun Nov 9 21:01:02 2025 +0100 Commit: Andras Timar <[email protected]> CommitDate: Mon Nov 17 19:05:02 2025 +0100 Table style: fix wrong sidebar context after selecting table style area. After we selected a draw object and then we clicked inside a table style area the context was not updated and only the cell context UI elements appeared. Also need force the update in case of we set the cursor position from one table cell area to another one, otherwise the sidebar will not update the different Table area properties on the panel. Change-Id: I70a25e30071779ad4053b967a3fb15ec0328d6cb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/193690 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-by: Andras Timar <[email protected]> diff --git a/sc/source/ui/drawfunc/drawsh2.cxx b/sc/source/ui/drawfunc/drawsh2.cxx index e089dda6de89..843a8a049236 100644 --- a/sc/source/ui/drawfunc/drawsh2.cxx +++ b/sc/source/ui/drawfunc/drawsh2.cxx @@ -45,6 +45,7 @@ #include <drwlayer.hxx> #include <drtxtob.hxx> #include <gridwin.hxx> +#include <dbdata.hxx> #include <svx/svdoole2.hxx> #include <svx/xflgrit.hxx> #include <comphelper/lok.hxx> @@ -567,9 +568,28 @@ void ScDrawShell::Activate (const bool) const OUString & ScDrawShell::GetSidebarContextName() { - return vcl::EnumContext::GetContextName( - svx::sidebar::SelectionAnalyzer::GetContextForSelection_SC( - GetDrawView()->GetMarkedObjectList())); + vcl::EnumContext::Context eContext = svx::sidebar::SelectionAnalyzer::GetContextForSelection_SC( + GetDrawView()->GetMarkedObjectList()); + + // If no special context detected, check for table context + if (eContext == vcl::EnumContext::Context::Unknown) + { + ScDocument& rDocument = rViewData.GetDocument(); + if (!rDocument.HasDataPilotAtPosition(rViewData.GetCurPos())) + { + const ScAddress aAddr = rViewData.GetCurPos(); + if (!rDocument.HasSparkline(aAddr)) + { + const ScDBData* pDbData = rDocument.GetDBAtCursor( + aAddr.Col(), aAddr.Row(), aAddr.Tab(), ScDBDataPortion::AREA); + if (pDbData && pDbData->GetTableStyleInfo()) + { + eContext = vcl::EnumContext::Context::Table; + } + } + } + } + return vcl::EnumContext::GetContextName(eContext); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/view/tabvwsh4.cxx b/sc/source/ui/view/tabvwsh4.cxx index eec78f7cdef5..2afa9a90042e 100644 --- a/sc/source/ui/view/tabvwsh4.cxx +++ b/sc/source/ui/view/tabvwsh4.cxx @@ -768,7 +768,7 @@ void ScTabViewShell::SetTableShell(bool bActive) bActiveMediaSh=false; bActiveOleObjectSh=false; bActiveChartSh=false; - SetCurSubShell(OST_Table); + SetCurSubShell(OST_Table, true); } else SetCurSubShell(OST_Cell);
