Tag: cws_src680_oj14 User: fs Date: 2007-06-18 08:58:25+0000 Modified: dba/reportdesign/java/com/sun/star/report/SDBCReportData.java
Log: copied the fix for #i78077#, originally done in ./pentaho/SDBCReportData, herein File Changes: Directory: /dba/reportdesign/java/com/sun/star/report/ ====================================================== File [changed]: SDBCReportData.java Url: http://dba.openoffice.org/source/browse/dba/reportdesign/java/com/sun/star/report/SDBCReportData.java?r1=1.1.2.2&r2=1.1.2.3 Delta lines: +71 -13 --------------------- --- SDBCReportData.java 2007-06-11 19:29:05+0000 1.1.2.2 +++ SDBCReportData.java 2007-06-18 08:58:22+0000 1.1.2.3 @@ -4,9 +4,9 @@ * * $RCSfile: SDBCReportData.java,v $ * - * $Revision: 1.1.2.2 $ + * $Revision: 1.1.2.3 $ * - * last change: $Author: fs $ $Date: 2007/06/11 19:29:05 $ + * last change: $Author: fs $ $Date: 2007/06/18 08:58:22 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -35,6 +35,9 @@ package com.sun.star.report; +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.XIndexAccess; +import com.sun.star.sdb.XParametersSupplier; import java.sql.Timestamp; import com.sun.star.sdbc.DataType; @@ -53,7 +56,9 @@ private XRowSet rowSet; private XRow row; private int rowCount; - private final int columnCount; + private XIndexAccess parameters; + private int firstParameterIndex = -1; + private int columnCount; private final String[] columnNames; private final int[] columnTypes; @@ -62,15 +67,46 @@ row = (XRow) UnoRuntime.queryInterface(XRow.class, rowSet); this.rowSet = rowSet; + XParametersSupplier xSuppParams = (XParametersSupplier)UnoRuntime.queryInterface( + XParametersSupplier.class, rowSet ); + if ( xSuppParams != null ) + parameters = xSuppParams.getParameters(); + final XResultSetMetaDataSupplier sup = (XResultSetMetaDataSupplier) UnoRuntime.queryInterface(XResultSetMetaDataSupplier.class, rowSet); final XResultSetMetaData resultSetMetaData = sup.getMetaData(); + columnCount = resultSetMetaData.getColumnCount(); + if ( parameters != null ) + { + firstParameterIndex = columnCount + 1; + columnCount += parameters.getCount(); + } + columnTypes = new int[columnCount]; columnNames = new String[columnCount]; - for (int i = 1; i <= columnCount; ++i) + + for (int i = 1;i <= columnCount;++i) + { + if ( i < firstParameterIndex ) + { + columnNames[i-1] = resultSetMetaData.getColumnName(i); + columnTypes[i-1] = resultSetMetaData.getColumnType(i); + } + else + { + try + { + XPropertySet paramColumn = (XPropertySet)UnoRuntime.queryInterface( + XPropertySet.class, parameters.getByIndex(i-firstParameterIndex) ); + columnNames[i-1] = (String)paramColumn.getPropertyValue( "Name" ); + columnTypes[i-1] = ((Integer)paramColumn.getPropertyValue( "Type" )).intValue(); + } + catch( Exception e ) { - columnNames[i - 1] = resultSetMetaData.getColumnName(i); - columnTypes[i - 1] = resultSetMetaData.getColumnType(i); + columnNames[i-1] = "Error"; + columnTypes[i-1] = DataType.CHAR; + } + } } if (rowSet.last()) @@ -144,7 +180,7 @@ // } // } - private java.sql.Date getDate(final Object obj) + static private java.sql.Date getDate(final Object obj) { java.sql.Date date = null; if (obj != null && obj instanceof com.sun.star.util.Date) @@ -178,7 +214,7 @@ return timeString; } - private StringBuffer getDateString(final int years, final int months, final int days) + static private StringBuffer getDateString(final int years, final int months, final int days) { final StringBuffer str = new StringBuffer(); str.append(years); @@ -200,7 +236,7 @@ return str; } - private java.sql.Time getTime(final Object obj) + static private java.sql.Time getTime(final Object obj) { java.sql.Time time = null; if (obj != null && obj instanceof Time) @@ -212,7 +248,7 @@ return time; } - private Timestamp getTimestamp(final Object obj) + static private Timestamp getTimestamp(final Object obj) { Timestamp ts = null; if (obj != null && obj instanceof DateTime) @@ -232,8 +268,30 @@ { try { - Object obj = row.getObject(column, null); - if (row.wasNull()) + boolean isParameterValue = ( parameters != null ) && ( column >= firstParameterIndex ); + Object obj = null; + boolean wasNull = true; + if ( isParameterValue ) + { + try + { + XPropertySet paramCol = (XPropertySet)UnoRuntime.queryInterface( + XPropertySet.class, parameters.getByIndex( column - firstParameterIndex ) ); + obj = paramCol.getPropertyValue( "Value" ); + wasNull = false; + } + catch( Exception e ) + { + wasNull = true; + } + } + else + { + obj = row.getObject( column, null ); + wasNull = row.wasNull(); + } + + if ( wasNull ) { return null; } @@ -257,7 +315,7 @@ } break; default: - ; + break; } return obj; } --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
