[Libreoffice-commits] core.git: Branch 'distro/nisz/libreoffice-7-0' - sc/source
Tünde Tóth (via logerrit)
logerrit at kemper.freedesktop.org
Thu Apr 29 06:23:14 UTC 2021
sc/source/ui/inc/hdrcont.hxx | 2
sc/source/ui/view/hdrcont.cxx | 103 +++++++++++++++++++++++++++++++++++++++---
2 files changed, 98 insertions(+), 7 deletions(-)
New commits:
commit 8a657f9ad3f1097da8bdb04c249424858a998b26
Author: Tünde Tóth <toth.tunde at nisz.hu>
AuthorDate: Thu Jan 28 12:50:53 2021 +0100
Commit: Gabor Kelemen <kelemen.gabor2 at nisz.hu>
CommitDate: Thu Apr 29 08:22:39 2021 +0200
tdf#89841 sc UI: show blue row numbers for filtered rows
improving appearance of Autofilter for interoperability.
Change-Id: I4bbfacd732e8a7d5bb592ae6bb9313be2a8d03d7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110130
Tested-by: László Németh <nemeth at numbertext.org>
Reviewed-by: László Németh <nemeth at numbertext.org>
(cherry picked from commit 9bba5f418d4900ba20503dd1d310b3ff68bb14df)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114725
Tested-by: Gabor Kelemen <kelemen.gabor2 at nisz.hu>
Reviewed-by: Gabor Kelemen <kelemen.gabor2 at nisz.hu>
diff --git a/sc/source/ui/inc/hdrcont.hxx b/sc/source/ui/inc/hdrcont.hxx
index 08be7eba5010..0e5dd90ec674 100644
--- a/sc/source/ui/inc/hdrcont.hxx
+++ b/sc/source/ui/inc/hdrcont.hxx
@@ -38,7 +38,9 @@ private:
SelectionEngine* pSelEngine;
vcl::Font aNormFont;
vcl::Font aBoldFont;
+ vcl::Font aAutoFilterFont;
bool bBoldSet;
+ bool bAutoFilterSet;
bool bVertical; // Vertical = Row header
diff --git a/sc/source/ui/view/hdrcont.cxx b/sc/source/ui/view/hdrcont.cxx
index a8aeb47f9f88..5e50031f69f9 100644
--- a/sc/source/ui/view/hdrcont.cxx
+++ b/sc/source/ui/view/hdrcont.cxx
@@ -25,6 +25,7 @@
#include <tabvwsh.hxx>
#include <hdrcont.hxx>
+#include <dbdata.hxx>
#include <scmod.hxx>
#include <inputopt.hxx>
#include <gridmerg.hxx>
@@ -32,6 +33,7 @@
#include <markdata.hxx>
#include <tabview.hxx>
#include <viewdata.hxx>
+#include <columnspanset.hxx>
#define SC_DRAG_MIN 2
@@ -74,9 +76,11 @@ ScHeaderControl::ScHeaderControl( vcl::Window* pParent, SelectionEngine* pSelect
aNormFont.SetTransparent( true ); //! hard-set WEIGHT_NORMAL ???
aBoldFont = aNormFont;
aBoldFont.SetWeight( WEIGHT_BOLD );
+ aAutoFilterFont = aNormFont;
SetFont(aBoldFont);
bBoldSet = true;
+ bAutoFilterSet = false;
Size aSize = LogicToPixel( Size(
GetTextWidth("8888"),
@@ -213,12 +217,18 @@ void ScHeaderControl::Paint( vcl::RenderContext& /*rRenderContext*/, const tools
Color aTextColor = rStyleSettings.GetButtonTextColor();
Color aSelTextColor = rStyleSettings.GetHighlightTextColor();
+ Color aAFilterTextColor = COL_LIGHTBLUE; // color of filtered row numbers
aNormFont.SetColor( aTextColor );
+ aAutoFilterFont.SetColor(aAFilterTextColor);
if ( bHighContrast )
aBoldFont.SetColor( aTextColor );
else
aBoldFont.SetColor( aSelTextColor );
- SetTextColor( ( bBoldSet && !bHighContrast ) ? aSelTextColor : aTextColor );
+
+ if (bAutoFilterSet)
+ SetTextColor(aAFilterTextColor);
+ else
+ SetTextColor((bBoldSet && !bHighContrast) ? aSelTextColor : aTextColor);
Color aSelLineColor = rStyleSettings.GetHighlightColor();
aSelLineColor.Merge( COL_BLACK, 0xe0 ); // darken just a little bit
@@ -371,6 +381,57 @@ void ScHeaderControl::Paint( vcl::RenderContext& /*rRenderContext*/, const tools
}
}
+ // tdf#89841 Use blue row numbers when Autofilter selected
+ std::vector<sc::ColRowSpan> aSpans;
+ if (bVertical)
+ {
+ SCTAB nTab = pTabView->GetViewData().GetTabNo();
+ ScDocument* pDoc = pTabView->GetViewData().GetDocument();
+
+ ScDBData* pDBData = pDoc->GetAnonymousDBData(nTab);
+ if (pDBData && pDBData->HasAutoFilter())
+ {
+ SCSIZE nSelected = 0;
+ SCSIZE nTotal = 0;
+ pDBData->GetFilterSelCount(nSelected, nTotal);
+ if (nTotal > nSelected)
+ {
+ ScRange aRange;
+ pDBData->GetArea(aRange);
+ SCCOLROW nStartRow = static_cast<SCCOLROW>(aRange.aStart.Row());
+ SCCOLROW nEndRow = static_cast<SCCOLROW>(aRange.aEnd.Row());
+ if (pDBData->HasHeader())
+ nStartRow++;
+ aSpans.push_back(sc::ColRowSpan(nStartRow, nEndRow));
+ }
+ }
+
+ ScDBCollection* pDocColl = pDoc->GetDBCollection();
+ if (!pDocColl->empty())
+ {
+ ScDBCollection::NamedDBs& rDBs = pDocColl->getNamedDBs();
+ for (const auto& rxDB : rDBs)
+ {
+ if (rxDB->GetTab() == nTab && rxDB->HasAutoFilter())
+ {
+ SCSIZE nSelected = 0;
+ SCSIZE nTotal = 0;
+ rxDB->GetFilterSelCount(nSelected, nTotal);
+ if (nTotal > nSelected)
+ {
+ ScRange aRange;
+ rxDB->GetArea(aRange);
+ SCCOLROW nStartRow = static_cast<SCCOLROW>(aRange.aStart.Row());
+ SCCOLROW nEndRow = static_cast<SCCOLROW>(aRange.aEnd.Row());
+ if (rxDB->HasHeader())
+ nStartRow++;
+ aSpans.push_back(sc::ColRowSpan(nStartRow, nEndRow));
+ }
+ }
+ }
+ }
+ }
+
// loop through entries several times to avoid changing the line color too often
// and to allow merging of lines
@@ -478,14 +539,42 @@ void ScHeaderControl::Paint( vcl::RenderContext& /*rRenderContext*/, const tools
case SC_HDRPAINT_TEXT:
if ( nSizePix > 1 ) // minimal check for small columns/rows
{
- if ( bMark != bBoldSet )
+ if (bVertical)
{
- if (bMark)
- SetFont(aBoldFont);
- else
- SetFont(aNormFont);
- bBoldSet = bMark;
+ bool bAutoFilterPos = false;
+ for (const auto& rSpan : aSpans)
+ {
+ if (nEntryNo >= rSpan.mnStart && nEntryNo <= rSpan.mnEnd)
+ {
+ bAutoFilterPos = true;
+ break;
+ }
+ }
+
+ if (bMark != bBoldSet || bAutoFilterPos != bAutoFilterSet)
+ {
+ if (bMark)
+ SetFont(aBoldFont);
+ else if (bAutoFilterPos)
+ SetFont(aAutoFilterFont);
+ else
+ SetFont(aNormFont);
+ bBoldSet = bMark;
+ bAutoFilterSet = bAutoFilterPos && !bMark;
+ }
+ }
+ else
+ {
+ if (bMark != bBoldSet)
+ {
+ if (bMark)
+ SetFont(aBoldFont);
+ else
+ SetFont(aNormFont);
+ bBoldSet = bMark;
+ }
}
+
aString = GetEntryText( nEntryNo );
aTextSize.setWidth( GetTextWidth( aString ) );
aTextSize.setHeight( GetTextHeight() );
More information about the Libreoffice-commits
mailing list