Blob Blame History Raw
From 566a24640ac3066bbf85f7e315a0092bc464cab2 Mon Sep 17 00:00:00 2001
Message-Id: <566a24640ac3066bbf85f7e315a0092bc464cab2.1418394850.git.erack@redhat.com>
From: Eike Rathke <erack@redhat.com>
Date: Fri, 12 Dec 2014 14:49:09 +0100
Subject: [PATCH] resolved fdo#86809 connect filter conditions correctly
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="------------erAck-patch-parts"

This is a multi-part message in MIME format.
--------------erAck-patch-parts
Content-Type: text/plain; charset=UTF-8; format=fixed
Content-Transfer-Encoding: 8bit


Maybe since 0960ec3e1b7b0d872d1f84d2d56f480a4df08b21 all conditions of a
single filter stack were OR connected, regardless whether filter-and was
given in the file.

Change-Id: Ifb423ccc7deb42bb6bba0bfc810607633f2c342c
(cherry picked from commit b500e60b32b5cf8fd61beb7476c2c29e65aee3e4)
---
 sc/source/filter/xml/xmlfilti.cxx | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)


--------------erAck-patch-parts
Content-Type: text/x-patch; name="0001-resolved-fdo-86809-connect-filter-conditions-correct.patch"
Content-Transfer-Encoding: 8bit
Content-Disposition: attachment; filename="0001-resolved-fdo-86809-connect-filter-conditions-correct.patch"

diff --git a/sc/source/filter/xml/xmlfilti.cxx b/sc/source/filter/xml/xmlfilti.cxx
index 34327eb..03cfdfd 100644
--- a/sc/source/filter/xml/xmlfilti.cxx
+++ b/sc/source/filter/xml/xmlfilti.cxx
@@ -178,12 +178,19 @@ bool ScXMLFilterContext::GetConnection()
         // secondary item gets the current connection.
         return rItem.mbOr;
 
+    // The next condition of this stack will get the current connection.
+    ++rItem.mnCondCount;
+
     if (maConnStack.size() < 2)
         // There is no last stack.  Likely the first condition in the first
-        // stack whose connection is not used.
-        return true;
+        // stack whose connection is not used.  Default in
+        // ScQueryEntry::eConnect is SC_AND, so return false (AND instead of
+        // OR) here. Otherwise, when saving the document again, we'd write a
+        // uselessly stacked
+        // <table:filter-or><table:filter-and>...</table:filter-and></table:filter-or>
+        // for two conditions connected with AND.
+        return false;
 
-    ++rItem.mnCondCount;
     std::vector<ConnStackItem>::reverse_iterator itr = maConnStack.rbegin();
     ++itr;
     return itr->mbOr; // connection of the last stack.

--------------erAck-patch-parts--