chart2/source/controller/dialogs/DialogModel.cxx | 2 sc/inc/column.hxx | 2 sc/inc/dbdata.hxx | 1 sc/inc/document.hxx | 7 + sc/inc/table.hxx | 3 sc/source/core/data/column3.cxx | 83 +++++++++++++++++++---- sc/source/core/data/document.cxx | 7 + sc/source/core/data/table3.cxx | 6 + sc/source/core/data/table4.cxx | 34 +++++++++ sc/source/core/tool/dbdata.cxx | 17 ++++ sc/source/ui/view/gridwin.cxx | 1 sc/source/ui/view/tabvwshc.cxx | 1 12 files changed, 153 insertions(+), 11 deletions(-)
New commits: commit 55179934c0fb48e43ef16172e85b2d7af360fee4 Author: Henry Castro <hcas...@collabora.com> AuthorDate: Thu Nov 23 11:49:15 2023 -0400 Commit: Aron Budea <aron.bu...@collabora.com> CommitDate: Sat Dec 9 21:30:04 2023 +1030 sc: fix back color filter entries The function "GetFilterEntries" iterates only that contains cell data value entries, the background color filter feature requires to iterate background color attribute which is not stored in multi type vector cells. Signed-off-by: Henry Castro <hcas...@collabora.com> Change-Id: I372db48d2399f62712f642eefdbfea8885b09f58 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159864 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> (cherry picked from commit 826eae46095b2184554565bab1792e96964a720f) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159905 Tested-by: Jenkins (cherry picked from commit 8b2369236dea7d6863c2df3d4ce5e356c9c8010c) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160038 (cherry picked from commit 6b1d35b9af28e9f54306112203fa98961cd3e567) diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx index b8e348d00e70..2f22ada03caa 100644 --- a/sc/inc/column.hxx +++ b/sc/inc/column.hxx @@ -544,6 +544,8 @@ public: sc::ColumnBlockConstPosition& rBlockPos, SCROW nStartRow, SCROW nEndRow, ScFilterEntries& rFilterEntries, bool bFiltering ); + void GetBackColorFilterEntries(SCROW nRow1, SCROW nRow2, ScFilterEntries& rFilterEntries ); + bool GetDataEntries( SCROW nRow, std::set<ScTypedStrData>& rStrings) const; void UpdateInsertTabAbs(SCTAB nNewPos); diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx index 69a32eaad433..ebec09e581ef 100644 --- a/sc/source/core/data/column3.cxx +++ b/sc/source/core/data/column3.cxx @@ -2720,6 +2720,66 @@ void ScColumn::GetFilterEntries( sc::ParseAll(rBlockPos.miCellPos, maCells, nStartRow, nEndRow, aFunc, aFunc); } +void ScColumn::GetBackColorFilterEntries(SCROW nRow1, SCROW nRow2, ScFilterEntries& rFilterEntries) +{ + Color aBackColor; + bool bCondBackColor = false; + ScAddress aCell(GetCol(), 0, GetTab()); + ScConditionalFormat* pCondFormat = nullptr; + + const SfxItemSet* pCondSet = nullptr; + const SvxBrushItem* pBrush = nullptr; + const ScPatternAttr* pPattern = nullptr; + const ScColorScaleFormat* pColFormat = nullptr; + + if (!GetDoc().ValidRow(nRow1) || !GetDoc().ValidRow(nRow2)) + return; + + while (nRow1 <= nRow2) + { + aCell.SetRow(nRow1); + pPattern = GetDoc().GetPattern(aCell.Col(), aCell.Row(), aCell.Tab()); + if (pPattern) + { + if (!pPattern->GetItem(ATTR_CONDITIONAL).GetCondFormatData().empty()) + { + pCondSet = GetDoc().GetCondResult(GetCol(), nRow1, GetTab()); + pBrush = &pPattern->GetItem(ATTR_BACKGROUND, pCondSet); + aBackColor = pBrush->GetColor(); + bCondBackColor = true; + } + } + + pCondFormat = GetDoc().GetCondFormat(aCell.Col(), aCell.Row(), aCell.Tab()); + if (pCondFormat) + { + for (size_t nFormat = 0; nFormat < pCondFormat->size(); nFormat++) + { + auto aEntry = pCondFormat->GetEntry(nFormat); + if (aEntry->GetType() == ScFormatEntry::Type::Colorscale) + { + pColFormat = static_cast<const ScColorScaleFormat*>(aEntry); + std::optional<Color> oColor = pColFormat->GetColor(aCell); + if (oColor) + { + aBackColor = *oColor; + bCondBackColor = true; + } + } + } + } + + if (!bCondBackColor) + { + pBrush = GetDoc().GetAttr(aCell, ATTR_BACKGROUND); + aBackColor = pBrush->GetColor(); + } + + rFilterEntries.addBackgroundColor(aBackColor); + nRow1++; + } +} + namespace { /** diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx index efcc910dc696..e4b13f8ad17f 100644 --- a/sc/source/core/data/table3.cxx +++ b/sc/source/core/data/table3.cxx @@ -2968,6 +2968,12 @@ void ScTable::GetFilterEntries( SCCOL nCol, SCROW nRow1, SCROW nRow2, ScFilterEn sc::ColumnBlockConstPosition aBlockPos; aCol[nCol].InitBlockPosition(aBlockPos); aCol[nCol].GetFilterEntries(aBlockPos, nRow1, nRow2, rFilterEntries, bFiltering); + + SCROW nLastRow = aBlockPos.miCellPos->position; + if (nLastRow < nRow2) + { + aCol[nCol].GetBackColorFilterEntries(nLastRow, nRow2, rFilterEntries); + } } void ScTable::GetFilteredFilterEntries( commit 4a3cb6b1c27173df5e8e4aac62d25079f7b59505 Author: Henry Castro <hcas...@collabora.com> AuthorDate: Mon Nov 6 07:18:48 2023 -0400 Commit: Aron Budea <aron.bu...@collabora.com> CommitDate: Sat Dec 9 21:18:57 2023 +1030 sc: extend backcolor area If the filter background color is selected, the automatic selection area should include, the attribute of background cell color too. Signed-off-by: Henry Castro <hcas...@collabora.com> Change-Id: I341c602247e7f71e3c9665e1b594177d8f5553b5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158991 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> (cherry picked from commit 768433f07873eb608837630f85e7e1b375239fca) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159238 Tested-by: Jenkins (cherry picked from commit 4abe6c83e76f825319e8b2a0c0b8b8e92177da65) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159249 (cherry picked from commit 64a4011951f54f8b86205798b968b20b532ea703) diff --git a/sc/inc/dbdata.hxx b/sc/inc/dbdata.hxx index f12ba3fb976d..e03e41f6562a 100644 --- a/sc/inc/dbdata.hxx +++ b/sc/inc/dbdata.hxx @@ -213,6 +213,7 @@ public: SCCOL nDx, SCROW nDy, SCTAB nDz); void ExtendDataArea(const ScDocument& rDoc); + void ExtendBackColorArea(const ScDocument& rDoc); void CalcSaveFilteredCount(SCSIZE nNonFilteredRowCount); void GetFilterSelCount(SCSIZE& nSelected, SCSIZE& nTotal); diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx index 2050eac9595f..b8a0c3a2ed8f 100644 --- a/sc/inc/document.hxx +++ b/sc/inc/document.hxx @@ -1455,6 +1455,13 @@ public: SCCOL& rEndCol, SCROW& rEndRow, bool bIncludeOld, bool bOnlyDown ) const; + /** + * Return the extended area containing at least all contiguous cells + * having background color. + */ + SC_DLLPUBLIC void GetBackColorArea( SCTAB nTab, SCCOL& rStartCol, SCROW& rStartRow, + SCCOL& rEndCol, SCROW& rEndRow ) const; + /** * Returns true if there is a non-empty subrange in the range given as input. * In that case it also modifies rRange to largest subrange that does not diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx index 4026a6b82d01..54792b66ea1c 100644 --- a/sc/inc/table.hxx +++ b/sc/inc/table.hxx @@ -598,6 +598,9 @@ public: void GetDataArea( SCCOL& rStartCol, SCROW& rStartRow, SCCOL& rEndCol, SCROW& rEndRow, bool bIncludeOld, bool bOnlyDown ) const; + void GetBackColorArea( SCCOL& rStartCol, SCROW& rStartRow, + SCCOL& rEndCol, SCROW& rEndRow ) const; + bool GetDataAreaSubrange( ScRange& rRange ) const; bool ShrinkToUsedDataArea( bool& o_bShrunk, SCCOL& rStartCol, SCROW& rStartRow, diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx index 5fe2cfe08d0d..26b6db992a5f 100644 --- a/sc/source/core/data/document.cxx +++ b/sc/source/core/data/document.cxx @@ -1092,6 +1092,13 @@ void ScDocument::GetDataArea( SCTAB nTab, SCCOL& rStartCol, SCROW& rStartRow, maTabs[nTab]->GetDataArea( rStartCol, rStartRow, rEndCol, rEndRow, bIncludeOld, bOnlyDown ); } +void ScDocument::GetBackColorArea( SCTAB nTab, SCCOL& rStartCol, SCROW& rStartRow, + SCCOL& rEndCol, SCROW& rEndRow ) const +{ + if (ValidTab(nTab) && nTab < static_cast<SCTAB> (maTabs.size()) && maTabs[nTab]) + maTabs[nTab]->GetBackColorArea( rStartCol, rStartRow, rEndCol, rEndRow ); +} + bool ScDocument::GetDataAreaSubrange(ScRange& rRange) const { SCTAB nTab = rRange.aStart.Tab(); diff --git a/sc/source/core/data/table4.cxx b/sc/source/core/data/table4.cxx index d2fdde2718b8..23c21aa577ed 100644 --- a/sc/source/core/data/table4.cxx +++ b/sc/source/core/data/table4.cxx @@ -23,6 +23,7 @@ #include <editeng/editeng.hxx> #include <editeng/eeitem.hxx> #include <editeng/escapementitem.hxx> +#include <editeng/brushitem.hxx> #include <svl/numformat.hxx> #include <svl/zforlist.hxx> #include <vcl/keycodes.hxx> @@ -1208,6 +1209,39 @@ void ScTable::FillAuto( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, } } +void ScTable::GetBackColorArea(SCCOL& rStartCol, SCROW& /*rStartRow*/, + SCCOL& rEndCol, SCROW& rEndRow ) const +{ + bool bExtend; + const SvxBrushItem* pDefBackground = &rDocument.GetPool()->GetDefaultItem(ATTR_BACKGROUND); + + rStartCol = std::min<SCCOL>(rStartCol, aCol.size() - 1); + rEndCol = std::min<SCCOL>(rEndCol, aCol.size() - 1); + + do + { + bExtend = false; + + if (rEndRow < rDocument.MaxRow()) + { + for (SCCOL nCol = rStartCol; nCol <= rEndCol; ++nCol) + { + const ScPatternAttr* pPattern = aCol[nCol].GetPattern(rEndRow + 1); + const SvxBrushItem* pBackground = &pPattern->GetItem(ATTR_BACKGROUND); + if (!pPattern->GetItem(ATTR_CONDITIONAL).GetCondFormatData().empty() || + pBackground != pDefBackground) + { + bExtend = true; + break; + } + } + + if (bExtend) + ++rEndRow; + } + } while (bExtend); +} + OUString ScTable::GetAutoFillPreview( const ScRange& rSource, SCCOL nEndX, SCROW nEndY ) { OUString aValue; diff --git a/sc/source/core/tool/dbdata.cxx b/sc/source/core/tool/dbdata.cxx index e441c7418796..29d96cd90692 100644 --- a/sc/source/core/tool/dbdata.cxx +++ b/sc/source/core/tool/dbdata.cxx @@ -666,6 +666,23 @@ void ScDBData::ExtendDataArea(const ScDocument& rDoc) } } +void ScDBData::ExtendBackColorArea(const ScDocument& rDoc) +{ + // Extend the DB area to include data rows immediately below. + SCCOL nOldCol1 = nStartCol, nOldCol2 = nEndCol; + SCROW nOldEndRow = nEndRow; + rDoc.GetBackColorArea(nTable, nStartCol, nStartRow, nEndCol, nEndRow); + + if (nOldEndRow < rDoc.MaxRow() && nEndRow < nOldEndRow) + nEndRow = nOldEndRow; + + if (nStartCol != nOldCol1 || nEndCol != nOldCol2) + { + SAL_WARN_IF( !maTableColumnNames.empty(), "sc.core", "ScDBData::ExtendBackColorArea - invalidating column names/offsets"); + InvalidateTableColumnNames( true); + } +} + void ScDBData::StartTableColumnNamesListener() { if (mpContainer && bHasHeader) diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx index f41d7b580a01..93616da64389 100644 --- a/sc/source/ui/view/gridwin.cxx +++ b/sc/source/ui/view/gridwin.cxx @@ -901,6 +901,7 @@ void ScGridWindow::LaunchAutoFilterMenu(SCCOL nCol, SCROW nRow) if (!pDBData) return; + pDBData->ExtendBackColorArea(rDoc); pData->mpData = pDBData; mpAutoFilterPopup->setExtendedData(std::move(pData)); diff --git a/sc/source/ui/view/tabvwshc.cxx b/sc/source/ui/view/tabvwshc.cxx index e43cb2ff31bc..e956f600356e 100644 --- a/sc/source/ui/view/tabvwshc.cxx +++ b/sc/source/ui/view/tabvwshc.cxx @@ -316,6 +316,7 @@ std::shared_ptr<SfxModelessDialogController> ScTabViewShell::CreateRefDialogCont ScDBData* pDBData = GetDBData(false, SC_DB_MAKE, ScGetDBSelection::RowDown); pDBData->ExtendDataArea(rDoc); + pDBData->ExtendBackColorArea(rDoc); pDBData->GetQueryParam( aQueryParam ); ScRange aArea; commit 02bb1849ffa352cfafdf1e4a7d13ad7ca43205ca Author: Samuel Mehrbrodt <samuel.mehrbr...@allotropia.de> AuthorDate: Thu Apr 27 13:58:26 2023 +0200 Commit: Aron Budea <aron.bu...@collabora.com> CommitDate: Sat Dec 9 21:13:27 2023 +1030 tdf#153972 Fix color filter when cells have no content Change-Id: I9742fc0627c2311bfe4c067961e0feea476f1899 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151096 Tested-by: Jenkins Reviewed-by: Samuel Mehrbrodt <samuel.mehrbr...@allotropia.de> Signed-off-by: Xisco Fauli <xiscofa...@libreoffice.org> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152493 (cherry picked from commit 1aa089472457f0d6b67abb4637a5803b73682028) diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx index 5996e5edf25c..69a32eaad433 100644 --- a/sc/source/core/data/column3.cxx +++ b/sc/source/core/data/column3.cxx @@ -2530,7 +2530,7 @@ class FilterEntriesHandler ScColumn& mrColumn; ScFilterEntries& mrFilterEntries; - void processCell(const ScColumn& rColumn, SCROW nRow, ScRefCellValue& rCell) + void processCell(const ScColumn& rColumn, SCROW nRow, ScRefCellValue& rCell, bool bIsEmptyCell=false) { SvNumberFormatter* pFormatter = mrColumn.GetDoc().GetFormatTable(); sal_uLong nFormat = mrColumn.GetNumberFormat(mrColumn.GetDoc().GetNonThreadedContext(), nRow); @@ -2598,6 +2598,16 @@ class FilterEntriesHandler } mrFilterEntries.addBackgroundColor(backgroundColor); + if (bIsEmptyCell) + { + if (!mrFilterEntries.mbHasEmpties) + { + mrFilterEntries.push_back(ScTypedStrData(OUString())); + mrFilterEntries.mbHasEmpties = true; + } + return; + } + if (rCell.hasString()) { mrFilterEntries.push_back(ScTypedStrData(aStr)); @@ -2693,17 +2703,8 @@ public: void operator() (const int nElemType, size_t nRow, size_t /* nDataSize */) { - if ( nElemType == sc::element_type_empty ) - { - if (!mrFilterEntries.mbHasEmpties) - { - mrFilterEntries.push_back(ScTypedStrData(OUString())); - mrFilterEntries.mbHasEmpties = true; - } - return; - } ScRefCellValue aCell = mrColumn.GetCellValue(nRow); - processCell(mrColumn, nRow, aCell); + processCell(mrColumn, nRow, aCell, nElemType == sc::element_type_empty); } }; commit 97953a126ecbb364144a33937fc7cd75948c8024 Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Thu Jan 6 12:22:55 2022 +0300 Commit: Aron Budea <aron.bu...@collabora.com> CommitDate: Sat Dec 9 21:13:13 2023 +1030 Add 'reference' to the iterator_traits, needed by LegacyIterator reqs This addressed a failure with VS2022 Version 17.1.0 Preview 2.0: C:\PROGRA~1\MIB055~1\2022\Preview\VC\Tools\MSVC\1431~1.309\Include\xutility(1152): error C2794: 'reference': is not a member of any direct or in direct base class of 'std::iterator_traits<`anonymous-namespace'::lcl_DataSeriesContainerAppend>' C:\PROGRA~1\MIB055~1\2022\Preview\VC\Tools\MSVC\1431~1.309\Include\xutility(3932): note: see reference to alias template instantiation 'std::_Iter_ref_t<`anonymous-namespace'::lcl_DataSeriesContainerAppend>' being compiled C:\PROGRA~1\MIB055~1\2022\Preview\VC\Tools\MSVC\1431~1.309\Include\xutility(3992): note: see reference to variable template 'const bool _Iterator_is_volatile<`anonymous namespace'::lcl_DataSeriesContainerAppend>' being compiled C:\PROGRA~1\MIB055~1\2022\Preview\VC\Tools\MSVC\1431~1.309\Include\xutility(4048): note: see reference to function template instantiation '_OutIt std::_Copy_unchecked<com::sun::star::uno::Reference<com::sun::star::chart2::XDataSeriesContainer>*,_OutIt>(_InIt,_InIt,_OutIt)' being compiled with [ _OutIt=`anonymous-namespace'::lcl_DataSeriesContainerAppend, _InIt=com::sun::star::uno::Reference<com::sun::star::chart2::XDataSeriesContainer> * ] C:/lo/src/core/chart2/source/controller/dialogs/DialogModel.cxx(504): note: see reference to function template instantiation '_OutIt std::copy<std::_Vector_iterator<std::_Vector_val<std::_Simple_types<_Ty>>>,`anonymous-namespace'::lcl_DataSeriesContainerAppend>(_InIt,_InIt,_OutIt)' being compiled with [ _OutIt=`anonymous-namespace'::lcl_DataSeriesContainerAppend, _Ty=com::sun::star::uno::Reference<com::sun::star::chart2::XDataSeriesContainer>, _InIt=std::_Vector_iterator<std::_Vector_val<std::_Simple_types<com::sun::star::uno::Reference<com::sun::star::chart2::XDataSeriesContainer>>>> ] C:\PROGRA~1\MIB055~1\2022\Preview\VC\Tools\MSVC\1431~1.309\Include\xutility(3932): error C2938: 'std::_Iter_ref_t' : Failed to specialize alias template C:\PROGRA~1\MIB055~1\2022\Preview\VC\Tools\MSVC\1431~1.309\Include\xutility(3932): error C2062: type 'unknown-type' unexpected C:\PROGRA~1\MIB055~1\2022\Preview\VC\Tools\MSVC\1431~1.309\Include\xutility(3992): error C3376: 'std::_Iterator_is_volatile': only static data member templates are allowed C:\PROGRA~1\MIB055~1\2022\Preview\VC\Tools\MSVC\1431~1.309\Include\xutility(4026): error C2976: 'std::_Iter_copy_cat': too few template arguments C:\PROGRA~1\MIB055~1\2022\Preview\VC\Tools\MSVC\1431~1.309\Include\xutility(3994): note: see declaration of 'std::_Iter_copy_cat' C:\PROGRA~1\MIB055~1\2022\Preview\VC\Tools\MSVC\1431~1.309\Include\xutility(1152): error C2794: 'reference': is not a member of any direct or in direct base class of 'std::iterator_traits<`anonymous-namespace'::lcl_RolesWithRangeAppend>' C:\PROGRA~1\MIB055~1\2022\Preview\VC\Tools\MSVC\1431~1.309\Include\xutility(3932): note: see reference to alias template instantiation 'std::_Iter_ref_t<`anonymous-namespace'::lcl_RolesWithRangeAppend>' being compiled C:\PROGRA~1\MIB055~1\2022\Preview\VC\Tools\MSVC\1431~1.309\Include\xutility(3992): note: see reference to variable template 'const bool _Iterator_is_volatile<`anonymous namespace'::lcl_RolesWithRangeAppend>' being compiled C:\PROGRA~1\MIB055~1\2022\Preview\VC\Tools\MSVC\1431~1.309\Include\xutility(4048): note: see reference to function template instantiation '_OutIt std::_Copy_unchecked<_InIt,_OutIt>(_InIt,_InIt,_OutIt)' being compiled with [ _OutIt=`anonymous-namespace'::lcl_RolesWithRangeAppend, _InIt=const com::sun::star::uno::Reference<com::sun::star::chart2::data::XLabeledDataSequence> * ] C:/lo/src/core/chart2/source/controller/dialogs/DialogModel.cxx(563): note: see reference to function template instantiation '_OutIt std::copy<const E*,`anonymous-namespace'::lcl_RolesWithRangeAppend>(_InIt,_InIt,_OutIt)' being compiled with [ _OutIt=`anonymous-namespace'::lcl_RolesWithRangeAppend, E=com::sun::star::uno::Reference<com::sun::star::chart2::data::XLabeledDataSequence>, _InIt=const com::sun::star::uno::Reference<com::sun::star::chart2::data::XLabeledDataSequence> * ] make[1]: *** [C:/lo/src/core/solenv/gbuild/LinkTarget.mk:332: C:/lo/src/build/workdir/CxxObject/chart2/source/controller/dialogs/DialogModel.o] Error 2 Change-Id: Ic93dc7922cd48870ef62bfd682dd5cbdc827a255 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128036 Tested-by: Mike Kaganski <mike.kagan...@collabora.com> Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> (cherry picked from commit 0bc5584ef296683c015357232d48180b85f8baac) diff --git a/chart2/source/controller/dialogs/DialogModel.cxx b/chart2/source/controller/dialogs/DialogModel.cxx index ce6da753d6c4..9c735a489b5e 100644 --- a/chart2/source/controller/dialogs/DialogModel.cxx +++ b/chart2/source/controller/dialogs/DialogModel.cxx @@ -241,12 +241,14 @@ namespace std { typedef std::output_iterator_tag iterator_category; typedef Reference< XDataSeriesContainer > value_type; + typedef value_type& reference; }; template<> struct iterator_traits<lcl_RolesWithRangeAppend> { typedef std::output_iterator_tag iterator_category; typedef Reference< data::XLabeledDataSequence > value_type; + typedef value_type& reference; }; }