diff options
56 files changed, 800 insertions, 581 deletions
diff --git a/reportbuilder/java/com/sun/star/report/DataRow.java b/reportbuilder/java/com/sun/star/report/DataRow.java index 1875578213ed..47f471113362 100644 --- a/reportbuilder/java/com/sun/star/report/DataRow.java +++ b/reportbuilder/java/com/sun/star/report/DataRow.java @@ -41,9 +41,9 @@ package com.sun.star.report; public interface DataRow { - public int getColumnCount() throws DataSourceException; + int getColumnCount() throws DataSourceException; - public String getColumnName(int column) throws DataSourceException; + String getColumnName(int column) throws DataSourceException; - public Object getObject(int column) throws DataSourceException; + Object getObject(int column) throws DataSourceException; } diff --git a/reportbuilder/java/com/sun/star/report/DataSource.java b/reportbuilder/java/com/sun/star/report/DataSource.java index 20f83a8a7798..42d78abcc9d1 100644 --- a/reportbuilder/java/com/sun/star/report/DataSource.java +++ b/reportbuilder/java/com/sun/star/report/DataSource.java @@ -41,11 +41,11 @@ package com.sun.star.report; public interface DataSource extends DataRow { - public int getRowCount() throws DataSourceException; + int getRowCount() throws DataSourceException; - public boolean absolute(int row) throws DataSourceException; + boolean absolute(int row) throws DataSourceException; - public boolean next() throws DataSourceException; + boolean next() throws DataSourceException; - public void close() throws DataSourceException; + void close() throws DataSourceException; } diff --git a/reportbuilder/java/com/sun/star/report/ImageService.java b/reportbuilder/java/com/sun/star/report/ImageService.java index e0b558933703..193b97d66d58 100644 --- a/reportbuilder/java/com/sun/star/report/ImageService.java +++ b/reportbuilder/java/com/sun/star/report/ImageService.java @@ -42,21 +42,21 @@ public interface ImageService /** * @return the mime-type of the image as string. */ - public String getMimeType(final InputStream image) throws ReportExecutionException; + String getMimeType(final InputStream image) throws ReportExecutionException; /** * @return the mime-type of the image as string. */ - public String getMimeType(final byte[] image) throws ReportExecutionException; + String getMimeType(final byte[] image) throws ReportExecutionException; /** * @returns the dimension in 100th mm. **/ - public Dimension getImageSize(final InputStream image) throws ReportExecutionException; + Dimension getImageSize(final InputStream image) throws ReportExecutionException; /** * @returns the dimension in 100th mm. **/ - public Dimension getImageSize(final byte[] image) throws ReportExecutionException; + Dimension getImageSize(final byte[] image) throws ReportExecutionException; } diff --git a/reportbuilder/java/com/sun/star/report/InputRepository.java b/reportbuilder/java/com/sun/star/report/InputRepository.java index 5ee660f9d03a..21564d5851df 100644 --- a/reportbuilder/java/com/sun/star/report/InputRepository.java +++ b/reportbuilder/java/com/sun/star/report/InputRepository.java @@ -54,9 +54,9 @@ public interface InputRepository * * @return the repository id */ - public Object getId(); + Object getId(); - public InputStream createInputStream(final String name) throws IOException; + InputStream createInputStream(final String name) throws IOException; /** allows to acces sub repositories inside this repository * @@ -64,7 +64,7 @@ public interface InputRepository * @return the sub repository * @throws java.io.IOException when the sub repository doesn't exist. */ - public InputRepository openInputRepository(final String name) throws IOException; + InputRepository openInputRepository(final String name) throws IOException; /** * This returns an version number for the given resource. Return zero, if @@ -75,11 +75,11 @@ public interface InputRepository * @param name the name of the resource * @return the version number */ - public long getVersion(final String name); + long getVersion(final String name); - public boolean exists(final String name); + boolean exists(final String name); - public boolean isReadable(final String name); + boolean isReadable(final String name); - public void closeInputRepository(); + void closeInputRepository(); } diff --git a/reportbuilder/java/com/sun/star/report/JobProgressIndicator.java b/reportbuilder/java/com/sun/star/report/JobProgressIndicator.java index 00dcdecc9a8d..4cda72cacb5d 100644 --- a/reportbuilder/java/com/sun/star/report/JobProgressIndicator.java +++ b/reportbuilder/java/com/sun/star/report/JobProgressIndicator.java @@ -43,7 +43,7 @@ public interface JobProgressIndicator * * @param string the new description */ - public void setText(String string); + void setText(String string); /** * Initializes the progress indicator and sets the progress description to @@ -56,7 +56,7 @@ public interface JobProgressIndicator * @param maxValue the maximum value * @see JobProgressIndicator#setText(String) */ - public void start(String text, int maxValue); + void start(String text, int maxValue); /** * Updates the value to the specified value. Invalid values must be ignored. @@ -65,17 +65,17 @@ public interface JobProgressIndicator * @param value the new value that should be shown now. This must fit the * range [0..maxValue] as defined in {@link JobProgressIndicator#start(String, int)}. */ - public void setValue(int value); + void setValue(int value); /** * Stop the progress. A progress indicator cannot be destructed before end() * has been called. */ - public void end(); + void end(); /** * Clear progress value and description. Calling of setValue(0) and * setText("") should do the same. Stopped indicators must ignore this call. */ - public void reset(); + void reset(); } diff --git a/reportbuilder/java/com/sun/star/report/JobProperties.java b/reportbuilder/java/com/sun/star/report/JobProperties.java index b0fcff494b87..9d8932c1219b 100644 --- a/reportbuilder/java/com/sun/star/report/JobProperties.java +++ b/reportbuilder/java/com/sun/star/report/JobProperties.java @@ -32,10 +32,10 @@ package com.sun.star.report; public interface JobProperties { - public void setProperty(String key, Object value) + void setProperty(String key, Object value) throws JobDefinitionException; - public Object getProperty(String key); + Object getProperty(String key); /** * A type safe clone operation. We derive a copy of all properties, @@ -44,5 +44,5 @@ public interface JobProperties * * @return a copy. */ - public JobProperties copy(); + JobProperties copy(); } diff --git a/reportbuilder/java/com/sun/star/report/OfficeToken.java b/reportbuilder/java/com/sun/star/report/OfficeToken.java index 5649abdac863..6685afe297da 100644 --- a/reportbuilder/java/com/sun/star/report/OfficeToken.java +++ b/reportbuilder/java/com/sun/star/report/OfficeToken.java @@ -61,4 +61,7 @@ public class OfficeToken { public static final String SCALE = "scale"; public static final String NAME = "name"; public static final String SHAPES = "shapes"; + public static final String ISOTROPIC = "isotropic";
+ public static final String ANISOTROPIC = "anisotropic";
+ public static final String NONE = "none"; } diff --git a/reportbuilder/java/com/sun/star/report/OutputRepository.java b/reportbuilder/java/com/sun/star/report/OutputRepository.java index 915ca1b88324..aba5deba5f51 100644 --- a/reportbuilder/java/com/sun/star/report/OutputRepository.java +++ b/reportbuilder/java/com/sun/star/report/OutputRepository.java @@ -53,7 +53,7 @@ public interface OutputRepository * @return the outputstream * @throws IOException if opening the stream fails */ - public OutputStream createOutputStream(final String name, final String mimeType) throws IOException; + OutputStream createOutputStream(final String name, final String mimeType) throws IOException; /** allows to acces sub repositories inside this repository * @@ -61,13 +61,13 @@ public interface OutputRepository * @return the sub repository * @throws java.io.IOException when the sub repository doesn't exist. */ - public OutputRepository openOutputRepository(final String name, final String mimeType) throws IOException; + OutputRepository openOutputRepository(final String name, final String mimeType) throws IOException; - public boolean exists(final String name); + boolean exists(final String name); - public boolean existsStorage(final String name); + boolean existsStorage(final String name); - public boolean isWritable(final String name); + boolean isWritable(final String name); - public void closeOutputRepository(); + void closeOutputRepository(); } diff --git a/reportbuilder/java/com/sun/star/report/ParameterMap.java b/reportbuilder/java/com/sun/star/report/ParameterMap.java index cf3aed4de598..45a5206583ed 100644 --- a/reportbuilder/java/com/sun/star/report/ParameterMap.java +++ b/reportbuilder/java/com/sun/star/report/ParameterMap.java @@ -49,7 +49,7 @@ public interface ParameterMap * @return The stored value, or <code>null</code> if the key does not exist in this * collection. */ - public Object get(final String key); + Object get(final String key); /** * Retrieves the value stored for a key in this properties collection, and returning the @@ -61,11 +61,11 @@ public interface ParameterMap * @return The stored value, or the default value if the key does not exist in this * collection. */ - public Object get(final String key, final Object defaultValue); + Object get(final String key, final Object defaultValue); - public String[] keys(); + String[] keys(); - public void clear(); + void clear(); - public int size(); + int size(); } diff --git a/reportbuilder/java/com/sun/star/report/ReportAddIn.java b/reportbuilder/java/com/sun/star/report/ReportAddIn.java index 6057a1e20eb2..112e182a0663 100644 --- a/reportbuilder/java/com/sun/star/report/ReportAddIn.java +++ b/reportbuilder/java/com/sun/star/report/ReportAddIn.java @@ -40,9 +40,9 @@ package com.sun.star.report; public interface ReportAddIn { - public int getExpressionCount(); + int getExpressionCount(); - public ReportExpression createExpression(int expression); + ReportExpression createExpression(int expression); - public ReportExpressionMetaData getMetaData(int expression); + ReportExpressionMetaData getMetaData(int expression); } diff --git a/reportbuilder/java/com/sun/star/report/ReportEngineMetaData.java b/reportbuilder/java/com/sun/star/report/ReportEngineMetaData.java index 486a58053e51..49ef491177ae 100644 --- a/reportbuilder/java/com/sun/star/report/ReportEngineMetaData.java +++ b/reportbuilder/java/com/sun/star/report/ReportEngineMetaData.java @@ -40,7 +40,7 @@ public interface ReportEngineMetaData * @param mimeType * @return true, if the output type is supported; false otherwise. */ - public boolean isOutputSupported(String mimeType); + boolean isOutputSupported(String mimeType); /** * Lists all supported output parameters for the given mime-type. @@ -50,13 +50,13 @@ public interface ReportEngineMetaData * @param mimeType * @return */ - public String[] getOutputParameters(String mimeType); + String[] getOutputParameters(String mimeType); - public Class getParameterType(String parameter); + Class getParameterType(String parameter); - public boolean isMandatory(String parameter); + boolean isMandatory(String parameter); - public boolean isEnumeration(String parameter); + boolean isEnumeration(String parameter); - public Object[] getEnumerationValues(String parameter); + Object[] getEnumerationValues(String parameter); } diff --git a/reportbuilder/java/com/sun/star/report/ReportEngineParameterNames.java b/reportbuilder/java/com/sun/star/report/ReportEngineParameterNames.java index 4b0002ba8d8c..8c191a77d2a3 100644 --- a/reportbuilder/java/com/sun/star/report/ReportEngineParameterNames.java +++ b/reportbuilder/java/com/sun/star/report/ReportEngineParameterNames.java @@ -51,6 +51,7 @@ public class ReportEngineParameterNames public static final String MIMETYPE = "output.mimetype"; public static final String AUTHOR = "Author"; public static final String TITLE = "Title"; + public static final String MAXROWS = "MaxRows"; private ReportEngineParameterNames () { diff --git a/reportbuilder/java/com/sun/star/report/ReportExpression.java b/reportbuilder/java/com/sun/star/report/ReportExpression.java index c544659f2c4f..5576a74205d5 100644 --- a/reportbuilder/java/com/sun/star/report/ReportExpression.java +++ b/reportbuilder/java/com/sun/star/report/ReportExpression.java @@ -47,8 +47,8 @@ package com.sun.star.report; */ public interface ReportExpression { - public void setParameters (Object[] parameters); - public Object getParameters (); + void setParameters (Object[] parameters); + Object getParameters (); - public Object getValue(DataRow row); + Object getValue(DataRow row); } diff --git a/reportbuilder/java/com/sun/star/report/ReportExpressionMetaData.java b/reportbuilder/java/com/sun/star/report/ReportExpressionMetaData.java index 830ae3927f44..c2caabfec78e 100644 --- a/reportbuilder/java/com/sun/star/report/ReportExpressionMetaData.java +++ b/reportbuilder/java/com/sun/star/report/ReportExpressionMetaData.java @@ -34,17 +34,17 @@ import java.util.Locale; public interface ReportExpressionMetaData { - public int getParameterCount(); + int getParameterCount(); - public String getParameterName(int param); + String getParameterName(int param); - public String getParameterDisplayName(int param, Locale locale); + String getParameterDisplayName(int param, Locale locale); - public String getParameterDescription(int param, Locale locale); + String getParameterDescription(int param, Locale locale); - public String getName(); + String getName(); - public String getDisplayName(Locale l); + String getDisplayName(Locale l); - public String getDescription(Locale l); + String getDescription(Locale l); } diff --git a/reportbuilder/java/com/sun/star/report/ReportJob.java b/reportbuilder/java/com/sun/star/report/ReportJob.java index bbd02ff5e390..8caf39b9bdae 100644 --- a/reportbuilder/java/com/sun/star/report/ReportJob.java +++ b/reportbuilder/java/com/sun/star/report/ReportJob.java @@ -63,20 +63,20 @@ public interface ReportJob * threading code or wont receive any progress information in single * threaded environments. */ - public void execute() + void execute() throws ReportExecutionException, IOException; /** * Interrupt the job. */ - public void interrupt(); + void interrupt(); /** * Queries the jobs execution status. * * @return true, if the job is currently running, false otherwise. */ - public boolean isRunning(); + boolean isRunning(); /** * Queries the jobs result status. @@ -84,9 +84,9 @@ public interface ReportJob * @return true, if the job is finished (or has been interrupted), false * if the job waits for activation. */ - public boolean isFinished(); + boolean isFinished(); - public void addProgressIndicator(JobProgressIndicator indicator); + void addProgressIndicator(JobProgressIndicator indicator); - public void removeProgressIndicator(JobProgressIndicator indicator); + void removeProgressIndicator(JobProgressIndicator indicator); } diff --git a/reportbuilder/java/com/sun/star/report/ReportJobDefinition.java b/reportbuilder/java/com/sun/star/report/ReportJobDefinition.java index ff1b78b6aace..1bad0c4f0de4 100644 --- a/reportbuilder/java/com/sun/star/report/ReportJobDefinition.java +++ b/reportbuilder/java/com/sun/star/report/ReportJobDefinition.java @@ -47,7 +47,7 @@ public interface ReportJobDefinition * * @return a map containing the report parameters */ - public ParameterMap getQueryParameters(); + ParameterMap getQueryParameters(); /** * The report processing parameters control the behaviour of the report. There are @@ -56,5 +56,5 @@ public interface ReportJobDefinition * * @return the processing parameters */ - public JobProperties getProcessingParameters(); + JobProperties getProcessingParameters(); } diff --git a/reportbuilder/java/com/sun/star/report/ReportJobFactory.java b/reportbuilder/java/com/sun/star/report/ReportJobFactory.java index cf8ed01ba736..fda22b4d907e 100644 --- a/reportbuilder/java/com/sun/star/report/ReportJobFactory.java +++ b/reportbuilder/java/com/sun/star/report/ReportJobFactory.java @@ -40,5 +40,5 @@ import com.sun.star.uno.Exception; public interface ReportJobFactory { - public ReportJob createReportJob(final NamedValue[] namedValue) throws IllegalArgumentException, ReportExecutionException, Exception; + ReportJob createReportJob(final NamedValue[] namedValue) throws IllegalArgumentException, ReportExecutionException, Exception; } diff --git a/reportbuilder/java/com/sun/star/report/SDBCReportDataFactory.java b/reportbuilder/java/com/sun/star/report/SDBCReportDataFactory.java index bc248c29bbd9..af396d415338 100644 --- a/reportbuilder/java/com/sun/star/report/SDBCReportDataFactory.java +++ b/reportbuilder/java/com/sun/star/report/SDBCReportDataFactory.java @@ -35,6 +35,7 @@ import com.sun.star.beans.XPropertySet; import com.sun.star.container.NoSuchElementException; import com.sun.star.container.XIndexAccess; import com.sun.star.lang.IllegalArgumentException; +import com.sun.star.lang.IndexOutOfBoundsException; import com.sun.star.lang.WrappedTargetException; import com.sun.star.sdbc.XConnection; import com.sun.star.container.XNameAccess; @@ -44,12 +45,14 @@ import com.sun.star.sdb.CommandType; import com.sun.star.sdb.XCompletedExecution; import com.sun.star.sdb.XParametersSupplier; import com.sun.star.sdb.XQueriesSupplier; +import com.sun.star.sdb.XResultSetAccess; import com.sun.star.sdb.XSingleSelectQueryComposer; import com.sun.star.sdb.tools.XConnectionTools; import com.sun.star.sdbc.SQLException; import com.sun.star.sdbc.XParameters; import com.sun.star.sdbc.XPreparedStatement; import com.sun.star.uno.Exception; +import java.util.HashMap; import java.util.Map; import com.sun.star.sdbc.XRowSet; @@ -63,6 +66,8 @@ import java.math.BigDecimal; import java.util.ArrayList; import java.util.Iterator; import java.util.List; +import java.util.logging.Level; +import java.util.logging.Logger; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -72,6 +77,77 @@ import org.apache.commons.logging.LogFactory; */ public class SDBCReportDataFactory implements DataSourceFactory { + private static final String ESCAPEPROCESSING = "EscapeProcessing"; + + private class RowSetProperties + { + + final Boolean escapeProcessing; + final int commandType; + final Integer maxRows; + final String command; + final String filter; + + public RowSetProperties(final Boolean escapeProcessing, final int commandType, final String command, final String filter, final Integer maxRows) + { + this.escapeProcessing = escapeProcessing; + this.commandType = commandType; + this.command = command; + this.filter = filter; + this.maxRows = maxRows; + } + + + public boolean equals(Object obj) + { + if (obj == null) + { + return false; + } + if (getClass() != obj.getClass()) + { + return false; + } + final RowSetProperties other = (RowSetProperties) obj; + if (this.escapeProcessing != other.escapeProcessing && (this.escapeProcessing == null || !this.escapeProcessing.equals(other.escapeProcessing))) + { + return false; + } + if (this.commandType != other.commandType) + { + return false; + } + if (this.maxRows != other.maxRows && (this.maxRows == null || !this.maxRows.equals(other.maxRows))) + { + return false; + } + if ((this.command == null) ? (other.command != null) : !this.command.equals(other.command)) + { + return false; + } + if ((this.filter == null) ? (other.filter != null) : !this.filter.equals(other.filter)) + { + return false; + } + return true; + } + + public int hashCode() + { + int hash = 3; + hash = 59 * hash + (this.escapeProcessing != null ? this.escapeProcessing.hashCode() : 0); + hash = 59 * hash + this.commandType; + hash = 59 * hash + (this.maxRows != null ? this.maxRows.hashCode() : 0); + hash = 59 * hash + (this.command != null ? this.command.hashCode() : 0); + hash = 59 * hash + (this.filter != null ? this.filter.hashCode() : 0); + return hash; + } + } + class ParameterDefinition + { + int parameterCount = 0; + private ArrayList parameterIndex = new ArrayList(); + } private static final Log LOGGER = LogFactory.getLog(SDBCReportDataFactory.class); public static final String COMMAND_TYPE = "command-type"; public static final String ESCAPE_PROCESSING = "escape-processing"; @@ -94,6 +170,9 @@ public class SDBCReportDataFactory implements DataSourceFactory private static final int HANDLE_QUERY = 4; private static final int HANDLE_TABLE = 5; private static final int HANDLE_SQL = 6; + private final Map rowSetProperties = new HashMap(); + private final Map parameterMap = new HashMap(); + private boolean rowSetCreated = false; public SDBCReportDataFactory(final XComponentContext cmpCtx, final XConnection connection) { @@ -105,19 +184,19 @@ public class SDBCReportDataFactory implements DataSourceFactory { try { - if ( command == null ) + if (command == null) { return new SDBCReportData(null); } int commandType = CommandType.COMMAND; final String commandTypeValue = (String) parameters.get(COMMAND_TYPE); - if ( commandTypeValue != null ) + if (commandTypeValue != null) { - if ( commandTypeValue.equals("query") ) + if ("query".equals(commandTypeValue)) { commandType = CommandType.QUERY; } - else if ( commandTypeValue.equals("table") ) + else if ("table".equals(commandTypeValue)) { commandType = CommandType.TABLE; } @@ -126,18 +205,22 @@ public class SDBCReportDataFactory implements DataSourceFactory commandType = CommandType.COMMAND; } } - final XRowSet rowSet = createRowSet(command, commandType, parameters); - final XPropertySet rowSetProp = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, rowSet); + final Boolean escapeProcessing = (Boolean) parameters.get(ESCAPE_PROCESSING); + final String filter = (String) parameters.get(UNO_FILTER); + final Integer maxRows = (Integer) parameters.get("MaxRows"); + RowSetProperties rowSetProps = new RowSetProperties(escapeProcessing, commandType, command, filter, maxRows); - final XConnectionTools tools = (XConnectionTools) UnoRuntime.queryInterface(XConnectionTools.class, connection); - fillOrderStatement(command, commandType, parameters, tools, rowSetProp); + final Object[] p = createRowSet(rowSetProps,parameters); + final XRowSet rowSet = (XRowSet)p[0]; - if ( command.length() != 0 ) + if (command.length() != 0 ) { - final int oldParameterCount = fillParameter(parameters, tools, command, commandType, rowSet); + final ParameterDefinition paramDef = (ParameterDefinition)p[1]; + fillParameter(parameters, rowSet,paramDef); + rowSetCreated = rowSetCreated && ( maxRows == null || maxRows.intValue() == 0); final XCompletedExecution execute = (XCompletedExecution) UnoRuntime.queryInterface(XCompletedExecution.class, rowSet); - if ( execute != null && oldParameterCount > 0 ) + if (rowSetCreated && execute != null && paramDef.parameterCount > 0) { final XInteractionHandler handler = (XInteractionHandler) UnoRuntime.queryInterface(XInteractionHandler.class, m_cmpCtx.getServiceManager().createInstanceWithContext("com.sun.star.sdb.InteractionHandler", m_cmpCtx)); execute.executeWithCompletion(handler); @@ -147,9 +230,13 @@ public class SDBCReportDataFactory implements DataSourceFactory rowSet.execute(); } } + + rowSetCreated = false; return new SDBCReportData(rowSet); - } catch ( Exception ex ) + } + catch (Exception ex) { + rowSetCreated = false; throw new DataSourceException(ex.getMessage(), ex); } } @@ -158,7 +245,7 @@ public class SDBCReportDataFactory implements DataSourceFactory { final StringBuffer order = new StringBuffer(); final int count = groupExpressions.size(); - if ( count != 0 ) + if (count != 0) { try { @@ -196,10 +283,6 @@ public class SDBCReportDataFactory implements DataSourceFactory } } } - catch (IndexOutOfBoundsException ex) - { - LOGGER.error("ReportProcessing failed", ex); - } catch (SQLException ex) { LOGGER.error("ReportProcessing failed", ex); @@ -219,14 +302,15 @@ public class SDBCReportDataFactory implements DataSourceFactory { tools.getClass().getMethod("getFieldsByCommandDescriptor", parameter); return tools.getFieldsByCommandDescriptor(commandType, command, out); - } catch ( NoSuchMethodException ex ) + } + catch (NoSuchMethodException ex) { } XNameAccess xFields = null; // some kind of state machine to ease the sharing of code int eState = FAILED; - switch ( commandType ) + switch (commandType) { case CommandType.TABLE: eState = HANDLE_TABLE; @@ -248,41 +332,41 @@ public class SDBCReportDataFactory implements DataSourceFactory // go! while ((DONE != eState) && (FAILED != eState)) { - switch ( eState ) + switch (eState) { case HANDLE_TABLE: - { - // initial state for handling the tables + { + // initial state for handling the tables - // get the table objects - final XTablesSupplier xSupplyTables = (XTablesSupplier) UnoRuntime.queryInterface(XTablesSupplier.class, connection); - if ( xSupplyTables != null ) - { - xObjectCollection = xSupplyTables.getTables(); + // get the table objects + final XTablesSupplier xSupplyTables = (XTablesSupplier) UnoRuntime.queryInterface(XTablesSupplier.class, connection); + if (xSupplyTables != null) + { + xObjectCollection = xSupplyTables.getTables(); // if something went wrong 'til here, then this will be handled in the next state // next state: get the object } - eState = RETRIEVE_OBJECT; - } - break; + eState = RETRIEVE_OBJECT; + } + break; case HANDLE_QUERY: - { - // initial state for handling the tables + { + // initial state for handling the tables - // get the table objects - final XQueriesSupplier xSupplyQueries = (XQueriesSupplier) UnoRuntime.queryInterface(XQueriesSupplier.class, connection); - if ( xSupplyQueries != null ) - { - xObjectCollection = xSupplyQueries.getQueries(); + // get the table objects + final XQueriesSupplier xSupplyQueries = (XQueriesSupplier) UnoRuntime.queryInterface(XQueriesSupplier.class, connection); + if (xSupplyQueries != null) + { + xObjectCollection = xSupplyQueries.getQueries(); // if something went wrong 'til here, then this will be handled in the next state // next state: get the object } - eState = RETRIEVE_OBJECT; - } - break; + eState = RETRIEVE_OBJECT; + } + break; case RETRIEVE_OBJECT: // here we should have an object (aka query or table) collection, and are going @@ -291,7 +375,7 @@ public class SDBCReportDataFactory implements DataSourceFactory // next state: default to FAILED eState = FAILED; - if ( xObjectCollection != null && xObjectCollection.hasByName(command) ) + if (xObjectCollection != null && xObjectCollection.hasByName(command)) { xSupplyColumns = (XColumnsSupplier) UnoRuntime.queryInterface(XColumnsSupplier.class, xObjectCollection.getByName(command)); @@ -304,7 +388,7 @@ public class SDBCReportDataFactory implements DataSourceFactory // next state: default to FAILED eState = FAILED; - if ( xSupplyColumns != null ) + if (xSupplyColumns != null) { xFields = xSupplyColumns.getColumns(); // that's it @@ -313,75 +397,78 @@ public class SDBCReportDataFactory implements DataSourceFactory break; case HANDLE_SQL: - { - String sStatementToExecute = command; + { + String sStatementToExecute = command; - // well, the main problem here is to handle statements which contain a parameter - // If we would simply execute a parametrized statement, then this will fail because - // we cannot supply any parameter values. - // Thus, we try to analyze the statement, and to append a WHERE 0=1 filter criterion - // This should cause every driver to not really execute the statement, but to return - // an empty result set with the proper structure. We then can use this result set - // to retrieve the columns. + // well, the main problem here is to handle statements which contain a parameter + // If we would simply execute a parametrized statement, then this will fail because + // we cannot supply any parameter values. + // Thus, we try to analyze the statement, and to append a WHERE 0=1 filter criterion + // This should cause every driver to not really execute the statement, but to return + // an empty result set with the proper structure. We then can use this result set + // to retrieve the columns. - try - { - final XMultiServiceFactory xComposerFac = (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, connection); + try + { + final XMultiServiceFactory xComposerFac = (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, connection); - if ( xComposerFac != null ) + if (xComposerFac != null) + { + final XSingleSelectQueryComposer xComposer = (XSingleSelectQueryComposer) UnoRuntime.queryInterface(XSingleSelectQueryComposer.class, xComposerFac.createInstance("com.sun.star.sdb.SingleSelectQueryComposer")); + if (xComposer != null) { - final XSingleSelectQueryComposer xComposer = (XSingleSelectQueryComposer) UnoRuntime.queryInterface(XSingleSelectQueryComposer.class, xComposerFac.createInstance("com.sun.star.sdb.SingleSelectQueryComposer")); - if ( xComposer != null ) - { - xComposer.setQuery(sStatementToExecute); + xComposer.setQuery(sStatementToExecute); - // Now set the filter to a dummy restriction which will result in an empty - // result set. - xComposer.setFilter("0=1"); + // Now set the filter to a dummy restriction which will result in an empty + // result set. + xComposer.setFilter("0=1"); - sStatementToExecute = xComposer.getQuery(); - } + sStatementToExecute = xComposer.getQuery(); } - } catch ( com.sun.star.uno.Exception ex ) - { - // silent this error, this was just a try. If we're here, we did not change sStatementToExecute, - // so it will still be _rCommand, which then will be executed without being touched + } + } + catch (com.sun.star.uno.Exception ex) + { + // silent this error, this was just a try. If we're here, we did not change sStatementToExecute, + // so it will still be _rCommand, which then will be executed without being touched } - // now execute - final XPreparedStatement xStatement = connection.prepareStatement(sStatementToExecute); - // transfer ownership of this temporary object to the caller - out[0] = (XComponent) UnoRuntime.queryInterface(XComponent.class, xStatement); + // now execute + final XPreparedStatement xStatement = connection.prepareStatement(sStatementToExecute); + // transfer ownership of this temporary object to the caller + out[0] = (XComponent) UnoRuntime.queryInterface(XComponent.class, xStatement); - // set the "MaxRows" to 0. This is just in case our attempt to append a 0=1 filter - // failed - in this case, the MaxRows restriction should at least ensure that there - // is no data returned (which would be potentially expensive) - final XPropertySet xStatementProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xStatement); - try - { - if ( xStatementProps != null ) - { - xStatementProps.setPropertyValue("MaxRows", new Integer(0)); - } - } catch ( com.sun.star.uno.Exception ex ) + // set the "MaxRows" to 0. This is just in case our attempt to append a 0=1 filter + // failed - in this case, the MaxRows restriction should at least ensure that there + // is no data returned (which would be potentially expensive) + final XPropertySet xStatementProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xStatement); + try + { + if (xStatementProps != null) { - // oh damn. Not much of a chance to recover, we will no retrieve the complete - // full blown result set + xStatementProps.setPropertyValue("MaxRows", Integer.valueOf(0)); + } + } + catch (com.sun.star.uno.Exception ex) + { + // oh damn. Not much of a chance to recover, we will no retrieve the complete + // full blown result set } - xSupplyColumns = (XColumnsSupplier) UnoRuntime.queryInterface(XColumnsSupplier.class, xStatement.executeQuery()); - // this should have given us a result set which does not contain any data, but - // the structural information we need + xSupplyColumns = (XColumnsSupplier) UnoRuntime.queryInterface(XColumnsSupplier.class, xStatement.executeQuery()); + // this should have given us a result set which does not contain any data, but + // the structural information we need - // so the next state is to get the columns - eState = RETRIEVE_COLUMNS; - } - break; + // so the next state is to get the columns + eState = RETRIEVE_COLUMNS; + } + break; default: eState = FAILED; } } - } catch ( com.sun.star.uno.Exception ex ) + } + catch (com.sun.star.uno.Exception ex) { } return xFields; @@ -399,15 +486,18 @@ public class SDBCReportDataFactory implements DataSourceFactory final Object[] param = new Object[2]; param[0] = commandType; param[1] = command; - Method call = tools.getClass().getMethod("getComposer", parameter); + final Method call = tools.getClass().getMethod("getComposer", parameter); return (XSingleSelectQueryComposer) call.invoke(tools, param); - } catch ( NoSuchMethodException ex ) + } + catch (NoSuchMethodException ex) { - } catch ( IllegalAccessException ex ) + } + catch (IllegalAccessException ex) { // should not happen // assert False - } catch ( java.lang.reflect.InvocationTargetException ex ) + } + catch (java.lang.reflect.InvocationTargetException ex) { // should not happen // assert False @@ -418,172 +508,230 @@ public class SDBCReportDataFactory implements DataSourceFactory final XSingleSelectQueryComposer out = (XSingleSelectQueryComposer) UnoRuntime.queryInterface(XSingleSelectQueryComposer.class, factory.createInstance("com.sun.star.sdb.SingleSelectQueryAnalyzer")); final String quote = connection.getMetaData().getIdentifierQuoteString(); String statement = command; - switch ( commandType ) + switch (commandType) { case CommandType.TABLE: statement = "SELECT * FROM " + quote + command + quote; break; case CommandType.QUERY: + { + final XQueriesSupplier xSupplyQueries = (XQueriesSupplier) UnoRuntime.queryInterface(XQueriesSupplier.class, connection); + final XNameAccess queries = xSupplyQueries.getQueries(); + if (queries.hasByName(command)) { - final XQueriesSupplier xSupplyQueries = (XQueriesSupplier) UnoRuntime.queryInterface(XQueriesSupplier.class, connection); - final XNameAccess queries = xSupplyQueries.getQueries(); - if ( queries.hasByName(command) ) + final XPropertySet prop = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, queries.getByName(command)); + final Boolean escape = (Boolean) prop.getPropertyValue(ESCAPEPROCESSING); + if (escape.booleanValue()) { - final XPropertySet prop = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, queries.getByName(command)); - final Boolean escape = (Boolean) prop.getPropertyValue("EscapeProcessing"); - if (escape.booleanValue()) + statement = (String) prop.getPropertyValue(UNO_COMMAND); + final XSingleSelectQueryComposer composer = getComposer(tools, statement, CommandType.COMMAND); + if (composer != null) { - statement = (String) prop.getPropertyValue(UNO_COMMAND); - final XSingleSelectQueryComposer composer = getComposer(tools, statement, CommandType.COMMAND); - if (composer != null) + final String order = (String) prop.getPropertyValue(UNO_ORDER); + if (order != null && order.length() != 0) { - final String order = (String) prop.getPropertyValue(UNO_ORDER); - if (order != null && order.length() != 0) - { - composer.setOrder(order); - } - final Boolean applyFilter = (Boolean) prop.getPropertyValue(UNO_APPLY_FILTER); - if (applyFilter.booleanValue()) + composer.setOrder(order); + } + final Boolean applyFilter = (Boolean) prop.getPropertyValue(UNO_APPLY_FILTER); + if (applyFilter.booleanValue()) + { + final String filter = (String) prop.getPropertyValue(UNO_FILTER); + if (filter != null && filter.length() != 0) { - final String filter = (String) prop.getPropertyValue(UNO_FILTER); - if (filter != null && filter.length() != 0) - { - composer.setFilter(filter); - } + composer.setFilter(filter); } - statement = composer.getQuery(); } + statement = composer.getQuery(); } } } break; + } case CommandType.COMMAND: statement = command; break; } out.setElementaryQuery(statement); return out; - } catch ( Exception e ) + } + catch (Exception e) { } return null; } - int fillParameter(final Map parameters, - final XConnectionTools tools, - final String command, - final int commandType, final XRowSet rowSet) + private void fillParameter(final Map parameters, + final XRowSet rowSet,final ParameterDefinition paramDef) throws SQLException, UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException { - int oldParameterCount = 0; + final ArrayList masterValues = (ArrayList) parameters.get(MASTER_VALUES); + if (masterValues != null && !masterValues.isEmpty()) + { + final XParameters para = (XParameters) UnoRuntime.queryInterface(XParameters.class, rowSet); + + for (int i = 0; + i < masterValues.size(); + i++) + { + Object object = masterValues.get(i); + if (object instanceof BigDecimal) + { + object = ((BigDecimal) object).toString(); + } + final Integer pos = (Integer)paramDef.parameterIndex.get(i); + para.setObject(pos + 1, object); + } + } + } + + private final Object[] createRowSet(final RowSetProperties rowSetProps,final Map parameters) + throws Exception + { + final ArrayList detailColumns = (ArrayList) parameters.get(DETAIL_COLUMNS); + if (rowSetProperties.containsKey(rowSetProps) && detailColumns != null && !detailColumns.isEmpty() ) + { + return new Object[]{ rowSetProperties.get(rowSetProps),parameterMap.get(rowSetProps)}; + } + + rowSetCreated = true; + final XRowSet rowSet = (XRowSet) UnoRuntime.queryInterface(XRowSet.class, m_cmpCtx.getServiceManager().createInstanceWithContext("com.sun.star.sdb.RowSet", m_cmpCtx)); + final XPropertySet rowSetProp = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, rowSet); + + rowSetProp.setPropertyValue("ActiveConnection", connection); + rowSetProp.setPropertyValue(ESCAPEPROCESSING, rowSetProps.escapeProcessing); + rowSetProp.setPropertyValue(UNO_COMMAND_TYPE, Integer.valueOf(rowSetProps.commandType)); + rowSetProp.setPropertyValue(UNO_COMMAND, rowSetProps.command); + + if (rowSetProps.filter != null) + { + rowSetProp.setPropertyValue("Filter", rowSetProps.filter); + rowSetProp.setPropertyValue(APPLY_FILTER, Boolean.valueOf(rowSetProps.filter.length() != 0)); + } + else + { + rowSetProp.setPropertyValue(APPLY_FILTER, Boolean.FALSE); + } + + if (rowSetProps.maxRows != null) + { + rowSetProp.setPropertyValue("MaxRows", rowSetProps.maxRows); + } - final XSingleSelectQueryComposer composer = getComposer(tools, command, commandType); - if ( composer != null ) + final XConnectionTools tools = (XConnectionTools) UnoRuntime.queryInterface(XConnectionTools.class, connection); + fillOrderStatement(rowSetProps.command, rowSetProps.commandType, parameters, tools, rowSetProp); + final ParameterDefinition paramDef = createParameter(parameters, tools, rowSetProps, rowSet); + + rowSetProperties.put(rowSetProps, rowSet); + parameterMap.put(rowSetProps, paramDef); + + return new Object[]{rowSet,paramDef}; + } + + private ParameterDefinition createParameter(final Map parameters, + final XConnectionTools tools, + RowSetProperties rowSetProps, final XRowSet rowSet) + throws SQLException, + UnknownPropertyException, + PropertyVetoException, + IllegalArgumentException, + WrappedTargetException + { + final ParameterDefinition paramDef = new ParameterDefinition(); + final XSingleSelectQueryComposer composer = getComposer(tools, rowSetProps.command, rowSetProps.commandType); + if (composer != null) { final XPropertySet rowSetProp = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, rowSet); - if ( ((Boolean)rowSetProp.getPropertyValue(APPLY_FILTER)).booleanValue() ) + if (((Boolean) rowSetProp.getPropertyValue(APPLY_FILTER)).booleanValue()) { - composer.setFilter((String)rowSetProp.getPropertyValue("Filter")); + composer.setFilter((String) rowSetProp.getPropertyValue("Filter")); } // get old parameter count + final ArrayList detailColumns = (ArrayList) parameters.get(DETAIL_COLUMNS); + final ArrayList handledColumns = new ArrayList(); final XParametersSupplier paraSup = (XParametersSupplier) UnoRuntime.queryInterface(XParametersSupplier.class, composer); - if ( paraSup != null ) + if (paraSup != null) { final XIndexAccess params = paraSup.getParameters(); - if ( params != null ) + if (params != null) { - oldParameterCount = params.getCount(); + final int oldParameterCount = params.getCount(); + paramDef.parameterCount = oldParameterCount; + if ( detailColumns != null ) + { + for (int i = 0; i < oldParameterCount; i++) + { + try + { + final XPropertySet parameter = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, params.getByIndex(i)); + if (parameter != null) + { + final String name = (String) parameter.getPropertyValue("Name"); + for (int j = 0; j < detailColumns.size(); j++) + { + if ( name.equals(detailColumns.get(j) ) ) + { + handledColumns.add(name); + paramDef.parameterIndex.add(Integer.valueOf(i)); + --paramDef.parameterCount; + break; + } + } + } + } + catch (IndexOutOfBoundsException ex) + { + Logger.getLogger(SDBCReportDataFactory.class.getName()).log(Level.SEVERE, null, ex); + } + } + } } } final ArrayList masterValues = (ArrayList) parameters.get(MASTER_VALUES); - if ( masterValues != null && !masterValues.isEmpty() ) + if (masterValues != null && !masterValues.isEmpty() && paramDef.parameterIndex.size() != detailColumns.size() ) { // Vector masterColumns = (Vector) parameters.get("master-columns"); - final ArrayList detailColumns = (ArrayList) parameters.get(DETAIL_COLUMNS); - if ( oldParameterCount < detailColumns.size() ) + + // create the new filter + final String quote = connection.getMetaData().getIdentifierQuoteString(); + final StringBuffer oldFilter = new StringBuffer(); + oldFilter.append(composer.getFilter()); + if (oldFilter.length() != 0) { - // create the new filter - final String quote = connection.getMetaData().getIdentifierQuoteString(); - final StringBuffer oldFilter = new StringBuffer(); - oldFilter.append(composer.getFilter()); - if ( oldFilter.length() != 0 ) - { - oldFilter.append(" AND "); - } - int newParamterCounter = 1; - for (final Iterator it = detailColumns.iterator(); it.hasNext(); - ++newParamterCounter) + oldFilter.append(" AND "); + } + int newParamterCounter = 1; + for (final Iterator it = detailColumns.iterator(); it.hasNext(); + ++newParamterCounter) + { + final String detail = (String) it.next(); + if ( !handledColumns.contains(detail) ) { - final String detail = (String) it.next(); //String master = (String) masterIt.next(); oldFilter.append(quote); oldFilter.append(detail); oldFilter.append(quote); oldFilter.append(" = :link_"); oldFilter.append(newParamterCounter); - if ( it.hasNext() ) + if (it.hasNext()) { oldFilter.append(" AND "); } + paramDef.parameterIndex.add(Integer.valueOf(newParamterCounter + paramDef.parameterCount - 1)); } - - composer.setFilter(oldFilter.toString()); } - else - oldParameterCount = 0; + + composer.setFilter(oldFilter.toString()); final String sQuery = composer.getQuery(); rowSetProp.setPropertyValue(UNO_COMMAND, sQuery); - rowSetProp.setPropertyValue(UNO_COMMAND_TYPE, - new Integer(CommandType.COMMAND)); - - final XParameters para = (XParameters) UnoRuntime.queryInterface(XParameters.class, rowSet); - - for (int i = 0; - i < masterValues.size(); - i++) - { - Object object = masterValues.get(i); - if ( object instanceof BigDecimal ) - { - object = ((BigDecimal) object).toString(); - } - para.setObject(oldParameterCount + i + 1, object); - } + rowSetProp.setPropertyValue(UNO_COMMAND_TYPE,Integer.valueOf(CommandType.COMMAND)); } } - - return oldParameterCount; - } - - private final XRowSet createRowSet(final String command, - final int commandType, final Map parameters) - throws Exception - { - final XRowSet rowSet = (XRowSet) UnoRuntime.queryInterface(XRowSet.class, m_cmpCtx.getServiceManager().createInstanceWithContext("com.sun.star.sdb.RowSet", m_cmpCtx)); - final XPropertySet rowSetProp = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, rowSet); - - rowSetProp.setPropertyValue("ActiveConnection", connection); - final Boolean escapeProcessing = (Boolean)parameters.get(ESCAPE_PROCESSING); - rowSetProp.setPropertyValue("EscapeProcessing", escapeProcessing); - rowSetProp.setPropertyValue(UNO_COMMAND_TYPE, new Integer(commandType)); - rowSetProp.setPropertyValue(UNO_COMMAND, command); - - final String filter = (String) parameters.get(UNO_FILTER); - if ( filter != null ) - { - rowSetProp.setPropertyValue("Filter", filter); - rowSetProp.setPropertyValue(APPLY_FILTER, Boolean.valueOf(filter.length() != 0)); - } - else - { - rowSetProp.setPropertyValue(APPLY_FILTER, Boolean.FALSE); - } - return rowSet; + return paramDef; } void fillOrderStatement(final String command, @@ -598,16 +746,16 @@ public class SDBCReportDataFactory implements DataSourceFactory NoSuchElementException { final StringBuffer order = new StringBuffer(getOrderStatement(commandType, command, (ArrayList) parameters.get(GROUP_EXPRESSIONS))); - if ( order.length() > 0 && commandType != CommandType.TABLE ) + if (order.length() > 0 && commandType != CommandType.TABLE) { String statement = command; final XSingleSelectQueryComposer composer = getComposer(tools, command, commandType); - if ( composer != null ) + if (composer != null) { statement = composer.getQuery(); composer.setQuery(statement); final String sOldOrder = composer.getOrder(); - if ( sOldOrder.length() > 0 ) + if (sOldOrder.length() > 0) { order.append(','); order.append(sOldOrder); @@ -617,15 +765,15 @@ public class SDBCReportDataFactory implements DataSourceFactory } else { - if ( commandType == CommandType.QUERY ) + if (commandType == CommandType.QUERY) { final XQueriesSupplier xSupplyQueries = (XQueriesSupplier) UnoRuntime.queryInterface(XQueriesSupplier.class, connection); final XNameAccess queries = xSupplyQueries.getQueries(); - if ( queries.hasByName(command) ) + if (queries.hasByName(command)) { final XPropertySet prop = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, queries.getByName(command)); - final Boolean escape = (Boolean) prop.getPropertyValue("EscapeProcessing"); - rowSetProp.setPropertyValue("EscapeProcessing", escape); + final Boolean escape = (Boolean) prop.getPropertyValue(ESCAPEPROCESSING); + rowSetProp.setPropertyValue( ESCAPEPROCESSING, escape); final String queryCommand = (String) prop.getPropertyValue(UNO_COMMAND); statement = "SELECT * FROM (" + queryCommand + ")"; } @@ -637,7 +785,7 @@ public class SDBCReportDataFactory implements DataSourceFactory } } rowSetProp.setPropertyValue(UNO_COMMAND, statement); - rowSetProp.setPropertyValue(UNO_COMMAND_TYPE, new Integer(CommandType.COMMAND)); + rowSetProp.setPropertyValue(UNO_COMMAND_TYPE, Integer.valueOf(CommandType.COMMAND)); } rowSetProp.setPropertyValue("Order", order.toString()); } diff --git a/reportbuilder/java/com/sun/star/report/SOImageService.java b/reportbuilder/java/com/sun/star/report/SOImageService.java index 3073a52179fa..83413fe91deb 100644 --- a/reportbuilder/java/com/sun/star/report/SOImageService.java +++ b/reportbuilder/java/com/sun/star/report/SOImageService.java @@ -106,7 +106,7 @@ public class SOImageService implements ImageService { imageSize = (Size) xImage.getPropertyValue("SizePixel"); final int dpi = java.awt.Toolkit.getDefaultToolkit().getScreenResolution(); - final double fac = 2540 / dpi; + final double fac = 2540 / (double)dpi; dim.setSize(imageSize.Width * fac, imageSize.Height * fac); } } diff --git a/reportbuilder/java/com/sun/star/report/StorageRepository.java b/reportbuilder/java/com/sun/star/report/StorageRepository.java index b32bcb3dab86..da0c7fe9e123 100644 --- a/reportbuilder/java/com/sun/star/report/StorageRepository.java +++ b/reportbuilder/java/com/sun/star/report/StorageRepository.java @@ -148,7 +148,7 @@ public class StorageRepository implements InputRepository, OutputRepository { LOGGER.error(REPORT_PROCESSING_FAILED, ex); } - catch (NoSuchElementException ex) + catch (NoSuchElementException e) { // We expect this exception, no need to log it. } diff --git a/reportbuilder/java/com/sun/star/report/function/metadata/AuthorFunction.java b/reportbuilder/java/com/sun/star/report/function/metadata/AuthorFunction.java index 63b15fab0200..87cb540b4a94 100644 --- a/reportbuilder/java/com/sun/star/report/function/metadata/AuthorFunction.java +++ b/reportbuilder/java/com/sun/star/report/function/metadata/AuthorFunction.java @@ -45,10 +45,6 @@ import org.pentaho.reporting.libraries.formula.typing.coretypes.TextType; public class AuthorFunction implements Function { - public AuthorFunction() - { - } - public String getCanonicalName() { return "AUTHOR"; diff --git a/reportbuilder/java/com/sun/star/report/function/metadata/AuthorFunctionDescription.java b/reportbuilder/java/com/sun/star/report/function/metadata/AuthorFunctionDescription.java index fecfcd5753c1..475ce31ab9a1 100644 --- a/reportbuilder/java/com/sun/star/report/function/metadata/AuthorFunctionDescription.java +++ b/reportbuilder/java/com/sun/star/report/function/metadata/AuthorFunctionDescription.java @@ -32,7 +32,6 @@ package com.sun.star.report.function.metadata; import org.pentaho.reporting.libraries.formula.function.AbstractFunctionDescription; import org.pentaho.reporting.libraries.formula.function.FunctionCategory; import org.pentaho.reporting.libraries.formula.typing.Type; -import org.pentaho.reporting.libraries.formula.typing.coretypes.NumberType; import org.pentaho.reporting.libraries.formula.typing.coretypes.TextType; /** diff --git a/reportbuilder/java/com/sun/star/report/function/metadata/TitleFunctionDescription.java b/reportbuilder/java/com/sun/star/report/function/metadata/TitleFunctionDescription.java index 5db1a898b04e..a8dadc17a00d 100644 --- a/reportbuilder/java/com/sun/star/report/function/metadata/TitleFunctionDescription.java +++ b/reportbuilder/java/com/sun/star/report/function/metadata/TitleFunctionDescription.java @@ -32,7 +32,6 @@ package com.sun.star.report.function.metadata; import org.pentaho.reporting.libraries.formula.function.AbstractFunctionDescription; import org.pentaho.reporting.libraries.formula.function.FunctionCategory; import org.pentaho.reporting.libraries.formula.typing.Type; -import org.pentaho.reporting.libraries.formula.typing.coretypes.NumberType; import org.pentaho.reporting.libraries.formula.typing.coretypes.TextType; /** diff --git a/reportbuilder/java/com/sun/star/report/pentaho/DefaultNameGenerator.java b/reportbuilder/java/com/sun/star/report/pentaho/DefaultNameGenerator.java index 6cfac589b900..0f2c858d1c96 100644 --- a/reportbuilder/java/com/sun/star/report/pentaho/DefaultNameGenerator.java +++ b/reportbuilder/java/com/sun/star/report/pentaho/DefaultNameGenerator.java @@ -80,25 +80,28 @@ public class DefaultNameGenerator name = "file"; } - String firstFileName = name; + StringBuffer firstFileName = new StringBuffer(); + firstFileName.append(name); final String suffix; if (mimeType != null) { suffix = getSuffixForType(mimeType); - firstFileName += "." + suffix; + firstFileName.append('.'); + firstFileName.append(suffix); } else { suffix = null; } + String newName = firstFileName.toString(); boolean exists; if (isStream) { - exists = outputRepository.exists(firstFileName); + exists = outputRepository.exists(newName); } else { - exists = outputRepository.existsStorage(firstFileName); + exists = outputRepository.existsStorage(newName); } if (exists) { @@ -109,23 +112,27 @@ public class DefaultNameGenerator { throw new IOException(); } - firstFileName = name + counter; + firstFileName.delete(0,firstFileName.length() ); + firstFileName.append(name); + firstFileName.append(counter); if (suffix != null) { - firstFileName += "." + suffix; + firstFileName.append('.'); + firstFileName.append(suffix); } + newName = firstFileName.toString(); if (isStream) { - exists = outputRepository.exists(firstFileName); + exists = outputRepository.exists(newName); } else { - exists = outputRepository.existsStorage(firstFileName); + exists = outputRepository.existsStorage(newName); } - counter += 1; + counter++; } } - return firstFileName; + return newName; } protected String getSuffixForType(final String mimeType) diff --git a/reportbuilder/java/com/sun/star/report/pentaho/PentahoReportEngineMetaData.java b/reportbuilder/java/com/sun/star/report/pentaho/PentahoReportEngineMetaData.java index 7285e9b897be..1f4dce14950d 100644 --- a/reportbuilder/java/com/sun/star/report/pentaho/PentahoReportEngineMetaData.java +++ b/reportbuilder/java/com/sun/star/report/pentaho/PentahoReportEngineMetaData.java @@ -73,6 +73,7 @@ public class PentahoReportEngineMetaData mandatoryParameters.add(ReportEngineParameterNames.INPUT_DETAIL_COLUMNS); mandatoryParameters.add(ReportEngineParameterNames.AUTHOR); mandatoryParameters.add(ReportEngineParameterNames.TITLE); + mandatoryParameters.add(ReportEngineParameterNames.MAXROWS); parameterTypes = new HashMap(); @@ -89,6 +90,7 @@ public class PentahoReportEngineMetaData parameterTypes.put(ReportEngineParameterNames.INPUT_DETAIL_COLUMNS, List.class); parameterTypes.put(ReportEngineParameterNames.AUTHOR, String.class); parameterTypes.put(ReportEngineParameterNames.TITLE, String.class); + parameterTypes.put(ReportEngineParameterNames.MAXROWS, Integer.class); enumerationValues = new HashNMap(); enumerationValues.add(CONTENT_TYPE, diff --git a/reportbuilder/java/com/sun/star/report/pentaho/PentahoReportJob.java b/reportbuilder/java/com/sun/star/report/pentaho/PentahoReportJob.java index f64c1bd7d741..e3b5b268ea43 100644 --- a/reportbuilder/java/com/sun/star/report/pentaho/PentahoReportJob.java +++ b/reportbuilder/java/com/sun/star/report/pentaho/PentahoReportJob.java @@ -60,9 +60,6 @@ import org.pentaho.reporting.libraries.formula.lvalues.LValue; import org.pentaho.reporting.libraries.formula.lvalues.Term; import org.pentaho.reporting.libraries.formula.parser.FormulaParser; import org.pentaho.reporting.libraries.formula.parser.ParseException; -import org.pentaho.reporting.libraries.formula.DefaultFormulaContext; -import org.pentaho.reporting.libraries.formula.function.FunctionCategory; -import org.pentaho.reporting.libraries.formula.function.FunctionRegistry; import org.jfree.report.expressions.Expression; import org.jfree.report.expressions.FormulaExpression; import org.jfree.report.flow.DefaultReportJob; @@ -96,6 +93,7 @@ public class PentahoReportJob implements ReportJob private final ReportJobDefinition definition; private final List masterValues; private final List detailColumns; + private final Integer maxRows; public ReportJobDefinition getDefinition() { @@ -147,6 +145,7 @@ public class PentahoReportJob implements ReportJob this.masterValues = (ArrayList) jobProperties.getProperty(ReportEngineParameterNames.INPUT_MASTER_VALUES); this.detailColumns = (ArrayList) jobProperties.getProperty(ReportEngineParameterNames.INPUT_DETAIL_COLUMNS); + this.maxRows = (Integer) jobProperties.getProperty(ReportEngineParameterNames.MAXROWS); this.resourceManager = new ResourceManager(); this.resourceManager.registerDefaults(); @@ -241,6 +240,8 @@ public class PentahoReportJob implements ReportJob { final OfficeGroup group = (OfficeGroup) node; final FormulaExpression exp = (FormulaExpression) group.getGroupingExpression(); + if ( exp == null ) + continue; try { @@ -343,11 +344,13 @@ public class PentahoReportJob implements ReportJob final String escapeProcessing = (String) officeReport.getAttribute(OfficeNamespaces.OOREPORT_NS, SDBCReportDataFactory.ESCAPE_PROCESSING); report.setQuery(command); parameters.put(SDBCReportDataFactory.COMMAND_TYPE, commandType); - parameters.put(SDBCReportDataFactory.ESCAPE_PROCESSING,new Boolean(!("false".equals(escapeProcessing)))); + parameters.put(SDBCReportDataFactory.ESCAPE_PROCESSING,Boolean.valueOf(!("false".equals(escapeProcessing)))); final String filter = (String) officeReport.getAttribute(OfficeNamespaces.OOREPORT_NS, "filter"); parameters.put(SDBCReportDataFactory.UNO_FILTER, filter); + parameters.put(ReportEngineParameterNames.MAXROWS, report.getJobProperties().getProperty(ReportEngineParameterNames.MAXROWS)); + final long startTime = System.currentTimeMillis(); final ReportProcessor rp = getProcessorForContentType(contentType); rp.processReport(job); diff --git a/reportbuilder/java/com/sun/star/report/pentaho/SOFormulaOpCodeMapper.java b/reportbuilder/java/com/sun/star/report/pentaho/SOFormulaOpCodeMapper.java index a225c93a749d..30c9711dce05 100644 --- a/reportbuilder/java/com/sun/star/report/pentaho/SOFormulaOpCodeMapper.java +++ b/reportbuilder/java/com/sun/star/report/pentaho/SOFormulaOpCodeMapper.java @@ -44,16 +44,14 @@ public final class SOFormulaOpCodeMapper extends WeakBase implements com.sun.star.sheet.XFormulaOpCodeMapper, XServiceInfo { - private final XComponentContext m_xContext; private static final String __serviceName = "com.sun.star.report.pentaho.SOFormulaOpCodeMapper"; private final SOFormulaParser parser; // attributes final private int m_OpCodeExternal = 0; final private int m_OpCodeUnknown = 0; - public SOFormulaOpCodeMapper(XComponentContext context, SOFormulaParser parser) + public SOFormulaOpCodeMapper(SOFormulaParser parser) { - m_xContext = context; this.parser = parser; } diff --git a/reportbuilder/java/com/sun/star/report/pentaho/SOFormulaParser.java b/reportbuilder/java/com/sun/star/report/pentaho/SOFormulaParser.java index 1a8d02d53b64..a5fe1ab5c61f 100644 --- a/reportbuilder/java/com/sun/star/report/pentaho/SOFormulaParser.java +++ b/reportbuilder/java/com/sun/star/report/pentaho/SOFormulaParser.java @@ -82,9 +82,9 @@ public final class SOFormulaParser extends ComponentBase private final Map parserAllOpCodes = new HashMap(); private final Map parserNames = new HashMap(); private final Map[] groupOpCodes = new HashMap[5]; - private final Vector specialOpCodes = new Vector(); + private final List specialOpCodes = new ArrayList(); - public Vector getSpecialOpCodes() + public List getSpecialOpCodes() { return specialOpCodes; } @@ -92,7 +92,7 @@ public final class SOFormulaParser extends ComponentBase private final FormulaOpCodeMapEntry opCodePush; private final FormulaParser parser; - public SOFormulaParser(XComponentContext context) + public SOFormulaParser(final XComponentContext context) { m_xContext = context; @@ -131,7 +131,6 @@ public final class SOFormulaParser extends ComponentBase addOpCodes(names, opCodes, ARRAY_SEPARATORS, false); opCodes = mapper.getAvailableMappings(FormulaLanguage.ODFF, FormulaMapGroup.SPECIAL); - names = new String[opCodes.length]; for (int i = 0; i < opCodes.length; i++) { @@ -179,9 +178,9 @@ public final class SOFormulaParser extends ComponentBase final String upper = token.image.toUpperCase(); if ( parserNames.containsKey(upper) ) { - if ( token.image.equals("(")) + if ( "(".equals(token.image)) brackets++; - else if ( token.image.equals(")")) + else if ( ")".equals(token.image)) --brackets; final FormulaOpCodeMapEntry opCode = (FormulaOpCodeMapEntry) parserNames.get(upper); formulaToken = opCode.Token; @@ -237,8 +236,7 @@ public final class SOFormulaParser extends ComponentBase { } } - FormulaToken[] ret = (FormulaToken[]) tokens.toArray(new FormulaToken[tokens.size()]); - return ret; + return (FormulaToken[]) tokens.toArray(new FormulaToken[tokens.size()]); } public String printFormula(com.sun.star.sheet.FormulaToken[] aTokens) @@ -345,7 +343,7 @@ public final class SOFormulaParser extends ComponentBase { if ( formulaOpCodeMapper == null ) { - formulaOpCodeMapper = new SOFormulaOpCodeMapper(m_xContext, this); + formulaOpCodeMapper = new SOFormulaOpCodeMapper(this); } return formulaOpCodeMapper; @@ -384,12 +382,12 @@ public final class SOFormulaParser extends ComponentBase } } - final public Map getNames() + public Map getNames() { return parserNames; } - final public Map getGroup(int group) + public Map getGroup(int group) { return groupOpCodes[group]; } diff --git a/reportbuilder/java/com/sun/star/report/pentaho/SOFunctionManager.java b/reportbuilder/java/com/sun/star/report/pentaho/SOFunctionManager.java index 059aed34796a..333441f8b2b5 100644 --- a/reportbuilder/java/com/sun/star/report/pentaho/SOFunctionManager.java +++ b/reportbuilder/java/com/sun/star/report/pentaho/SOFunctionManager.java @@ -31,8 +31,6 @@ package com.sun.star.report.pentaho; import com.sun.star.container.NoSuchElementException; -import com.sun.star.lang.IndexOutOfBoundsException; -import com.sun.star.lang.WrappedTargetException; import com.sun.star.lang.XServiceInfo; import com.sun.star.report.meta.XFunctionDescription; import com.sun.star.uno.XComponentContext; @@ -43,9 +41,6 @@ import org.pentaho.reporting.libraries.formula.DefaultFormulaContext; import org.pentaho.reporting.libraries.formula.function.FunctionCategory; import org.pentaho.reporting.libraries.formula.function.FunctionDescription; import org.pentaho.reporting.libraries.formula.function.FunctionRegistry; -import org.pentaho.reporting.libraries.formula.lvalues.LValue; -import org.pentaho.reporting.libraries.formula.parser.FormulaParser; -import org.pentaho.reporting.libraries.formula.parser.ParseException; /** * This class capsulates the class, that implements the minimal component, a factory for creating the service @@ -150,31 +145,6 @@ public final class SOFunctionManager extends ComponentBase implements XFunctionM return new StarFunctionCategory(defaultContext,m_xContext, functionRegistry, position, categories[position]); } - public int getFunctionStartAtIndex(String formula, int position) - { - int nStartPos = -1; - try - { - final FormulaParser parser = new FormulaParser(); - final LValue x = parser.parse(formula); - String part = x.toString(); - while ( part.length() < position ) - { - final LValue[] children = x.getChildValues(); - if ( children != null ) - { - for(int i = 0; i < children.length;++i) - { - part = children[i].toString(); - } - } - } - } catch ( ParseException ex ) - { - } - return nStartPos; - } - public XFunctionDescription getFunctionByName(String arg0) throws NoSuchElementException { final FunctionDescription func = functionRegistry.getMetaData(arg0); @@ -188,7 +158,7 @@ public final class SOFunctionManager extends ComponentBase implements XFunctionM } try { - return new StarFunctionDescription(defaultContext, m_xContext, getCategory(i), functionRegistry, func); + return new StarFunctionDescription(defaultContext, m_xContext, getCategory(i), func); } catch ( Exception ex ) { diff --git a/reportbuilder/java/com/sun/star/report/pentaho/SOReportJobFactory.java b/reportbuilder/java/com/sun/star/report/pentaho/SOReportJobFactory.java index cda541184968..1acf2c846bcb 100644 --- a/reportbuilder/java/com/sun/star/report/pentaho/SOReportJobFactory.java +++ b/reportbuilder/java/com/sun/star/report/pentaho/SOReportJobFactory.java @@ -174,9 +174,9 @@ public class SOReportJobFactory try { simpleReg.open(path, true, false); - XRegistryKey xRegistryRootKey = simpleReg.getRootKey(); + final XRegistryKey xRegistryRootKey = simpleReg.getRootKey(); // read locale - XRegistryKey locale = xRegistryRootKey.openKey(value); + final XRegistryKey locale = xRegistryRootKey.openKey(value); if ( locale != null ) { final String newLocale = locale.getStringValue(); @@ -205,7 +205,7 @@ public class SOReportJobFactory Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader()); try { - XSimpleRegistry simpleReg = (XSimpleRegistry) UnoRuntime.queryInterface(XSimpleRegistry.class, + final XSimpleRegistry simpleReg = (XSimpleRegistry) UnoRuntime.queryInterface(XSimpleRegistry.class, m_cmpCtx.getServiceManager().createInstanceWithContext("com.sun.star.configuration.ConfigurationRegistry", m_cmpCtx)); String currentLocale = getLocaleFromRegistry(simpleReg,"org.openoffice.Setup","L10N/ooSetupSystemLocale"); @@ -242,6 +242,7 @@ public class SOReportJobFactory String mimetype = null; String author = null; String title = null; + Integer maxRows = null; for ( int i = 0; i < namedValue.length; ++i ) { @@ -270,6 +271,10 @@ public class SOReportJobFactory { mimetype = (String) aProps.Value; } + else if ( "MaxRows".equalsIgnoreCase(aProps.Name) ) + { + maxRows = (Integer) aProps.Value; + } else if ( ReportEngineParameterNames.AUTHOR.equalsIgnoreCase(aProps.Name) ) { author = (String) aProps.Value; @@ -324,6 +329,7 @@ public class SOReportJobFactory procParms.setProperty(ReportEngineParameterNames.INPUT_DATASOURCE_FACTORY, dataFactory); procParms.setProperty(ReportEngineParameterNames.IMAGE_SERVICE, new SOImageService(m_cmpCtx)); procParms.setProperty(ReportEngineParameterNames.INPUT_REPORTJOB_FACTORY, this); + procParms.setProperty(ReportEngineParameterNames.MAXROWS, maxRows); if ( author != null ) { procParms.setProperty(ReportEngineParameterNames.AUTHOR, author); diff --git a/reportbuilder/java/com/sun/star/report/pentaho/StarFunctionCategory.java b/reportbuilder/java/com/sun/star/report/pentaho/StarFunctionCategory.java index 9c98f42eb6eb..19b041715acf 100644 --- a/reportbuilder/java/com/sun/star/report/pentaho/StarFunctionCategory.java +++ b/reportbuilder/java/com/sun/star/report/pentaho/StarFunctionCategory.java @@ -156,7 +156,7 @@ public final class StarFunctionCategory extends WeakBase { if ( position >= functions.length ) throw new IndexOutOfBoundsException(); - return new StarFunctionDescription(defaultContext,m_xContext,this,functionRegistry,functionRegistry.getMetaData(functions[position])); + return new StarFunctionDescription(defaultContext,m_xContext,this,functionRegistry.getMetaData(functions[position])); } } diff --git a/reportbuilder/java/com/sun/star/report/pentaho/StarFunctionDescription.java b/reportbuilder/java/com/sun/star/report/pentaho/StarFunctionDescription.java index bca8ad026b19..df19a3f06174 100644 --- a/reportbuilder/java/com/sun/star/report/pentaho/StarFunctionDescription.java +++ b/reportbuilder/java/com/sun/star/report/pentaho/StarFunctionDescription.java @@ -51,11 +51,10 @@ public final class StarFunctionDescription extends WeakBase // attributes // final private com.sun.star.report.meta.XFunctionCategory m_Category; private final FunctionDescription functionDescription; - private final FunctionRegistry functionRegistry; private final XFunctionCategory category; private final Locale defaultLocale; - public StarFunctionDescription(final DefaultFormulaContext defaultContext, final XComponentContext context, final XFunctionCategory category, final FunctionRegistry functionRegistry, final FunctionDescription functionDescription) + public StarFunctionDescription(final DefaultFormulaContext defaultContext, final XComponentContext context, final XFunctionCategory category, final FunctionDescription functionDescription) { m_xContext = context; this.category = category; @@ -71,7 +70,6 @@ public final class StarFunctionDescription extends WeakBase this.defaultLocale = locale; this.functionDescription = functionDescription; - this.functionRegistry = functionRegistry; // use the last parameter of the PropertySetMixin constructor // for your optional attributes if necessary. See the documentation // of the PropertySetMixin helper for further information. @@ -137,14 +135,14 @@ public final class StarFunctionDescription extends WeakBase { final int count = functionDescription.getParameterCount(); final StringBuffer signature = new StringBuffer(getName()); - signature.append("("); + signature.append('('); for (int i = 0; i < count; i++) { signature.append(functionDescription.getParameterDisplayName(i, defaultLocale)); if ( i != (count - 1) ) - signature.append(";"); + signature.append(';'); } - signature.append(")"); + signature.append(')'); return signature.toString(); } @@ -176,16 +174,16 @@ public final class StarFunctionDescription extends WeakBase throw new com.sun.star.lang.IllegalArgumentException(); final StringBuffer formula = new StringBuffer(getName()); - formula.append("("); + formula.append('('); for (int i = 0; i < arguments.length; ++i) { if ( arguments[i].length() == 0 ) break; formula.append(arguments[i]); if ( i < (arguments.length - 1) && arguments[i+1].length() != 0 ) - formula.append(";"); + formula.append(';'); } - formula.append(")"); + formula.append(')'); return formula.toString(); } } diff --git a/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/FormatValueUtility.java b/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/FormatValueUtility.java index 4eea93329cb4..e6f27564b519 100755 --- a/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/FormatValueUtility.java +++ b/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/FormatValueUtility.java @@ -43,6 +43,8 @@ import org.jfree.report.data.DefaultDataFlags; import org.jfree.report.expressions.FormulaExpression; import org.jfree.report.flow.FlowController; import org.jfree.report.flow.layoutprocessor.LayoutControllerUtil; +import org.pentaho.reporting.libraries.formula.util.DateUtil; +import org.pentaho.reporting.libraries.formula.util.HSSFDateUtil; /** * Creation-Date: 06.06.2007, 17:03:30 @@ -100,13 +102,21 @@ public class FormatValueUtility return ret; } - public static void applyValueForCell(final Object value, final AttributeMap variableSection) + public static void applyValueForCell(final Object value, final AttributeMap variableSection,final String valueType) { - if (value instanceof Date) + if (value instanceof Date ) { - variableSection.setAttribute(OfficeNamespaces.OFFICE_NS, "date-value", formatDate((Date) value)); + if ( "date".equals(valueType) ) + { + variableSection.setAttribute(OfficeNamespaces.OFFICE_NS, "date-value", formatDate((Date) value)); + } + else + { + variableSection.setAttribute(OfficeNamespaces.OFFICE_NS, "value", String.valueOf(HSSFDateUtil.getExcelDate((Date)value))); + } + } - else if (value instanceof Number) + else if (value instanceof Number ) { variableSection.setAttribute(OfficeNamespaces.OFFICE_NS, "value", String.valueOf(value)); } @@ -123,7 +133,24 @@ public class FormatValueUtility } else if (value != null) { - variableSection.setAttribute(OfficeNamespaces.OFFICE_NS,STRING_VALUE, String.valueOf(value)); + try + { + final Float number = Float.valueOf(String.valueOf(value)); + applyValueForCell(number,variableSection,valueType); + return; + } + catch(NumberFormatException e) + { + + } + if ( !"string".equals(valueType)) + { + variableSection.setAttribute(OfficeNamespaces.OFFICE_NS, "value", String.valueOf(value)); + } + else + { + variableSection.setAttribute(OfficeNamespaces.OFFICE_NS,STRING_VALUE, String.valueOf(value)); + } } else { diff --git a/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/ImageElementLayoutController.java b/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/ImageElementLayoutController.java index 8cd296151005..68d1fc6351c4 100644 --- a/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/ImageElementLayoutController.java +++ b/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/ImageElementLayoutController.java @@ -85,20 +85,20 @@ public class ImageElementLayoutController // A static image is easy. At least at this level. Dont ask about the weird things we have to do in the // output targets ... final String linkTarget = imageElement.getImageData(); - generateImage(target, linkTarget, imageElement.isScale(), imageElement.isPreserveIRI()); + generateImage(target, linkTarget, imageElement.getScaleMode(), imageElement.isPreserveIRI()); } else { final Object value = LayoutControllerUtil.evaluateExpression(getFlowController(), imageElement, formulaExpression); - generateImage(target, value, imageElement.isScale(), imageElement.isPreserveIRI()); + generateImage(target, value, imageElement.getScaleMode(), imageElement.isPreserveIRI()); } return join(getFlowController()); } private void generateImage(final ReportTarget target, final Object linkTarget, - final boolean scale, + final String scale, final boolean preserveIri) throws ReportProcessingException, DataSourceException { @@ -110,7 +110,7 @@ public class ImageElementLayoutController final AttributeMap image = new AttributeMap(); image.setAttribute(JFreeReportInfo.REPORT_NAMESPACE, Element.NAMESPACE_ATTRIBUTE, JFreeReportInfo.REPORT_NAMESPACE); image.setAttribute(JFreeReportInfo.REPORT_NAMESPACE, Element.TYPE_ATTRIBUTE, OfficeToken.IMAGE); - image.setAttribute(JFreeReportInfo.REPORT_NAMESPACE, OfficeToken.SCALE, String.valueOf(scale)); + image.setAttribute(JFreeReportInfo.REPORT_NAMESPACE, OfficeToken.SCALE, scale); image.setAttribute(JFreeReportInfo.REPORT_NAMESPACE, OfficeToken.PRESERVE_IRI, String.valueOf(preserveIri)); image.setAttribute(JFreeReportInfo.REPORT_NAMESPACE, "image-context", createContext()); image.setAttribute(JFreeReportInfo.REPORT_NAMESPACE, OfficeToken.IMAGE_DATA, linkTarget); diff --git a/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/ObjectOleLayoutController.java b/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/ObjectOleLayoutController.java index 97e4332217a9..54f4fd0b1acb 100644 --- a/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/ObjectOleLayoutController.java +++ b/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/ObjectOleLayoutController.java @@ -30,7 +30,6 @@ package com.sun.star.report.pentaho.layoutprocessor; import com.sun.star.report.SDBCReportDataFactory; -import com.sun.star.report.pentaho.OfficeNamespaces; import com.sun.star.report.OfficeToken; import com.sun.star.report.pentaho.model.ObjectOleElement; import java.util.ArrayList; diff --git a/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/OfficeGroupInstanceSectionLayoutController.java b/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/OfficeGroupInstanceSectionLayoutController.java index 8a3779cebe03..d61f03eb319e 100644 --- a/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/OfficeGroupInstanceSectionLayoutController.java +++ b/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/OfficeGroupInstanceSectionLayoutController.java @@ -152,7 +152,7 @@ public class OfficeGroupInstanceSectionLayoutController extends SectionLayoutCon throws DataSourceException { final AttributeMap map = new AttributeMap( super.computeAttributes(fc, element, target) ); - map.setAttribute(JFreeReportInfo.REPORT_NAMESPACE, "iteration-count", new Integer(getIterationCount())); + map.setAttribute(JFreeReportInfo.REPORT_NAMESPACE, "iteration-count", Integer.valueOf(getIterationCount())); map.makeReadOnly(); return map; } diff --git a/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/OfficeGroupLayoutController.java b/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/OfficeGroupLayoutController.java index 78180c7dc9cb..25e12d17edab 100644 --- a/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/OfficeGroupLayoutController.java +++ b/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/OfficeGroupLayoutController.java @@ -185,7 +185,7 @@ public class OfficeGroupLayoutController extends SectionLayoutController { if (lc instanceof OfficeGroupLayoutController) { - count += 1; + count++; } lc = lc.getParent(); } diff --git a/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/TableCellLayoutController.java b/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/TableCellLayoutController.java index daacce47aa48..44117380e176 100644 --- a/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/TableCellLayoutController.java +++ b/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/TableCellLayoutController.java @@ -70,6 +70,7 @@ public class TableCellLayoutController extends SectionLayoutController { final AttributeMap attributeMap = new AttributeMap(super.computeAttributes(fc, element, target)); final String definedStyle = (String) attributeMap.getAttribute(OfficeNamespaces.TABLE_NS, OfficeToken.STYLE_NAME); + final String valueType = (String) attributeMap.getAttribute(OfficeNamespaces.OFFICE_NS, FormatValueUtility.VALUE_TYPE); attributeMap.setAttribute(OfficeNamespaces.TABLE_NS, OfficeToken.STYLE_NAME, getDisplayStyleName((Section) element, definedStyle)); try @@ -77,7 +78,7 @@ public class TableCellLayoutController extends SectionLayoutController final DataFlags value = computeValue(); if (value != null) { - FormatValueUtility.applyValueForCell(value.getValue(), attributeMap); + FormatValueUtility.applyValueForCell(value.getValue(), attributeMap,valueType); } } catch (Exception e) diff --git a/reportbuilder/java/com/sun/star/report/pentaho/makefile.mk b/reportbuilder/java/com/sun/star/report/pentaho/makefile.mk index 5d448a6bc2be..36e83afac2d0 100644 --- a/reportbuilder/java/com/sun/star/report/pentaho/makefile.mk +++ b/reportbuilder/java/com/sun/star/report/pentaho/makefile.mk @@ -103,18 +103,18 @@ CUSTOMMANIFESTFILE = Manifest.mf $(JARTARGETN) : $(COMP) $(PROPERTYFILES) $(CSSFILES) $(XSDFILES) $(TXTFILES) $(XMLFILES) .ENDIF # "$(JARTARGETN)"!="" -fix_system_libs: +fix_system_libs: $(JARMANIFEST) @echo "Fix Java Class-Path entry for libraries from system." .IF ("$(SYSTEM_JFREEREPORT)" != "YES" && "$(SYSTEM_APACHE_COMMONS)" == "YES") @$(SED) -r -e "s#commons-logging-1.1.1.jar#file://$(COMMONS_LOGGING_JAR)#" \ - -i ../../../../../../$(INPATH)/class/sun-report-builder/META-INF/MANIFEST.MF + -i $< .ENDIF .IF ("$(SYSTEM_JFREEREPORT)" == "YES" && "$(SYSTEM_APACHE_COMMONS)" == "YES") @$(SED) '/flute/,/sac/d' -i ../../../../../../$(INPATH)/class/sun-report-builder/META-INF/MANIFEST.MF @$(SED) -r -e "s#^Class-Path.*#\0\n file://$(LIBBASE_JAR)\n file://$(SAC_JAR)\n file://$(LIBXML_JAR)\n\ file://$(FLUTE_JAR)\n file://$(JFREEREPORT_JAR)\n file://$(LIBLAYOUT_JAR)\n file://$(LIBLOADER_JAR)\n file://$(LIBFORMULA_JAR)\n\ file://$(LIBREPOSITORY_JAR)\n file://$(LIBFONTS_JAR)\n file://$(LIBSERIALIZER_JAR)\n file://$(COMMONS_LOGGING_JAR)#" \ - -i ../../../../../../$(INPATH)/class/sun-report-builder/META-INF/MANIFEST.MF + -i $< .ENDIF $(CLASSDIR)$/$(PACKAGE)$/%.properties : %.properties diff --git a/reportbuilder/java/com/sun/star/report/pentaho/model/ImageElement.java b/reportbuilder/java/com/sun/star/report/pentaho/model/ImageElement.java index 45e11580cd8f..195c569a3028 100644 --- a/reportbuilder/java/com/sun/star/report/pentaho/model/ImageElement.java +++ b/reportbuilder/java/com/sun/star/report/pentaho/model/ImageElement.java @@ -59,15 +59,16 @@ public class ImageElement extends ReportElement this.formula = formula; } - public boolean isScale() - { - return OfficeToken.TRUE.equals(getAttribute(OfficeNamespaces.OOREPORT_NS, OfficeToken.SCALE)); - } - public void setScale(final boolean scale) - { - setAttribute(OfficeNamespaces.OOREPORT_NS, OfficeToken.SCALE, String.valueOf(scale)); - } + public String getScaleMode()
+ {
+ String val = (String)getAttribute(OfficeNamespaces.OOREPORT_NS, OfficeToken.SCALE);
+ if ( OfficeToken.TRUE.equals(val) )
+ val = OfficeToken.ANISOTROPIC;
+ else if ( OfficeToken.FALSE.equals(val) || val == null )
+ val = OfficeToken.NONE;
+ return val;
+ }
public boolean isPreserveIRI() { diff --git a/reportbuilder/java/com/sun/star/report/pentaho/output/ImageProducer.java b/reportbuilder/java/com/sun/star/report/pentaho/output/ImageProducer.java index 9866d1a41c5e..af34c5ed5a00 100644 --- a/reportbuilder/java/com/sun/star/report/pentaho/output/ImageProducer.java +++ b/reportbuilder/java/com/sun/star/report/pentaho/output/ImageProducer.java @@ -38,6 +38,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.net.MalformedURLException; +import java.net.URISyntaxException; import java.net.URL; import java.net.URLConnection; import java.sql.Blob; @@ -50,7 +51,10 @@ import com.sun.star.report.OutputRepository; import com.sun.star.report.ImageService; import com.sun.star.report.ReportExecutionException; import com.sun.star.report.pentaho.DefaultNameGenerator; +import java.net.URI; import java.util.Map; +import java.util.logging.Level; +import java.util.logging.Logger; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.jfree.layouting.input.style.values.CSSNumericType; @@ -347,7 +351,7 @@ public class ImageProducer final CSSNumericValue widthVal = CSSNumericValue.createValue(CSSNumericType.MM, dims.getWidth() / 100.0); final CSSNumericValue heightVal = CSSNumericValue.createValue(CSSNumericType.MM, dims.getHeight() / 100.0); - final String filename = copyToOutputRepository(mimeType, source, data); + final String filename = copyToOutputRepository(mimeType, data); final OfficeImage officeImage = new OfficeImage(filename, widthVal, heightVal); imageCache.put(source, officeImage); return officeImage; @@ -371,7 +375,17 @@ public class ImageProducer private OfficeImage produceFromURL(final URL url, final boolean preserveIRI) { - final OfficeImage o = (OfficeImage) imageCache.get(url); + final String urlString = url.toString(); + URI uri = null; + try + { + uri = new URI(urlString); + } + catch ( URISyntaxException ex ) + { + Logger.getLogger(ImageProducer.class.getName()).log(Level.SEVERE, null, ex); + } + final OfficeImage o = (OfficeImage) imageCache.get(uri); if (o != null) { return o; @@ -398,15 +412,14 @@ public class ImageProducer if (preserveIRI) { - final OfficeImage retval = new OfficeImage(url.toString(), widthVal, heightVal); - imageCache.put(url, retval); + final OfficeImage retval = new OfficeImage(urlString, widthVal, heightVal); + imageCache.put(uri, retval); return retval; } - final String file = url.getFile(); - final String name = copyToOutputRepository(mimeType, file, data); + final String name = copyToOutputRepository(mimeType, data); final OfficeImage officeImage = new OfficeImage(name, widthVal, heightVal); - imageCache.put(url, officeImage); + imageCache.put(uri, officeImage); return officeImage; } catch (IOException e) @@ -420,8 +433,8 @@ public class ImageProducer if (!preserveIRI) { - final OfficeImage image = new OfficeImage(url.toString(), null, null); - imageCache.put(url, image); + final OfficeImage image = new OfficeImage(urlString, null, null); + imageCache.put(uri, image); return image; } @@ -429,7 +442,7 @@ public class ImageProducer return null; } - private String copyToOutputRepository(final String urlMimeType, final String file, final byte[] data) + private String copyToOutputRepository(final String urlMimeType, final byte[] data) throws IOException, ReportExecutionException { final String mimeType; diff --git a/reportbuilder/java/com/sun/star/report/pentaho/output/OfficeDocumentReportTarget.java b/reportbuilder/java/com/sun/star/report/pentaho/output/OfficeDocumentReportTarget.java index e9b6f8da882c..42fef8d10f45 100644 --- a/reportbuilder/java/com/sun/star/report/pentaho/output/OfficeDocumentReportTarget.java +++ b/reportbuilder/java/com/sun/star/report/pentaho/output/OfficeDocumentReportTarget.java @@ -43,7 +43,7 @@ import java.util.Iterator; import java.util.Map; import java.util.zip.DeflaterOutputStream; import java.util.zip.InflaterInputStream; - +import com.sun.star.report.ReportEngineParameterNames; import com.sun.star.report.ImageService; import com.sun.star.report.InputRepository; import com.sun.star.report.OutputRepository; @@ -65,6 +65,7 @@ import org.apache.commons.logging.LogFactory; import org.jfree.layouting.input.style.parser.CSSValueFactory; import org.jfree.layouting.input.style.parser.StyleSheetParserUtil; import org.jfree.layouting.input.style.values.CSSNumericValue; +import org.jfree.layouting.input.style.values.CSSNumericType; import org.jfree.layouting.layouter.style.CSSValueResolverUtility; import org.jfree.layouting.namespace.NamespaceDefinition; import org.jfree.layouting.namespace.Namespaces; @@ -300,7 +301,7 @@ public abstract class OfficeDocumentReportTarget extends AbstractReportTarget this.imageNames = new AttributeNameGenerator(); this.imageProducer = new ImageProducer(inputRepository, outputRepository, imageService); - this.oleProducer = new OleProducer(inputRepository, outputRepository, imageService, datasourcefactory); + this.oleProducer = new OleProducer(inputRepository, outputRepository, imageService, datasourcefactory,(Integer)reportJob.getParameters().get(ReportEngineParameterNames.MAXROWS)); try { @@ -1121,7 +1122,7 @@ public abstract class OfficeDocumentReportTarget extends AbstractReportTarget } catch (IOException ioe) { - throw new ReportProcessingException("Unable to create the buffer"); + throw new ReportProcessingException("Unable to create the buffer",ioe); } } @@ -1152,8 +1153,9 @@ public abstract class OfficeDocumentReportTarget extends AbstractReportTarget return null; } - protected AttributeList buildAttributeList(final AttributeMap attrs) + protected AttributeList buildAttributeList(final AttributeMap attrs) { + final String elementType = ReportTargetUtil.getElemenTypeFromAttribute(attrs); final AttributeList attrList = new AttributeList(); final String[] namespaces = attrs.getNameSpaces(); for (int i = 0; i < namespaces.length; i++) @@ -1179,7 +1181,8 @@ public abstract class OfficeDocumentReportTarget extends AbstractReportTarget tableNameGenerator.generateName(saneName)); } else if (OfficeNamespaces.DRAWING_NS.equals(attrNamespace) && - "name".equals(key)) + "name".equals(key) && + !"equation".equals(elementType) ) { final String objectName = String.valueOf(entry.getValue()); attrList.setAttribute(attrNamespace, key, @@ -1284,6 +1287,9 @@ public abstract class OfficeDocumentReportTarget extends AbstractReportTarget CSSNumericValue imageAreaWidthVal; CSSNumericValue imageAreaHeightVal; + CSSNumericValue posX = CSSNumericValue.createValue(CSSNumericType.CM, 0.0); + CSSNumericValue posY = CSSNumericValue.createValue(CSSNumericType.CM, 0.0); + String styleName = null; if (imageContext != null) { @@ -1303,8 +1309,8 @@ public abstract class OfficeDocumentReportTarget extends AbstractReportTarget final CSSNumericValue normalizedImageHeight = CSSValueResolverUtility.convertLength(height, imageAreaHeightVal.getType()); - final boolean scale = OfficeToken.TRUE.equals(attrs.getAttribute(JFreeReportInfo.REPORT_NAMESPACE, OfficeToken.SCALE)); - if (!scale && normalizedImageWidth.getValue() > 0 && normalizedImageHeight.getValue() > 0) + final String scale = (String)attrs.getAttribute(JFreeReportInfo.REPORT_NAMESPACE, OfficeToken.SCALE); + if ( OfficeToken.NONE.equals(scale) && normalizedImageWidth.getValue() > 0 && normalizedImageHeight.getValue() > 0) { final double clipWidth = normalizedImageWidth.getValue() - imageAreaWidthVal.getValue(); final double clipHeight = normalizedImageHeight.getValue() - imageAreaHeightVal.getValue(); @@ -1373,6 +1379,16 @@ public abstract class OfficeDocumentReportTarget extends AbstractReportTarget imageAreaHeightVal = normalizedImageHeight; } } + else if ( OfficeToken.ISOTROPIC.equals(scale) ) + { + final double[] ret = calcPaintSize(imageAreaWidthVal,imageAreaHeightVal,normalizedImageWidth,normalizedImageHeight); + + posX = CSSNumericValue.createValue(imageAreaWidthVal.getType(),( imageAreaWidthVal.getValue() - ret[0]) * 0.5); + posY = CSSNumericValue.createValue(imageAreaHeightVal.getType(),( imageAreaHeightVal.getValue() - ret[1]) * 0.5); + + imageAreaWidthVal = CSSNumericValue.createValue(imageAreaWidthVal.getType(),ret[0]); + imageAreaHeightVal = CSSNumericValue.createValue(imageAreaHeightVal.getType(),ret[1]); + } } // If we do scale, then we simply use the given image-area-size as valid image size and dont // care about the image itself .. @@ -1393,8 +1409,9 @@ public abstract class OfficeDocumentReportTarget extends AbstractReportTarget } frameList.setAttribute(OfficeNamespaces.TEXT_NS, "anchor-type", OfficeToken.PARAGRAPH); frameList.setAttribute(OfficeNamespaces.SVG_NS, "z-index", "0"); - frameList.setAttribute(OfficeNamespaces.SVG_NS, "x", ZERO_CM); - frameList.setAttribute(OfficeNamespaces.SVG_NS, "y", ZERO_CM); + frameList.setAttribute(OfficeNamespaces.SVG_NS, "x", posX.getValue() + posX.getType().getType()); + frameList.setAttribute(OfficeNamespaces.SVG_NS, "y", posY.getValue() + posY.getType().getType()); + LOGGER.debug("Image " + imageData + " A-Width: " + imageAreaWidthVal + ", A-Height: " + imageAreaHeightVal); @@ -1635,7 +1652,28 @@ public abstract class OfficeDocumentReportTarget extends AbstractReportTarget { throw new ReportProcessingException(FAILED, ioe); } + } + static private double[] calcPaintSize( final CSSNumericValue areaWidth, final CSSNumericValue areaHeight, + final CSSNumericValue imageWidth, final CSSNumericValue imageHeight) + { + final double ratioX = areaWidth.getValue() / imageWidth.getValue(); + final double ratioY = areaHeight.getValue() / imageHeight.getValue(); + final double ratioMin = Math.min( ratioX, ratioY ); + double[] ret = new double[2]; + ret[0] = imageWidth.getValue() * ratioMin; + ret[1] = imageHeight.getValue() * ratioMin; + return ret; + } + protected void writeNullDate() throws IOException + { + // write NULL DATE + final XmlWriter xmlWriter = getXmlWriter(); + xmlWriter.writeTag(OfficeNamespaces.TABLE_NS, "calculation-settings", null, XmlWriterSupport.OPEN); + final AttributeMap nullDateAttributes = new AttributeMap(); + nullDateAttributes.setAttribute(OfficeNamespaces.TABLE_NS, "date-value", "1900-01-01"); + xmlWriter.writeTag(OfficeNamespaces.TABLE_NS, "null-date", buildAttributeList(nullDateAttributes), XmlWriterSupport.CLOSE); + xmlWriter.writeCloseTag(); } } diff --git a/reportbuilder/java/com/sun/star/report/pentaho/output/OleProducer.java b/reportbuilder/java/com/sun/star/report/pentaho/output/OleProducer.java index cc4b466fae31..36dffa290da1 100644 --- a/reportbuilder/java/com/sun/star/report/pentaho/output/OleProducer.java +++ b/reportbuilder/java/com/sun/star/report/pentaho/output/OleProducer.java @@ -57,10 +57,11 @@ public class OleProducer { private final DefaultNameGenerator nameGenerator; private final DataSourceFactory dataSourceFactory; private final ImageService imageService; + private final Integer maxRows; public OleProducer(final InputRepository inputRepository, - final OutputRepository outputRepository,final ImageService imageService,final DataSourceFactory dataSourceFactory) { + final OutputRepository outputRepository,final ImageService imageService,final DataSourceFactory dataSourceFactory,final Integer maxRows) { if (inputRepository == null) { throw new NullPointerException(); } @@ -73,6 +74,7 @@ public class OleProducer { this.nameGenerator = new DefaultNameGenerator(outputRepository); this.dataSourceFactory = dataSourceFactory; this.imageService = imageService; + this.maxRows = maxRows; } String produceOle(final String source,final List masterColumns,final List masterValues,final List detailColumns) { @@ -99,6 +101,7 @@ public class OleProducer { procParms.setProperty(ReportEngineParameterNames.INPUT_MASTER_VALUES, masterValues); procParms.setProperty(ReportEngineParameterNames.INPUT_DETAIL_COLUMNS, detailColumns); procParms.setProperty(ReportEngineParameterNames.IMAGE_SERVICE, imageService); + procParms.setProperty(ReportEngineParameterNames.MAXROWS, maxRows); engine.createJob(definition).execute(); } catch (ReportExecutionException ex) { diff --git a/reportbuilder/java/com/sun/star/report/pentaho/output/chart/ChartRawReportTarget.java b/reportbuilder/java/com/sun/star/report/pentaho/output/chart/ChartRawReportTarget.java index 56a2c036f2e8..9328be4fd031 100644 --- a/reportbuilder/java/com/sun/star/report/pentaho/output/chart/ChartRawReportTarget.java +++ b/reportbuilder/java/com/sun/star/report/pentaho/output/chart/ChartRawReportTarget.java @@ -101,6 +101,7 @@ public class ChartRawReportTarget extends OfficeDocumentReportTarget tableCount = 0; final XmlWriter xmlWriter = getXmlWriter(); xmlWriter.writeTag(OfficeNamespaces.OFFICE_NS, getStartContent(), null, XmlWriterSupport.OPEN); + writeNullDate(); ++closeTags; } @@ -280,7 +281,7 @@ public class ChartRawReportTarget extends OfficeDocumentReportTarget } catch (IOException ioe) { - throw new ReportProcessingException("Failed to write settings document"); + throw new ReportProcessingException("Failed to write settings document",ioe); } } } diff --git a/reportbuilder/java/com/sun/star/report/pentaho/output/spreadsheet/SpreadsheetRawReportTarget.java b/reportbuilder/java/com/sun/star/report/pentaho/output/spreadsheet/SpreadsheetRawReportTarget.java index 2b764f371fc1..3be3c523662e 100644 --- a/reportbuilder/java/com/sun/star/report/pentaho/output/spreadsheet/SpreadsheetRawReportTarget.java +++ b/reportbuilder/java/com/sun/star/report/pentaho/output/spreadsheet/SpreadsheetRawReportTarget.java @@ -81,6 +81,17 @@ import org.pentaho.reporting.libraries.xmlns.writer.XmlWriterSupport; public class SpreadsheetRawReportTarget extends OfficeDocumentReportTarget { + private static final String[] FOPROPS = new String[] + { + "letter-spacing", "font-variant", "text-transform" + }; + private static final String NUMBERCOLUMNSSPANNED = "number-columns-spanned"; + private static final String[] STYLEPROPS = new String[] + { + "text-combine", "font-pitch-complex", "text-rotation-angle", "font-name", "text-blinking", "letter-kerning", "text-combine-start-char", "text-combine-end-char", "text-position", "text-scale" + }; + private static final int CELL_WIDTH_FACTOR = 10000; + private static final String TRANSPARENT = "transparent"; private boolean paragraphFound = false; private boolean paragraphHandled = false; @@ -93,9 +104,9 @@ public class SpreadsheetRawReportTarget extends OfficeDocumentReportTarget { private final Set tableIndices; - private final float boundary; + private final long boundary; - private ColumnBoundary(final float boundary) + private ColumnBoundary(final long boundary) { this.tableIndices = new HashSet(); this.boundary = boundary; @@ -119,13 +130,13 @@ public class SpreadsheetRawReportTarget extends OfficeDocumentReportTarget public int compareTo(final Object arg0) { - if (arg0.equals(this)) + if ( arg0.equals(this) ) { return 0; } - if (arg0 instanceof ColumnBoundary) + if ( arg0 instanceof ColumnBoundary ) { - if (boundary > ((ColumnBoundary) arg0).boundary) + if ( boundary > ((ColumnBoundary) arg0).boundary ) { return 1; } @@ -139,38 +150,45 @@ public class SpreadsheetRawReportTarget extends OfficeDocumentReportTarget public boolean equals(final Object obj) { - if (obj instanceof ColumnBoundary) + if ( obj instanceof ColumnBoundary ) { return ((ColumnBoundary) obj).boundary == boundary; } return false; } + + public int hashCode() + { + assert false : "hashCode not designed"; + return 42; // any arbitrary constant will do + } } private String tableBackgroundColor; // null means transparent ... - private static final ColumnBoundary[] EMPTY_COLBOUNDS = new ColumnBoundary[0]; + private static final ColumnBoundary[] EMPTY_COLBOUNDS = new ColumnBoundary[ 0 ]; private boolean elementBoundaryCollectionPass; private boolean oleHandled; private final List columnBoundaryList; - private float currentRowBoundaryMarker; + private long currentRowBoundaryMarker; private ColumnBoundary[] sortedBoundaryArray; private ColumnBoundary[] boundariesForTableArray; private int tableCounter; private int columnCounter; private int columnSpanCounter; + private int currentSpan = 0; private String unitsOfMeasure; - final private ArrayList shapes; - final private ArrayList ole; - final private ArrayList rowHeights; + final private List shapes; + final private List ole; + final private List rowHeights; public SpreadsheetRawReportTarget(final ReportJob reportJob, - final ResourceManager resourceManager, - final ResourceKey baseResource, - final InputRepository inputRepository, - final OutputRepository outputRepository, - final String target, - final ImageService imageService, - final DataSourceFactory dataSourceFactory) - throws ReportProcessingException + final ResourceManager resourceManager, + final ResourceKey baseResource, + final InputRepository inputRepository, + final OutputRepository outputRepository, + final String target, + final ImageService imageService, + final DataSourceFactory dataSourceFactory) + throws ReportProcessingException { super(reportJob, resourceManager, baseResource, inputRepository, outputRepository, target, imageService, dataSourceFactory); columnBoundaryList = new ArrayList(); @@ -183,9 +201,9 @@ public class SpreadsheetRawReportTarget extends OfficeDocumentReportTarget public void startOther(final AttributeMap attrs) throws DataSourceException, ReportProcessingException { - if (ReportTargetUtil.isElementOfType(JFreeReportInfo.REPORT_NAMESPACE, OfficeToken.OBJECT_OLE, attrs)) + if ( ReportTargetUtil.isElementOfType(JFreeReportInfo.REPORT_NAMESPACE, OfficeToken.OBJECT_OLE, attrs) ) { - if (isElementBoundaryCollectionPass() && getCurrentRole() != ROLE_TEMPLATE) + if ( isElementBoundaryCollectionPass() && getCurrentRole() != ROLE_TEMPLATE ) { ole.add(attrs); } @@ -193,27 +211,27 @@ public class SpreadsheetRawReportTarget extends OfficeDocumentReportTarget return; } final String namespace = ReportTargetUtil.getNamespaceFromAttribute(attrs); - if (isRepeatingSection() || isFilteredNamespace(namespace)) + if ( isRepeatingSection() || isFilteredNamespace(namespace) ) { return; } final String elementType = ReportTargetUtil.getElemenTypeFromAttribute(attrs); - if (OfficeNamespaces.TEXT_NS.equals(namespace) && OfficeToken.P.equals(elementType) && !paragraphHandled) + if ( OfficeNamespaces.TEXT_NS.equals(namespace) && OfficeToken.P.equals(elementType) && !paragraphHandled ) { paragraphFound = true; return; } - if (OfficeNamespaces.DRAWING_NS.equals(namespace) && OfficeToken.FRAME.equals(elementType)) + if ( OfficeNamespaces.DRAWING_NS.equals(namespace) && OfficeToken.FRAME.equals(elementType) ) { - if (isElementBoundaryCollectionPass() && getCurrentRole() != ROLE_TEMPLATE) + if ( isElementBoundaryCollectionPass() && getCurrentRole() != ROLE_TEMPLATE ) { final LengthCalculator len = new LengthCalculator(); - for (int i = 0; i < rowHeights.size(); i++) + for ( int i = 0; i < rowHeights.size(); i++ ) { len.add((CSSNumericValue) rowHeights.get(i)); - // val += ((CSSNumericValue)rowHeights.get(i)).getValue(); + // val += ((CSSNumericValue)rowHeights.get(i)).getValue(); } rowHeights.clear(); @@ -221,7 +239,7 @@ public class SpreadsheetRawReportTarget extends OfficeDocumentReportTarget rowHeights.add(currentRowHeight); attrs.setAttribute(OfficeNamespaces.DRAWING_NS, "z-index", String.valueOf(shapes.size())); final String y = (String) attrs.getAttribute(OfficeNamespaces.SVG_NS, "y"); - if (y != null) + if ( y != null ) { len.add(parseLength(y)); final CSSNumericValue currentY = len.getResult(); @@ -231,9 +249,9 @@ public class SpreadsheetRawReportTarget extends OfficeDocumentReportTarget } return; } - if (oleHandled) + if ( oleHandled ) { - if (isElementBoundaryCollectionPass() && getCurrentRole() != ROLE_TEMPLATE) + if ( isElementBoundaryCollectionPass() && getCurrentRole() != ROLE_TEMPLATE ) { ole.add(attrs); } @@ -241,14 +259,14 @@ public class SpreadsheetRawReportTarget extends OfficeDocumentReportTarget } // if this is the report namespace, write out a table definition .. - if (OfficeNamespaces.TABLE_NS.equals(namespace) && OfficeToken.TABLE.equals(elementType)) + if ( OfficeNamespaces.TABLE_NS.equals(namespace) && OfficeToken.TABLE.equals(elementType) ) { // whenever we see a new table, we increment our tableCounter // this is used to keep tracked of the boundary conditions per table tableCounter++; } - if (isElementBoundaryCollectionPass()) + if ( isElementBoundaryCollectionPass() ) { collectBoundaryForElement(attrs); } @@ -259,7 +277,7 @@ public class SpreadsheetRawReportTarget extends OfficeDocumentReportTarget { processElement(attrs, namespace, elementType); } - catch (IOException e) + catch ( IOException e ) { throw new ReportProcessingException("Failed", e); } @@ -268,13 +286,12 @@ public class SpreadsheetRawReportTarget extends OfficeDocumentReportTarget protected void startReportSection(final AttributeMap attrs, final int role) throws IOException, DataSourceException, ReportProcessingException { - if ((role == OfficeDocumentReportTarget.ROLE_SPREADSHEET_PAGE_HEADER || - role == OfficeDocumentReportTarget.ROLE_SPREADSHEET_PAGE_FOOTER) && - (!PageSection.isPrintWithReportHeader(attrs) || - !PageSection.isPrintWithReportFooter(attrs))) + if ( (role == OfficeDocumentReportTarget.ROLE_SPREADSHEET_PAGE_HEADER || + role == OfficeDocumentReportTarget.ROLE_SPREADSHEET_PAGE_FOOTER ) && + (!PageSection.isPrintWithReportHeader(attrs) || + !PageSection.isPrintWithReportFooter(attrs)) ) { startBuffering(new OfficeStylesCollection(), true); - } else { @@ -284,10 +301,10 @@ public class SpreadsheetRawReportTarget extends OfficeDocumentReportTarget protected void endReportSection(final AttributeMap attrs, final int role) throws IOException, DataSourceException, ReportProcessingException { - if ((role == OfficeDocumentReportTarget.ROLE_SPREADSHEET_PAGE_HEADER || - role == OfficeDocumentReportTarget.ROLE_SPREADSHEET_PAGE_FOOTER) && - (!PageSection.isPrintWithReportHeader(attrs) || - !PageSection.isPrintWithReportFooter(attrs))) + if ( (role == OfficeDocumentReportTarget.ROLE_SPREADSHEET_PAGE_HEADER || + role == OfficeDocumentReportTarget.ROLE_SPREADSHEET_PAGE_FOOTER) && + (!PageSection.isPrintWithReportHeader(attrs) || + !PageSection.isPrintWithReportFooter(attrs)) ) { finishBuffering(); } @@ -299,7 +316,7 @@ public class SpreadsheetRawReportTarget extends OfficeDocumentReportTarget private void handleParagraph() { - if (paragraphFound) + if ( paragraphFound ) { try { @@ -308,7 +325,7 @@ public class SpreadsheetRawReportTarget extends OfficeDocumentReportTarget paragraphHandled = true; paragraphFound = false; } - catch (IOException ex) + catch ( IOException ex ) { LOGGER.error("ReportProcessing failed", ex); } @@ -316,26 +333,25 @@ public class SpreadsheetRawReportTarget extends OfficeDocumentReportTarget } private void processElement(final AttributeMap attrs, final String namespace, final String elementType) - throws IOException, ReportProcessingException + throws IOException, ReportProcessingException { final XmlWriter xmlWriter = getXmlWriter(); - final AttributeMap retval = new AttributeMap(attrs); - if (ReportTargetUtil.isElementOfType(OfficeNamespaces.TABLE_NS, OfficeToken.TABLE, attrs)) + if ( ReportTargetUtil.isElementOfType(OfficeNamespaces.TABLE_NS, OfficeToken.TABLE, attrs) ) { // a new table means we must clear our "calculated" table boundary array cache boundariesForTableArray = null; final String tableStyle = (String) attrs.getAttribute(OfficeNamespaces.TABLE_NS, OfficeToken.STYLE_NAME); - if (tableStyle == null) + if ( tableStyle == null ) { tableBackgroundColor = null; } else { final Object raw = StyleUtilities.queryStyle(getPredefinedStylesCollection(), OfficeToken.TABLE, tableStyle, - "table-properties", OfficeNamespaces.FO_NS, OfficeToken.BACKGROUND_COLOR); - if (raw == null || "transparent".equals(raw)) + "table-properties", OfficeNamespaces.FO_NS, OfficeToken.BACKGROUND_COLOR); + if ( raw == null || TRANSPARENT.equals(raw) ) { tableBackgroundColor = null; } @@ -347,29 +363,29 @@ public class SpreadsheetRawReportTarget extends OfficeDocumentReportTarget return; } - if (ReportTargetUtil.isElementOfType(OfficeNamespaces.TABLE_NS, OfficeToken.TABLE_COLUMN, attrs) || - ReportTargetUtil.isElementOfType(OfficeNamespaces.TABLE_NS, OfficeToken.TABLE_COLUMNS, attrs)) + if ( ReportTargetUtil.isElementOfType(OfficeNamespaces.TABLE_NS, OfficeToken.TABLE_COLUMN, attrs) || + ReportTargetUtil.isElementOfType(OfficeNamespaces.TABLE_NS, OfficeToken.TABLE_COLUMNS, attrs) ) { return; } // covered-table-cell elements may appear in the input from row or column spans. In the event that we hit a // column-span we simply ignore these elements because we are going to adjust the span to fit the uniform table. - if (ReportTargetUtil.isElementOfType(OfficeNamespaces.TABLE_NS, OfficeToken.COVERED_TABLE_CELL, attrs)) + if ( ReportTargetUtil.isElementOfType(OfficeNamespaces.TABLE_NS, OfficeToken.COVERED_TABLE_CELL, attrs) ) { - if (columnSpanCounter > 0) + if ( columnSpanCounter > 0 ) { columnSpanCounter--; } - if (columnSpanCounter == 0) + if ( columnSpanCounter == 0 ) { // if we weren't expecting a covered-table-cell, let's use it, it's probably from a row-span columnCounter++; final int span = getColumnSpanForCell(tableCounter, columnCounter, 1); // use the calculated span for the column in the uniform table to create any additional covered-table-cell // elements - for (int i = 0; i < span; i++) + for ( int i = 0; i < span; i++ ) { xmlWriter.writeTag(namespace, OfficeToken.COVERED_TABLE_CELL, null, XmlWriter.CLOSE); } @@ -377,17 +393,17 @@ public class SpreadsheetRawReportTarget extends OfficeDocumentReportTarget return; } - if (ReportTargetUtil.isElementOfType(OfficeNamespaces.TABLE_NS, OfficeToken.TABLE_ROW, attrs)) + if ( ReportTargetUtil.isElementOfType(OfficeNamespaces.TABLE_NS, OfficeToken.TABLE_ROW, attrs) ) { // a new row means our column counter gets reset columnCounter = 0; // Lets make sure the color of the table is ok .. - if (tableBackgroundColor != null) + if ( tableBackgroundColor != null ) { final String styleName = (String) attrs.getAttribute(OfficeNamespaces.TABLE_NS, OfficeToken.STYLE_NAME); final OfficeStyle style = deriveStyle(OfficeToken.TABLE_ROW, styleName); Element tableRowProperties = style.getTableRowProperties(); - if (tableRowProperties == null) + if ( tableRowProperties == null ) { tableRowProperties = new Section(); tableRowProperties.setNamespace(OfficeNamespaces.STYLE_NS); @@ -398,44 +414,59 @@ public class SpreadsheetRawReportTarget extends OfficeDocumentReportTarget else { final Object oldValue = tableRowProperties.getAttribute(OfficeNamespaces.FO_NS, OfficeToken.BACKGROUND_COLOR); - if (oldValue == null || "transparent".equals(oldValue)) + if ( oldValue == null || TRANSPARENT.equals(oldValue) ) { tableRowProperties.setAttribute(OfficeNamespaces.FO_NS, OfficeToken.BACKGROUND_COLOR, tableBackgroundColor); } } - retval.setAttribute(OfficeNamespaces.TABLE_NS, OfficeToken.STYLE_NAME, style.getStyleName()); + attrs.setAttribute(OfficeNamespaces.TABLE_NS, OfficeToken.STYLE_NAME, style.getStyleName()); } } - else if (ReportTargetUtil.isElementOfType(OfficeNamespaces.TABLE_NS, OfficeToken.TABLE_CELL, attrs)) + else if ( ReportTargetUtil.isElementOfType(OfficeNamespaces.TABLE_NS, OfficeToken.TABLE_CELL, attrs) ) { columnCounter++; final String styleName = (String) attrs.getAttribute(OfficeNamespaces.TABLE_NS, OfficeToken.STYLE_NAME); - if (styleName != null) + if ( styleName != null ) { final OfficeStyle cellStyle = getPredefinedStylesCollection().getStyle(OfficeToken.TABLE_CELL, styleName); - if (cellStyle != null) + if ( cellStyle != null ) { - final Element props = cellStyle.getTableCellProperties(); - if (props != null) + final Section textProperties = (Section) cellStyle.getTextProperties(); + if ( textProperties != null ) + { + for ( String i : FOPROPS ) + { + textProperties.setAttribute(OfficeNamespaces.FO_NS, i, null); + } + textProperties.setAttribute(OfficeNamespaces.TEXT_NS, "display", null); + for ( String i : STYLEPROPS ) + { + textProperties.setAttribute(OfficeNamespaces.STYLE_NS, i, null); + } + } + final Section props = (Section) cellStyle.getTableCellProperties(); + if ( props != null ) { final Object raw = props.getAttribute(OfficeNamespaces.FO_NS, OfficeToken.BACKGROUND_COLOR); - if (raw == null || "transparent".equals(raw)) + if ( TRANSPARENT.equals(raw) ) { - cellStyle.removeNode(props); + props.setAttribute(OfficeNamespaces.FO_NS, OfficeToken.BACKGROUND_COLOR, null); + // cellStyle.removeNode(props); } } } + attrs.setAttribute(OfficeNamespaces.TABLE_NS, OfficeToken.STYLE_NAME, styleName); } - final String numColSpanStr = (String) attrs.getAttribute(namespace, "number-columns-spanned"); + final String numColSpanStr = (String) attrs.getAttribute(namespace,NUMBERCOLUMNSSPANNED); int initialColumnSpan = columnSpanCounter = 1; - if (numColSpanStr != null) + if ( numColSpanStr != null ) { initialColumnSpan = Integer.parseInt(numColSpanStr); columnSpanCounter = initialColumnSpan; } final int span = getColumnSpanForCell(tableCounter, columnCounter, initialColumnSpan); - if (initialColumnSpan > 1) + if ( initialColumnSpan > 1 ) { // add the initial column span to our column counter index (subtract 1, since it is counted by default) columnCounter += initialColumnSpan - 1; @@ -455,41 +486,42 @@ public class SpreadsheetRawReportTarget extends OfficeDocumentReportTarget // } // there's no point to create number-columns-spanned attributes if we only span 1 column - if (span > 1) + if ( span > 1 ) { - retval.setAttribute(namespace, "number-columns-spanned", "" + span); + attrs.setAttribute(namespace,NUMBERCOLUMNSSPANNED, "" + span); + currentSpan = span; } - // we must also generate "covered-table-cell" elements for each column spanned - // but we'll do this in the endElement, after we close this OfficeToken.TABLE_CELL + // we must also generate "covered-table-cell" elements for each column spanned + // but we'll do this in the endElement, after we close this OfficeToken.TABLE_CELL } // All styles have to be processed or you will loose the paragraph-styles and inline text-styles. // .. - performStyleProcessing(retval); + performStyleProcessing(attrs); - final AttributeList attrList = buildAttributeList(retval); + final AttributeList attrList = buildAttributeList(attrs); xmlWriter.writeTag(namespace, elementType, attrList, XmlWriter.OPEN); - // System.out.println("elementType = " + elementType); + // System.out.println("elementType = " + elementType); } private void collectBoundaryForElement(final AttributeMap attrs) { - if (ReportTargetUtil.isElementOfType(OfficeNamespaces.TABLE_NS, OfficeToken.TABLE_COLUMNS, attrs)) + if ( ReportTargetUtil.isElementOfType(OfficeNamespaces.TABLE_NS, OfficeToken.TABLE_COLUMNS, attrs) ) { // A table row resets the column counter. resetCurrentRowBoundaryMarker(); } - else if (ReportTargetUtil.isElementOfType(OfficeNamespaces.TABLE_NS, OfficeToken.TABLE_COLUMN, attrs)) + else if ( ReportTargetUtil.isElementOfType(OfficeNamespaces.TABLE_NS, OfficeToken.TABLE_COLUMN, attrs) ) { final String styleName = (String) attrs.getAttribute(OfficeNamespaces.TABLE_NS, OfficeToken.STYLE_NAME); - if (styleName == null) + if ( styleName == null ) { // This should not happen, but if it does, we will ignore that cell. return; } final OfficeStyle style = getPredefinedStylesCollection().getStyle(OfficeToken.TABLE_COLUMN, styleName); - if (style == null) + if ( style == null ) { // Now this is very bad. It means that there is no style defined with the given name. return; @@ -498,11 +530,12 @@ public class SpreadsheetRawReportTarget extends OfficeDocumentReportTarget final Element tableColumnProperties = style.getTableColumnProperties(); String widthStr = (String) tableColumnProperties.getAttribute("column-width"); widthStr = widthStr.substring(0, widthStr.indexOf(getUnitsOfMeasure(widthStr))); - addColumnWidthToRowBoundaryMarker(Float.parseFloat(widthStr)); + final float val = Float.parseFloat(widthStr) * CELL_WIDTH_FACTOR; + addColumnWidthToRowBoundaryMarker((long) val); ColumnBoundary currentRowBoundary = new ColumnBoundary(getCurrentRowBoundaryMarker()); final List columnBoundaryList_ = getColumnBoundaryList(); final int idx = columnBoundaryList_.indexOf(currentRowBoundary); - if (idx == -1) + if ( idx == -1 ) { columnBoundaryList_.add(currentRowBoundary); } @@ -516,9 +549,9 @@ public class SpreadsheetRawReportTarget extends OfficeDocumentReportTarget private String getUnitsOfMeasure(final String str) { - if (unitsOfMeasure == null || "".equals(unitsOfMeasure)) + if ( unitsOfMeasure == null || "".equals(unitsOfMeasure) ) { - if (str == null || "".equals(str)) + if ( str == null || "".equals(str) ) { unitsOfMeasure = "cm"; return unitsOfMeasure; @@ -526,10 +559,10 @@ public class SpreadsheetRawReportTarget extends OfficeDocumentReportTarget // build units of measure, set it int i = str.length() - 1; - for (; i >= 0; i--) + for ( ; i >= 0; i-- ) { final char c = str.charAt(i); - if (Character.isDigit(c) || c == '.' || c == ',') + if ( Character.isDigit(c) || c == '.' || c == ',' ) { break; } @@ -541,7 +574,7 @@ public class SpreadsheetRawReportTarget extends OfficeDocumentReportTarget private void createTableShapes() throws ReportProcessingException { - if (!shapes.isEmpty()) + if ( !shapes.isEmpty() ) { try { @@ -554,7 +587,7 @@ public class SpreadsheetRawReportTarget extends OfficeDocumentReportTarget xmlWriter.writeTag(OfficeNamespaces.TABLE_NS, OfficeToken.SHAPES, null, XmlWriterSupport.OPEN); - for (int i = 0; i < shapes.size(); i++) + for ( int i = 0; i < shapes.size(); i++ ) { final AttributeMap attrs = (AttributeMap) shapes.get(i); final AttributeList attrList = buildAttributeList(attrs); @@ -566,7 +599,7 @@ public class SpreadsheetRawReportTarget extends OfficeDocumentReportTarget } xmlWriter.writeCloseTag(); } - catch (IOException e) + catch ( IOException e ) { throw new ReportProcessingException("Failed", e); } @@ -589,14 +622,15 @@ public class SpreadsheetRawReportTarget extends OfficeDocumentReportTarget // blow away current column styles // start processing at i=1 because we added a boundary for "0" which is virtual final ColumnBoundary[] cba = getSortedColumnBoundaryArray(); - for (int i = 1; i < cba.length; i++) + for ( int i = 1; i < cba.length; i++ ) { final ColumnBoundary cb = cba[i]; float columnWidth = cb.getBoundary(); - if (i > 1) + if ( i > 1 ) { columnWidth -= cba[i - 1].getBoundary(); } + columnWidth = columnWidth / CELL_WIDTH_FACTOR; final OfficeStyle style = deriveStyle(OfficeToken.TABLE_COLUMN, ("co" + i + "_")); final Section tableColumnProperties = new Section(); tableColumnProperties.setType("table-column-properties"); @@ -610,7 +644,7 @@ public class SpreadsheetRawReportTarget extends OfficeDocumentReportTarget } xmlWriter.writeCloseTag(); } - catch (IOException e) + catch ( IOException e ) { throw new ReportProcessingException("Failed", e); } @@ -618,46 +652,46 @@ public class SpreadsheetRawReportTarget extends OfficeDocumentReportTarget protected void endOther(final AttributeMap attrs) throws DataSourceException, ReportProcessingException { - if (ReportTargetUtil.isElementOfType(JFreeReportInfo.REPORT_NAMESPACE, OfficeToken.OBJECT_OLE, attrs) || oleHandled) + if ( ReportTargetUtil.isElementOfType(JFreeReportInfo.REPORT_NAMESPACE, OfficeToken.OBJECT_OLE, attrs) || oleHandled ) { oleHandled = false; return; } - if (ReportTargetUtil.isElementOfType(OfficeNamespaces.TABLE_NS, OfficeToken.TABLE_ROW, attrs) && isElementBoundaryCollectionPass() && getCurrentRole() != ROLE_TEMPLATE) + if ( ReportTargetUtil.isElementOfType(OfficeNamespaces.TABLE_NS, OfficeToken.TABLE_ROW, attrs) && isElementBoundaryCollectionPass() && getCurrentRole() != ROLE_TEMPLATE ) { final String styleName = (String) attrs.getAttribute(OfficeNamespaces.TABLE_NS, OfficeToken.STYLE_NAME); rowHeights.add(computeRowHeight(styleName)); } - if (isRepeatingSection() || isElementBoundaryCollectionPass()) + if ( isRepeatingSection() || isElementBoundaryCollectionPass() ) { return; } final String namespace = ReportTargetUtil.getNamespaceFromAttribute(attrs); - if (isFilteredNamespace(namespace)) + if ( isFilteredNamespace(namespace) ) { return; } final String elementType = ReportTargetUtil.getElemenTypeFromAttribute(attrs); - if (OfficeNamespaces.DRAWING_NS.equals(namespace) && OfficeToken.FRAME.equals(elementType)) + if ( OfficeNamespaces.DRAWING_NS.equals(namespace) && OfficeToken.FRAME.equals(elementType) ) { return; } // if this is the report namespace, write out a table definition .. - if (OfficeNamespaces.TABLE_NS.equals(namespace) && (OfficeToken.TABLE.equals(elementType) || - OfficeToken.COVERED_TABLE_CELL.equals(elementType) || - OfficeToken.TABLE_COLUMN.equals(elementType) || - OfficeToken.TABLE_COLUMNS.equals(elementType))) + if ( OfficeNamespaces.TABLE_NS.equals(namespace) && (OfficeToken.TABLE.equals(elementType) || + OfficeToken.COVERED_TABLE_CELL.equals(elementType) || + OfficeToken.TABLE_COLUMN.equals(elementType) || + OfficeToken.TABLE_COLUMNS.equals(elementType)) ) { return; } - if ( !paragraphHandled && OfficeNamespaces.TEXT_NS.equals(namespace) && OfficeToken.P.equals(elementType)) + if ( !paragraphHandled && OfficeNamespaces.TEXT_NS.equals(namespace) && OfficeToken.P.equals(elementType) ) { - if (!paragraphHandled) + if ( !paragraphHandled ) { return; } @@ -672,7 +706,7 @@ public class SpreadsheetRawReportTarget extends OfficeDocumentReportTarget // 'covered-table-cell' elements we need to generate generateCoveredTableCells(attrs); } - catch (IOException e) + catch ( IOException e ) { throw new ReportProcessingException("Failed", e); } @@ -680,16 +714,18 @@ public class SpreadsheetRawReportTarget extends OfficeDocumentReportTarget private void generateCoveredTableCells(final AttributeMap attrs) throws IOException { - if (!ReportTargetUtil.isElementOfType(OfficeNamespaces.TABLE_NS, OfficeToken.TABLE_CELL, attrs)) + if ( !ReportTargetUtil.isElementOfType(OfficeNamespaces.TABLE_NS, OfficeToken.TABLE_CELL, attrs) ) { return; } // do this after we close the tag final XmlWriter xmlWriter = getXmlWriter(); - final Object attribute = attrs.getAttribute(OfficeNamespaces.TABLE_NS, "number-columns-spanned"); - final int span = TextUtilities.parseInt((String) attribute, 0); - for (int i = 1; i < span; i++) + // final Object attribute = attrs.getAttribute(OfficeNamespaces.TABLE_NS,NUMBERCOLUMNSSPANNED); + // final int span = TextUtilities.parseInt((String) attribute, 0); + final int span = currentSpan; + currentSpan = 0; + for ( int i = 1; i < span; i++ ) { xmlWriter.writeTag(OfficeNamespaces.TABLE_NS, OfficeToken.COVERED_TABLE_CELL, null, XmlWriter.CLOSE); } @@ -703,7 +739,7 @@ public class SpreadsheetRawReportTarget extends OfficeDocumentReportTarget // ///////////////////////////////////////////////////////////////////////// public void processText(final String text) throws DataSourceException, ReportProcessingException { - if (!(isRepeatingSection() || isElementBoundaryCollectionPass())) + if ( !(isRepeatingSection() || isElementBoundaryCollectionPass()) ) { handleParagraph(); super.processText(text); @@ -712,7 +748,7 @@ public class SpreadsheetRawReportTarget extends OfficeDocumentReportTarget public void processContent(final DataFlags value) throws DataSourceException, ReportProcessingException { - if (!(isRepeatingSection() || isElementBoundaryCollectionPass())) + if ( !(isRepeatingSection() || isElementBoundaryCollectionPass()) ) { handleParagraph(); super.processContent(value); @@ -725,13 +761,15 @@ public class SpreadsheetRawReportTarget extends OfficeDocumentReportTarget } protected void startContent(final AttributeMap attrs) throws IOException, DataSourceException, - ReportProcessingException + ReportProcessingException { - if (!isElementBoundaryCollectionPass()) + if ( !isElementBoundaryCollectionPass() ) { final XmlWriter xmlWriter = getXmlWriter(); xmlWriter.writeTag(OfficeNamespaces.OFFICE_NS, getStartContent(), null, XmlWriterSupport.OPEN); + writeNullDate(); + final AttributeMap tableAttributes = new AttributeMap(); tableAttributes.setAttribute(JFreeReportInfo.REPORT_NAMESPACE, Element.NAMESPACE_ATTRIBUTE, OfficeNamespaces.TABLE_NS); tableAttributes.setAttribute(JFreeReportInfo.REPORT_NAMESPACE, Element.TYPE_ATTRIBUTE, OfficeToken.TABLE); @@ -750,7 +788,7 @@ public class SpreadsheetRawReportTarget extends OfficeDocumentReportTarget { final OfficeStylesCollection predefStyles = getPredefinedStylesCollection(); final OfficeStyles commonStyles = predefStyles.getAutomaticStyles(); - if (!commonStyles.containsStyle(OfficeToken.TABLE, "Initial_Table")) + if ( !commonStyles.containsStyle(OfficeToken.TABLE, "Initial_Table") ) { final String masterPageName = createMasterPage(); @@ -759,7 +797,7 @@ public class SpreadsheetRawReportTarget extends OfficeDocumentReportTarget tableStyle.setStyleName("Initial_Table"); tableStyle.setAttribute(OfficeNamespaces.STYLE_NS, "master-page-name", masterPageName); final Element tableProperties = produceFirstChild(tableStyle, OfficeNamespaces.STYLE_NS, "table-properties"); - tableProperties.setAttribute(OfficeNamespaces.FO_NS, OfficeToken.BACKGROUND_COLOR, "transparent"); + tableProperties.setAttribute(OfficeNamespaces.FO_NS, OfficeToken.BACKGROUND_COLOR,TRANSPARENT); commonStyles.addStyle(tableStyle); } return "Initial_Table"; @@ -770,13 +808,13 @@ public class SpreadsheetRawReportTarget extends OfficeDocumentReportTarget final OfficeStylesCollection predefStyles = getPredefinedStylesCollection(); final MasterPageFactory masterPageFactory = new MasterPageFactory(predefStyles.getMasterStyles()); final OfficeMasterPage masterPage; - if (!masterPageFactory.containsMasterPage("Standard", null, null)) + if ( !masterPageFactory.containsMasterPage("Standard", null, null) ) { masterPage = masterPageFactory.createMasterPage("Standard", null, null); final CSSNumericValue zeroLength = CSSNumericValue.createValue(CSSNumericType.CM, 0); final String pageLayoutTemplate = masterPage.getPageLayout(); - if (pageLayoutTemplate == null) + if ( pageLayoutTemplate == null ) { // there is no pagelayout. Create one .. final String derivedLayout = masterPageFactory.createPageStyle(getGlobalStylesCollection().getAutomaticStyles(), zeroLength, zeroLength); @@ -785,8 +823,8 @@ public class SpreadsheetRawReportTarget extends OfficeDocumentReportTarget else { final String derivedLayout = masterPageFactory.derivePageStyle(pageLayoutTemplate, - getPredefinedStylesCollection().getAutomaticStyles(), - getGlobalStylesCollection().getAutomaticStyles(), zeroLength, zeroLength); + getPredefinedStylesCollection().getAutomaticStyles(), + getGlobalStylesCollection().getAutomaticStyles(), zeroLength, zeroLength); masterPage.setPageLayout(derivedLayout); } @@ -802,10 +840,10 @@ public class SpreadsheetRawReportTarget extends OfficeDocumentReportTarget } protected void endContent(final AttributeMap attrs) throws IOException, DataSourceException, - ReportProcessingException + ReportProcessingException { // todo - if (!isElementBoundaryCollectionPass()) + if ( !isElementBoundaryCollectionPass() ) { final XmlWriter xmlWriter = getXmlWriter(); xmlWriter.writeCloseTag(); @@ -833,7 +871,7 @@ public class SpreadsheetRawReportTarget extends OfficeDocumentReportTarget private ColumnBoundary[] getSortedColumnBoundaryArray() { - if (sortedBoundaryArray == null) + if ( sortedBoundaryArray == null ) { getColumnBoundaryList().add(new ColumnBoundary(0)); sortedBoundaryArray = (ColumnBoundary[]) getColumnBoundaryList().toArray(EMPTY_COLBOUNDS); @@ -847,12 +885,12 @@ public class SpreadsheetRawReportTarget extends OfficeDocumentReportTarget return columnBoundaryList; } - private void addColumnWidthToRowBoundaryMarker(final float width) + private void addColumnWidthToRowBoundaryMarker(final long width) { currentRowBoundaryMarker += width; } - private float getCurrentRowBoundaryMarker() + private long getCurrentRowBoundaryMarker() { return currentRowBoundaryMarker; } @@ -869,14 +907,14 @@ public class SpreadsheetRawReportTarget extends OfficeDocumentReportTarget private ColumnBoundary[] getBoundariesForTable(final int table) { - if (boundariesForTableArray == null) + if ( boundariesForTableArray == null ) { final List boundariesForTable = new ArrayList(); final List boundaryList = getColumnBoundaryList(); - for (int i = 0; i < boundaryList.size(); i++) + for ( int i = 0; i < boundaryList.size(); i++ ) { final ColumnBoundary b = (ColumnBoundary) boundaryList.get(i); - if (b.isContainedByTable(table)) + if ( b.isContainedByTable(table) ) { boundariesForTable.add(b); } @@ -897,12 +935,12 @@ public class SpreadsheetRawReportTarget extends OfficeDocumentReportTarget float cellBoundary = tableBoundaries[col - 1].getBoundary(); float cellWidth = tableBoundaries[col - 1].getBoundary(); - if (col > 1) + if ( col > 1 ) { cellWidth = cellWidth - tableBoundaries[col - 2].getBoundary(); } - if (initialColumnSpan > 1) + if ( initialColumnSpan > 1 ) { // ok we've got some additional spanning specified on the input final int index = (col - 1) + (initialColumnSpan - 1); @@ -912,21 +950,21 @@ public class SpreadsheetRawReportTarget extends OfficeDocumentReportTarget int beginBoundaryIndex = 0; int endBoundaryIndex = globalBoundaries.length - 1; - for (int i = 0; i < globalBoundaries.length; i++) + for ( int i = 0; i < globalBoundaries.length; i++ ) { // find beginning boundary - if (globalBoundaries[i].getBoundary() <= cellBoundary - cellWidth) + if ( globalBoundaries[i].getBoundary() <= cellBoundary - cellWidth ) { beginBoundaryIndex = i; } - if (globalBoundaries[i].getBoundary() <= cellBoundary) + if ( globalBoundaries[i].getBoundary() <= cellBoundary ) { endBoundaryIndex = i; } } final int span = endBoundaryIndex - beginBoundaryIndex; // span will be zero for the first column, so we adjust it to 1 - if (span == 0) + if ( span == 0 ) { return 1; } diff --git a/reportbuilder/java/com/sun/star/report/pentaho/output/text/MasterPageFactory.java b/reportbuilder/java/com/sun/star/report/pentaho/output/text/MasterPageFactory.java index 48879bf8ce2b..0a5988a44b94 100644 --- a/reportbuilder/java/com/sun/star/report/pentaho/output/text/MasterPageFactory.java +++ b/reportbuilder/java/com/sun/star/report/pentaho/output/text/MasterPageFactory.java @@ -265,7 +265,7 @@ public class MasterPageFactory } catch (CloneNotSupportedException cne) { - throw new IllegalStateException("Implementation error: Unable to derive page"); + throw new IllegalStateException("Implementation error: Unable to derive page",cne); } } @@ -403,7 +403,7 @@ public class MasterPageFactory } catch (CloneNotSupportedException e) { - throw new IllegalStateException("Clone failed."); + throw new IllegalStateException("Clone failed.",e); } } diff --git a/reportbuilder/java/com/sun/star/report/pentaho/output/text/PageContext.java b/reportbuilder/java/com/sun/star/report/pentaho/output/text/PageContext.java index fdd82694cae3..88c2742c91d5 100644 --- a/reportbuilder/java/com/sun/star/report/pentaho/output/text/PageContext.java +++ b/reportbuilder/java/com/sun/star/report/pentaho/output/text/PageContext.java @@ -208,17 +208,8 @@ public class PageContext } final StringBuffer b = new StringBuffer(); - - PageContext pc = this; - while (pc != null) - { - final String header_ = pc.getHeader(); - if (header_ != null) - { - b.append(header_); - } - pc = pc.getParent(); - } + b.append(parent.getPageHeaderContent()); + b.append(getHeader()); if (b.length() != 0) { diff --git a/reportbuilder/java/com/sun/star/report/pentaho/output/text/TextRawReportTarget.java b/reportbuilder/java/com/sun/star/report/pentaho/output/text/TextRawReportTarget.java index 28999ebac793..6ce89c5c0324 100644 --- a/reportbuilder/java/com/sun/star/report/pentaho/output/text/TextRawReportTarget.java +++ b/reportbuilder/java/com/sun/star/report/pentaho/output/text/TextRawReportTarget.java @@ -96,7 +96,6 @@ public class TextRawReportTarget extends OfficeDocumentReportTarget private static final String VARIABLES_HIDDEN_STYLE_WITH_KEEPWNEXT = "variables_paragraph_with_next"; private static final String VARIABLES_HIDDEN_STYLE_WITHOUT_KEEPWNEXT = "variables_paragraph_without_next"; private static final int TABLE_LAYOUT_VARIABLES_PARAGRAPH = 0; - private static final int TABLE_LAYOUT_VARIABLES_IN_FIRST_CELL = 1; private static final int TABLE_LAYOUT_SINGLE_DETAIL_TABLE = 2; private static final int CP_SETUP = 0; private static final int CP_FIRST_TABLE = 1; @@ -132,7 +131,6 @@ public class TextRawReportTarget extends OfficeDocumentReportTarget private final int tableLayoutConfig; private int expectedTableRowCount; private boolean firstCellSeen; - private boolean cellEmpty; public TextRawReportTarget(final ReportJob reportJob, final ResourceManager resourceManager, @@ -543,6 +541,8 @@ public class TextRawReportTarget extends OfficeDocumentReportTarget final XmlWriter xmlWriter = getXmlWriter(); xmlWriter.writeTag(OfficeNamespaces.OFFICE_NS, "text", null, XmlWriterSupport.OPEN); + writeNullDate(); + // now start the buffering. We have to insert the variables declaration // later .. startBuffering(getStylesCollection(), true); @@ -646,11 +646,6 @@ public class TextRawReportTarget extends OfficeDocumentReportTarget variables = null; } - if (isTableNS && ObjectUtilities.equal(OfficeToken.TABLE_CELL, elementType)) - { - cellEmpty = true; - } - final boolean keepTogetherOnParagraph = true; if (keepTogetherOnParagraph) @@ -658,7 +653,6 @@ public class TextRawReportTarget extends OfficeDocumentReportTarget if (ReportTargetUtil.isElementOfType(OfficeNamespaces.TEXT_NS, OfficeToken.P, attrs)) { final int keepTogetherState = getCurrentContext().getKeepTogether(); - cellEmpty = false; if (!firstCellSeen && (sectionKeepTogether || keepTogetherState == PageContext.KEEP_TOGETHER_GROUP)) { OfficeStyle style = null; @@ -740,15 +734,12 @@ public class TextRawReportTarget extends OfficeDocumentReportTarget final AttributeList attrList = buildAttributeList(attrs); xmlWriter.writeTag(namespace, elementType, attrList, XmlWriterSupport.OPEN); - if (ReportTargetUtil.isElementOfType(OfficeNamespaces.TEXT_NS, OfficeToken.P, attrs)) + if (ReportTargetUtil.isElementOfType(OfficeNamespaces.TEXT_NS, OfficeToken.P, attrs) && + tableLayoutConfig != TABLE_LAYOUT_VARIABLES_PARAGRAPH && variables != null) { - cellEmpty = false; - if (tableLayoutConfig != TABLE_LAYOUT_VARIABLES_PARAGRAPH && variables != null) - { - //LOGGER.debug("Variables-Section in existing cell " + variables); - xmlWriter.writeText(variables); - variables = null; - } + //LOGGER.debug("Variables-Section in existing cell " + variables); + xmlWriter.writeText(variables); + variables = null; } } } diff --git a/reportbuilder/java/com/sun/star/report/pentaho/parser/StyleMapper.java b/reportbuilder/java/com/sun/star/report/pentaho/parser/StyleMapper.java index c3c8013b3fff..f29d0b0abad5 100644 --- a/reportbuilder/java/com/sun/star/report/pentaho/parser/StyleMapper.java +++ b/reportbuilder/java/com/sun/star/report/pentaho/parser/StyleMapper.java @@ -35,7 +35,7 @@ import org.jfree.layouting.input.style.CSSDeclarationRule; public interface StyleMapper { - public void updateStyle (final String uri, + void updateStyle (final String uri, final String attrName, final String attrValue, final CSSDeclarationRule targetRule); diff --git a/reportbuilder/java/com/sun/star/report/pentaho/parser/rpt/ConditionalPrintExpressionReadHandler.java b/reportbuilder/java/com/sun/star/report/pentaho/parser/rpt/ConditionalPrintExpressionReadHandler.java index 4367f4a78c1d..7378637bae15 100644 --- a/reportbuilder/java/com/sun/star/report/pentaho/parser/rpt/ConditionalPrintExpressionReadHandler.java +++ b/reportbuilder/java/com/sun/star/report/pentaho/parser/rpt/ConditionalPrintExpressionReadHandler.java @@ -51,10 +51,6 @@ public class ConditionalPrintExpressionReadHandler public ConditionalPrintExpressionReadHandler(final Element element) { - if (element == null) - { - throw new NullPointerException(); - } this.element = element; } diff --git a/reportbuilder/java/com/sun/star/report/pentaho/parser/rpt/GroupReadHandler.java b/reportbuilder/java/com/sun/star/report/pentaho/parser/rpt/GroupReadHandler.java index 2364eb212f9d..55ed4759c6be 100644 --- a/reportbuilder/java/com/sun/star/report/pentaho/parser/rpt/GroupReadHandler.java +++ b/reportbuilder/java/com/sun/star/report/pentaho/parser/rpt/GroupReadHandler.java @@ -79,7 +79,7 @@ public class GroupReadHandler extends ElementReadHandler super.startParsing(attrs); final String groupExpr = attrs.getValue(OfficeNamespaces.OOREPORT_NS, "group-expression"); - if (groupExpr != null) + if ( groupExpr != null && !"".equals(groupExpr) ) { final FormulaExpression function = new FormulaExpression(); function.setFormula(groupExpr); diff --git a/reportbuilder/java/com/sun/star/report/pentaho/parser/stylemapper/fo/BackgroundColorMapper.java b/reportbuilder/java/com/sun/star/report/pentaho/parser/stylemapper/fo/BackgroundColorMapper.java index a0f6c4e217ad..a2ca9ca9e496 100644 --- a/reportbuilder/java/com/sun/star/report/pentaho/parser/stylemapper/fo/BackgroundColorMapper.java +++ b/reportbuilder/java/com/sun/star/report/pentaho/parser/stylemapper/fo/BackgroundColorMapper.java @@ -38,10 +38,6 @@ import org.jfree.layouting.util.ColorUtil; public class BackgroundColorMapper implements StyleMapper { - public BackgroundColorMapper() - { - } - public void updateStyle(final String uri, final String attrName, final String attrValue, diff --git a/reportbuilder/java/com/sun/star/report/pentaho/parser/stylemapper/fo/BorderRightMapper.java b/reportbuilder/java/com/sun/star/report/pentaho/parser/stylemapper/fo/BorderRightMapper.java index b668301c3603..14b9f4dd5b3b 100644 --- a/reportbuilder/java/com/sun/star/report/pentaho/parser/stylemapper/fo/BorderRightMapper.java +++ b/reportbuilder/java/com/sun/star/report/pentaho/parser/stylemapper/fo/BorderRightMapper.java @@ -47,11 +47,6 @@ import org.jfree.layouting.input.style.CSSDeclarationRule; public class BorderRightMapper implements StyleMapper { - /** Creates a new instance of BorderRightMapper */ - public BorderRightMapper() - { - } - public void updateStyle(final String uri, final String attrName, final String attrValue, diff --git a/reportbuilder/java/com/sun/star/report/util/ReportUtil.java b/reportbuilder/java/com/sun/star/report/util/ReportUtil.java index b82a25a7a060..e2b3602e19fb 100644 --- a/reportbuilder/java/com/sun/star/report/util/ReportUtil.java +++ b/reportbuilder/java/com/sun/star/report/util/ReportUtil.java @@ -27,7 +27,6 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ - package com.sun.star.report.util; import org.pentaho.reporting.libraries.base.util.ObjectUtilities; @@ -36,9 +35,14 @@ import org.pentaho.reporting.libraries.base.util.ObjectUtilities; * * @author Ocke Janssen */ -public class ReportUtil { +public class ReportUtil +{ + + private ReportUtil() + { + } - public static boolean equalString(final String uri,final String uri2) + public static boolean equalString(final String uri, final String uri2) { return ObjectUtilities.equal(uri, uri2); } diff --git a/reportbuilder/registry/data/org/openoffice/Office/UI/DbReportWindowState.xcu b/reportbuilder/registry/data/org/openoffice/Office/UI/DbReportWindowState.xcu index 2a31839f8a84..7dba5df7901e 100644 --- a/reportbuilder/registry/data/org/openoffice/Office/UI/DbReportWindowState.xcu +++ b/reportbuilder/registry/data/org/openoffice/Office/UI/DbReportWindowState.xcu @@ -66,10 +66,7 @@ </prop>
<prop oor:name="Visible" oor:type="xs:boolean">
<value>true</value>
- </prop>
- <prop oor:name="ContextSensitive" oor:type="xs:boolean">
- <value>true</value>
- </prop>
+ </prop> </node>
<node oor:name="private:resource/toolbar/reportcontrols" oor:op="replace">
<prop oor:name="UIName" oor:type="xs:string">
diff --git a/xpdf/makefile.mk b/xpdf/makefile.mk index 5ae45fadcb88..7aed6d5ac68b 100644 --- a/xpdf/makefile.mk +++ b/xpdf/makefile.mk @@ -81,7 +81,7 @@ CONFIGURE_ACTION=./configure --without-x --enable-multithreaded --enable-excepti .ELSE #CONFIGURE_ACTION=./configure #CONFIGURE_ACTION=./configure --without-x --enable-multithreaded --enable-exceptions CFLAGS="-g -O0" CXXFLAGS="-g -O0" -CONFIGURE_ACTION=./configure --without-libpaper-library --without-x --enable-multithreaded --enable-exceptions +CONFIGURE_ACTION=./configure --without-libpaper-library --without-t1-library --without-x --enable-multithreaded --enable-exceptions .ENDIF BUILD_ACTION=$(GNUMAKE) -j$(EXTMAXPROCESS) |