You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openoffice.apache.org by ar...@apache.org on 2022/03/16 21:02:15 UTC

[openoffice] 01/01: Add "empty" and "not empty" autofilters

This is an automated email from the ASF dual-hosted git repository.

ardovm pushed a commit to branch bug35578
in repository https://gitbox.apache.org/repos/asf/openoffice.git

commit e4261b3f576e1ecd15352e270e6c8ceccdfd4a13
Author: Arrigo Marchiori <ar...@yahoo.it>
AuthorDate: Wed Mar 16 21:55:52 2022 +0100

    Add "empty" and "not empty" autofilters
    
    Patch by Srinivasa Ragavan (sragavan), adapted to current sources
---
 main/sc/source/ui/view/gridwin.cxx | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/main/sc/source/ui/view/gridwin.cxx b/main/sc/source/ui/view/gridwin.cxx
index c40d38d..c343059 100644
--- a/main/sc/source/ui/view/gridwin.cxx
+++ b/main/sc/source/ui/view/gridwin.cxx
@@ -136,6 +136,8 @@ const sal_uInt8 SC_NESTEDBUTTON_UP   = 2;
 #define SC_AUTOFILTER_ALL		0
 #define	SC_AUTOFILTER_TOP10     1
 #define	SC_AUTOFILTER_CUSTOM    2
+#define SC_AUTOFILTER_EMPTY     3
+#define SC_AUTOFILTER_NOTEMPTY  4
 
 //	Modi fuer die FilterListBox
 enum ScFilterBoxMode
@@ -975,7 +977,7 @@ void ScGridWindow::DoAutoFilterMenue( SCCOL nCol, SCROW nRow, sal_Bool bDataSele
 		long nMaxText = 0;
 
 		//	default entries
-        static const sal_uInt16 nDefIDs[] = { SCSTR_ALLFILTER, SCSTR_TOP10FILTER, SCSTR_STDFILTER };
+        static const sal_uInt16 nDefIDs[] = { SCSTR_ALLFILTER, SCSTR_TOP10FILTER, SCSTR_STDFILTER, SCSTR_EMPTY, SCSTR_NOTEMPTY };
 		const sal_uInt16 nDefCount = sizeof(nDefIDs) / sizeof(sal_uInt16);
 		for (i=0; i<nDefCount; i++)
 		{
@@ -1311,7 +1313,20 @@ void ScGridWindow::ExecFilter( sal_uLong nSel,
 						rNewEntry.eOp	= SC_TOPVAL;
 						*rNewEntry.pStr	= String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("10"));
 					}
-					else
+					else if ( nSel == SC_AUTOFILTER_EMPTY) {
+                        rNewEntry.pStr->Erase();
+                        rNewEntry.bQueryByString = sal_False;
+                        rNewEntry.eOp   = SC_EQUAL;
+                        rNewEntry.nVal  = SC_EMPTYFIELDS;
+                    }
+                    else if (nSel == SC_AUTOFILTER_NOTEMPTY)
+                    {
+                        rNewEntry.pStr->Erase();
+                        rNewEntry.bQueryByString = sal_False;
+                        rNewEntry.eOp   = SC_EQUAL;
+                        rNewEntry.nVal  = SC_NONEMPTYFIELDS;
+                    }
+                    else
 					{
 						rNewEntry.eOp	= SC_EQUAL;
 						*rNewEntry.pStr	= aValue;