From 80f468de1e670de020ae4ac6ab15baefbd905a71 Mon Sep 17 00:00:00 2001 From: "Ocke Janssen [oj]" Date: Fri, 22 Jan 2010 08:14:22 +0100 Subject: dba33f: #i108548# extend SingleSelectQueryComposer appendFilterByColumn with additonal parameter --- .../sun/star/wizards/common/NumberFormatter.java | 1 + wizards/com/sun/star/wizards/db/DBMetaData.java | 2 - wizards/com/sun/star/wizards/db/QueryMetaData.java | 7 + .../com/sun/star/wizards/db/SQLQueryComposer.java | 36 +- wizards/com/sun/star/wizards/query/Finalizer.java | 6 +- .../wizards/report/ReportTextImplementation.java | 5 +- .../com/sun/star/wizards/report/ReportWizard.java | 11 +- .../com/sun/star/wizards/ui/FilterComponent.java | 569 +++++++++------------ 8 files changed, 293 insertions(+), 344 deletions(-) (limited to 'wizards') diff --git a/wizards/com/sun/star/wizards/common/NumberFormatter.java b/wizards/com/sun/star/wizards/common/NumberFormatter.java index a837b78ebbad..fd3f19baaef8 100644 --- a/wizards/com/sun/star/wizards/common/NumberFormatter.java +++ b/wizards/com/sun/star/wizards/common/NumberFormatter.java @@ -204,6 +204,7 @@ public class NumberFormatter Locale oLocale = (Locale) Helper.getUnoPropertyValue(xNumberFormat, "Locale"); int NewFormatKey = defineNumberFormat(FormatString, oLocale); XPropertySet xPSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, _xFormatObject); + xPSet.setPropertyValue("FormatsSupplier", _oNumberFormatter.xNumberFormatter.getNumberFormatsSupplier()); if (xPSet.getPropertySetInfo().hasPropertyByName("NumberFormat")) { xPSet.setPropertyValue("NumberFormat", new Integer(NewFormatKey)); diff --git a/wizards/com/sun/star/wizards/db/DBMetaData.java b/wizards/com/sun/star/wizards/db/DBMetaData.java index 59f63afed114..c20625218d0a 100644 --- a/wizards/com/sun/star/wizards/db/DBMetaData.java +++ b/wizards/com/sun/star/wizards/db/DBMetaData.java @@ -103,7 +103,6 @@ public class DBMetaData public com.sun.star.sdb.tools.XConnectionTools ConnectionTools; public com.sun.star.lang.XMultiServiceFactory xMSF; public XComponent xConnectionComponent; - public SQLQueryComposer oSQLQueryComposer; private XNameAccess m_xTableNames; private XInteractionHandler oInteractionHandler; @@ -1163,7 +1162,6 @@ public class DBMetaData ConnectionTools = null; xMSF = null; xConnectionComponent = null; - oSQLQueryComposer = null; CommandObjects = null; } } diff --git a/wizards/com/sun/star/wizards/db/QueryMetaData.java b/wizards/com/sun/star/wizards/db/QueryMetaData.java index 229dd8624691..28afd8b4998d 100644 --- a/wizards/com/sun/star/wizards/db/QueryMetaData.java +++ b/wizards/com/sun/star/wizards/db/QueryMetaData.java @@ -39,6 +39,7 @@ import com.sun.star.wizards.common.*; public class QueryMetaData extends CommandMetaData { + private SQLQueryComposer oSQLQueryComposer = null; FieldColumn CurFieldColumn; public String Command; // Vector CommandNamesV; @@ -293,4 +294,10 @@ public class QueryMetaData extends CommandMetaData } return iAggregate; } + public SQLQueryComposer getSQLQueryComposer() + { + if ( oSQLQueryComposer == null ) + oSQLQueryComposer = new SQLQueryComposer(this); + return oSQLQueryComposer; + } } diff --git a/wizards/com/sun/star/wizards/db/SQLQueryComposer.java b/wizards/com/sun/star/wizards/db/SQLQueryComposer.java index 10677558488c..d1a44b9ecf58 100644 --- a/wizards/com/sun/star/wizards/db/SQLQueryComposer.java +++ b/wizards/com/sun/star/wizards/db/SQLQueryComposer.java @@ -63,7 +63,7 @@ public class SQLQueryComposer // String m_sFromClause; public XSingleSelectQueryAnalyzer m_xQueryAnalyzer; Vector composedCommandNames = new Vector(1); - public XSingleSelectQueryComposer m_xQueryComposer; + private XSingleSelectQueryComposer m_xQueryComposer; XMultiServiceFactory xMSF; boolean bincludeGrouping = true; @@ -163,10 +163,8 @@ public class SQLQueryComposer { for (int i = 0; i < CurDBMetaData.getFilterConditions().length; i++) { - String sCurFieldName = CurDBMetaData.getFilterConditions()[i][0].Name; m_xQueryComposer.setStructuredFilter(CurDBMetaData.getFilterConditions()); } - String s = m_xQueryAnalyzer.getQuery(); } catch (Exception exception) { @@ -273,9 +271,10 @@ public class SQLQueryComposer return m_xQueryAnalyzer.getQuery(); } - private String getFromClause() + public String getFromClause() { String sFromClause = "FROM"; + composedCommandNames.clear(); String[] sCommandNames = CurDBMetaData.getIncludedCommandNames(); for (int i = 0; i < sCommandNames.length; i++) { @@ -293,21 +292,28 @@ public class SQLQueryComposer } public boolean setQueryCommand(XWindow _xParentWindow, boolean _bincludeGrouping, boolean _baddAliasFieldNames) + { + return setQueryCommand(_xParentWindow,_bincludeGrouping, _baddAliasFieldNames,true); + } + public boolean setQueryCommand(XWindow _xParentWindow, boolean _bincludeGrouping, boolean _baddAliasFieldNames, boolean addQuery) { try { String s; bincludeGrouping = _bincludeGrouping; - String sFromClause = getFromClause(); - String sSelectClause = getSelectClause(_baddAliasFieldNames); - String queryclause = sSelectClause + " " + sFromClause; - m_xQueryAnalyzer.setQuery(queryclause); - if (CurDBMetaData.getFilterConditions() != null) + if ( addQuery ) { - if (CurDBMetaData.getFilterConditions().length > 0) + String sFromClause = getFromClause(); + String sSelectClause = getSelectClause(_baddAliasFieldNames); + String queryclause = sSelectClause + " " + sFromClause; + m_xQueryAnalyzer.setQuery(queryclause); + if (CurDBMetaData.getFilterConditions() != null) { - CurDBMetaData.setFilterConditions(replaceConditionsByAlias(CurDBMetaData.getFilterConditions())); - m_xQueryComposer.setStructuredFilter(CurDBMetaData.getFilterConditions()); + if (CurDBMetaData.getFilterConditions().length > 0) + { + CurDBMetaData.setFilterConditions(replaceConditionsByAlias(CurDBMetaData.getFilterConditions())); + m_xQueryComposer.setStructuredFilter(CurDBMetaData.getFilterConditions()); + } } } s = m_xQueryAnalyzer.getQuery(); @@ -336,6 +342,8 @@ public class SQLQueryComposer { FieldColumn CurFieldColumn = CurDBMetaData.getFieldColumnByDisplayName(_fieldname); CommandName curComposedCommandName = getComposedCommandByDisplayName(CurFieldColumn.getCommandName()); + if ( curComposedCommandName == null ) + return _fieldname; String curAliasName = curComposedCommandName.getAliasName(); return quoteName(curAliasName) + "." + quoteName(CurFieldColumn.getFieldName()); } @@ -421,4 +429,8 @@ public class SQLQueryComposer typeexception.printStackTrace(System.out); } } + public XSingleSelectQueryComposer getQueryComposer() + { + return m_xQueryComposer; + } } diff --git a/wizards/com/sun/star/wizards/query/Finalizer.java b/wizards/com/sun/star/wizards/query/Finalizer.java index f690102ea49f..2ea0b295a592 100644 --- a/wizards/com/sun/star/wizards/query/Finalizer.java +++ b/wizards/com/sun/star/wizards/query/Finalizer.java @@ -175,12 +175,11 @@ public class Finalizer XComponent[] ret = null; try { - CurDBMetaData.oSQLQueryComposer = new SQLQueryComposer(CurDBMetaData); String queryname = getTitle(); - boolean bsuccess = CurDBMetaData.oSQLQueryComposer.setQueryCommand(CurUnoDialog.xWindow, true, true); + boolean bsuccess = CurDBMetaData.getSQLQueryComposer().setQueryCommand(CurUnoDialog.xWindow, true, true,false); if (bsuccess) { - bsuccess = CurDBMetaData.createQuery(CurDBMetaData.oSQLQueryComposer, queryname); + bsuccess = CurDBMetaData.createQuery(CurDBMetaData.getSQLQueryComposer(), queryname); if (bsuccess) { short igoon = AnyConverter.toShort(Helper.getUnoPropertyValue(UnoDialog.getModel(xRadioDisplayQuery), "State")); @@ -197,7 +196,6 @@ public class Finalizer CurUnoDialog.getCurFrame()); } CurUnoDialog.xDialog.endExecute(); - CurDBMetaData.oSQLQueryComposer = null; CurDBMetaData = null; CurUnoDialog = null; } diff --git a/wizards/com/sun/star/wizards/report/ReportTextImplementation.java b/wizards/com/sun/star/wizards/report/ReportTextImplementation.java index 6e0091b52ef5..ea9650f80360 100644 --- a/wizards/com/sun/star/wizards/report/ReportTextImplementation.java +++ b/wizards/com/sun/star/wizards/report/ReportTextImplementation.java @@ -255,13 +255,12 @@ public class ReportTextImplementation extends ReportImplementationHelper impleme if ((getRecordParser().getCommandType() == CommandType.QUERY) && (getRecordParser().Command.equals(""))) { - getRecordParser().oSQLQueryComposer = new SQLQueryComposer(getRecordParser()); DBMetaData.CommandObject oCommand = getRecordParser().getQueryByName(sQueryName); if (getRecordParser().hasEscapeProcessing(oCommand.getPropertySet())) { getRecordParser().Command = (String) oCommand.getPropertySet().getPropertyValue("Command"); - getRecordParser().oSQLQueryComposer.m_xQueryAnalyzer.setQuery(getRecordParser().Command); - getRecordParser().oSQLQueryComposer.prependSortingCriteria(); + getRecordParser().getSQLQueryComposer().m_xQueryAnalyzer.setQuery(getRecordParser().Command); + getRecordParser().getSQLQueryComposer().prependSortingCriteria(); } else { diff --git a/wizards/com/sun/star/wizards/report/ReportWizard.java b/wizards/com/sun/star/wizards/report/ReportWizard.java index a959c2dfd183..9cff5db089ac 100644 --- a/wizards/com/sun/star/wizards/report/ReportWizard.java +++ b/wizards/com/sun/star/wizards/report/ReportWizard.java @@ -329,10 +329,10 @@ public class ReportWizard extends WizardDialog implements XTextListener, XComple boolean bQueryCreated = false; if (this.CurDBCommandFieldSelection.getSelectedCommandType() == CommandType.TABLE) { - bQueryCreated = CurReportDocument.getRecordParser().oSQLQueryComposer.setQueryCommand(this.xWindow, false, false); + bQueryCreated = CurReportDocument.getRecordParser().getSQLQueryComposer().setQueryCommand(this.xWindow, false, false); CurReportDocument.setCommandType(CommandType.COMMAND); - String sQuery = CurReportDocument.getRecordParser().oSQLQueryComposer.getQuery(); + String sQuery = CurReportDocument.getRecordParser().getSQLQueryComposer().getQuery(); CurReportDocument.setCommand(sQuery); } else @@ -347,11 +347,11 @@ public class ReportWizard extends WizardDialog implements XTextListener, XComple { // String sCommand = (String) oCommand.xPropertySet.getPropertyValue("Command"); bQueryCreated = (!sCommand.equals("")); - CurReportDocument.getRecordParser().oSQLQueryComposer.m_xQueryAnalyzer.setQuery(sCommand); - CurReportDocument.getRecordParser().oSQLQueryComposer.prependSortingCriteria(); + CurReportDocument.getRecordParser().getSQLQueryComposer().m_xQueryAnalyzer.setQuery(sCommand); + CurReportDocument.getRecordParser().getSQLQueryComposer().prependSortingCriteria(); // TODO: check with query CurReportDocument.setCommandType(CommandType.COMMAND); - CurReportDocument.setCommand(CurReportDocument.getRecordParser().oSQLQueryComposer.getQuery()); + CurReportDocument.setCommand(CurReportDocument.getRecordParser().getSQLQueryComposer().getQuery()); bQueryCreated = true; } else @@ -711,7 +711,6 @@ public static XLogger getLogger() if (CurReportDocument.getRecordParser().getConnection(CurPropertyValue)) { // CurReportDocument.getDoc().xProgressBar.setValue(20); - CurReportDocument.getRecordParser().oSQLQueryComposer = new SQLQueryComposer(CurReportDocument.getRecordParser()); buildSteps(); CurReportDocument.checkInvariants(); diff --git a/wizards/com/sun/star/wizards/ui/FilterComponent.java b/wizards/com/sun/star/wizards/ui/FilterComponent.java index 3191c62d639f..440b72d2bbe1 100644 --- a/wizards/com/sun/star/wizards/ui/FilterComponent.java +++ b/wizards/com/sun/star/wizards/ui/FilterComponent.java @@ -36,13 +36,19 @@ import com.sun.star.awt.VclWindowPeerAttribute; import com.sun.star.awt.XControl; import com.sun.star.awt.XListBox; import com.sun.star.awt.XRadioButton; +import com.sun.star.beans.PropertyAttribute; import com.sun.star.beans.PropertyValue; +import com.sun.star.beans.XPropertyContainer; import com.sun.star.beans.XPropertySet; import com.sun.star.lang.EventObject; import com.sun.star.lang.IllegalArgumentException; import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.lib.uno.helper.PropertySet; import com.sun.star.sdbc.DataType; +import com.sun.star.uno.Any; import com.sun.star.uno.AnyConverter; +import com.sun.star.uno.Exception; +import com.sun.star.uno.Type; import com.sun.star.uno.UnoRuntime; import com.sun.star.uno.XInterface; import com.sun.star.wizards.common.NumberFormatter; @@ -51,6 +57,8 @@ import com.sun.star.wizards.common.JavaTools; import com.sun.star.wizards.common.Properties; import com.sun.star.wizards.db.FieldColumn; import com.sun.star.wizards.db.QueryMetaData; +import java.util.logging.Level; +import java.util.logging.Logger; public class FilterComponent { @@ -115,10 +123,10 @@ public class FilterComponent final int SO_SECONDBOOLFIELDNAME = 256 + 2; final int SO_THIRDBOOLFIELDNAME = 256 + 3; final int SO_FOURTHBOOLFIELDNAME = 256 + 4; - int SO_BOOLEANLIST[] = { + int SO_BOOLEANLIST[] = + { SO_FIRSTBOOLFIELDNAME, SO_SECONDBOOLFIELDNAME, SO_THIRDBOOLFIELDNAME, SO_FOURTHBOOLFIELDNAME }; - final int SO_OPTQUERYMODE = 5; int SOI_MATCHALL = 0; int SOI_MATCHANY = 1; @@ -130,25 +138,23 @@ public class FilterComponent public void itemStateChanged(com.sun.star.awt.ItemEvent EventObject) { - try + int iKey = CurUnoDialog.getControlKey(EventObject.Source, CurUnoDialog.ControlList); + String sControlName = ""; + switch (iKey) { - int iKey = CurUnoDialog.getControlKey(EventObject.Source, CurUnoDialog.ControlList); - String sControlName = ""; - switch (iKey) - { - // case SOOPTQUERYMODE: - // getfilterstate(); - case SO_FIRSTFIELDNAME: - case SO_SECONDFIELDNAME: - case SO_THIRDFIELDNAME: - case SO_FOURTHFIELDNAME: - sControlName = getControlName(EventObject.Source); - String sControlNameSuffix = sIncSuffix + "_" + getIndexNumber(sControlName); - XListBox xCurFieldListBox = (XListBox) UnoRuntime.queryInterface(XListBox.class, CurUnoDialog.xDlgContainer.getControl(sControlName)); - String CurDisplayFieldName = xCurFieldListBox.getSelectedItem(); - FieldColumn CurFieldColumn = new FieldColumn(oQueryMetaData, CurDisplayFieldName); - - String sControlNameTextValue = "txtValue" + sControlNameSuffix; + // case SOOPTQUERYMODE: + // getfilterstate(); + case SO_FIRSTFIELDNAME: + case SO_SECONDFIELDNAME: + case SO_THIRDFIELDNAME: + case SO_FOURTHFIELDNAME: + sControlName = getControlName(EventObject.Source); + String sControlNameSuffix = sIncSuffix + "_" + getIndexNumber(sControlName); + XListBox xCurFieldListBox = (XListBox) UnoRuntime.queryInterface(XListBox.class, CurUnoDialog.xDlgContainer.getControl(sControlName)); + String CurDisplayFieldName = xCurFieldListBox.getSelectedItem(); + FieldColumn CurFieldColumn = new FieldColumn(oQueryMetaData, CurDisplayFieldName); + + String sControlNameTextValue = "txtValue" + sControlNameSuffix; // String sControlNameBooleanList = "lstBoolean" + sControlNameSuffix; // if (aFieldColumn.FieldType == DataType.BOOLEAN) // { @@ -161,41 +167,36 @@ public class FilterComponent // CurUnoDialog.setControlVisible(sControlNameTextValue, true); // CurUnoDialog.setControlVisible(sControlNameBooleanList, false); - XControl xValueControl = CurUnoDialog.xDlgContainer.getControl(sControlNameTextValue); - XInterface xValueModel = (XInterface) UnoDialog.getModel(xValueControl); - Helper.setUnoPropertyValue(xValueModel, "TreatAsNumber", Boolean.valueOf(CurFieldColumn.isNumberFormat())); - final NumberFormatter aNumberFormatter = oQueryMetaData.getNumberFormatter(); - aNumberFormatter.setNumberFormat(xValueModel, CurFieldColumn.getDBFormatKey(), aNumberFormatter); + XControl xValueControl = CurUnoDialog.xDlgContainer.getControl(sControlNameTextValue); + XInterface xValueModel = (XInterface) UnoDialog.getModel(xValueControl); + Helper.setUnoPropertyValue(xValueModel, "TreatAsNumber", Boolean.valueOf(CurFieldColumn.isNumberFormat())); + final NumberFormatter aNumberFormatter = oQueryMetaData.getNumberFormatter(); + aNumberFormatter.setNumberFormat(xValueModel, CurFieldColumn.getDBFormatKey(), aNumberFormatter); // } - break; - case SO_FIRSTCONDITION: - case SO_SECONDCONDITION: - case SO_THIRDCONDITION: - case SO_FOURTHCONDITION: - sControlName = getControlName(EventObject.Source); - break; - case SOOPTORMODE: - case SOOPTANDMODE: - // getfilterstate(); - return; + break; + case SO_FIRSTCONDITION: + case SO_SECONDCONDITION: + case SO_THIRDCONDITION: + case SO_FOURTHCONDITION: + sControlName = getControlName(EventObject.Source); + break; + case SOOPTORMODE: + case SOOPTANDMODE: + // getfilterstate(); + return; case SO_FIRSTBOOLFIELDNAME: case SO_SECONDBOOLFIELDNAME: case SO_THIRDBOOLFIELDNAME: case SO_FOURTHBOOLFIELDNAME: - sControlName = getControlName(EventObject.Source); + sControlName = getControlName(EventObject.Source); break; - default: - break; - } - togglefollowingControlRow(sControlName); - } - catch (Exception exception) - { - exception.printStackTrace(System.out); + default: + break; } + togglefollowingControlRow(sControlName); } public void disposing(com.sun.star.lang.EventObject eventObject) @@ -208,15 +209,8 @@ public class FilterComponent public void textChanged(TextEvent EventObject) { - try - { - String sName = getControlName(EventObject.Source); - togglefollowingControlRow(sName); - } - catch (Exception exception) - { - exception.printStackTrace(System.out); - } + String sName = getControlName(EventObject.Source); + togglefollowingControlRow(sName); } public void disposing(EventObject EventObject) @@ -248,10 +242,10 @@ public class FilterComponent } public static String getIndexNumber(String _sStr) - { - String sLastNumber = _sStr.substring(_sStr.length() - 1, _sStr.length()); - return sLastNumber; - } + { + String sLastNumber = _sStr.substring(_sStr.length() - 1, _sStr.length()); + return sLastNumber; + } /** * Enable the next ControlRow if the Condition is complete in the current line @@ -293,102 +287,67 @@ public class FilterComponent int nFilterCount = getFilterCount(); if (nFilterCount > 0) { - if (this.getfilterstate() == this.SOI_MATCHALL) - { - filterconditions = new PropertyValue[1][nFilterCount]; - } - else - { - filterconditions = new PropertyValue[nFilterCount][1]; - } - int a = 0; - for (int i = 0; i < RowCount; i++) + try { - ControlRow CurControlRow = oControlRows[i]; - if (CurControlRow.isEnabled()) + final String serviceName = "com.sun.star.beans.PropertyBag"; + final XPropertyContainer column = (XPropertyContainer) UnoRuntime.queryInterface(XPropertyContainer.class, oQueryMetaData.xMSF.createInstance(serviceName)); + + column.addProperty("Type", PropertyAttribute.BOUND, DataType.VARCHAR); + column.addProperty("Name", PropertyAttribute.BOUND, ""); + final XPropertySet columnSet = UnoRuntime.queryInterface(XPropertySet.class, column); + + if ( oQueryMetaData.getSQLQueryComposer().getQuery().length() == 0) + { + final String fromClause = oQueryMetaData.getSQLQueryComposer().getFromClause(); + StringBuffer sql = new StringBuffer(); + sql.append(oQueryMetaData.getSQLQueryComposer().getSelectClause(true)); + sql.append(' '); + sql.append(fromClause); + oQueryMetaData.getSQLQueryComposer().getQueryComposer().setElementaryQuery(sql.toString()); + } + int a = 0; + for (int i = 0; i < RowCount; i++) { - if (CurControlRow.isConditionComplete()) + ControlRow CurControlRow = oControlRows[i]; + if (CurControlRow.isEnabled()) { - Object aValue; - String sFieldName = CurControlRow.getSelectedFieldName(); - int nOperator = (int) CurControlRow.getSelectedOperator(); - FieldColumn aFieldColumn = oQueryMetaData.getFieldColumnByDisplayName(sFieldName); - if (aFieldColumn.getStandardFormatKey() == oQueryMetaData.getNumberFormatter().getTextFormatKey()) - { - aValue = "'" + CurControlRow.getValue() + "'"; - } -//// TODO the following code is bound to be deprecated as soon as the query composer is able to handle date/time values as numbers - else if ((aFieldColumn.getStandardFormatKey() == oQueryMetaData.getNumberFormatter().getDateFormatKey()) || - (aFieldColumn.getStandardFormatKey() == oQueryMetaData.getNumberFormatter().getDateTimeFormatKey())) - { - String sDate = CurControlRow.getDateTimeString(true); - aValue = "{D '" + sDate + "' }"; // FormatsSupplier - } - else if (aFieldColumn.getStandardFormatKey() == oQueryMetaData.getNumberFormatter().getTimeFormatKey()) - { - String sTime = CurControlRow.getDateTimeString(true); - aValue = "'{T '" + sTime + "' }"; - } - else - { - aValue = CurControlRow.getValue(); - // if void - if (! AnyConverter.isVoid(aValue)) - { - switch (aFieldColumn.getFieldType()) - { - case DataType.TINYINT: - case DataType.BIGINT: - case DataType.INTEGER: - case DataType.SMALLINT: - if ( AnyConverter.isDouble(aValue) ) - aValue = String.valueOf(((Double) aValue).intValue()); - break; - case DataType.BIT: - case DataType.BOOLEAN: - // curValue = CurControlRow.getText(); // wrong! (creates something like 'WAHR'/'FALSCH' if german locale is used. - - // double dblvalue = ((Double) curValue).doubleValue(); - //curValue = new Boolean(dblvalue == 1.0); // wrong! we need a string, not a boolean value - - // converts the '1.0'/'0.0' (EffectiveValue) to a 'boolean' String like 'true'/'false' - if ( AnyConverter.isDouble(aValue) ) - aValue = String.valueOf(((Double) aValue).intValue() == 1); - break; - default: - aValue = String.valueOf(aValue); - break; - } - } - } - - PropertyValue oPropertyValue = Properties.createProperty(sFieldName, aValue, nOperator); - if (getfilterstate()/*this.ifilterstate*/ == this.SOI_MATCHALL) + if (CurControlRow.isConditionComplete()) { - if (i == 0) + String sFieldName = CurControlRow.getSelectedFieldName(); + int nOperator = (int) CurControlRow.getSelectedOperator(); + FieldColumn aFieldColumn = oQueryMetaData.getFieldColumnByDisplayName(sFieldName); + columnSet.setPropertyValue("Name", aFieldColumn.getFieldName()); + columnSet.setPropertyValue("Type", aFieldColumn.getXColumnPropertySet().getPropertyValue("Type")); + Object value = CurControlRow.getValue(); + switch(aFieldColumn.getFieldType()) { - filterconditions[0] = new PropertyValue[nFilterCount]; + case DataType.TIMESTAMP: + case DataType.DATE: + value = ((Double)value) - oQueryMetaData.getNullDateCorrection(); + break; } - filterconditions[0][a] = oPropertyValue; + column.addProperty("Value", PropertyAttribute.MAYBEVOID, value); + columnSet.setPropertyValue("Value", value); + oQueryMetaData.getSQLQueryComposer().getQueryComposer().appendFilterByColumn(columnSet, getfilterstate() == this.SOI_MATCHALL,nOperator); } - else - { - filterconditions[a][0] = oPropertyValue; - } - a++; } } + filterconditions = oQueryMetaData.getSQLQueryComposer().getQueryComposer().getStructuredFilter(); + int[] iduplicate = JavaTools.getDuplicateFieldIndex(filterconditions); + if (iduplicate[0] != -1) + { + PropertyValue aduplicatecondition = filterconditions[iduplicate[0]][iduplicate[1]]; + String smsgDuplicateCondition = getDisplayCondition(sDuplicateCondition, aduplicatecondition, null); + CurUnoDialog.showMessageBox("WarningBox", VclWindowPeerAttribute.OK, smsgDuplicateCondition); + CurUnoDialog.vetoableChange(new java.beans.PropertyChangeEvent(CurUnoDialog, "Steps", Integer.valueOf(1), Integer.valueOf(2))); + return new PropertyValue[][] + { + }; + } } - int[] iduplicate = JavaTools.getDuplicateFieldIndex(filterconditions); - if (iduplicate[0] != -1) + catch (Exception ex) { - PropertyValue aduplicatecondition = filterconditions[iduplicate[0]][iduplicate[1]]; - String smsgDuplicateCondition = getDisplayCondition(sDuplicateCondition, aduplicatecondition, null); - CurUnoDialog.showMessageBox("WarningBox", VclWindowPeerAttribute.OK, smsgDuplicateCondition); - CurUnoDialog.vetoableChange(new java.beans.PropertyChangeEvent(CurUnoDialog, "Steps", Integer.valueOf(1), Integer.valueOf(2))); - return new PropertyValue[][] - { - }; + Logger.getLogger(FilterComponent.class.getName()).log(Level.SEVERE, null, ex); } } else @@ -416,8 +375,10 @@ public class FilterComponent String soperator = sLogicOperators[_filtercondition.Handle - 1]; sreturn = JavaTools.replaceSubString(sreturn, soperator, ""); String sDisplayValue = ""; - if ( !AnyConverter.isVoid(_filtercondition.Value) ) + if (!AnyConverter.isVoid(_filtercondition.Value)) + { sDisplayValue = AnyConverter.toString(_filtercondition.Value); + } sreturn = JavaTools.replaceSubString(sreturn, sDisplayValue, ""); return sreturn; } @@ -446,24 +407,17 @@ public class FilterComponent private void addfiltercondition(int _index, String _curFieldName, Object _curValue, int _curOperator) { - try + String ValString = String.valueOf(_curValue); + PropertyValue oPropertyValue = Properties.createProperty(_curFieldName, ValString, _curOperator); + getfilterstate(); + if (getfilterstate() == this.SOI_MATCHALL) { - String ValString = String.valueOf(_curValue); - PropertyValue oPropertyValue = Properties.createProperty(_curFieldName, ValString, _curOperator); - getfilterstate(); - if (getfilterstate() == this.SOI_MATCHALL) + if (_index == 0) { - if (_index == 0) - { - filterconditions[0] = new PropertyValue[getFilterCount()]; - } - filterconditions[0][_index] = new PropertyValue(); - filterconditions[0][_index] = oPropertyValue; + filterconditions[0] = new PropertyValue[getFilterCount()]; } - } - catch (Exception exception) - { - exception.printStackTrace(System.out); + filterconditions[0][_index] = new PropertyValue(); + filterconditions[0][_index] = oPropertyValue; } } @@ -478,8 +432,8 @@ public class FilterComponent } } return a; - // FilterCount = a; - // return FilterCount; + // FilterCount = a; + // return FilterCount; } /** Creates a new instance of FilterComponent @@ -495,95 +449,88 @@ public class FilterComponent */ public FilterComponent(WizardDialog CurUnoDialog, XMultiServiceFactory _xMSF, int iStep, int iPosX, int iPosY, int iWidth, int FilterCount, QueryMetaData _oQueryMetaData, int _firstHelpID) { - try - { - this.curHelpID = _firstHelpID; - this.xMSF = _xMSF; - this.IStep = Integer.valueOf(iStep); - - curtabindex = UnoDialog.setInitialTabindex(iStep); - this.CurUnoDialog = CurUnoDialog; - this.RowCount = FilterCount; - this.oQueryMetaData = _oQueryMetaData; - boolean bEnabled; - sIncSuffix = com.sun.star.wizards.common.Desktop.getIncrementSuffix(CurUnoDialog.getDlgNameAccess(), "optMatchAll"); - // iStartPosX = iPosX; - // iStartPosY = iPosY; - - String soptMatchAll = CurUnoDialog.m_oResource.getResText(BaseID + 9); - String soptMatchAny = CurUnoDialog.m_oResource.getResText(BaseID + 10); - slblFieldNames = CurUnoDialog.m_oResource.getResText(BaseID + 17); - slblOperators = CurUnoDialog.m_oResource.getResText(BaseID + 24); - slblValue = CurUnoDialog.m_oResource.getResText(BaseID + 25); - sLogicOperators = CurUnoDialog.m_oResource.getResArray(BaseID + 26, 10 /* 7 */); // =, <>, <, >, <=, >=, like, !like, is null, !is null - sBooleanValues = CurUnoDialog.m_oResource.getResArray(BaseID + 36, 2); // true, false - - sDuplicateCondition = CurUnoDialog.m_oResource.getResText(BaseID + 89); - - // create Radiobuttons - // * match all - // * match one - optMatchAll = CurUnoDialog.insertRadioButton("optMatchAll" + sIncSuffix, SOOPTANDMODE, new ItemListenerImpl(), - new String[] - { - "Height", - "HelpURL", - "Label", - "PositionX", - "PositionY", - "State", - "Step", - "TabIndex", - "Width" - }, - new Object[] - { - Integer.valueOf(9), - "HID:" + curHelpID++, - soptMatchAll, - Integer.valueOf(iPosX), - Integer.valueOf(iPosY), - Short.valueOf((short) 1), - IStep, - Short.valueOf(curtabindex++), - Integer.valueOf(203) - }); - optMatchAny = CurUnoDialog.insertRadioButton("optMatchAny" + sIncSuffix, SOOPTORMODE, new ItemListenerImpl(), - new String[] - { - "Height", - "HelpURL", - "Label", - "PositionX", - "PositionY", - "Step", - "TabIndex", - "Width" - }, - new Object[] - { - Integer.valueOf(9), - "HID:" + curHelpID++, - soptMatchAny, - Integer.valueOf(iPosX), - Integer.valueOf(iPosY + 12), - IStep, - Short.valueOf(curtabindex++), - Integer.valueOf(203) - }); - getfilterstate(); - - oControlRows = new ControlRow[FilterCount]; - for (int i = 0; i < FilterCount; i++) - { - bEnabled = (i == 0); - oControlRows[i] = new ControlRow(iPosX, iPosY + 20, i, bEnabled, (this.curHelpID + (i * 3))); - iPosY += 43; - } - } - catch (Exception exception) + this.curHelpID = _firstHelpID; + this.xMSF = _xMSF; + this.IStep = Integer.valueOf(iStep); + + curtabindex = UnoDialog.setInitialTabindex(iStep); + this.CurUnoDialog = CurUnoDialog; + this.RowCount = FilterCount; + this.oQueryMetaData = _oQueryMetaData; + boolean bEnabled; + sIncSuffix = com.sun.star.wizards.common.Desktop.getIncrementSuffix(CurUnoDialog.getDlgNameAccess(), "optMatchAll"); + // iStartPosX = iPosX; + // iStartPosY = iPosY; + + String soptMatchAll = CurUnoDialog.m_oResource.getResText(BaseID + 9); + String soptMatchAny = CurUnoDialog.m_oResource.getResText(BaseID + 10); + slblFieldNames = CurUnoDialog.m_oResource.getResText(BaseID + 17); + slblOperators = CurUnoDialog.m_oResource.getResText(BaseID + 24); + slblValue = CurUnoDialog.m_oResource.getResText(BaseID + 25); + sLogicOperators = CurUnoDialog.m_oResource.getResArray(BaseID + 26, 10 /* 7 */); // =, <>, <, >, <=, >=, like, !like, is null, !is null + sBooleanValues = CurUnoDialog.m_oResource.getResArray(BaseID + 36, 2); // true, false + + sDuplicateCondition = CurUnoDialog.m_oResource.getResText(BaseID + 89); + + // create Radiobuttons + // * match all + // * match one + optMatchAll = CurUnoDialog.insertRadioButton("optMatchAll" + sIncSuffix, SOOPTANDMODE, new ItemListenerImpl(), + new String[] + { + "Height", + "HelpURL", + "Label", + "PositionX", + "PositionY", + "State", + "Step", + "TabIndex", + "Width" + }, + new Object[] + { + Integer.valueOf(9), + "HID:" + curHelpID++, + soptMatchAll, + Integer.valueOf(iPosX), + Integer.valueOf(iPosY), + Short.valueOf((short) 1), + IStep, + Short.valueOf(curtabindex++), + Integer.valueOf(203) + }); + optMatchAny = CurUnoDialog.insertRadioButton("optMatchAny" + sIncSuffix, SOOPTORMODE, new ItemListenerImpl(), + new String[] + { + "Height", + "HelpURL", + "Label", + "PositionX", + "PositionY", + "Step", + "TabIndex", + "Width" + }, + new Object[] + { + Integer.valueOf(9), + "HID:" + curHelpID++, + soptMatchAny, + Integer.valueOf(iPosX), + Integer.valueOf(iPosY + 12), + IStep, + Short.valueOf(curtabindex++), + Integer.valueOf(203) + }); + getfilterstate(); + + oControlRows = new ControlRow[FilterCount]; + for (int i = 0; i < FilterCount; i++) { - exception.printStackTrace(System.out); + bEnabled = (i == 0); + oControlRows[i] = new ControlRow(iPosX, iPosY + 20, i, bEnabled, (this.curHelpID + (i * 3))); + iPosY += 43; } } @@ -639,29 +586,21 @@ public class FilterComponent public void addNumberFormats() { - try - { - iDateFormat = oQueryMetaData.getNumberFormatter().defineNumberFormat("YYYY-MM-DD"); - iTimeFormat = oQueryMetaData.getNumberFormatter().defineNumberFormat("HH:MM:SS"); - iDateTimeFormat = oQueryMetaData.getNumberFormatter().defineNumberFormat("YYYY-MM-DD HH:MM:SS"); - } - catch (Exception e) - { - e.printStackTrace(System.out); - } + iDateFormat = oQueryMetaData.getNumberFormatter().defineNumberFormat("YYYY-MM-DD"); + iTimeFormat = oQueryMetaData.getNumberFormatter().defineNumberFormat("HH:MM:SS"); + iDateTimeFormat = oQueryMetaData.getNumberFormatter().defineNumberFormat("YYYY-MM-DD HH:MM:SS"); } // ------------------------------------------------------------------------- // // // ------------------------------------------------------------------------- - class ControlRow { + private final static int SOLSTFIELDNAME = 3; private final static int SOLSTOPERATOR = 4; private final static int SOTXTVALUE = 5; - protected XInterface[] ControlElements = new XInterface[6]; private boolean m_bEnabled; String[] FieldNames; @@ -778,7 +717,7 @@ public class FilterComponent Boolean.TRUE, Integer.valueOf(13), "HID:" + _firstRowHelpID++, - Short.valueOf(UnoDialog.getListBoxLineCount() /* 7 */) , + Short.valueOf(UnoDialog.getListBoxLineCount() /* 7 */), Integer.valueOf(nPosX1), Integer.valueOf(iCompPosY + 23), IStep, @@ -808,7 +747,7 @@ public class FilterComponent Boolean.TRUE, Integer.valueOf(13), "HID:" + _firstRowHelpID++, - Short.valueOf((short) sLogicOperators.length /* 7 */ ), + Short.valueOf((short) sLogicOperators.length /* 7 */), Integer.valueOf(nPosX2), Integer.valueOf(iCompPosY + 23), IStep, @@ -883,8 +822,9 @@ public class FilterComponent { int nSelOperator = getSelectedOperator(); // short[] SelOperator = (short[]) AnyConverter.toArray(Helper.getUnoPropertyValue(UnoDialog.getModel(ControlElements[SOLSTOPERATOR]), "SelectedItems")); - if (nSelOperator == com.sun.star.sdb.SQLFilterOperator.SQLNULL || /* is null */ - nSelOperator == com.sun.star.sdb.SQLFilterOperator.NOT_SQLNULL) /* is not null */ + if (nSelOperator == com.sun.star.sdb.SQLFilterOperator.SQLNULL + || /* is null */ nSelOperator == com.sun.star.sdb.SQLFilterOperator.NOT_SQLNULL) /* is not null */ + { // disable value field Helper.setUnoPropertyValue(UnoDialog.getModel(ControlElements[2]), "Enabled", Boolean.FALSE); @@ -946,13 +886,27 @@ public class FilterComponent { sValue = JavaTools.replaceSubString(sValue, "", "{D '"); sValue = JavaTools.replaceSubString(sValue, "", "' }"); - oQueryMetaData.getNumberFormatter().convertStringToNumber(iDateFormat, sValue); + try + { + oQueryMetaData.getNumberFormatter().convertStringToNumber(iDateFormat, sValue); + } + catch (java.lang.Exception ex) + { + Logger.getLogger(FilterComponent.class.getName()).log(Level.SEVERE, null, ex); + } } else if (sValue.indexOf("{T '") > -1) { sValue = JavaTools.replaceSubString(sValue, "", "{T '"); sValue = JavaTools.replaceSubString(sValue, "", "' }"); - oQueryMetaData.getNumberFormatter().convertStringToNumber(iTimeFormat, sValue); + try + { + oQueryMetaData.getNumberFormatter().convertStringToNumber(iTimeFormat, sValue); + } + catch (java.lang.Exception ex) + { + Logger.getLogger(FilterComponent.class.getName()).log(Level.SEVERE, null, ex); + } } } else if (AnyConverter.isBoolean(_filtercondition.Value)) @@ -1004,7 +958,9 @@ public class FilterComponent m_bEnabled = _bEnabled; if (isEnabled()) { - short[] iselected = new short[] {}; + short[] iselected = new short[] + { + }; try { iselected = (short[]) AnyConverter.toArray(Helper.getUnoPropertyValue(UnoDialog.getModel(ControlElements[SOLSTOPERATOR]), "SelectedItems")); @@ -1015,7 +971,10 @@ public class FilterComponent } if ((iselected.length) == 0) { - Helper.setUnoPropertyValue(UnoDialog.getModel(ControlElements[SOLSTOPERATOR]), "SelectedItems", new short[] { 0 }); + Helper.setUnoPropertyValue(UnoDialog.getModel(ControlElements[SOLSTOPERATOR]), "SelectedItems", new short[] + { + 0 + }); } } else if (!isConditionComplete()) @@ -1047,28 +1006,28 @@ public class FilterComponent short[] SelFields = (short[]) AnyConverter.toArray(Helper.getUnoPropertyValue(UnoDialog.getModel(ControlElements[SOLSTOPERATOR]), "SelectedItems")); switch (SelFields[0]) { - case 0: - return com.sun.star.sdb.SQLFilterOperator.EQUAL; - case 1: - return com.sun.star.sdb.SQLFilterOperator.NOT_EQUAL; - case 2: - return com.sun.star.sdb.SQLFilterOperator.LESS; - case 3: - return com.sun.star.sdb.SQLFilterOperator.GREATER; - case 4: - return com.sun.star.sdb.SQLFilterOperator.LESS_EQUAL; - case 5: - return com.sun.star.sdb.SQLFilterOperator.GREATER_EQUAL; - case 6: - return com.sun.star.sdb.SQLFilterOperator.LIKE; - case 7: - return com.sun.star.sdb.SQLFilterOperator.NOT_LIKE; - case 8: - return com.sun.star.sdb.SQLFilterOperator.SQLNULL; - case 9: - return com.sun.star.sdb.SQLFilterOperator.NOT_SQLNULL; - default: - return -1; + case 0: + return com.sun.star.sdb.SQLFilterOperator.EQUAL; + case 1: + return com.sun.star.sdb.SQLFilterOperator.NOT_EQUAL; + case 2: + return com.sun.star.sdb.SQLFilterOperator.LESS; + case 3: + return com.sun.star.sdb.SQLFilterOperator.GREATER; + case 4: + return com.sun.star.sdb.SQLFilterOperator.LESS_EQUAL; + case 5: + return com.sun.star.sdb.SQLFilterOperator.GREATER_EQUAL; + case 6: + return com.sun.star.sdb.SQLFilterOperator.LIKE; + case 7: + return com.sun.star.sdb.SQLFilterOperator.NOT_LIKE; + case 8: + return com.sun.star.sdb.SQLFilterOperator.SQLNULL; + case 9: + return com.sun.star.sdb.SQLFilterOperator.NOT_SQLNULL; + default: + return -1; } } catch (Exception exception) @@ -1081,43 +1040,19 @@ public class FilterComponent // TODO make a difference between Text and Numbers protected Object getValue() { - try - { - return (Helper.getUnoPropertyValue(UnoDialog.getModel(ControlElements[SOTXTVALUE]), "EffectiveValue")); - } - catch (Exception exception) - { - exception.printStackTrace(System.out); - } - return null; + return (Helper.getUnoPropertyValue(UnoDialog.getModel(ControlElements[SOTXTVALUE]), "EffectiveValue")); } protected Object getText() { - try - { - return (Helper.getUnoPropertyValue(UnoDialog.getModel(ControlElements[SOTXTVALUE]), "Text")); - } - catch (Exception exception) - { - exception.printStackTrace(System.out); - } - return null; + return (Helper.getUnoPropertyValue(UnoDialog.getModel(ControlElements[SOTXTVALUE]), "Text")); } protected String getDateTimeString(boolean bgetDate) { - try - { double dblValue = ((Double) getValue()).doubleValue(); NumberFormatter oNumberFormatter = oQueryMetaData.getNumberFormatter(); return oNumberFormatter.convertNumberToString(iDateTimeFormat, dblValue); - } - catch (Exception exception) - { - exception.printStackTrace(System.out); - return null; - } } } } -- cgit v1.2.3 From 6c07c7cad453e4ebb447577c7313323764d50ea9 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Mon, 15 Mar 2010 14:07:56 +0100 Subject: dba33f: #i110036#: when creating new controls or grid columns, set MouseWheelBehavior to NEVER --- extensions/source/dbpilots/gridwizard.cxx | 30 ++++++++++++---------- forms/source/component/Columns.cxx | 20 +++++++++++---- forms/source/inc/componenttools.hxx | 6 +++-- forms/source/misc/componenttools.cxx | 12 +++++++++ wizards/com/sun/star/wizards/document/Control.java | 12 ++++++--- .../sun/star/wizards/document/DatabaseControl.java | 6 +++++ .../com/sun/star/wizards/document/GridControl.java | 12 ++++----- 7 files changed, 69 insertions(+), 29 deletions(-) (limited to 'wizards') diff --git a/extensions/source/dbpilots/gridwizard.cxx b/extensions/source/dbpilots/gridwizard.cxx index c3d50e6c112d..bee49039a99c 100644 --- a/extensions/source/dbpilots/gridwizard.cxx +++ b/extensions/source/dbpilots/gridwizard.cxx @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include "dbptools.hxx" @@ -55,6 +56,7 @@ namespace dbp using namespace ::com::sun::star::sdbc; using namespace ::com::sun::star::container; using namespace ::com::sun::star::form; + using namespace ::com::sun::star::awt; using namespace ::svt; //===================================================================== @@ -114,6 +116,7 @@ namespace dbp static const ::rtl::OUString s_sDataFieldProperty = ::rtl::OUString::createFromAscii("DataField"); static const ::rtl::OUString s_sLabelProperty = ::rtl::OUString::createFromAscii("Label"); static const ::rtl::OUString s_sWidthProperty = ::rtl::OUString::createFromAscii("Width"); + static const ::rtl::OUString s_sMouseWheelBehavior = ::rtl::OUString::createFromAscii("MouseWheelBehavior"); static const ::rtl::OUString s_sEmptyString; // collect "descriptors" for the to-be-created (grid)columns @@ -205,23 +208,24 @@ namespace dbp // create a (grid)column for the (resultset)column try { - Reference< XPropertySet > xColumn = xColumnFactory->createColumn(*pColumnServiceName); + Reference< XPropertySet > xColumn( xColumnFactory->createColumn(*pColumnServiceName), UNO_SET_THROW ); + Reference< XPropertySetInfo > xColumnPSI( xColumn->getPropertySetInfo(), UNO_SET_THROW ); ::rtl::OUString sColumnName(*pColumnServiceName); disambiguateName(xExistenceChecker, sColumnName); - if (xColumn.is()) - { - // the data field the column should be bound to - xColumn->setPropertyValue(s_sDataFieldProperty, makeAny(*pFormFieldName)); - // the label - xColumn->setPropertyValue(s_sLabelProperty, makeAny(::rtl::OUString(*pFormFieldName) += *pColumnLabelPostfix)); - // the width ( => column will be auto-sized) - xColumn->setPropertyValue(s_sWidthProperty, Any()); - - // insert the column - xColumnContainer->insertByName(sColumnName, makeAny(xColumn)); - } + // the data field the column should be bound to + xColumn->setPropertyValue(s_sDataFieldProperty, makeAny(*pFormFieldName)); + // the label + xColumn->setPropertyValue(s_sLabelProperty, makeAny(::rtl::OUString(*pFormFieldName) += *pColumnLabelPostfix)); + // the width ( => column will be auto-sized) + xColumn->setPropertyValue(s_sWidthProperty, Any()); + + if ( xColumnPSI->hasPropertyByName( s_sMouseWheelBehavior ) ) + xColumn->setPropertyValue( s_sMouseWheelBehavior, makeAny( MouseWheelBehavior::SCROLL_DISABLED ) ); + + // insert the column + xColumnContainer->insertByName(sColumnName, makeAny(xColumn)); } catch(Exception&) { diff --git a/forms/source/component/Columns.cxx b/forms/source/component/Columns.cxx index 29d6f1130509..ae685ef768fb 100644 --- a/forms/source/component/Columns.cxx +++ b/forms/source/component/Columns.cxx @@ -35,6 +35,7 @@ #include "property.hrc" #endif #include "property.hxx" +#include "componenttools.hxx" #include "ids.hxx" #include "findpos.hxx" #include @@ -172,11 +173,20 @@ Sequence SAL_CALL OGridColumn::getImplementationId() throw(RuntimeExce //------------------------------------------------------------------ Sequence SAL_CALL OGridColumn::getTypes() throw(RuntimeException) { - Reference xProv; - - if (query_aggregation(m_xAggregate, xProv)) - return concatSequences(OGridColumn_BASE::getTypes(), xProv->getTypes()); - return OGridColumn_BASE::getTypes(); + TypeBag aTypes( OGridColumn_BASE::getTypes() ); + // erase the types which we do not support + aTypes.removeType( XFormComponent::static_type() ); + aTypes.removeType( XServiceInfo::static_type() ); + aTypes.removeType( XBindableValue::static_type() ); + aTypes.removeType( XPropertyContainer::static_type() ); + // but re-add their base class(es) + aTypes.addType( XChild::static_type() ); + + Reference< XTypeProvider > xProv; + if ( query_aggregation( m_xAggregate, xProv )) + aTypes.addTypes( xProv->getTypes() ); + + return aTypes.getTypes(); } //------------------------------------------------------------------ diff --git a/forms/source/inc/componenttools.hxx b/forms/source/inc/componenttools.hxx index f15a4fc528dc..b9806bc5dc85 100644 --- a/forms/source/inc/componenttools.hxx +++ b/forms/source/inc/componenttools.hxx @@ -51,7 +51,7 @@ namespace frm typedef ::com::sun::star::uno::Type Type; public: - bool operator()( const Type& _rLHS, const Type& _rRHS ) + bool operator()( const Type& _rLHS, const Type& _rRHS ) const { return _rLHS.getTypeName() < _rRHS.getTypeName(); } @@ -88,7 +88,9 @@ namespace frm const TypeSequence& _rTypes3 ); - void addTypes( const TypeSequence& _rTypes ); + void addType( const Type& i_rType ); + void addTypes( const TypeSequence& _rTypes ); + void removeType( const Type& i_rType ); /** returns the types represented by this bag */ diff --git a/forms/source/misc/componenttools.cxx b/forms/source/misc/componenttools.cxx index 21740749d4d4..c0d0f5548294 100644 --- a/forms/source/misc/componenttools.cxx +++ b/forms/source/misc/componenttools.cxx @@ -86,6 +86,18 @@ namespace frm ); } + //-------------------------------------------------------------------- + void TypeBag::addType( const Type& i_rType ) + { + m_aTypes.insert( i_rType ); + } + + //-------------------------------------------------------------------- + void TypeBag::removeType( const TypeBag::Type& i_rType ) + { + m_aTypes.erase( i_rType ); + } + //-------------------------------------------------------------------- TypeBag::TypeSequence TypeBag::getTypes() const { diff --git a/wizards/com/sun/star/wizards/document/Control.java b/wizards/com/sun/star/wizards/document/Control.java index 602aab2fd423..b81cc792e412 100644 --- a/wizards/com/sun/star/wizards/document/Control.java +++ b/wizards/com/sun/star/wizards/document/Control.java @@ -36,6 +36,7 @@ import com.sun.star.awt.XControlModel; import com.sun.star.awt.XLayoutConstrains; import com.sun.star.awt.XWindowPeer; import com.sun.star.beans.XPropertySet; +import com.sun.star.beans.XPropertySetInfo; import com.sun.star.container.XNameAccess; import com.sun.star.container.XNameContainer; import com.sun.star.container.XNamed; @@ -100,8 +101,13 @@ public class Control extends Shape icontroltype = _icontroltype; sServiceName = oFormHandler.sModelServices[getControlType()]; Object oControlModel = oFormHandler.xMSFDoc.createInstance(sServiceName); - xControlModel = (XControlModel) UnoRuntime.queryInterface(XControlModel.class, oControlModel); - xPropertySet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, oControlModel); + xControlModel = UnoRuntime.queryInterface( XControlModel.class, oControlModel ); + xPropertySet = UnoRuntime.queryInterface( XPropertySet.class, oControlModel ); + + XPropertySetInfo xPSI = xPropertySet.getPropertySetInfo(); + if ( xPSI.hasPropertyByName( "MouseWheelBehavior" ) ) + xPropertySet.setPropertyValue( "MouseWheelBehavior", new Short( com.sun.star.awt.MouseWheelBehavior.SCROLL_DISABLED ) ); + insertControlInContainer(_FieldName); xControlShape.setControl(xControlModel); if (_xGroupShapes == null) @@ -113,7 +119,7 @@ public class Control extends Shape _xGroupShapes.add(xShape); } xControl = oFormHandler.xControlAccess.getControl(xControlModel); - xControlPropertySet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xControl); + xControlPropertySet = UnoRuntime.queryInterface( XPropertySet.class, xControl ); xWindowPeer = xControl.getPeer(); } catch (Exception e) diff --git a/wizards/com/sun/star/wizards/document/DatabaseControl.java b/wizards/com/sun/star/wizards/document/DatabaseControl.java index ed48ddbc04ea..9e2db8eca332 100644 --- a/wizards/com/sun/star/wizards/document/DatabaseControl.java +++ b/wizards/com/sun/star/wizards/document/DatabaseControl.java @@ -32,6 +32,7 @@ package com.sun.star.wizards.document; import com.sun.star.awt.Point; import com.sun.star.beans.XPropertySet; +import com.sun.star.beans.XPropertySetInfo; import com.sun.star.container.XNameContainer; import com.sun.star.drawing.XShapes; import com.sun.star.sdbc.DataType; @@ -95,6 +96,11 @@ public class DatabaseControl extends Control xPropColumn.setPropertyValue("DataField", sFieldName); xPropColumn.setPropertyValue("Label", _columntitle); xPropColumn.setPropertyValue("Width", new Integer(0)); // Width of column is adjusted to Columname + + XPropertySetInfo xPSI = xPropColumn.getPropertySetInfo(); + if ( xPSI.hasPropertyByName( "MouseWheelBehavior" ) ) + xPropColumn.setPropertyValue( "MouseWheelBehavior", new Short( com.sun.star.awt.MouseWheelBehavior.SCROLL_DISABLED ) ); + setNumericLimits(); _oGridControl.xNameContainer.insertByName(sFieldName, xPropColumn); } diff --git a/wizards/com/sun/star/wizards/document/GridControl.java b/wizards/com/sun/star/wizards/document/GridControl.java index 426aa026213b..791e7fc85497 100644 --- a/wizards/com/sun/star/wizards/document/GridControl.java +++ b/wizards/com/sun/star/wizards/document/GridControl.java @@ -63,15 +63,15 @@ public class GridControl extends Shape { fieldcolumns = _fieldcolumns; Object oGridModel = oFormHandler.xMSFDoc.createInstance(oFormHandler.sModelServices[FormHandler.SOGRIDCONTROL]); - xNameContainer = (XNameContainer) UnoRuntime.queryInterface(XNameContainer.class, oGridModel); - xNameAccess = (XNameAccess) UnoRuntime.queryInterface(XNameAccess.class, oGridModel); + xNameContainer = UnoRuntime.queryInterface( XNameContainer.class, oGridModel ); + xNameAccess = UnoRuntime.queryInterface( XNameAccess.class, oGridModel ); _xFormName.insertByName(_sname, oGridModel); - xControlModel = (XControlModel) UnoRuntime.queryInterface(XControlModel.class, oGridModel); + xControlModel = UnoRuntime.queryInterface( XControlModel.class, oGridModel ); xControlShape.setControl(xControlModel); - xPropertySet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, oGridModel); + xPropertySet = UnoRuntime.queryInterface( XPropertySet.class, oGridModel ); oFormHandler.xDrawPage.add(xShape); - xGridColumnFactory = (XGridColumnFactory) UnoRuntime.queryInterface(XGridColumnFactory.class, oGridModel); - xComponent = (XComponent) UnoRuntime.queryInterface(XComponent.class, oGridModel); + xGridColumnFactory = UnoRuntime.queryInterface( XGridColumnFactory.class, oGridModel ); + xComponent = UnoRuntime.queryInterface( XComponent.class, oGridModel ); // Helper.setUnoPropertyValue(oGridModel, "Name", _sname); for (int i = 0; i < fieldcolumns.length; i++) -- cgit v1.2.3