From 2c76fd1e04441889fbc416d4e5815ef31b474193 Mon Sep 17 00:00:00 2001 From: Fabio Buso Date: Tue, 9 Aug 2016 10:25:37 +0200 Subject: tdf#67647 getStructuredFilter returns operator Change-Id: I010ea3c24b4d5411711a93e35d4b173f5bde9e55 Reviewed-on: https://gerrit.libreoffice.org/28000 Reviewed-by: Lionel Elie Mamane Tested-by: Lionel Elie Mamane --- .../com/sun/star/wizards/db/SQLQueryComposer.java | 56 ---------------------- .../com/sun/star/wizards/ui/FilterComponent.java | 2 +- 2 files changed, 1 insertion(+), 57 deletions(-) (limited to 'wizards/com/sun') diff --git a/wizards/com/sun/star/wizards/db/SQLQueryComposer.java b/wizards/com/sun/star/wizards/db/SQLQueryComposer.java index d169f7dd951a..17bc953affa9 100644 --- a/wizards/com/sun/star/wizards/db/SQLQueryComposer.java +++ b/wizards/com/sun/star/wizards/db/SQLQueryComposer.java @@ -429,62 +429,6 @@ public class SQLQueryComposer } } - /** - * retrieves a normalized structured filter - * - *

XSingleSelectQueryComposer.getStructuredFilter has a strange habit of returning the predicate (equal, not equal, etc) - * effectively twice: Once as SQLFilterOperator, and once in the value. That is, if you have a term {@literal "column <> 3"}, then - * you'll get an SQLFilterOperator.NOT_EQUAL (which is fine), and the textual value of the condition - * will read {@literal "<> 3"}. The latter is strange enough, but even more strange is that this behavior is not even consistent: - * for SQLFilterOperator.EQUAL, the "=" sign is not include in the textual value.

- * - *

To abstract from this weirdness, use this function here, which strips the unwanted tokens from the textual value - * representation.

- */ - public PropertyValue[][] getNormalizedStructuredFilter() - { - final PropertyValue[][] structuredFilter = m_queryComposer.getStructuredFilter(); - for (int i = 0; i < structuredFilter.length; ++i) - { - for (int j = 0; j < structuredFilter[i].length; ++j) - { - if (!(structuredFilter[i][j].Value instanceof String)) - { - continue; - } - final StringBuffer textualValue = new StringBuffer((String) structuredFilter[i][j].Value); - switch (structuredFilter[i][j].Handle) - { - case SQLFilterOperator.EQUAL: - break; - case SQLFilterOperator.NOT_EQUAL: - case SQLFilterOperator.LESS_EQUAL: - case SQLFilterOperator.GREATER_EQUAL: - textualValue.delete(0, 2); - break; - case SQLFilterOperator.LESS: - case SQLFilterOperator.GREATER: - textualValue.delete(0, 1); - break; - case SQLFilterOperator.NOT_LIKE: - textualValue.delete(0, 8); - break; - case SQLFilterOperator.LIKE: - textualValue.delete(0, 4); - break; - case SQLFilterOperator.SQLNULL: - textualValue.delete(0, 7); - break; - case SQLFilterOperator.NOT_SQLNULL: - textualValue.delete(0, 11); - break; - } - structuredFilter[i][j].Value = textualValue.toString().trim(); - } - } - return structuredFilter; - } - public XSingleSelectQueryComposer getQueryComposer() { return m_queryComposer; diff --git a/wizards/com/sun/star/wizards/ui/FilterComponent.java b/wizards/com/sun/star/wizards/ui/FilterComponent.java index ad1eb18ca318..b6c39fc55603 100644 --- a/wizards/com/sun/star/wizards/ui/FilterComponent.java +++ b/wizards/com/sun/star/wizards/ui/FilterComponent.java @@ -274,7 +274,7 @@ public class FilterComponent composer.getQueryComposer().appendFilterByColumn(columnSet, getfilterstate() == this.SOI_MATCHALL, nOperator); } } - filterconditions = composer.getNormalizedStructuredFilter(); + filterconditions = composer.getQueryComposer().getStructuredFilter(); int[] iduplicate = JavaTools.getDuplicateFieldIndex(filterconditions); if (iduplicate[0] != -1) { -- cgit