sc/source/ui/view/gridwin.cxx |   16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

New commits:
commit 4c8b1fa44d4f49510d3910981e649dcb08bceb36
Author:     Justin Luth <jl...@mail.com>
AuthorDate: Fri Oct 28 13:15:00 2022 -0400
Commit:     Justin Luth <jl...@mail.com>
CommitDate: Sat Oct 29 00:11:38 2022 +0200

    tdf#151794 sc validate: honor NO_BLANK in Cell range dropdown
    
    This fixes LO 6.0 regression 3567d00b5e1168affd067330037e062e10b05b2d
    
    Not really a regression - it never let any blanks before then,
    regardless of the "Allow empty cells" setting in the
    Data - Validity rule.
    
    The default in LO is to allow empty cells.
    
    Change-Id: I2d6fb4d7be3622c81b28f5d30985cdb5e6b2fe11
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142002
    Tested-by: Jenkins
    Reviewed-by: Justin Luth <jl...@mail.com>

diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index 4e620c2c4f12..69a1daf6f9ce 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -1376,12 +1376,12 @@ void ScGridWindow::DoScenarioMenu( const ScRange& 
rScenRange )
     mpFilterBox->EndInit();
 }
 
-void ScGridWindow::LaunchDataSelectMenu( SCCOL nCol, SCROW nRow )
+void ScGridWindow::LaunchDataSelectMenu(const SCCOL nCol, const SCROW nRow)
 {
     mpFilterBox.reset();
 
     ScDocument& rDoc = mrViewData.GetDocument();
-    SCTAB nTab = mrViewData.GetTabNo();
+    const SCTAB nTab = mrViewData.GetTabNo();
     bool bLayoutRTL = rDoc.IsLayoutRTL( nTab );
 
     tools::Long nSizeX  = 0;
@@ -1417,6 +1417,9 @@ void ScGridWindow::LaunchDataSelectMenu( SCCOL nCol, 
SCROW nRow )
 
     // SetSize later
 
+    const sal_uInt32 nIndex = rDoc.GetAttr(nCol, nRow, nTab, 
ATTR_VALIDDATA)->GetValue();
+    const ScValidationData* pData = nIndex ? rDoc.GetValidationEntry(nIndex) : 
nullptr;
+
     bool bEmpty = false;
     std::vector<ScTypedStrData> aStrings; // case sensitive
     // Fill List
@@ -1435,7 +1438,12 @@ void ScGridWindow::LaunchDataSelectMenu( SCCOL nCol, 
SCROW nRow )
             EnterWait();
 
         for (const auto& rString : aStrings)
-            rFilterBox.append_text(rString.GetString());
+        {
+            // IsIgnoreBlank allows blank values. Don't add empty string 
unless "Allow Empty Cells"
+            const OUString& rFilterString = rString.GetString();
+            if (!rFilterString.isEmpty() || !pData || pData->IsIgnoreBlank())
+                rFilterBox.append_text(rFilterString);
+        }
 
         if (bWait)
             LeaveWait();
@@ -1447,10 +1455,8 @@ void ScGridWindow::LaunchDataSelectMenu( SCCOL nCol, 
SCROW nRow )
 
     sal_Int32 nSelPos = -1;
 
-    sal_uInt32 nIndex = rDoc.GetAttr( nCol, nRow, nTab, ATTR_VALIDDATA 
)->GetValue();
     if ( nIndex )
     {
-        const ScValidationData* pData = rDoc.GetValidationEntry( nIndex );
         if (pData)
         {
             std::unique_ptr<ScTypedStrData> pNew;

Reply via email to