wizards/com/sun/star/wizards/db/SQLQueryComposer.java | 22 +++++++- wizards/com/sun/star/wizards/report/ReportTextDocument.java | 3 - wizards/com/sun/star/wizards/report/ReportTextImplementation.java | 25 ++++++---- wizards/com/sun/star/wizards/ui/SortingComponent.java | 11 +--- 4 files changed, 41 insertions(+), 20 deletions(-)
New commits: commit b679dd69c0ebc1e8f4a3e85a2ef39c6a68a814f5 Author: Lionel Elie Mamane <lio...@mamane.lu> Date: Wed Jun 6 14:28:50 2012 +0200 legacy reports: unify treatment of query and table In *both* cases, the value of hidden control "Sorting" (if non-empty) decides the columns being sorted on. Change-Id: I7f4b50c3af8c12e48e5dedd36b5877ad7a9e1b66 diff --git a/wizards/com/sun/star/wizards/report/ReportTextImplementation.java b/wizards/com/sun/star/wizards/report/ReportTextImplementation.java index 6be5b36..937d9f2 100644 --- a/wizards/com/sun/star/wizards/report/ReportTextImplementation.java +++ b/wizards/com/sun/star/wizards/report/ReportTextImplementation.java @@ -264,7 +264,8 @@ public class ReportTextImplementation extends ReportImplementationHelper impleme } getRecordParser().setRecordFieldNames(sNewList); getRecordParser().GroupFieldNames = JavaTools.ArrayoutofString(sGroupFieldNames, PropertyNames.SEMI_COLON); - getRecordParser().setCommandType(Integer.valueOf(sCommandType).intValue()); + int nOrigCommandType = Integer.valueOf(sCommandType).intValue(); + getRecordParser().setCommandType(nOrigCommandType); sMsgQueryCreationImpossible = JavaTools.replaceSubString(sMsgQueryCreationImpossible, getRecordParser().Command, "<STATEMENT>"); bgetConnection = getRecordParser().getConnection(_properties); @@ -278,8 +279,6 @@ public class ReportTextImplementation extends ReportImplementationHelper impleme if (getRecordParser().hasEscapeProcessing(oCommand.getPropertySet())) { getRecordParser().Command = (String) oCommand.getPropertySet().getPropertyValue(PropertyNames.COMMAND); - getRecordParser().getSQLQueryComposer().m_xQueryAnalyzer.setQuery(getRecordParser().Command); - getRecordParser().Command = getRecordParser().getSQLQueryComposer().getQuery(); } else { @@ -291,14 +290,24 @@ public class ReportTextImplementation extends ReportImplementationHelper impleme bexecute = getRecordParser().executeCommand(nCommandType); //sMsgQueryCreationImpossible + (char) 13 + sMsgEndAutopilot, sFieldNameList, true); if (bexecute) { - DBMetaData.CommandObject oCommand = getRecordParser().getQueryByName(sQueryName); bexecute = getRecordParser().getFields(sFieldNameList, true); - if (bexecute && getRecordParser().hasEscapeProcessing(oCommand.getPropertySet())) + + boolean addSort = true; + if ( (nOrigCommandType == CommandType.QUERY) && !sQueryName.equals(PropertyNames.EMPTY_STRING) ) { - getRecordParser().getSQLQueryComposer().prependSortingCriteria(); - getRecordParser().Command = getRecordParser().getSQLQueryComposer().getQuery(); - bexecute = getRecordParser().executeCommand(nCommandType); + DBMetaData.CommandObject oCommand = getRecordParser().getQueryByName(sQueryName); + if (!getRecordParser().hasEscapeProcessing(oCommand.getPropertySet())) + addSort = false; } + if ( !(addSort && bexecute) ) + { + return bexecute; + } + getRecordParser().getSQLQueryComposer().m_xQueryAnalyzer.setQuery(getRecordParser().Command); + getRecordParser().getSQLQueryComposer().prependSortingCriteria(); + getRecordParser().Command = getRecordParser().getSQLQueryComposer().getQuery(); + + bexecute = getRecordParser().executeCommand(nCommandType); } return bexecute; } commit e08b4b98c35a5e314c35e24174f31aaaa6950064 Author: Lionel Elie Mamane <lio...@mamane.lu> Date: Wed Jun 6 14:26:58 2012 +0200 legacy report wizard: when source is table, save name in QueryName Change-Id: Ie0bdbed9578b95f7fccc3d9ff6d9c8b5b91ac0ab diff --git a/wizards/com/sun/star/wizards/report/ReportTextDocument.java b/wizards/com/sun/star/wizards/report/ReportTextDocument.java index 5cddeca..cbb7b9a 100644 --- a/wizards/com/sun/star/wizards/report/ReportTextDocument.java +++ b/wizards/com/sun/star/wizards/report/ReportTextDocument.java @@ -206,16 +206,15 @@ class ReportTextDocument extends com.sun.star.wizards.text.TextDocument implemen com.sun.star.container.XNameContainer xNamedForm = oFormHandler.insertFormbyName(SOREPORTFORMNAME); XNameAccess xNameAccess = UnoRuntime.queryInterface(XNameAccess.class, xNamedForm); oFormHandler.insertHiddenControl(xNameAccess, xNamedForm, PropertyNames.COMMAND_TYPE, Integer.toString(CurDBMetaData.getCommandType())); + oFormHandler.insertHiddenControl(xNameAccess, xNamedForm, QUERYNAME, CurDBMetaData.getCommandName()); if (CurDBMetaData.getCommandType() == CommandType.QUERY) { - oFormHandler.insertHiddenControl(xNameAccess, xNamedForm, QUERYNAME, CurDBMetaData.getCommandName()); oFormHandler.insertHiddenControl(xNameAccess, xNamedForm, PropertyNames.COMMAND, ""); //DBMetaData.CommandObject oCommand = CurDBMetaData.getQueryByName(CurDBMetaData.getCommandName()); //oFormHandler.insertHiddenControl(xNameAccess, xNamedForm, COMMAND, CurDBMetaData.Command); } else { - oFormHandler.insertHiddenControl(xNameAccess, xNamedForm, QUERYNAME, ""); oFormHandler.insertHiddenControl(xNameAccess, xNamedForm, PropertyNames.COMMAND, CurDBMetaData.Command); } oFormHandler.insertHiddenControl(xNameAccess, xNamedForm, "GroupFieldNames", JavaTools.ArraytoString(CurDBMetaData.GroupFieldNames)); commit 817ab31b8c609d1914b066bdc0141fa2fac35686 Author: Lionel Elie Mamane <lio...@mamane.lu> Date: Wed Jun 6 14:25:51 2012 +0200 SQLQueryComposer allow setQueryCommand with prependSorting instead of append Change-Id: Ia06794537ea4d0f6f069c83709792ebbcc084804 diff --git a/wizards/com/sun/star/wizards/db/SQLQueryComposer.java b/wizards/com/sun/star/wizards/db/SQLQueryComposer.java index 059412a..2b24ac3 100644 --- a/wizards/com/sun/star/wizards/db/SQLQueryComposer.java +++ b/wizards/com/sun/star/wizards/db/SQLQueryComposer.java @@ -286,6 +286,11 @@ public class SQLQueryComposer public boolean setQueryCommand(XWindow _xParentWindow, boolean _bincludeGrouping, boolean _baddAliasFieldNames, boolean addQuery) { + return setQueryCommand(_xParentWindow, _bincludeGrouping, _baddAliasFieldNames, addQuery, false); + } + + public boolean setQueryCommand(XWindow _xParentWindow, boolean _bincludeGrouping, boolean _baddAliasFieldNames, boolean addQuery, boolean prependSortingCriteria) + { try { bincludeGrouping = _bincludeGrouping; @@ -309,7 +314,14 @@ public class SQLQueryComposer m_queryComposer.setStructuredHavingClause(CurDBMetaData.GroupByFilterConditions); } } - appendSortingcriteria(_baddAliasFieldNames); + if (prependSortingCriteria) + { + prependSortingCriteria(_baddAliasFieldNames); + } + else + { + appendSortingcriteria(_baddAliasFieldNames); + } return true; } commit 27cab1806f8359ee078ac74e17f8ea40a2e5c85d Author: Lionel Elie Mamane <lio...@mamane.lu> Date: Wed Jun 6 14:24:54 2012 +0200 db.SQLQueryComposer allow prependSortingCriteria call with addAliasFieldNames Change-Id: I05889ccac213743a55c302bd7249b30f817c0428 diff --git a/wizards/com/sun/star/wizards/db/SQLQueryComposer.java b/wizards/com/sun/star/wizards/db/SQLQueryComposer.java index a1cdb56..059412a 100644 --- a/wizards/com/sun/star/wizards/db/SQLQueryComposer.java +++ b/wizards/com/sun/star/wizards/db/SQLQueryComposer.java @@ -155,11 +155,16 @@ public class SQLQueryComposer public void prependSortingCriteria() throws SQLException { + prependSortingCriteria(false); + } + + public void prependSortingCriteria(boolean _baddAliasFieldNames) throws SQLException + { XIndexAccess xColumnIndexAccess = m_xQueryAnalyzer.getOrderColumns(); m_queryComposer.setOrder(""); for (int i = 0; i < CurDBMetaData.getSortFieldNames().length; i++) { - appendSortingCriterion(i, false); + appendSortingCriterion(i, _baddAliasFieldNames); } for (int i = 0; i < xColumnIndexAccess.getCount(); i++) { commit b107e8a126afdd43f998c6027b86ad687a6369ca Author: Lionel Elie Mamane <lio...@mamane.lu> Date: Wed Jun 6 14:23:50 2012 +0200 cleanup Change-Id: I1ce4279d434ffa58328e17863b2e68af1e813a99 diff --git a/wizards/com/sun/star/wizards/db/SQLQueryComposer.java b/wizards/com/sun/star/wizards/db/SQLQueryComposer.java index 8469a2b..a1cdb56 100644 --- a/wizards/com/sun/star/wizards/db/SQLQueryComposer.java +++ b/wizards/com/sun/star/wizards/db/SQLQueryComposer.java @@ -241,7 +241,6 @@ public class SQLQueryComposer { for (int m = 0; m < _filterconditions[n].length; m++) { - // _filterconditions[n][m].Name = getComposedAliasFieldName(_filterconditions[n][m].Name); final String aliasName = getComposedAliasFieldName(_filterconditions[n][m].Name); if ( columns.hasByName(aliasName)) _filterconditions[n][m].Name = aliasName; commit f824f851c5f0282581732a081cadb1745e44f1bf Author: Lionel Elie Mamane <lio...@mamane.lu> Date: Wed Jun 6 14:22:45 2012 +0200 fdo#48018 legacy reports do not sort by group columns Legacy report means done with the "old" report system, as opposed to with report builder. This was caused by a misguided attempt to sort-of work around i#110536 instead of fixing it cleanly. Revert that. Apparently the idea was to not explicitly set grouping columns as sorting columns, but that the report execution would automagically add grouping columns at begin of sorting list at report execution time. That's a bad idea for at least two reasons: * This does not allow the user to chose ASC/DESC for grouping columns * In rare / advanced cases, sorting on another column *before* grouping is desirable. Plus, the "automagic adding" part apparently wasn't implemented anyway. Change-Id: I81e76eb4b6a0e543571a4df97d0ead77f6a2d7c8 diff --git a/wizards/com/sun/star/wizards/ui/SortingComponent.java b/wizards/com/sun/star/wizards/ui/SortingComponent.java index e24ef33..6c50c9b 100644 --- a/wizards/com/sun/star/wizards/ui/SortingComponent.java +++ b/wizards/com/sun/star/wizards/ui/SortingComponent.java @@ -258,13 +258,10 @@ public class SortingComponent ArrayList<String> SortDescriptions = new ArrayList<String>(); for (int i = 0; i <= MaxSortIndex; i++) { - if (!((Boolean) CurUnoDialog.getControlProperty("lstSort" + (i + 1), PropertyNames.READ_ONLY))) - { - CurFieldName = xSortListBox[i].getSelectedItem(); - SortDescriptions.add(CurFieldName); - iCurState = ((Short) CurUnoDialog.getControlProperty("optAscend" + Integer.toString(i + 1), PropertyNames.PROPERTY_STATE)).shortValue(); - SortFieldNames.add(new String[]{CurFieldName,iCurState == 1 ? PropertyNames.ASC :"DESC" }); - } + CurFieldName = xSortListBox[i].getSelectedItem(); + SortDescriptions.add(CurFieldName); + iCurState = ((Short) CurUnoDialog.getControlProperty("optAscend" + Integer.toString(i + 1), PropertyNames.PROPERTY_STATE)).shortValue(); + SortFieldNames.add(new String[]{CurFieldName,iCurState == 1 ? PropertyNames.ASC :"DESC" }); } // When searching for a duplicate entry we can neglect whether the entries are to be sorted ascending or descending // TODO for the future we should deliver a messagebox when two different sorting modes have been applied to one field _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits