summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xconnectivity/qa/connectivity/tools/AbstractDatabase.java230
-rw-r--r--connectivity/qa/connectivity/tools/DataSource.java79
-rwxr-xr-xconnectivity/qa/connectivity/tools/DatabaseAccess.java66
-rwxr-xr-xconnectivity/qa/connectivity/tools/DbaseDatabase.java100
-rw-r--r--connectivity/qa/connectivity/tools/HsqlDatabase.java338
-rw-r--r--connectivity/qa/drivers/dbase/DBaseDateFunctions.java369
-rw-r--r--connectivity/qa/drivers/dbase/DBaseDriverTest.java65
-rw-r--r--connectivity/qa/drivers/dbase/DBaseNumericFunctions.java436
-rwxr-xr-xconnectivity/qa/drivers/dbase/DBaseSqlTests.java99
-rw-r--r--connectivity/qa/drivers/dbase/DBaseStringFunctions.java370
-rw-r--r--connectivity/qa/drivers/dbase/makefile.mk9
-rw-r--r--connectivity/source/commontools/DateConversion.cxx1
-rw-r--r--connectivity/source/commontools/dbtools.cxx1
-rw-r--r--connectivity/source/drivers/file/FResultSet.cxx4
-rw-r--r--connectivity/source/drivers/file/FStatement.cxx1
-rw-r--r--connectivity/source/drivers/file/fcode.cxx25
-rw-r--r--connectivity/source/drivers/file/fcomp.cxx7
-rw-r--r--connectivity/source/drivers/file/quotedstring.cxx4
-rw-r--r--connectivity/source/drivers/flat/ETable.cxx10
-rwxr-xr-xconnectivity/source/drivers/flat/flat.xcu2
-rw-r--r--connectivity/source/inc/file/fcode.hxx10
-rw-r--r--connectivity/source/inc/flat/ETable.hxx1
-rw-r--r--connectivity/source/parse/sqlflex.l2
-rw-r--r--connectivity/source/resource/conn_shared_res.src2
-rw-r--r--formula/source/ui/dlg/formula.cxx1
-rw-r--r--sfx2/source/dialog/templdlg.cxx6
26 files changed, 1431 insertions, 807 deletions
diff --git a/connectivity/qa/connectivity/tools/AbstractDatabase.java b/connectivity/qa/connectivity/tools/AbstractDatabase.java
new file mode 100755
index 000000000000..d3150cd8aa07
--- /dev/null
+++ b/connectivity/qa/connectivity/tools/AbstractDatabase.java
@@ -0,0 +1,230 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: RowSetEventListener.java,v $
+ * $Revision: 1.4 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package connectivity.tools;
+
+import com.sun.star.container.XNameAccess;
+import com.sun.star.frame.XModel;
+import com.sun.star.frame.XStorable;
+import com.sun.star.io.IOException;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.sdb.XDocumentDataSource;
+import com.sun.star.sdb.XOfficeDatabaseDocument;
+import com.sun.star.sdbc.SQLException;
+import com.sun.star.sdbc.XCloseable;
+import com.sun.star.sdbc.XConnection;
+import com.sun.star.sdbc.XStatement;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.util.CloseVetoException;
+import java.io.File;
+
+/**
+ *
+ * @author oj93728
+ */
+public abstract class AbstractDatabase implements DatabaseAccess
+{
+ // the service factory
+
+ protected final XMultiServiceFactory m_orb;
+ // the URL of the temporary file used for the database document
+ protected String m_databaseDocumentFile;
+ // the database document
+ protected XOfficeDatabaseDocument m_databaseDocument;
+ // the data source belonging to the database document
+ protected DataSource m_dataSource;
+ // the default connection
+ protected XConnection m_connection;
+
+ public AbstractDatabase(final XMultiServiceFactory orb) throws Exception
+ {
+ m_orb = orb;
+ }
+
+ // --------------------------------------------------------------------------------------------------------
+ public AbstractDatabase(final XMultiServiceFactory orb, final String _existingDocumentURL ) throws Exception
+ {
+ m_orb = orb;
+ createDBDocument( _existingDocumentURL );
+ }
+
+ /** returns a connection to the database
+ *
+ * Multiple calls to this method return the same connection. The DbaseDatabase object keeps
+ * the ownership of the connection, so you don't need to (and should not) dispose/close it.
+ *
+ */
+ public XConnection defaultConnection() throws SQLException
+ {
+ if (m_connection == null)
+ {
+ m_connection = m_databaseDocument.getDataSource().getConnection("", "");
+ }
+
+ return m_connection;
+ }
+
+ /** executes the given SQL statement via the defaultConnection
+ */
+ public void executeSQL(final String statementString) throws SQLException
+ {
+ final XStatement statement = defaultConnection().createStatement();
+ statement.execute(statementString);
+ }
+
+ /** stores the database document
+ */
+ public void store() throws IOException
+ {
+ if (m_databaseDocument != null)
+ {
+ final XStorable storeDoc = (XStorable) UnoRuntime.queryInterface(XStorable.class,
+ m_databaseDocument);
+ storeDoc.store();
+ }
+ }
+
+ /** closes the database document
+ *
+ * Any CloseVetoExceptions fired by third parties are ignored, and any reference to the
+ * database document is released.
+ */
+ public void close()
+ {
+ // close connection
+ final XCloseable closeConn = (XCloseable) UnoRuntime.queryInterface(XCloseable.class,
+ m_connection);
+ if (closeConn != null)
+ {
+ try
+ {
+ closeConn.close();
+ }
+ catch (SQLException e)
+ {
+ }
+ }
+ m_connection = null;
+
+ // close document
+ final com.sun.star.util.XCloseable closeDoc = (com.sun.star.util.XCloseable) UnoRuntime.queryInterface(
+ com.sun.star.util.XCloseable.class, m_databaseDocument);
+ if (closeDoc != null)
+ {
+ try
+ {
+ closeDoc.close(true);
+ }
+ catch (CloseVetoException e)
+ {
+ }
+ }
+ m_databaseDocument = null;
+ }
+
+ /** closes the document, and deletes the underlying file
+ */
+ public void closeAndDelete()
+ {
+ close();
+
+ if (m_databaseDocumentFile != null)
+ {
+ try
+ {
+ final File file = new File(m_databaseDocumentFile);
+ file.delete();
+ }
+ catch (Exception e)
+ {
+ }
+ }
+ }
+
+ /** returns the underlying database document
+ */
+ public XOfficeDatabaseDocument getDatabaseDocument()
+ {
+ return m_databaseDocument;
+ }
+
+ /** returns the model interface of the underlying database document
+ */
+ public XModel getModel()
+ {
+ return (XModel) UnoRuntime.queryInterface(XModel.class, m_databaseDocument);
+ }
+
+ public XMultiServiceFactory getORB()
+ {
+ return m_orb;
+ }
+
+ // --------------------------------------------------------------------------------------------------------
+ final protected void createDBDocument(final String _docURL) throws Exception
+ {
+ m_databaseDocumentFile = _docURL;
+
+ final XNameAccess dbContext = (XNameAccess) UnoRuntime.queryInterface(XNameAccess.class,
+ m_orb.createInstance("com.sun.star.sdb.DatabaseContext"));
+ final XDocumentDataSource dataSource = (XDocumentDataSource) UnoRuntime.queryInterface(XDocumentDataSource.class,
+ dbContext.getByName(_docURL));
+
+ m_databaseDocument = dataSource.getDatabaseDocument();
+ m_dataSource = new DataSource(m_orb, m_databaseDocument.getDataSource());
+ }
+
+ /** returns the URL of the ODB document represented by this instance
+ */
+ public String getDocumentURL()
+ {
+ return m_databaseDocumentFile;
+ }
+
+ /** returns the data source belonging to this database
+ */
+ public DataSource getDataSource()
+ {
+ return m_dataSource;
+ }
+
+ /** creates a row set operating the database, with a given command/type
+ */
+ public RowSet createRowSet(final int _commandType, final String _command)
+ {
+ return new RowSet(m_orb, getDocumentURL(), _commandType, _command);
+ }
+
+ @Override
+ protected void finalize() throws Throwable
+ {
+ closeAndDelete();
+ super.finalize();
+ }
+}
diff --git a/connectivity/qa/connectivity/tools/DataSource.java b/connectivity/qa/connectivity/tools/DataSource.java
index 531ec70d2930..1ed8f7f98af7 100644
--- a/connectivity/qa/connectivity/tools/DataSource.java
+++ b/connectivity/qa/connectivity/tools/DataSource.java
@@ -27,10 +27,8 @@
* for a copy of the LGPLv3 License.
*
************************************************************************/
-
package connectivity.tools;
-import com.sun.star.beans.UnknownPropertyException;
import com.sun.star.container.ElementExistException;
import com.sun.star.container.NoSuchElementException;
import com.sun.star.container.XNameAccess;
@@ -51,21 +49,22 @@ import java.util.logging.Logger;
public class DataSource
{
// the service factory
- XMultiServiceFactory m_orb;
- XDataSource m_dataSource;
- public DataSource( XMultiServiceFactory _orb, String _registeredName ) throws Exception
+ private final XMultiServiceFactory m_orb;
+ private XDataSource m_dataSource;
+
+ public DataSource(final XMultiServiceFactory _orb, final String _registeredName) throws Exception
{
m_orb = _orb;
- XNameAccess dbContext = (XNameAccess)UnoRuntime.queryInterface(XNameAccess.class,
- _orb.createInstance("com.sun.star.sdb.DatabaseContext"));
+ final XNameAccess dbContext = (XNameAccess) UnoRuntime.queryInterface(XNameAccess.class,
+ _orb.createInstance("com.sun.star.sdb.DatabaseContext"));
- m_dataSource = (XDataSource)UnoRuntime.queryInterface(XDataSource.class,
- dbContext.getByName( _registeredName ) );
+ m_dataSource = (XDataSource) UnoRuntime.queryInterface(XDataSource.class,
+ dbContext.getByName(_registeredName));
}
- public DataSource( XMultiServiceFactory _orb, XDataSource _dataSource )
+ public DataSource(final XMultiServiceFactory _orb,final XDataSource _dataSource)
{
m_orb = _orb;
m_dataSource = _dataSource;
@@ -77,47 +76,47 @@ public class DataSource
}
/** creates a query with a given name and SQL command
- */
- public void createQuery( String _name, String _sqlCommand ) throws ElementExistException, WrappedTargetException, com.sun.star.lang.IllegalArgumentException
+ */
+ public void createQuery(final String _name, final String _sqlCommand) throws ElementExistException, WrappedTargetException, com.sun.star.lang.IllegalArgumentException
{
- createQuery( _name, _sqlCommand, true );
+ createQuery(_name, _sqlCommand, true);
}
/** creates a query with a given name, SQL command, and EscapeProcessing flag
- */
- public void createQuery( String _name, String _sqlCommand, boolean _escapeProcessing ) throws ElementExistException, WrappedTargetException, com.sun.star.lang.IllegalArgumentException
+ */
+ public void createQuery(final String _name, final String _sqlCommand, final boolean _escapeProcessing) throws ElementExistException, WrappedTargetException, com.sun.star.lang.IllegalArgumentException
{
- XSingleServiceFactory queryDefsFac = (XSingleServiceFactory)UnoRuntime.queryInterface(
- XSingleServiceFactory.class, getQueryDefinitions() );
+ final XSingleServiceFactory queryDefsFac = (XSingleServiceFactory) UnoRuntime.queryInterface(
+ XSingleServiceFactory.class, getQueryDefinitions());
XPropertySet queryDef = null;
try
{
- queryDef = (XPropertySet)UnoRuntime.queryInterface(
- XPropertySet.class, queryDefsFac.createInstance() );
- queryDef.setPropertyValue( "Command", _sqlCommand );
- queryDef.setPropertyValue( "EscapeProcessing", new Boolean( _escapeProcessing ) );
+ queryDef = (XPropertySet) UnoRuntime.queryInterface(
+ XPropertySet.class, queryDefsFac.createInstance());
+ queryDef.setPropertyValue("Command", _sqlCommand);
+ queryDef.setPropertyValue("EscapeProcessing", Boolean.valueOf(_escapeProcessing));
}
- catch( com.sun.star.uno.Exception e )
+ catch (com.sun.star.uno.Exception e)
{
- e.printStackTrace( System.err );
+ e.printStackTrace(System.err);
}
- XNameContainer queryDefsContainer = (XNameContainer)UnoRuntime.queryInterface(
- XNameContainer.class, getQueryDefinitions() );
- queryDefsContainer.insertByName( _name, queryDef );
+ final XNameContainer queryDefsContainer = (XNameContainer) UnoRuntime.queryInterface(
+ XNameContainer.class, getQueryDefinitions());
+ queryDefsContainer.insertByName(_name, queryDef);
}
/** provides the query definition with the given name
*/
- public QueryDefinition getQueryDefinition( String _name ) throws NoSuchElementException
+ public QueryDefinition getQueryDefinition(final String _name) throws NoSuchElementException
{
- XNameAccess allDefs = getQueryDefinitions();
+ final XNameAccess allDefs = getQueryDefinitions();
try
{
return new QueryDefinition(
- (XPropertySet)UnoRuntime.queryInterface( XPropertySet.class, allDefs.getByName( _name ) ) );
+ (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, allDefs.getByName(_name)));
}
- catch ( WrappedTargetException e )
+ catch (WrappedTargetException e)
{
}
throw new NoSuchElementException();
@@ -127,8 +126,8 @@ public class DataSource
*/
public XNameAccess getQueryDefinitions()
{
- XQueryDefinitionsSupplier suppQueries = (XQueryDefinitionsSupplier)UnoRuntime.queryInterface(
- XQueryDefinitionsSupplier.class, m_dataSource );
+ final XQueryDefinitionsSupplier suppQueries = (XQueryDefinitionsSupplier) UnoRuntime.queryInterface(
+ XQueryDefinitionsSupplier.class, m_dataSource);
return suppQueries.getQueryDefinitions();
}
@@ -137,12 +136,12 @@ public class DataSource
* This is usually necessary if you created tables by directly executing SQL statements,
* bypassing the SDBCX layer.
*/
- public void refreshTables( com.sun.star.sdbc.XConnection _connection )
+ public void refreshTables(final com.sun.star.sdbc.XConnection _connection)
{
- XTablesSupplier suppTables = (XTablesSupplier)UnoRuntime.queryInterface(
- XTablesSupplier.class, _connection );
- XRefreshable refreshTables = (XRefreshable)UnoRuntime.queryInterface(
- XRefreshable.class, suppTables.getTables() );
+ final XTablesSupplier suppTables = (XTablesSupplier) UnoRuntime.queryInterface(
+ XTablesSupplier.class, _connection);
+ final XRefreshable refreshTables = (XRefreshable) UnoRuntime.queryInterface(
+ XRefreshable.class, suppTables.getTables());
refreshTables.refresh();
}
@@ -158,9 +157,9 @@ public class DataSource
String name = null;
try
{
- XPropertySet dataSourceProps = (XPropertySet) UnoRuntime.queryInterface(
- XPropertySet.class, m_dataSource );
- name = (String)dataSourceProps.getPropertyValue("Name");
+ final XPropertySet dataSourceProps = (XPropertySet) UnoRuntime.queryInterface(
+ XPropertySet.class, m_dataSource);
+ name = (String) dataSourceProps.getPropertyValue("Name");
}
catch (Exception ex)
{
diff --git a/connectivity/qa/connectivity/tools/DatabaseAccess.java b/connectivity/qa/connectivity/tools/DatabaseAccess.java
new file mode 100755
index 000000000000..bc39bb099087
--- /dev/null
+++ b/connectivity/qa/connectivity/tools/DatabaseAccess.java
@@ -0,0 +1,66 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: RowSetEventListener.java,v $
+ * $Revision: 1.4 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package connectivity.tools;
+
+import com.sun.star.frame.XModel;
+import com.sun.star.io.IOException;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.sdb.XOfficeDatabaseDocument;
+import com.sun.star.sdbc.SQLException;
+import com.sun.star.sdbc.XConnection;
+
+/**
+ *
+ * @author oj93728
+ */
+public interface DatabaseAccess
+{
+ XConnection defaultConnection() throws SQLException;
+
+ void executeSQL(final String statementString) throws SQLException;
+
+ void store() throws IOException;
+
+ void close();
+
+ void closeAndDelete();
+
+ XOfficeDatabaseDocument getDatabaseDocument();
+
+ XModel getModel();
+
+ String getDocumentURL();
+
+ DataSource getDataSource();
+
+ RowSet createRowSet(final int _commandType, final String _command);
+
+ XMultiServiceFactory getORB();
+}
diff --git a/connectivity/qa/connectivity/tools/DbaseDatabase.java b/connectivity/qa/connectivity/tools/DbaseDatabase.java
new file mode 100755
index 000000000000..9c1d6ea47411
--- /dev/null
+++ b/connectivity/qa/connectivity/tools/DbaseDatabase.java
@@ -0,0 +1,100 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: DbaseDatabase.java,v $
+ * $Revision: 1.4.50.2 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package connectivity.tools;
+
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.frame.XStorable;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.sdb.XOfficeDatabaseDocument;
+import com.sun.star.sdbc.SQLException;
+import com.sun.star.uno.UnoRuntime;
+
+import helper.URLHelper;
+import java.io.File;
+
+/**
+ *
+ * @author Ocke
+ */
+public class DbaseDatabase extends AbstractDatabase
+{
+ // --------------------------------------------------------------------------------------------------------
+
+ public DbaseDatabase(final XMultiServiceFactory orb) throws Exception
+ {
+ super(orb);
+ createDBDocument();
+ }
+
+ // --------------------------------------------------------------------------------------------------------
+ public DbaseDatabase(final XMultiServiceFactory orb, final String _existingDocumentURL) throws Exception
+ {
+ super(orb, _existingDocumentURL);
+ }
+
+ /** creates an empty database document in a temporary location
+ */
+ private void createDBDocument() throws Exception
+ {
+ final File documentFile = File.createTempFile("dbase", ".odb");
+ documentFile.deleteOnExit();
+ final File subPath = new File(documentFile.getParent() + File.separator + documentFile.getName().replaceAll(".odb", "") + File.separator );
+ subPath.mkdir();
+ //subPath.deleteOnExit();
+ m_databaseDocumentFile = URLHelper.getFileURLFromSystemPath(documentFile);
+ final String path = URLHelper.getFileURLFromSystemPath(subPath.getPath());
+
+ m_databaseDocument = (XOfficeDatabaseDocument) UnoRuntime.queryInterface(
+ XOfficeDatabaseDocument.class, m_orb.createInstance("com.sun.star.sdb.OfficeDatabaseDocument"));
+ m_dataSource = new DataSource(m_orb, m_databaseDocument.getDataSource());
+
+ final XPropertySet dsProperties = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, m_databaseDocument.getDataSource());
+ dsProperties.setPropertyValue("URL", "sdbc:dbase:" + path);
+
+ final XStorable storable = (XStorable) UnoRuntime.queryInterface(XStorable.class, m_databaseDocument);
+ storable.storeAsURL(m_databaseDocumentFile, new PropertyValue[]
+ {
+ });
+ }
+
+ /** drops the table with a given name
+
+ @param _name
+ the name of the table to drop
+ @param _ifExists
+ TRUE if it should be dropped only when it exists.
+ */
+ public void dropTable(final String _name,final boolean _ifExists) throws SQLException
+ {
+ String dropStatement = "DROP TABLE \"" + _name;
+ executeSQL(dropStatement);
+ }
+}
diff --git a/connectivity/qa/connectivity/tools/HsqlDatabase.java b/connectivity/qa/connectivity/tools/HsqlDatabase.java
index e532a04bab22..d27816cf4b7e 100644
--- a/connectivity/qa/connectivity/tools/HsqlDatabase.java
+++ b/connectivity/qa/connectivity/tools/HsqlDatabase.java
@@ -27,29 +27,19 @@
* for a copy of the LGPLv3 License.
*
************************************************************************/
-
package connectivity.tools;
import com.sun.star.beans.PropertyValue;
import com.sun.star.beans.XPropertySet;
import com.sun.star.container.ElementExistException;
-import com.sun.star.container.XNameAccess;
import com.sun.star.frame.XStorable;
-import com.sun.star.frame.XModel;
import com.sun.star.lang.XMultiServiceFactory;
import com.sun.star.sdb.XOfficeDatabaseDocument;
import com.sun.star.sdbc.SQLException;
-import com.sun.star.sdbc.XCloseable;
-import com.sun.star.sdbc.XConnection;
-import com.sun.star.sdbc.XStatement;
import com.sun.star.sdbcx.XAppend;
import com.sun.star.sdbcx.XTablesSupplier;
import com.sun.star.uno.UnoRuntime;
-import com.sun.star.io.IOException;
-import com.sun.star.sdb.XDocumentDataSource;
-import java.io.File;
-import com.sun.star.util.CloseVetoException;
import helper.URLHelper;
import java.util.HashMap;
import java.util.Iterator;
@@ -60,309 +50,167 @@ import java.io.File;
*
* @author fs93730
*/
-public class HsqlDatabase
+public class HsqlDatabase extends AbstractDatabase
{
- // the service factory
- XMultiServiceFactory m_orb;
- // the URL of the temporary file used for the database document
- String m_databaseDocumentFile;
- // the database document
- XOfficeDatabaseDocument m_databaseDocument;
- // the data source belonging to the database document
- DataSource m_dataSource;
- // the default connection
- XConnection m_connection;
// --------------------------------------------------------------------------------------------------------
- public HsqlDatabase( XMultiServiceFactory orb ) throws Exception
+ public HsqlDatabase(final XMultiServiceFactory orb) throws Exception
{
- m_orb = orb;
+ super(orb);
createDBDocument();
}
// --------------------------------------------------------------------------------------------------------
- public HsqlDatabase( XMultiServiceFactory orb, String _existingDocumentURL ) throws Exception
- {
- m_orb = orb;
- createDBDocument( _existingDocumentURL );
- }
-
- // --------------------------------------------------------------------------------------------------------
- private void createDBDocument( String _docURL ) throws Exception
+ public HsqlDatabase(final XMultiServiceFactory orb, final String _existingDocumentURL) throws Exception
{
- m_databaseDocumentFile = _docURL;
-
- XNameAccess dbContext = (XNameAccess)UnoRuntime.queryInterface( XNameAccess.class,
- m_orb.createInstance( "com.sun.star.sdb.DatabaseContext" ) );
- XDocumentDataSource dataSource = (XDocumentDataSource)UnoRuntime.queryInterface( XDocumentDataSource.class,
- dbContext.getByName( _docURL ) );
-
- m_databaseDocument = dataSource.getDatabaseDocument();
- m_dataSource = new DataSource( m_orb, m_databaseDocument.getDataSource() );
+ super(orb, _existingDocumentURL);
}
/** creates an empty database document in a temporary location
*/
private void createDBDocument() throws Exception
{
- File documentFile = File.createTempFile("testdb",".odb");
+ final File documentFile = File.createTempFile("testdb", ".odb");
documentFile.deleteOnExit();
- m_databaseDocumentFile = URLHelper.getFileURLFromSystemPath( documentFile );
+ m_databaseDocumentFile = URLHelper.getFileURLFromSystemPath(documentFile);
- m_databaseDocument = (XOfficeDatabaseDocument)UnoRuntime.queryInterface(
- XOfficeDatabaseDocument.class, m_orb.createInstance( "com.sun.star.sdb.OfficeDatabaseDocument" ) );
- m_dataSource = new DataSource( m_orb, m_databaseDocument.getDataSource() );
+ m_databaseDocument = (XOfficeDatabaseDocument) UnoRuntime.queryInterface(
+ XOfficeDatabaseDocument.class, m_orb.createInstance("com.sun.star.sdb.OfficeDatabaseDocument"));
+ m_dataSource = new DataSource(m_orb, m_databaseDocument.getDataSource());
- XPropertySet dsProperties = (XPropertySet)UnoRuntime.queryInterface( XPropertySet.class, m_databaseDocument.getDataSource() );
+ final XPropertySet dsProperties = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, m_databaseDocument.getDataSource());
dsProperties.setPropertyValue("URL", "sdbc:embedded:hsqldb");
- XStorable storable = (XStorable)UnoRuntime.queryInterface( XStorable.class, m_databaseDocument );
- storable.storeAsURL( m_databaseDocumentFile, new PropertyValue[]{} );
+ final XStorable storable = (XStorable) UnoRuntime.queryInterface(XStorable.class, m_databaseDocument);
+ storable.storeAsURL(m_databaseDocumentFile, new PropertyValue[]
+ {
+ });
}
- /** returns a connection to the database
- *
- * Multiple calls to this method return the same connection. The HsqlDatabase object keeps
- * the ownership of the connection, so you don't need to (and should not) dispose/close it.
- *
- */
- public XConnection defaultConnection() throws SQLException
- {
- if ( m_connection != null )
- return m_connection;
- m_connection = m_databaseDocument.getDataSource().getConnection(new String(),new String());
- return m_connection;
- }
+ /** drops the table with a given name
- /** executes the given SQL statement via the defaultConnection
+ @param _name
+ the name of the table to drop
+ @param _ifExists
+ TRUE if it should be dropped only when it exists.
*/
- public void executeSQL( String statementString ) throws SQLException
- {
- XStatement statement = defaultConnection().createStatement();
- statement.execute( statementString );
- }
-
- /** stores the database document
- */
- public void store() throws IOException
+ public void dropTable(final String _name, final boolean _ifExists) throws SQLException
{
- if ( m_databaseDocument != null )
+ final StringBuffer dropStatement = new StringBuffer("DROP TABLE \"");
+ dropStatement.append(_name);
+ if (_ifExists)
{
- XStorable storeDoc = (XStorable)UnoRuntime.queryInterface( XStorable.class,
- m_databaseDocument );
- storeDoc.store();
+ dropStatement.append("\" IF EXISTS");
}
+ executeSQL(dropStatement.toString());
}
- /** closes the database document
- *
- * Any CloseVetoExceptions fired by third parties are ignored, and any reference to the
- * database document is released.
- */
- public void close()
+ public void createTable(final HsqlTableDescriptor _tableDesc, final boolean _dropIfExists) throws SQLException
{
- // close connection
- XCloseable closeConn = (XCloseable)UnoRuntime.queryInterface( XCloseable.class,
- m_connection );
- if ( closeConn != null )
+ if (_dropIfExists)
{
- try
- {
- closeConn.close();
- }
- catch( SQLException e )
- {
- }
+ dropTable(_tableDesc.getName(), true);
}
- m_connection = null;
-
- // close document
- com.sun.star.util.XCloseable closeDoc = (com.sun.star.util.XCloseable)UnoRuntime.queryInterface(
- com.sun.star.util.XCloseable.class, m_databaseDocument );
- if ( closeDoc != null )
- {
- try
- {
- closeDoc.close( true );
- }
- catch( CloseVetoException e )
- {
- }
- }
- m_databaseDocument = null;
- }
-
- /** closes the document, and deletes the underlying file
- */
- public void closeAndDelete()
- {
- close();
-
- if ( m_databaseDocumentFile != null )
- {
- try
- {
- File file = new File(m_databaseDocumentFile);
- file.delete();
- }
- catch(Exception e)
- {
- }
- m_databaseDocumentFile = null;
- }
- }
-
- /** returns the underlying database document
- */
- public XOfficeDatabaseDocument getDatabaseDocument()
- {
- return m_databaseDocument;
- }
-
- /** returns the model interface of the underlying database document
- */
- XModel getModel()
- {
- return (XModel)UnoRuntime.queryInterface( XModel.class, m_databaseDocument );
- }
-
- /** drops the table with a given name
-
- @param _name
- the name of the table to drop
- @param _ifExists
- TRUE if it should be dropped only when it exists.
- */
- public void dropTable( String _name, boolean _ifExists ) throws SQLException
- {
- String dropStatement = "DROP TABLE \"" + _name;
- if ( _ifExists )
- dropStatement += "\" IF EXISTS";
- executeSQL( dropStatement );
- }
-
- public void createTable( HsqlTableDescriptor _tableDesc, boolean _dropIfExists ) throws SQLException
- {
- if ( _dropIfExists )
- dropTable( _tableDesc.getName(), true );
- createTable( _tableDesc );
+ createTable(_tableDesc);
}
/** creates a table
*/
- public void createTable( HsqlTableDescriptor _tableDesc ) throws SQLException
+ public void createTable(final HsqlTableDescriptor _tableDesc) throws SQLException
{
- String createStatement = "CREATE CACHED TABLE \"";
- createStatement += _tableDesc.getName();
- createStatement += "\" ( ";
+ StringBuffer createStatement = new StringBuffer("CREATE CACHED TABLE \"");
+ createStatement.append(_tableDesc.getName());
+ createStatement.append("\" ( ");
String primaryKeyList = "";
- HashMap foreignKeys = new HashMap();
- HashMap foreignKeyRefs = new HashMap();
+ final HashMap foreignKeys = new HashMap();
+ final HashMap foreignKeyRefs = new HashMap();
- HsqlColumnDescriptor[] columns = _tableDesc.getColumns();
- for ( int i=0; i<columns.length; ++i )
+ final HsqlColumnDescriptor[] columns = _tableDesc.getColumns();
+ for (int i = 0; i < columns.length; ++i)
{
- if ( i > 0 )
- createStatement += ", ";
+ if (i > 0)
+ {
+ createStatement.append(", ");
+ }
- createStatement += "\"" + columns[i].getName();
- createStatement += "\" " + columns[i].getTypeName();
+ createStatement.append("\"" + columns[i].getName());
+ createStatement.append("\" " + columns[i].getTypeName());
- if ( columns[i].isRequired() )
- createStatement += " NOT NULL";
+ if (columns[i].isRequired())
+ {
+ createStatement.append(" NOT NULL");
+ }
- if ( columns[i].isPrimaryKey() )
+ if (columns[i].isPrimaryKey())
{
- if ( primaryKeyList.length() > 0 )
+ if (primaryKeyList.length() > 0)
+ {
primaryKeyList += ", ";
+ }
primaryKeyList += "\"" + columns[i].getName() + "\"";
}
- if ( columns[i].isForeignKey() )
+ if (columns[i].isForeignKey())
{
- String foreignTable = columns[i].getForeignTable();
+ final String foreignTable = columns[i].getForeignTable();
- String foreignKeysForTable = foreignKeys.containsKey( foreignTable ) ? (String)foreignKeys.get( foreignTable ) : "";
- if ( foreignKeysForTable.length() > 0 )
+ String foreignKeysForTable = foreignKeys.containsKey(foreignTable) ? (String) foreignKeys.get(foreignTable) : "";
+ if (foreignKeysForTable.length() > 0)
+ {
foreignKeysForTable += ", ";
+ }
foreignKeysForTable += "\"" + columns[i].getName() + "\"";
- foreignKeys.put( foreignTable, foreignKeysForTable );
-
- String foreignKeyRefsForTable = foreignKeyRefs.containsKey( foreignTable ) ? (String)foreignKeyRefs.get( foreignTable ) : "";
- if ( foreignKeyRefsForTable.length() > 0 )
- foreignKeyRefsForTable += ", ";
- foreignKeyRefsForTable += "\"" + columns[i].getForeignColumn() + "\"";
- foreignKeyRefs.put( foreignTable, foreignKeyRefsForTable );
+ foreignKeys.put(foreignTable, foreignKeysForTable);
+
+ final StringBuffer foreignKeyRefsForTable = new StringBuffer(foreignKeyRefs.containsKey(foreignTable) ? (String) foreignKeyRefs.get(foreignTable) : "");
+ if (foreignKeyRefsForTable.length() > 0)
+ {
+ foreignKeyRefsForTable.append(", ");
+ }
+ foreignKeyRefsForTable.append("\"" + columns[i].getForeignColumn() + "\"");
+ foreignKeyRefs.put(foreignTable, foreignKeyRefsForTable.toString());
}
}
- if ( primaryKeyList.length() > 0 )
+ if (primaryKeyList.length() > 0)
{
- createStatement += ", PRIMARY KEY (";
- createStatement += primaryKeyList;
- createStatement += ")";
+ createStatement.append(", PRIMARY KEY (");
+ createStatement.append(primaryKeyList);
+ createStatement.append(')');
}
- Set foreignKeyTables = foreignKeys.keySet();
- for ( Iterator foreignKey = foreignKeyTables.iterator();
- foreignKey.hasNext();
- )
+ final Set foreignKeyTables = foreignKeys.keySet();
+ for (final Iterator foreignKey = foreignKeyTables.iterator();
+ foreignKey.hasNext();)
{
- String foreignTable = (String)foreignKey.next();
-
- createStatement += ", FOREIGN KEY (";
- createStatement += (String)foreignKeys.get(foreignTable);
- createStatement += ") REFERENCES \"";
- createStatement += foreignTable;
- createStatement += "\"(";
- createStatement += (String)foreignKeyRefs.get(foreignTable);
- createStatement += ")";
+ final String foreignTable = (String) foreignKey.next();
+
+ createStatement.append(", FOREIGN KEY (");
+ createStatement.append((String) foreignKeys.get(foreignTable));
+ createStatement.append(") REFERENCES \"");
+ createStatement.append(foreignTable);
+ createStatement.append("\"(");
+ createStatement.append((String) foreignKeyRefs.get(foreignTable));
+ createStatement.append(')');
}
- createStatement += ")";
+ createStatement.append(')');
//System.err.println( createStatement );
- executeSQL( createStatement );
+ executeSQL(createStatement.toString());
}
/** creates a table in the database. using the SDBCX-API
*/
- public void createTableInSDBCX( HsqlTableDescriptor _tableDesc ) throws SQLException, ElementExistException
- {
- XPropertySet sdbcxDescriptor = _tableDesc.createSdbcxDescriptor( defaultConnection() );
- XTablesSupplier suppTables = (XTablesSupplier)UnoRuntime.queryInterface(
- XTablesSupplier.class, defaultConnection() );
- XAppend appendTable = (XAppend)UnoRuntime.queryInterface(
- XAppend.class, suppTables.getTables() );
- appendTable.appendByDescriptor( sdbcxDescriptor );
- }
-
- /** returns the URL of the ODB document represented by this instance
- */
- public String getDocumentURL()
- {
- return m_databaseDocumentFile;
- }
-
- /** returns the data source belonging to this database
- */
- public DataSource getDataSource()
- {
- return m_dataSource;
- }
-
- /** creates a row set operating the database, with a given command/type
- */
- public RowSet createRowSet( int _commandType, String _command )
- {
- return new RowSet(m_orb, getDocumentURL(), _commandType, _command);
- }
-
- protected void finalize() throws Throwable
- {
- closeAndDelete();
- super.finalize();
+ public void createTableInSDBCX(final HsqlTableDescriptor _tableDesc) throws SQLException, ElementExistException
+ {
+ final XPropertySet sdbcxDescriptor = _tableDesc.createSdbcxDescriptor(defaultConnection());
+ final XTablesSupplier suppTables = (XTablesSupplier) UnoRuntime.queryInterface(
+ XTablesSupplier.class, defaultConnection());
+ final XAppend appendTable = (XAppend) UnoRuntime.queryInterface(
+ XAppend.class, suppTables.getTables());
+ appendTable.appendByDescriptor(sdbcxDescriptor);
}
}
diff --git a/connectivity/qa/drivers/dbase/DBaseDateFunctions.java b/connectivity/qa/drivers/dbase/DBaseDateFunctions.java
index 7a12866b0121..7ed50cbd9fd0 100644
--- a/connectivity/qa/drivers/dbase/DBaseDateFunctions.java
+++ b/connectivity/qa/drivers/dbase/DBaseDateFunctions.java
@@ -27,219 +27,286 @@
* for a copy of the LGPLv3 License.
*
************************************************************************/
-package complex.connectivity;
+package qa.drivers.dbase;
-import complex.connectivity.DBaseDriverTest;
import com.sun.star.uno.UnoRuntime;
-import com.sun.star.util.XCloseable;
import com.sun.star.sdbc.*;
-import com.sun.star.sdb.*;
-import com.sun.star.beans.PropertyValue;
import com.sun.star.beans.XPropertySet;
import com.sun.star.lang.XMultiServiceFactory;
-import complexlib.ComplexTestCase;
+public class DBaseDateFunctions
+{
-import java.io.PrintWriter;
+ private final String where = "FROM \"biblio\" \"biblio\" where \"Identifier\" = 'BOR00'";
+ private final XMultiServiceFactory m_xORB;
+ private final DBaseDriverTest testcase;
-import util.utils;
-import java.util.*;
-import java.io.*;
-
-
-public class DBaseDateFunctions {
-
- private String where = "FROM \"biblio\" \"biblio\" where \"Identifier\" = 'BOR00'";
- private XMultiServiceFactory m_xORB;
- private DBaseDriverTest testcase;
- public DBaseDateFunctions(XMultiServiceFactory _xORB,DBaseDriverTest _testcase){
- m_xORB = _xORB;
- testcase = _testcase;
- }
+ public DBaseDateFunctions(final XMultiServiceFactory _xORB, final DBaseDriverTest _testcase)
+ {
+ m_xORB = _xORB;
+ testcase = _testcase;
+ }
- private void assure(String s,boolean b){
- testcase.assure2(s,b);
- }
+ private void assure(final String s, final boolean b)
+ {
+ testcase.assure2(s, b);
+ }
- public void testFunctions() throws com.sun.star.uno.Exception,com.sun.star.beans.UnknownPropertyException {
- XRowSet xRowRes = (XRowSet)UnoRuntime.queryInterface(XRowSet.class,
- m_xORB.createInstance("com.sun.star.sdb.RowSet"));
+ public void testFunctions() throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRowSet xRowRes = (XRowSet) UnoRuntime.queryInterface(XRowSet.class,
+ m_xORB.createInstance("com.sun.star.sdb.RowSet"));
- System.out.println("starting DateTime function test!");
+ testcase.getLog().println("starting DateTime function test!");
// set the properties needed to connect to a database
- XPropertySet xProp = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class,xRowRes);
- xProp.setPropertyValue("DataSourceName","Bibliography");
+ final XPropertySet xProp = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xRowRes);
+ xProp.setPropertyValue("DataSourceName", "Bibliography");
- xProp.setPropertyValue("CommandType",new Integer(com.sun.star.sdb.CommandType.COMMAND));
+ xProp.setPropertyValue("CommandType", Integer.valueOf(com.sun.star.sdb.CommandType.COMMAND));
- try {
+ try
+ {
curdate(xRowRes);
- } catch( SQLException ex){
- assure("upper " + ex.getMessage(),false);
+ }
+ catch (SQLException ex)
+ {
+ assure("upper " + ex.getMessage(), false);
throw ex;
}
- try{
+ try
+ {
curtime(xRowRes);
- } catch( SQLException ex){
- assure("lower " + ex.getMessage(),false);
+ }
+ catch (SQLException ex)
+ {
+ assure("lower " + ex.getMessage(), false);
throw ex;
}
- try{
+ try
+ {
dayname(xRowRes);
- } catch( SQLException ex){
- assure("ascii " + ex.getMessage(),false);
+ }
+ catch (SQLException ex)
+ {
+ assure("ascii " + ex.getMessage(), false);
throw ex;
}
- try{
+ try
+ {
dayofmonth(xRowRes);
- } catch( SQLException ex){
- assure("char_len " + ex.getMessage(),false);
+ }
+ catch (SQLException ex)
+ {
+ assure("char_len " + ex.getMessage(), false);
throw ex;
}
- try{
+ try
+ {
dayofweek(xRowRes);
- } catch( SQLException ex){
- assure("concat " + ex.getMessage(),false);
+ }
+ catch (SQLException ex)
+ {
+ assure("concat " + ex.getMessage(), false);
throw ex;
}
- try{
+ try
+ {
dayofyear(xRowRes);
- } catch( SQLException ex){
- assure("locate " + ex.getMessage(),false);
+ }
+ catch (SQLException ex)
+ {
+ assure("locate " + ex.getMessage(), false);
throw ex;
}
- try{
+ try
+ {
hour(xRowRes);
- } catch( SQLException ex){
- assure("substr " + ex.getMessage(),false);
+ }
+ catch (SQLException ex)
+ {
+ assure("substr " + ex.getMessage(), false);
throw ex;
}
- try{
+ try
+ {
minute(xRowRes);
- } catch( SQLException ex){
- assure("ltrim " + ex.getMessage(),false);
+ }
+ catch (SQLException ex)
+ {
+ assure("ltrim " + ex.getMessage(), false);
throw ex;
}
- try{
+ try
+ {
month(xRowRes);
- } catch( SQLException ex){
- assure("rtrim " + ex.getMessage(),false);
+ }
+ catch (SQLException ex)
+ {
+ assure("rtrim " + ex.getMessage(), false);
throw ex;
}
- try{
+ try
+ {
monthname(xRowRes);
- } catch( SQLException ex){
- assure("space " + ex.getMessage(),false);
+ }
+ catch (SQLException ex)
+ {
+ assure("space " + ex.getMessage(), false);
throw ex;
}
- try{
+ try
+ {
now(xRowRes);
- } catch( SQLException ex){
- assure("replace " + ex.getMessage(),false);
+ }
+ catch (SQLException ex)
+ {
+ assure("replace " + ex.getMessage(), false);
throw ex;
}
- try{
+ try
+ {
quarter(xRowRes);
- } catch( SQLException ex){
- assure("repeat " + ex.getMessage(),false);
+ }
+ catch (SQLException ex)
+ {
+ assure("repeat " + ex.getMessage(), false);
throw ex;
}
- try{
+ try
+ {
second(xRowRes);
- } catch( SQLException ex){
- assure("insert " + ex.getMessage(),false);
+ }
+ catch (SQLException ex)
+ {
+ assure("insert " + ex.getMessage(), false);
throw ex;
}
- try{
+ try
+ {
week(xRowRes);
- } catch( SQLException ex){
- assure("left " + ex.getMessage(),false);
+ }
+ catch (SQLException ex)
+ {
+ assure("left " + ex.getMessage(), false);
throw ex;
}
- try{
+ try
+ {
year(xRowRes);
- } catch( SQLException ex){
- assure("right " + ex.getMessage(),false);
+ }
+ catch (SQLException ex)
+ {
+ assure("right " + ex.getMessage(), false);
throw ex;
}
}
- private XRow execute(XRowSet xRowRes,String sql) throws com.sun.star.uno.Exception,com.sun.star.beans.UnknownPropertyException {
- XPropertySet xProp = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class,xRowRes);
- xProp.setPropertyValue("Command","SELECT " + sql + where);
+ private XRow execute(final XRowSet xRowRes, final String sql) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XPropertySet xProp = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xRowRes);
+ xProp.setPropertyValue("Command", "SELECT " + sql + where);
xRowRes.execute();
- XResultSet xRes = (XResultSet)UnoRuntime.queryInterface(XResultSet.class,xRowRes);
- assure("No valid row! ",xRes.next());
-
- return (XRow)UnoRuntime.queryInterface(XRow.class, xRes);
- }
-
- private void dayofweek(XRowSet xRowRes) throws com.sun.star.uno.Exception,com.sun.star.beans.UnknownPropertyException {
- XRow row = execute(xRowRes,"DAYOFWEEK('1998-02-03') ");
- assure("DAYOFWEEK('1998-02-03') failed!",row.getInt(1) == 3);
- }
- private void dayofmonth(XRowSet xRowRes) throws com.sun.star.uno.Exception,com.sun.star.beans.UnknownPropertyException {
- XRow row = execute(xRowRes,"DAYOFMONTH('1998-02-03') ");
- assure("DAYOFMONTH('1998-02-03') failed!",row.getInt(1) == 3);
- }
- private void dayofyear(XRowSet xRowRes) throws com.sun.star.uno.Exception,com.sun.star.beans.UnknownPropertyException {
- XRow row = execute(xRowRes,"DAYOFYEAR('1998-02-03') ");
- assure("DAYOFYEAR('1998-02-03') failed!",row.getInt(1) == 34);
- }
- private void month(XRowSet xRowRes) throws com.sun.star.uno.Exception,com.sun.star.beans.UnknownPropertyException {
- XRow row = execute(xRowRes,"month('1998-02-03') ");
- assure("month('1998-02-03') failed!",row.getInt(1) == 2);
- }
- private void dayname(XRowSet xRowRes) throws com.sun.star.uno.Exception,com.sun.star.beans.UnknownPropertyException {
- XRow row = execute(xRowRes,"DAYNAME('1998-02-05') ");
- assure("DAYNAME('1998-02-05') failed!",row.getString(1).equals("Thursday"));
- }
- private void monthname(XRowSet xRowRes) throws com.sun.star.uno.Exception,com.sun.star.beans.UnknownPropertyException {
- XRow row = execute(xRowRes,"MONTHNAME('1998-02-05') ");
- assure("MONTHNAME('1998-02-05') failed!",row.getString(1).equals("February"));
- }
- private void quarter(XRowSet xRowRes) throws com.sun.star.uno.Exception,com.sun.star.beans.UnknownPropertyException {
- XRow row = execute(xRowRes,"QUARTER('98-01-01'),QUARTER('98-04-01'),QUARTER('98-07-01'),QUARTER('98-10-01') ");
- assure("QUARTER('98-01-01') failed!",row.getInt(1) == 1);
- assure("QUARTER('98-04-01') failed!",row.getInt(2) == 2);
- assure("QUARTER('98-07-01') failed!",row.getInt(3) == 3);
- assure("QUARTER('98-10-01') failed!",row.getInt(4) == 4);
- }
- private void week(XRowSet xRowRes) throws com.sun.star.uno.Exception,com.sun.star.beans.UnknownPropertyException {
- XRow row = execute(xRowRes,"WEEK('1998-02-20') ");
- assure("WEEK('1998-02-20') failed!",row.getInt(1) == 7);
- }
- private void year(XRowSet xRowRes) throws com.sun.star.uno.Exception,com.sun.star.beans.UnknownPropertyException {
- XRow row = execute(xRowRes,"YEAR('98-02-03') ");
- assure("YEAR('98-02-03') failed!",row.getInt(1) == 98);
- }
- private void hour(XRowSet xRowRes) throws com.sun.star.uno.Exception,com.sun.star.beans.UnknownPropertyException {
- XRow row = execute(xRowRes,"HOUR('10:05:03') ");
- assure("HOUR('10:05:03') failed!",row.getInt(1) == 10);
- }
- private void minute(XRowSet xRowRes) throws com.sun.star.uno.Exception,com.sun.star.beans.UnknownPropertyException {
- XRow row = execute(xRowRes,"MINUTE('98-02-03 10:05:03') ");
- assure("MINUTE('98-02-03 10:05:03') failed!",row.getInt(1) == 5);
- }
- private void second(XRowSet xRowRes) throws com.sun.star.uno.Exception,com.sun.star.beans.UnknownPropertyException {
- XRow row = execute(xRowRes,"SECOND('10:05:03') ");
- assure("SECOND('10:05:03') failed!",row.getInt(1) == 3);
- }
- private void curdate(XRowSet xRowRes) throws com.sun.star.uno.Exception,com.sun.star.beans.UnknownPropertyException {
- XRow row = execute(xRowRes,"CURDATE() ");
- com.sun.star.util.Date aDate = row.getDate(1);
- System.out.println("CURDATE() is '" + aDate.Year + "-" + aDate.Month + "-" + aDate.Day +"'");
- }
- private void curtime(XRowSet xRowRes) throws com.sun.star.uno.Exception,com.sun.star.beans.UnknownPropertyException {
- XRow row = execute(xRowRes,"CURTIME() ");
- com.sun.star.util.Time aTime = row.getTime(1);
- System.out.println("CURTIME() is '" + aTime.Hours + ":" + aTime.Minutes + ":" + aTime.Seconds + "'");
- }
- private void now(XRowSet xRowRes) throws com.sun.star.uno.Exception,com.sun.star.beans.UnknownPropertyException {
- XRow row = execute(xRowRes,"NOW() ");
- com.sun.star.util.DateTime aTime = row.getTimestamp(1);
- System.out.println("NOW() is '" + aTime.Year + "-" + aTime.Month + "-" + aTime.Day + "'");
- System.out.println("'" + aTime.Hours + ":" + aTime.Minutes + ":" + aTime.Seconds + "'");
+ final XResultSet xRes = (XResultSet) UnoRuntime.queryInterface(XResultSet.class, xRowRes);
+ assure("No valid row! ", xRes.next());
+
+ return (XRow) UnoRuntime.queryInterface(XRow.class, xRes);
+ }
+
+ private void dayofweek(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "DAYOFWEEK('1998-02-03') ");
+ assure("DAYOFWEEK('1998-02-03') failed!", row.getInt(1) == 3);
+ }
+
+ private void dayofmonth(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "DAYOFMONTH('1998-02-03') ");
+ assure("DAYOFMONTH('1998-02-03') failed!", row.getInt(1) == 3);
+ }
+
+ private void dayofyear(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "DAYOFYEAR('1998-02-03') ");
+ assure("DAYOFYEAR('1998-02-03') failed!", row.getInt(1) == 34);
+ }
+
+ private void month(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "month('1998-02-03') ");
+ assure("month('1998-02-03') failed!", row.getInt(1) == 2);
+ }
+
+ private void dayname(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "DAYNAME('1998-02-05') ");
+ assure("DAYNAME('1998-02-05') failed!", row.getString(1).equals("Thursday"));
+ }
+
+ private void monthname(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "MONTHNAME('1998-02-05') ");
+ assure("MONTHNAME('1998-02-05') failed!", row.getString(1).equals("February"));
+ }
+
+ private void quarter(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "QUARTER('98-01-01'),QUARTER('98-04-01'),QUARTER('98-07-01'),QUARTER('98-10-01') ");
+ assure("QUARTER('98-01-01') failed!", row.getInt(1) == 1);
+ assure("QUARTER('98-04-01') failed!", row.getInt(2) == 2);
+ assure("QUARTER('98-07-01') failed!", row.getInt(3) == 3);
+ assure("QUARTER('98-10-01') failed!", row.getInt(4) == 4);
+ }
+
+ private void week(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "WEEK('1998-02-20') ");
+ assure("WEEK('1998-02-20') failed!", row.getInt(1) == 7);
+ }
+
+ private void year(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "YEAR('98-02-03') ");
+ assure("YEAR('98-02-03') failed!", row.getInt(1) == 98);
+ }
+
+ private void hour(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "HOUR('10:05:03') ");
+ assure("HOUR('10:05:03') failed!", row.getInt(1) == 10);
+ }
+
+ private void minute(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "MINUTE('98-02-03 10:05:03') ");
+ assure("MINUTE('98-02-03 10:05:03') failed!", row.getInt(1) == 5);
+ }
+
+ private void second(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "SECOND('10:05:03') ");
+ assure("SECOND('10:05:03') failed!", row.getInt(1) == 3);
+ }
+
+ private void curdate(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "CURDATE() ");
+ final com.sun.star.util.Date aDate = row.getDate(1);
+ testcase.getLog().println("CURDATE() is '" + aDate.Year + "-" + aDate.Month + "-" + aDate.Day + "'");
+ }
+
+ private void curtime(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "CURTIME() ");
+ final com.sun.star.util.Time aTime = row.getTime(1);
+ testcase.getLog().println("CURTIME() is '" + aTime.Hours + ":" + aTime.Minutes + ":" + aTime.Seconds + "'");
+ }
+
+ private void now(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "NOW() ");
+ final com.sun.star.util.DateTime aTime = row.getTimestamp(1);
+ testcase.getLog().println("NOW() is '" + aTime.Year + "-" + aTime.Month + "-" + aTime.Day + "'");
+ testcase.getLog().println("'" + aTime.Hours + ":" + aTime.Minutes + ":" + aTime.Seconds + "'");
}
}
diff --git a/connectivity/qa/drivers/dbase/DBaseDriverTest.java b/connectivity/qa/drivers/dbase/DBaseDriverTest.java
index 6fcbfa2d9a78..fd15eee54d00 100644
--- a/connectivity/qa/drivers/dbase/DBaseDriverTest.java
+++ b/connectivity/qa/drivers/dbase/DBaseDriverTest.java
@@ -27,60 +27,71 @@
* for a copy of the LGPLv3 License.
*
************************************************************************/
-package complex.connectivity;
+package qa.drivers.dbase;
-import com.sun.star.uno.UnoRuntime;
-import com.sun.star.util.XCloseable;
import com.sun.star.sdbc.*;
-import com.sun.star.sdb.*;
-import com.sun.star.beans.PropertyValue;
-import com.sun.star.beans.XPropertySet;
-
import com.sun.star.lang.XMultiServiceFactory;
-
import complexlib.ComplexTestCase;
-
-import java.io.PrintWriter;
-
-import util.utils;
import java.util.*;
import java.io.*;
+import share.LogWriter;
//import complex.connectivity.DBaseStringFunctions;
-public class DBaseDriverTest extends ComplexTestCase {
+public class DBaseDriverTest extends ComplexTestCase
+{
private static Properties props = new Properties();
private XDriver m_xDiver;
- private String where = "FROM \"biblio\" \"biblio\" where \"Identifier\" = 'BOR00'";
+ private String where = "FROM \"biblio\" \"biblio\" where \"Identifier\" = 'BOR00'";
- static {
- try {
+ static
+ {
+ try
+ {
String propsFile = "test.properties";
- props.load( new FileInputStream(propsFile) );
- } catch(Exception ex) {
+ props.load(new FileInputStream(propsFile));
+ }
+ catch (Exception ex)
+ {
throw new RuntimeException(ex);
}
}
- public String[] getTestMethodNames() {
- return new String[] { "Functions" };
+ public String[] getTestMethodNames()
+ {
+ return new String[]
+ {
+ "Functions"
+ };
}
- public String getTestObjectName() {
+ public String getTestObjectName()
+ {
return "DBaseDriverTest";
}
- public void assure2(String s,boolean b){
- assure(s,b);
+
+ public void assure2(String s, boolean b)
+ {
+ assure(s, b);
+ }
+
+ public LogWriter getLog()
+ {
+ return log;
}
- public void Functions() throws com.sun.star.uno.Exception,com.sun.star.beans.UnknownPropertyException {
- DBaseStringFunctions aStringTest = new DBaseStringFunctions(((XMultiServiceFactory)param.getMSF()),this);
+ public void Functions() throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ DBaseStringFunctions aStringTest = new DBaseStringFunctions(((XMultiServiceFactory) param.getMSF()), this);
aStringTest.testFunctions();
- DBaseNumericFunctions aNumericTest = new DBaseNumericFunctions(((XMultiServiceFactory)param.getMSF()),this);
+ DBaseNumericFunctions aNumericTest = new DBaseNumericFunctions(((XMultiServiceFactory) param.getMSF()), this);
aNumericTest.testFunctions();
- DBaseDateFunctions aDateTest = new DBaseDateFunctions(((XMultiServiceFactory)param.getMSF()),this);
+ DBaseDateFunctions aDateTest = new DBaseDateFunctions(((XMultiServiceFactory) param.getMSF()), this);
aDateTest.testFunctions();
+
+ DBaseSqlTests aSqlTest = new DBaseSqlTests(((XMultiServiceFactory) param.getMSF()), this);
+ aSqlTest.testFunctions();
}
}
diff --git a/connectivity/qa/drivers/dbase/DBaseNumericFunctions.java b/connectivity/qa/drivers/dbase/DBaseNumericFunctions.java
index 3e693c35f9a0..b31e92653f71 100644
--- a/connectivity/qa/drivers/dbase/DBaseNumericFunctions.java
+++ b/connectivity/qa/drivers/dbase/DBaseNumericFunctions.java
@@ -27,285 +27,379 @@
* for a copy of the LGPLv3 License.
*
************************************************************************/
-package complex.connectivity;
+package qa.drivers.dbase;
-import complex.connectivity.DBaseDriverTest;
import com.sun.star.uno.UnoRuntime;
-import com.sun.star.util.XCloseable;
import com.sun.star.sdbc.*;
-import com.sun.star.sdb.*;
-import com.sun.star.beans.PropertyValue;
import com.sun.star.beans.XPropertySet;
-
import com.sun.star.lang.XMultiServiceFactory;
-import complexlib.ComplexTestCase;
-
-import java.io.PrintWriter;
-
-import util.utils;
-import java.util.*;
-import java.io.*;
+public class DBaseNumericFunctions
+{
-public class DBaseNumericFunctions {
+ private final String where = "FROM \"biblio\" \"biblio\" where \"Identifier\" = 'BOR00'";
+ private final XMultiServiceFactory m_xORB;
+ private final DBaseDriverTest testcase;
- private String where = "FROM \"biblio\" \"biblio\" where \"Identifier\" = 'BOR00'";
- private XMultiServiceFactory m_xORB;
- private DBaseDriverTest testcase;
- public DBaseNumericFunctions(XMultiServiceFactory _xORB,DBaseDriverTest _testcase){
- m_xORB = _xORB;
- testcase = _testcase;
- }
+ public DBaseNumericFunctions(final XMultiServiceFactory _xORB, final DBaseDriverTest _testcase)
+ {
+ m_xORB = _xORB;
+ testcase = _testcase;
+ }
- private void assure(String s,boolean b){
- testcase.assure2(s,b);
- }
+ private void assure(final String s, final boolean b)
+ {
+ testcase.assure2(s, b);
+ }
- public void testFunctions() throws com.sun.star.uno.Exception,com.sun.star.beans.UnknownPropertyException {
- XRowSet xRowRes = (XRowSet)UnoRuntime.queryInterface(XRowSet.class,
- m_xORB.createInstance("com.sun.star.sdb.RowSet"));
+ public void testFunctions() throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRowSet xRowRes = (XRowSet) UnoRuntime.queryInterface(XRowSet.class,
+ m_xORB.createInstance("com.sun.star.sdb.RowSet"));
- System.out.println("starting Numeric function test");
+ testcase.getLog().println("starting Numeric function test");
// set the properties needed to connect to a database
- XPropertySet xProp = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class,xRowRes);
- xProp.setPropertyValue("DataSourceName","Bibliography");
+ final XPropertySet xProp = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xRowRes);
+ xProp.setPropertyValue("DataSourceName", "Bibliography");
- xProp.setPropertyValue("CommandType",new Integer(com.sun.star.sdb.CommandType.COMMAND));
+ xProp.setPropertyValue("CommandType", Integer.valueOf(com.sun.star.sdb.CommandType.COMMAND));
- try {
+ try
+ {
abs(xRowRes);
- } catch( SQLException ex){
- assure("abs " + ex.getMessage(),false);
+ }
+ catch (SQLException ex)
+ {
+ assure("abs " + ex.getMessage(), false);
throw ex;
}
- try{
+ try
+ {
acos(xRowRes);
- } catch( SQLException ex){
- assure("acos " + ex.getMessage(),false);
+ }
+ catch (SQLException ex)
+ {
+ assure("acos " + ex.getMessage(), false);
throw ex;
}
- try{
+ try
+ {
asin(xRowRes);
- } catch( SQLException ex){
- assure("asin " + ex.getMessage(),false);
+ }
+ catch (SQLException ex)
+ {
+ assure("asin " + ex.getMessage(), false);
throw ex;
}
- try{
+ try
+ {
atan(xRowRes);
- } catch( SQLException ex){
- assure("atan " + ex.getMessage(),false);
+ }
+ catch (SQLException ex)
+ {
+ assure("atan " + ex.getMessage(), false);
throw ex;
}
- try{
+ try
+ {
atan2(xRowRes);
- } catch( SQLException ex){
- assure("atan2 " + ex.getMessage(),false);
+ }
+ catch (SQLException ex)
+ {
+ assure("atan2 " + ex.getMessage(), false);
throw ex;
}
- try{
+ try
+ {
ceiling(xRowRes);
- } catch( SQLException ex){
- assure("ceiling " + ex.getMessage(),false);
+ }
+ catch (SQLException ex)
+ {
+ assure("ceiling " + ex.getMessage(), false);
throw ex;
}
- try{
+ try
+ {
cos(xRowRes);
- } catch( SQLException ex){
- assure("cos " + ex.getMessage(),false);
+ }
+ catch (SQLException ex)
+ {
+ assure("cos " + ex.getMessage(), false);
throw ex;
}
- try{
+ try
+ {
degrees(xRowRes);
- } catch( SQLException ex){
- assure("degrees " + ex.getMessage(),false);
+ }
+ catch (SQLException ex)
+ {
+ assure("degrees " + ex.getMessage(), false);
throw ex;
}
- try{
+ try
+ {
exp(xRowRes);
- } catch( SQLException ex){
- assure("exp " + ex.getMessage(),false);
+ }
+ catch (SQLException ex)
+ {
+ assure("exp " + ex.getMessage(), false);
throw ex;
}
- try{
+ try
+ {
floor(xRowRes);
- } catch( SQLException ex){
- assure("floor " + ex.getMessage(),false);
+ }
+ catch (SQLException ex)
+ {
+ assure("floor " + ex.getMessage(), false);
throw ex;
}
- try{
+ try
+ {
log(xRowRes);
- } catch( SQLException ex){
- assure("log " + ex.getMessage(),false);
+ }
+ catch (SQLException ex)
+ {
+ assure("log " + ex.getMessage(), false);
throw ex;
}
- try{
+ try
+ {
log10(xRowRes);
- } catch( SQLException ex){
- assure("log10 " + ex.getMessage(),false);
+ }
+ catch (SQLException ex)
+ {
+ assure("log10 " + ex.getMessage(), false);
throw ex;
}
- try{
+ try
+ {
mod(xRowRes);
- } catch( SQLException ex){
- assure("mod " + ex.getMessage(),false);
+ }
+ catch (SQLException ex)
+ {
+ assure("mod " + ex.getMessage(), false);
throw ex;
}
- try{
+ try
+ {
pi(xRowRes);
- } catch( SQLException ex){
- assure("pi " + ex.getMessage(),false);
+ }
+ catch (SQLException ex)
+ {
+ assure("pi " + ex.getMessage(), false);
throw ex;
}
- try{
+ try
+ {
pow(xRowRes);
- } catch( SQLException ex){
- assure("pow " + ex.getMessage(),false);
+ }
+ catch (SQLException ex)
+ {
+ assure("pow " + ex.getMessage(), false);
throw ex;
}
- try{
+ try
+ {
radians(xRowRes);
- } catch( SQLException ex){
- assure("radians " + ex.getMessage(),false);
+ }
+ catch (SQLException ex)
+ {
+ assure("radians " + ex.getMessage(), false);
throw ex;
}
- try{
+ try
+ {
round(xRowRes);
- } catch( SQLException ex){
- assure("round " + ex.getMessage(),false);
+ }
+ catch (SQLException ex)
+ {
+ assure("round " + ex.getMessage(), false);
throw ex;
}
- try{
+ try
+ {
sign(xRowRes);
- } catch( SQLException ex){
- assure("sign " + ex.getMessage(),false);
+ }
+ catch (SQLException ex)
+ {
+ assure("sign " + ex.getMessage(), false);
throw ex;
}
- try{
+ try
+ {
sin(xRowRes);
- } catch( SQLException ex){
- assure("sin " + ex.getMessage(),false);
+ }
+ catch (SQLException ex)
+ {
+ assure("sin " + ex.getMessage(), false);
throw ex;
}
- try{
+ try
+ {
sqrt(xRowRes);
- } catch( SQLException ex){
- assure("sqrt " + ex.getMessage(),false);
+ }
+ catch (SQLException ex)
+ {
+ assure("sqrt " + ex.getMessage(), false);
throw ex;
}
- try{
+ try
+ {
tan(xRowRes);
- } catch( SQLException ex){
- assure("tan " + ex.getMessage(),false);
+ }
+ catch (SQLException ex)
+ {
+ assure("tan " + ex.getMessage(), false);
throw ex;
}
}
- private XRow execute(XRowSet xRowRes,String sql) throws com.sun.star.uno.Exception,com.sun.star.beans.UnknownPropertyException {
- XPropertySet xProp = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class,xRowRes);
- xProp.setPropertyValue("Command","SELECT " + sql + where);
+ private XRow execute(final XRowSet xRowRes,final String sql) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XPropertySet xProp = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xRowRes);
+ xProp.setPropertyValue("Command", "SELECT " + sql + where);
xRowRes.execute();
- XResultSet xRes = (XResultSet)UnoRuntime.queryInterface(XResultSet.class,xRowRes);
- assure("No valid row! ",xRes.next());
+ final XResultSet xRes = (XResultSet) UnoRuntime.queryInterface(XResultSet.class, xRowRes);
+ assure("No valid row! ", xRes.next());
- return (XRow)UnoRuntime.queryInterface(XRow.class, xRes);
+ return (XRow) UnoRuntime.queryInterface(XRow.class, xRes);
}
- private void abs(XRowSet xRowRes) throws com.sun.star.uno.Exception,com.sun.star.beans.UnknownPropertyException {
- XRow row = execute(xRowRes,"ABS(2),ABS(-32) ");
- assure("ABS(2) failed!",row.getInt(1) == 2);
- assure("ABS(-32) failed!",row.getInt(2) == 32);
+ private void abs(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "ABS(2),ABS(-32) ");
+ assure("ABS(2) failed!", row.getInt(1) == 2);
+ assure("ABS(-32) failed!", row.getInt(2) == 32);
}
- private void sign(XRowSet xRowRes) throws com.sun.star.uno.Exception,com.sun.star.beans.UnknownPropertyException {
- XRow row = execute(xRowRes,"SIGN(-32),SIGN(0),SIGN(234) ");
- assure("SIGN(-32)failed!",row.getInt(1) == -1);
- assure("SIGN(0) failed!",row.getInt(2) == 0);
- assure("SIGN(234) failed!",row.getInt(3) == 1);
+ private void sign(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "SIGN(-32),SIGN(0),SIGN(234) ");
+ assure("SIGN(-32)failed!", row.getInt(1) == -1);
+ assure("SIGN(0) failed!", row.getInt(2) == 0);
+ assure("SIGN(234) failed!", row.getInt(3) == 1);
}
- private void mod(XRowSet xRowRes) throws com.sun.star.uno.Exception,com.sun.star.beans.UnknownPropertyException {
- XRow row = execute(xRowRes,"MOD(234, 10) ");
- assure("MOD(234, 10) failed!",row.getInt(1) == 4);
+ private void mod(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "MOD(234, 10) ");
+ assure("MOD(234, 10) failed!", row.getInt(1) == 4);
}
- private void floor(XRowSet xRowRes) throws com.sun.star.uno.Exception,com.sun.star.beans.UnknownPropertyException {
- XRow row = execute(xRowRes,"FLOOR(1.23),FLOOR(-1.23) ");
- assure("FLOOR(1.23) failed!",row.getInt(1) == 1);
- assure("FLOOR(-1.23) failed!",row.getInt(2) == -2);
+ private void floor(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "FLOOR(1.23),FLOOR(-1.23) ");
+ assure("FLOOR(1.23) failed!", row.getInt(1) == 1);
+ assure("FLOOR(-1.23) failed!", row.getInt(2) == -2);
}
- private void ceiling(XRowSet xRowRes) throws com.sun.star.uno.Exception,com.sun.star.beans.UnknownPropertyException {
- XRow row = execute(xRowRes,"CEILING(1.23),CEILING(-1.23) ");
- assure("CEILING(1.23) failed!",row.getInt(1) == 2);
- assure("CEILING(-1.23) failed!",row.getInt(2) == -1);
+
+ private void ceiling(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "CEILING(1.23),CEILING(-1.23) ");
+ assure("CEILING(1.23) failed!", row.getInt(1) == 2);
+ assure("CEILING(-1.23) failed!", row.getInt(2) == -1);
}
- private void round(XRowSet xRowRes) throws com.sun.star.uno.Exception,com.sun.star.beans.UnknownPropertyException {
- XRow row = execute(xRowRes,"ROUND(-1.23),ROUND(1.298, 1) ");
- assure("ROUND(-1.23) failed!",row.getInt(1) == -1);
- assure("ROUND(1.298, 1) failed!",row.getDouble(2) == 1.3);
+
+ private void round(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "ROUND(-1.23),ROUND(1.298, 1) ");
+ assure("ROUND(-1.23) failed!", row.getInt(1) == -1);
+ assure("ROUND(1.298, 1) failed!", row.getDouble(2) == 1.3);
}
- private void exp(XRowSet xRowRes) throws com.sun.star.uno.Exception,com.sun.star.beans.UnknownPropertyException {
- XRow row = execute(xRowRes,"EXP(2),EXP(-2) ");
- assure("EXP(2) failed!",(float)row.getDouble(1) == (float)java.lang.Math.exp(2) );
- assure("EXP(-2) failed!",(float)row.getDouble(2) == (float)java.lang.Math.exp(-2));
+
+ private void exp(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "EXP(2),EXP(-2) ");
+ assure("EXP(2) failed!", (float) row.getDouble(1) == (float) java.lang.Math.exp(2));
+ assure("EXP(-2) failed!", (float) row.getDouble(2) == (float) java.lang.Math.exp(-2));
}
- private void log(XRowSet xRowRes) throws com.sun.star.uno.Exception,com.sun.star.beans.UnknownPropertyException {
- XRow row = execute(xRowRes,"LOG(2),LOG(-2) ");
- assure("LOG(2) failed!",(float)row.getDouble(1) == (float)java.lang.Math.log(2) );
+
+ private void log(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "LOG(2),LOG(-2) ");
+ assure("LOG(2) failed!", (float) row.getDouble(1) == (float) java.lang.Math.log(2));
row.getDouble(2);
- assure("LOG(-2) failed!",row.wasNull());
+ assure("LOG(-2) failed!", row.wasNull());
}
- private void log10(XRowSet xRowRes) throws com.sun.star.uno.Exception,com.sun.star.beans.UnknownPropertyException {
- XRow row = execute(xRowRes,"LOG10(100) ");
- assure("LOG10(100) failed!",row.getDouble(1) == 2.0 );
+
+ private void log10(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "LOG10(100) ");
+ assure("LOG10(100) failed!", row.getDouble(1) == 2.0);
}
- private void pow(XRowSet xRowRes) throws com.sun.star.uno.Exception,com.sun.star.beans.UnknownPropertyException {
- XRow row = execute(xRowRes,"POWER(2,2) ");
- assure("POWER(2,2) failed!",row.getDouble(1) == 4.0 );
+
+ private void pow(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "POWER(2,2) ");
+ assure("POWER(2,2) failed!", row.getDouble(1) == 4.0);
}
- private void sqrt(XRowSet xRowRes) throws com.sun.star.uno.Exception,com.sun.star.beans.UnknownPropertyException {
- XRow row = execute(xRowRes,"SQRT(4) ");
- assure("SQRT(4) failed!",row.getDouble(1) == 2.0 );
+
+ private void sqrt(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "SQRT(4) ");
+ assure("SQRT(4) failed!", row.getDouble(1) == 2.0);
}
- private void pi(XRowSet xRowRes) throws com.sun.star.uno.Exception,com.sun.star.beans.UnknownPropertyException {
- XRow row = execute(xRowRes,"PI() ");
- assure("PI() failed!",(float)row.getDouble(1) == (float)java.lang.Math.PI );
+
+ private void pi(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "PI() ");
+ assure("PI() failed!", (float) row.getDouble(1) == (float) java.lang.Math.PI);
}
- private void cos(XRowSet xRowRes) throws com.sun.star.uno.Exception,com.sun.star.beans.UnknownPropertyException {
- XRow row = execute(xRowRes,"COS(PI()) ");
- assure("COS(PI()) failed!",row.getDouble(1) == -1.0 );
+
+ private void cos(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "COS(PI()) ");
+ assure("COS(PI()) failed!", row.getDouble(1) == -1.0);
}
- private void sin(XRowSet xRowRes) throws com.sun.star.uno.Exception,com.sun.star.beans.UnknownPropertyException {
- XRow row = execute(xRowRes,"SIN(2) ");
- assure("SIN(PI()) failed!",(float)row.getDouble(1) == (float)java.lang.Math.sin( 2 ) );
+
+ private void sin(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "SIN(2) ");
+ assure("SIN(PI()) failed!", (float) row.getDouble(1) == (float) java.lang.Math.sin(2));
}
- private void tan(XRowSet xRowRes) throws com.sun.star.uno.Exception,com.sun.star.beans.UnknownPropertyException {
- XRow row = execute(xRowRes,"TAN(PI()+1) ");
- assure("TAN(PI()+1) failed!",(float)row.getDouble(1) == (float)java.lang.Math.tan(java.lang.Math.PI+1.0) );
+
+ private void tan(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "TAN(PI()+1) ");
+ assure("TAN(PI()+1) failed!", (float) row.getDouble(1) == (float) java.lang.Math.tan(java.lang.Math.PI + 1.0));
}
- private void acos(XRowSet xRowRes) throws com.sun.star.uno.Exception,com.sun.star.beans.UnknownPropertyException {
- XRow row = execute(xRowRes,"ACOS(1) ");
- assure("ACOS(1) failed!",(float)row.getDouble(1) == 0.0 );
+
+ private void acos(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "ACOS(1) ");
+ assure("ACOS(1) failed!", (float) row.getDouble(1) == 0.0);
}
- private void asin(XRowSet xRowRes) throws com.sun.star.uno.Exception,com.sun.star.beans.UnknownPropertyException {
- XRow row = execute(xRowRes,"ASIN(0) ");
- assure("ASIN(0) failed!",(float)row.getDouble(1) == (float)java.lang.Math.asin(0.0) );
+
+ private void asin(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "ASIN(0) ");
+ assure("ASIN(0) failed!", (float) row.getDouble(1) == (float) java.lang.Math.asin(0.0));
}
- private void atan(XRowSet xRowRes) throws com.sun.star.uno.Exception,com.sun.star.beans.UnknownPropertyException {
- XRow row = execute(xRowRes,"ATAN(0) ");
- assure("ATAN(0) failed!",row.getDouble(1) == 0.0 );
+
+ private void atan(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "ATAN(0) ");
+ assure("ATAN(0) failed!", row.getDouble(1) == 0.0);
}
- private void atan2(XRowSet xRowRes) throws com.sun.star.uno.Exception,com.sun.star.beans.UnknownPropertyException {
- XRow row = execute(xRowRes,"ATAN2(0,2) ");
- assure("ATAN2(0,2) failed!",(float)row.getDouble(1) == 0.0 );
+
+ private void atan2(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "ATAN2(0,2) ");
+ assure("ATAN2(0,2) failed!", (float) row.getDouble(1) == 0.0);
}
- private void degrees(XRowSet xRowRes) throws com.sun.star.uno.Exception,com.sun.star.beans.UnknownPropertyException {
- XRow row = execute(xRowRes,"DEGREES(PI()) ");
- assure("DEGREES(PI()) failed!",row.getDouble(1) == 180.0 );
+
+ private void degrees(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "DEGREES(PI()) ");
+ assure("DEGREES(PI()) failed!", row.getDouble(1) == 180.0);
}
- private void radians(XRowSet xRowRes) throws com.sun.star.uno.Exception,com.sun.star.beans.UnknownPropertyException {
- XRow row = execute(xRowRes,"RADIANS(90) ");
- assure("RADIANS(90) failed!",(float)row.getDouble(1) == (float)(java.lang.Math.PI / 2.0) );
+
+ private void radians(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "RADIANS(90) ");
+ assure("RADIANS(90) failed!", (float) row.getDouble(1) == (float) (java.lang.Math.PI / 2.0));
}
}
diff --git a/connectivity/qa/drivers/dbase/DBaseSqlTests.java b/connectivity/qa/drivers/dbase/DBaseSqlTests.java
new file mode 100755
index 000000000000..0151952ad76b
--- /dev/null
+++ b/connectivity/qa/drivers/dbase/DBaseSqlTests.java
@@ -0,0 +1,99 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: DBaseStringFunctions.java,v $
+ * $Revision: 1.6 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package qa.drivers.dbase;
+
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.sdbc.*;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.lang.XMultiServiceFactory;
+
+public class DBaseSqlTests
+{
+ private final XMultiServiceFactory m_xORB;
+ private final DBaseDriverTest testcase;
+
+ public DBaseSqlTests(final XMultiServiceFactory _xORB,final DBaseDriverTest _testcase)
+ {
+ m_xORB = _xORB;
+ testcase = _testcase;
+ }
+
+ private void assure(final String s,final boolean b)
+ {
+ testcase.assure2(s, b);
+ }
+
+ public void testFunctions() throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRowSet xRowRes = (XRowSet) UnoRuntime.queryInterface(XRowSet.class,
+ m_xORB.createInstance("com.sun.star.sdb.RowSet"));
+
+ testcase.getLog().println("starting SQL test");
+ // set the properties needed to connect to a database
+ final XPropertySet xProp = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xRowRes);
+ xProp.setPropertyValue("DataSourceName", "Bibliography");
+ xProp.setPropertyValue("CommandType", Integer.valueOf(com.sun.star.sdb.CommandType.COMMAND));
+
+ execute(xRowRes,"1 FROM \"biblio\" \"biblio\" where \"Identifier\" like 'B%'");
+ execute(xRowRes,"1 FROM \"biblio\" \"biblio\" where not \"Identifier\" like 'B%'");
+ execute(xRowRes,"1 FROM \"biblio\" \"biblio\" where not \"Identifier\" not like 'B%'");
+ execute(xRowRes,"1 FROM \"biblio\" \"biblio\" where not(0 = 1)");
+ execute(xRowRes,"1 FROM \"biblio\" \"biblio\" where 0 = 0");
+ execute(xRowRes,"1 FROM \"biblio\" \"biblio\" where (0 = 0)");
+ execute(xRowRes,"1 FROM \"biblio\" \"biblio\" where 0 <> 1");
+ execute(xRowRes,"1 FROM \"biblio\" \"biblio\" where 0 < 1");
+ execute(xRowRes,"1 FROM \"biblio\" \"biblio\" where 2 > 1");
+ execute(xRowRes,"1,1+1,'a' + 'b' FROM \"biblio\" \"biblio\" where 2 > 1");
+ // execute(xRowRes,"1 FROM \"biblio\" \"biblio\" where (0 = 0) is true");
+ // execute(xRowRes,"1 FROM \"biblio\" \"biblio\" where not (0 = 0) is not true");
+ // execute(xRowRes,"1 FROM \"biblio\" \"biblio\" where 1 between 0 and 2");
+ execute(xRowRes,"1 FROM \"biblio\" \"biblio\" where not \"Identifier\" is NULL");
+ execute(xRowRes,"1 FROM \"biblio\" \"biblio\" where \"Identifier\" is not NULL");
+ execute(xRowRes,"1 FROM \"biblio\" \"biblio\" where \"Identifier\" = \"Identifier\"");
+ execute(xRowRes,"1 FROM \"biblio\" \"biblio\" where not(not(\"Identifier\" = \"Identifier\"))");
+ execute(xRowRes,"1 FROM \"biblio\" \"biblio\" where (1 = 1 and 2 = 1) or 3 = 33 or 4 = 44 or ('a' = 'a' and 'b' = 'b')");
+ }
+
+ private void execute(final XRowSet xRowRes, String sql) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ try
+ {
+ final XPropertySet xProp = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xRowRes);
+ xProp.setPropertyValue("Command", "SELECT " + sql);
+ xRowRes.execute();
+ }
+ catch(SQLException e)
+ {
+ testcase.getLog().println(sql + " Error: " + e.getMessage());
+ }
+ }
+
+
+}
diff --git a/connectivity/qa/drivers/dbase/DBaseStringFunctions.java b/connectivity/qa/drivers/dbase/DBaseStringFunctions.java
index 09ce4903b6a9..158a3f8e9489 100644
--- a/connectivity/qa/drivers/dbase/DBaseStringFunctions.java
+++ b/connectivity/qa/drivers/dbase/DBaseStringFunctions.java
@@ -27,244 +27,300 @@
* for a copy of the LGPLv3 License.
*
************************************************************************/
-package complex.connectivity;
+package qa.drivers.dbase;
-import complex.connectivity.DBaseDriverTest;
import com.sun.star.uno.UnoRuntime;
-import com.sun.star.util.XCloseable;
import com.sun.star.sdbc.*;
-import com.sun.star.sdb.*;
-import com.sun.star.beans.PropertyValue;
import com.sun.star.beans.XPropertySet;
-
import com.sun.star.lang.XMultiServiceFactory;
-import complexlib.ComplexTestCase;
-
-import java.io.PrintWriter;
-
-import util.utils;
-import java.util.*;
-import java.io.*;
-
+public class DBaseStringFunctions
+{
+ private String where = "FROM \"biblio\" \"biblio\" where \"Identifier\" = 'BOR00'";
+ private final XMultiServiceFactory m_xORB;
+ private final DBaseDriverTest testcase;
-public class DBaseStringFunctions {
-
- private String where = "FROM \"biblio\" \"biblio\" where \"Identifier\" = 'BOR00'";
- private XMultiServiceFactory m_xORB;
- private DBaseDriverTest testcase;
- public DBaseStringFunctions(XMultiServiceFactory _xORB,DBaseDriverTest _testcase){
- m_xORB = _xORB;
- testcase = _testcase;
- }
+ public DBaseStringFunctions(final XMultiServiceFactory _xORB,final DBaseDriverTest _testcase)
+ {
+ m_xORB = _xORB;
+ testcase = _testcase;
+ }
- private void assure(String s,boolean b){
- testcase.assure2(s,b);
- }
+ private void assure(final String s,final boolean b)
+ {
+ testcase.assure2(s, b);
+ }
- public void testFunctions() throws com.sun.star.uno.Exception,com.sun.star.beans.UnknownPropertyException {
- XRowSet xRowRes = (XRowSet)UnoRuntime.queryInterface(XRowSet.class,
- m_xORB.createInstance("com.sun.star.sdb.RowSet"));
+ public void testFunctions() throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRowSet xRowRes = (XRowSet) UnoRuntime.queryInterface(XRowSet.class,
+ m_xORB.createInstance("com.sun.star.sdb.RowSet"));
- System.out.println("starting String function test");
+ testcase.getLog().println("starting String function test");
// set the properties needed to connect to a database
- XPropertySet xProp = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class,xRowRes);
- xProp.setPropertyValue("DataSourceName","Bibliography");
+ final XPropertySet xProp = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xRowRes);
+ xProp.setPropertyValue("DataSourceName", "Bibliography");
- xProp.setPropertyValue("CommandType",new Integer(com.sun.star.sdb.CommandType.COMMAND));
+ xProp.setPropertyValue("CommandType", Integer.valueOf(com.sun.star.sdb.CommandType.COMMAND));
- try {
- upper(xRowRes);
- } catch( SQLException ex){
- assure("upper " + ex.getMessage(),false);
+ try
+ {
+ upper(xRowRes);
+ }
+ catch (SQLException ex)
+ {
+ assure("upper " + ex.getMessage(), false);
throw ex;
}
- try{
- lower(xRowRes);
- } catch( SQLException ex){
- assure("lower " + ex.getMessage(),false);
+ try
+ {
+ lower(xRowRes);
+ }
+ catch (SQLException ex)
+ {
+ assure("lower " + ex.getMessage(), false);
throw ex;
}
- try{
- acsii(xRowRes);
- } catch( SQLException ex){
- assure("ascii " + ex.getMessage(),false);
+ try
+ {
+ acsii(xRowRes);
+ }
+ catch (SQLException ex)
+ {
+ assure("ascii " + ex.getMessage(), false);
throw ex;
}
- try{
- char_length(xRowRes);
- } catch( SQLException ex){
- assure("char_len " + ex.getMessage(),false);
+ try
+ {
+ char_length(xRowRes);
+ }
+ catch (SQLException ex)
+ {
+ assure("char_len " + ex.getMessage(), false);
throw ex;
}
- try{
- concat(xRowRes);
- } catch( SQLException ex){
- assure("concat " + ex.getMessage(),false);
+ try
+ {
+ concat(xRowRes);
+ }
+ catch (SQLException ex)
+ {
+ assure("concat " + ex.getMessage(), false);
throw ex;
}
- try{
+ try
+ {
chartest(xRowRes);
- } catch( SQLException ex){
- assure("char " + ex.getMessage(),false);
+ }
+ catch (SQLException ex)
+ {
+ assure("char " + ex.getMessage(), false);
throw ex;
}
- try{
- locate(xRowRes);
- } catch( SQLException ex){
- assure("locate " + ex.getMessage(),false);
+ try
+ {
+ locate(xRowRes);
+ }
+ catch (SQLException ex)
+ {
+ assure("locate " + ex.getMessage(), false);
throw ex;
}
- try{
- substring(xRowRes);
- } catch( SQLException ex){
- assure("substr " + ex.getMessage(),false);
+ try
+ {
+ substring(xRowRes);
+ }
+ catch (SQLException ex)
+ {
+ assure("substr " + ex.getMessage(), false);
throw ex;
}
- try{
- ltrim(xRowRes);
- } catch( SQLException ex){
- assure("ltrim " + ex.getMessage(),false);
+ try
+ {
+ ltrim(xRowRes);
+ }
+ catch (SQLException ex)
+ {
+ assure("ltrim " + ex.getMessage(), false);
throw ex;
}
- try{
- rtrim(xRowRes);
- } catch( SQLException ex){
- assure("rtrim " + ex.getMessage(),false);
+ try
+ {
+ rtrim(xRowRes);
+ }
+ catch (SQLException ex)
+ {
+ assure("rtrim " + ex.getMessage(), false);
throw ex;
}
- try{
- space(xRowRes);
- } catch( SQLException ex){
- assure("space " + ex.getMessage(),false);
+ try
+ {
+ space(xRowRes);
+ }
+ catch (SQLException ex)
+ {
+ assure("space " + ex.getMessage(), false);
throw ex;
}
- try{
- replace(xRowRes);
- } catch( SQLException ex){
- assure("replace " + ex.getMessage(),false);
+ try
+ {
+ replace(xRowRes);
+ }
+ catch (SQLException ex)
+ {
+ assure("replace " + ex.getMessage(), false);
throw ex;
}
- try{
- repeat(xRowRes);
- } catch( SQLException ex){
- assure("repeat " + ex.getMessage(),false);
+ try
+ {
+ repeat(xRowRes);
+ }
+ catch (SQLException ex)
+ {
+ assure("repeat " + ex.getMessage(), false);
throw ex;
}
- try{
- insert(xRowRes);
- } catch( SQLException ex){
- assure("insert " + ex.getMessage(),false);
+ try
+ {
+ insert(xRowRes);
+ }
+ catch (SQLException ex)
+ {
+ assure("insert " + ex.getMessage(), false);
throw ex;
}
- try{
- left(xRowRes);
- } catch( SQLException ex){
- assure("left " + ex.getMessage(),false);
+ try
+ {
+ left(xRowRes);
+ }
+ catch (SQLException ex)
+ {
+ assure("left " + ex.getMessage(), false);
throw ex;
}
- try{
- right(xRowRes);
- } catch( SQLException ex){
- assure("right " + ex.getMessage(),false);
+ try
+ {
+ right(xRowRes);
+ }
+ catch (SQLException ex)
+ {
+ assure("right " + ex.getMessage(), false);
throw ex;
}
}
- private XRow execute(XRowSet xRowRes,String sql) throws com.sun.star.uno.Exception,com.sun.star.beans.UnknownPropertyException {
- XPropertySet xProp = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class,xRowRes);
- xProp.setPropertyValue("Command","SELECT " + sql + where);
+ private XRow execute(final XRowSet xRowRes, String sql) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XPropertySet xProp = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xRowRes);
+ xProp.setPropertyValue("Command", "SELECT " + sql + where);
xRowRes.execute();
- XResultSet xRes = (XResultSet)UnoRuntime.queryInterface(XResultSet.class,xRowRes);
- assure("No valid row! ",xRes.next());
+ final XResultSet xRes = (XResultSet) UnoRuntime.queryInterface(XResultSet.class, xRowRes);
+ assure("No valid row! ", xRes.next());
- return (XRow)UnoRuntime.queryInterface(XRow.class, xRes);
+ return (XRow) UnoRuntime.queryInterface(XRow.class, xRes);
}
- private void upper(XRowSet xRowRes) throws com.sun.star.uno.Exception,com.sun.star.beans.UnknownPropertyException {
- XRow row = execute(xRowRes,"upper('test'),UCASE('test') ");
- assure("upper('test') failed!",row.getString(1).equals("TEST"));
- assure("ucase('test') failed!",row.getString(2).equals("TEST"));
+ private void upper(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "upper('test'),UCASE('test') ");
+ assure("upper('test') failed!", row.getString(1).equals("TEST"));
+ assure("ucase('test') failed!", row.getString(2).equals("TEST"));
}
- private void lower(XRowSet xRowRes) throws com.sun.star.uno.Exception,com.sun.star.beans.UnknownPropertyException {
- XRow row = execute(xRowRes,"lower('TEST'),LCASE('TEST') ");
- assure("lower('TEST') failed!",row.getString(1).equals("test"));
- assure("lcase('TEST') failed!",row.getString(2).equals("test"));
- final String t = where;
+ private void lower(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "lower('TEST'),LCASE('TEST') ");
+ assure("lower('TEST') failed!", row.getString(1).equals("test"));
+ assure("lcase('TEST') failed!", row.getString(2).equals("test"));
+ final String temp = where;
where = "FROM \"biblio\" \"biblio\" where LOWER(\"Identifier\") like 'bor%'";
- row = execute(xRowRes,"lower('TEST'),LCASE('TEST') ");
- where = t;
+ execute(xRowRes, "lower('TEST'),LCASE('TEST') ");
+ where = temp;
}
- private void acsii(XRowSet xRowRes) throws com.sun.star.uno.Exception,com.sun.star.beans.UnknownPropertyException {
- XRow row = execute(xRowRes,"ASCII('2') ");
- assure("acsii('2') failed!",row.getInt(1) == 50);
+ private void acsii(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "ASCII('2') ");
+ assure("acsii('2') failed!", row.getInt(1) == 50);
}
- private void char_length(XRowSet xRowRes) throws com.sun.star.uno.Exception,com.sun.star.beans.UnknownPropertyException {
- XRow row = execute(xRowRes,"char_length('test'),character_length('test'),OCTET_LENGTH('test') ");
- assure("char_length('test') failed!",row.getInt(1) == 4);
- assure("character_length('test') failed!",row.getInt(2) == 4);
- assure("OCTET_LENGTH('test') failed!",row.getInt(3) == 4);
+ private void char_length(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "char_length('test'),character_length('test'),OCTET_LENGTH('test') ");
+ assure("char_length('test') failed!", row.getInt(1) == 4);
+ assure("character_length('test') failed!", row.getInt(2) == 4);
+ assure("OCTET_LENGTH('test') failed!", row.getInt(3) == 4);
}
- private void concat(XRowSet xRowRes) throws com.sun.star.uno.Exception,com.sun.star.beans.UnknownPropertyException {
- XRow row = execute(xRowRes,"CONCAT('Hello',' ','World') ");
- assure("CONCAT('Hello',' ',,'World') failed!",row.getString(1).equals("Hello World"));
+ private void concat(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "CONCAT('Hello',' ','World') ");
+ assure("CONCAT('Hello',' ',,'World') failed!", row.getString(1).equals("Hello World"));
}
- private void locate(XRowSet xRowRes) throws com.sun.star.uno.Exception,com.sun.star.beans.UnknownPropertyException {
- XRow row = execute(xRowRes,"LOCATE('bar', 'foobarbar') ");
- assure("LOCATE('bar', 'foobarbar') failed!",row.getInt(1) == 4);
+ private void locate(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "LOCATE('bar', 'foobarbar') ");
+ assure("LOCATE('bar', 'foobarbar') failed!", row.getInt(1) == 4);
}
- private void substring(XRowSet xRowRes) throws com.sun.star.uno.Exception,com.sun.star.beans.UnknownPropertyException {
- XRow row = execute(xRowRes,"SUBSTRING('Quadratically',5) ");
- assure("SUBSTRING('Quadratically',5) failed!",row.getString(1).equals("ratically"));
+ private void substring(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "SUBSTRING('Quadratically',5) ");
+ assure("SUBSTRING('Quadratically',5) failed!", row.getString(1).equals("ratically"));
}
- private void ltrim(XRowSet xRowRes) throws com.sun.star.uno.Exception,com.sun.star.beans.UnknownPropertyException {
- XRow row = execute(xRowRes,"LTRIM(' barbar') ");
- assure("LTRIM(' barbar') failed!",row.getString(1).equals("barbar"));
+ private void ltrim(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "LTRIM(' barbar') ");
+ assure("LTRIM(' barbar') failed!", row.getString(1).equals("barbar"));
}
- private void rtrim(XRowSet xRowRes) throws com.sun.star.uno.Exception,com.sun.star.beans.UnknownPropertyException {
- XRow row = execute(xRowRes,"RTRIM('barbar ') ");
- assure("RTRIM('barbar ') failed!",row.getString(1).equals( "barbar"));
+ private void rtrim(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "RTRIM('barbar ') ");
+ assure("RTRIM('barbar ') failed!", row.getString(1).equals("barbar"));
}
- private void space(XRowSet xRowRes) throws com.sun.star.uno.Exception,com.sun.star.beans.UnknownPropertyException {
- XRow row = execute(xRowRes,"space(6) ");
- assure("space(6) failed!",row.getString(1).equals(" "));
+ private void space(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "space(6) ");
+ assure("space(6) failed!", row.getString(1).equals(" "));
}
- private void replace(XRowSet xRowRes) throws com.sun.star.uno.Exception,com.sun.star.beans.UnknownPropertyException {
- XRow row = execute(xRowRes,"REPLACE('www.OOo.com', 'w', 'Ww') ");
- assure("REPLACE('www.OOo.com', 'w', 'Ww') failed!",row.getString(1).equals("WwWwWw.OOo.com"));
+ private void replace(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "REPLACE('www.OOo.com', 'w', 'Ww') ");
+ assure("REPLACE('www.OOo.com', 'w', 'Ww') failed!", row.getString(1).equals("WwWwWw.OOo.com"));
}
- private void repeat(XRowSet xRowRes) throws com.sun.star.uno.Exception,com.sun.star.beans.UnknownPropertyException {
- XRow row = execute(xRowRes,"REPEAT('OOo', 3) ");
- assure("REPEAT('OOo', 3) failed!",row.getString(1).equals("OOoOOoOOo"));
+ private void repeat(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "REPEAT('OOo', 3) ");
+ assure("REPEAT('OOo', 3) failed!", row.getString(1).equals("OOoOOoOOo"));
}
- private void insert(XRowSet xRowRes) throws com.sun.star.uno.Exception,com.sun.star.beans.UnknownPropertyException {
- XRow row = execute(xRowRes,"INSERT('Quadratic', 3, 4, 'What') ");
- assure("INSERT('Quadratic', 3, 4, 'What') failed!",row.getString(1).equals("QuWhattic"));
+ private void insert(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "INSERT('Quadratic', 3, 4, 'What') ");
+ assure("INSERT('Quadratic', 3, 4, 'What') failed!", row.getString(1).equals("QuWhattic"));
}
- private void left(XRowSet xRowRes) throws com.sun.star.uno.Exception,com.sun.star.beans.UnknownPropertyException {
- XRow row = execute(xRowRes,"LEFT('foobarbar', 5) ");
- assure("LEFT('foobarbar', 5) failed!",row.getString(1).equals("fooba"));
+ private void left(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "LEFT('foobarbar', 5) ");
+ assure("LEFT('foobarbar', 5) failed!", row.getString(1).equals("fooba"));
}
- private void right(XRowSet xRowRes) throws com.sun.star.uno.Exception,com.sun.star.beans.UnknownPropertyException {
- XRow row = execute(xRowRes,"RIGHT('foobarbar', 4) ");
- assure("RIGHT('foobarbar', 4) failed!",row.getString(1).equals("rbar"));
+ private void right(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "RIGHT('foobarbar', 4) ");
+ assure("RIGHT('foobarbar', 4) failed!", row.getString(1).equals("rbar"));
}
- private void chartest(XRowSet xRowRes) throws com.sun.star.uno.Exception,com.sun.star.beans.UnknownPropertyException {
- XRow row = execute(xRowRes,"CHAR(ascii('t'),ascii('e'),ascii('s'),ascii('t')) ");
- assure("CHAR(ascii('t'),ascii('e'),ascii('s'),ascii('t')) failed!",row.getString(1).equals("test"));
+
+ private void chartest(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "CHAR(ascii('t'),ascii('e'),ascii('s'),ascii('t')) ");
+ assure("CHAR(ascii('t'),ascii('e'),ascii('s'),ascii('t')) failed!", row.getString(1).equals("test"));
}
}
diff --git a/connectivity/qa/drivers/dbase/makefile.mk b/connectivity/qa/drivers/dbase/makefile.mk
index f7d2f79a7432..4544b2a2bc62 100644
--- a/connectivity/qa/drivers/dbase/makefile.mk
+++ b/connectivity/qa/drivers/dbase/makefile.mk
@@ -32,7 +32,7 @@
PRJ = ..$/..$/..
TARGET = DBaseDriverTest
PRJNAME = connectivity
-PACKAGE = complex$/connectivity
+PACKAGE = qa$/drivers$/dbase
# --- Settings -----------------------------------------------------
.INCLUDE: settings.mk
@@ -45,7 +45,8 @@ JAVAFILES =\
DBaseDateFunctions.java\
DBaseDriverTest.java\
DBaseNumericFunctions.java\
- DBaseStringFunctions.java
+ DBaseStringFunctions.java\
+ DBaseSqlTests.java
JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class)
@@ -62,6 +63,6 @@ JARCOMPRESS = TRUE
.INCLUDE : target.mk
-run:
- java -cp "$(CLASSPATH)$(PATH_SEPERATOR)$(SOLARBINDIR)$/OOoRunner.jar" org.openoffice.Runner -TestBase java_complex -o complex.connectivity.$(TARGET)
+run: $(CLASSDIR)$/$(JARTARGET)
+ java -cp "$(CLASSPATH)$(PATH_SEPERATOR)$(SOLARBINDIR)$/OOoRunner.jar" org.openoffice.Runner -TestBase java_complex -o qa.drivers.dbase.$(TARGET)
diff --git a/connectivity/source/commontools/DateConversion.cxx b/connectivity/source/commontools/DateConversion.cxx
index 5c43e5d50cf1..1b8f40f3b0d6 100644
--- a/connectivity/source/commontools/DateConversion.cxx
+++ b/connectivity/source/commontools/DateConversion.cxx
@@ -87,6 +87,7 @@ using namespace ::com::sun::star::beans;
break;
case DataType::CHAR:
case DataType::VARCHAR:
+ case DataType::LONGVARCHAR:
if (bQuote)
aRet += ::rtl::OUString::createFromAscii("'");
{
diff --git a/connectivity/source/commontools/dbtools.cxx b/connectivity/source/commontools/dbtools.cxx
index 6730d7beb9ce..5bd8c93cb639 100644
--- a/connectivity/source/commontools/dbtools.cxx
+++ b/connectivity/source/commontools/dbtools.cxx
@@ -1014,7 +1014,6 @@ try
Property* pResult = ::std::lower_bound(pNewProps, pNewProps + nNewLen,pOldProps[i].Name, ::comphelper::PropertyStringLessFunctor());
if ( pResult
&& ( pResult != pNewProps + nNewLen && pResult->Name == pOldProps[i].Name )
- && ( pResult->Attributes == pOldProps[i].Attributes )
&& ( (pResult->Attributes & PropertyAttribute::READONLY) == 0 )
&& ( pResult->Type.equals(pOldProps[i].Type)) )
{ // Attribute stimmen ueberein und Property ist nicht read-only
diff --git a/connectivity/source/drivers/file/FResultSet.cxx b/connectivity/source/drivers/file/FResultSet.cxx
index ca86fb2a3d73..d96245c06cda 100644
--- a/connectivity/source/drivers/file/FResultSet.cxx
+++ b/connectivity/source/drivers/file/FResultSet.cxx
@@ -1303,8 +1303,9 @@ void OResultSet::sortRows()
OSL_ENSURE((sal_Int32)m_aRow->get().size() > *aOrderByIter,"Invalid Index");
switch ((*(m_aRow->get().begin()+*aOrderByIter))->getValue().getTypeKind())
{
- case DataType::CHAR:
+ case DataType::CHAR:
case DataType::VARCHAR:
+ case DataType::LONGVARCHAR:
eKeyType[i] = SQL_ORDERBYKEY_STRING;
break;
@@ -1471,6 +1472,7 @@ BOOL OResultSet::OpenImpl()
if(IsSorted())
{
aOrderbyColumnNumberSave = m_aOrderbyColumnNumber;// .assign(m_aOrderbyColumnNumber.begin(), m_aOrderbyColumnNumber.end());
+ m_aOrderbyColumnNumber.clear();
aOrderbyAscendingSave.assign(m_aOrderbyAscending.begin(), m_aOrderbyAscending.end());
bWasSorted = TRUE;
}
diff --git a/connectivity/source/drivers/file/FStatement.cxx b/connectivity/source/drivers/file/FStatement.cxx
index 72ad91dbfa73..07cdf95d7b44 100644
--- a/connectivity/source/drivers/file/FStatement.cxx
+++ b/connectivity/source/drivers/file/FStatement.cxx
@@ -796,6 +796,7 @@ void OStatement_Base::SetAssignValue(const String& aColumnName,
// Kriterium je nach Typ als String oder double in die Variable packen ...
case DataType::CHAR:
case DataType::VARCHAR:
+ case DataType::LONGVARCHAR:
*(m_aAssignValues->get())[nId] = ORowSetValue(aValue);
// Zeichensatz ist bereits konvertiert, da ja das gesamte Statement konvertiert wurde
break;
diff --git a/connectivity/source/drivers/file/fcode.cxx b/connectivity/source/drivers/file/fcode.cxx
index 0bd0d354ba02..4b2865a67aa2 100644
--- a/connectivity/source/drivers/file/fcode.cxx
+++ b/connectivity/source/drivers/file/fcode.cxx
@@ -65,6 +65,7 @@ TYPEINIT1(OStopOperand, OOperandValue);
TYPEINIT1(OOperator, OCode);
TYPEINIT1(OBoolOperator,OOperator);
+TYPEINIT1(OOp_NOT, OBoolOperator);
TYPEINIT1(OOp_AND, OBoolOperator);
TYPEINIT1(OOp_OR, OBoolOperator);
TYPEINIT1(OOp_ISNULL, OBoolOperator);
@@ -242,6 +243,29 @@ void OBoolOperator::Exec(OCodeStack& rCodeStack)
if (IS_TYPE(OOperandResult,pRight))
delete pRight;
}
+//------------------------------------------------------------------
+sal_Bool OOp_NOT::operate(const OOperand* pLeft, const OOperand* ) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OOp_AND::operate" );
+ return !pLeft->isValid();
+}
+//------------------------------------------------------------------
+void OOp_NOT::Exec(OCodeStack& rCodeStack)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OOp_ISNULL::Exec" );
+ OOperand* pOperand = rCodeStack.top();
+ rCodeStack.pop();
+
+ rCodeStack.push(new OOperandResultBOOL(operate(pOperand)));
+ if (IS_TYPE(OOperandResult,pOperand))
+ delete pOperand;
+}
+//------------------------------------------------------------------
+sal_uInt16 OOp_NOT::getRequestedOperands() const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OOp_NOT::getRequestedOperands" );
+ return 1;
+}
//------------------------------------------------------------------
sal_Bool OOp_AND::operate(const OOperand* pLeft, const OOperand* pRight) const
@@ -331,6 +355,7 @@ sal_Bool OOp_COMPARE::operate(const OOperand* pLeft, const OOperand* pRight) con
{
case DataType::CHAR:
case DataType::VARCHAR:
+ case DataType::LONGVARCHAR:
{
rtl::OUString sLH = aLH, sRH = aRH;
INT32 nRes = rtl_ustr_compareIgnoreAsciiCase_WithLength
diff --git a/connectivity/source/drivers/file/fcomp.cxx b/connectivity/source/drivers/file/fcomp.cxx
index de243f83c71c..9c801d6d9b98 100644
--- a/connectivity/source/drivers/file/fcomp.cxx
+++ b/connectivity/source/drivers/file/fcomp.cxx
@@ -166,7 +166,7 @@ OOperand* OPredicateCompiler::execute(OSQLParseNode* pPredicateNode)
}
else if ((SQL_ISRULE(pPredicateNode,search_condition) || (SQL_ISRULE(pPredicateNode,boolean_term)))
&& // AND/OR-Verknuepfung:
- pPredicateNode->count() == 3)
+ pPredicateNode->count() == 3)
{
execute(pPredicateNode->getChild(0)); // Bearbeiten des linken Zweigs
execute(pPredicateNode->getChild(2)); // Bearbeiten des rechten Zweigs
@@ -183,6 +183,11 @@ OOperand* OPredicateCompiler::execute(OSQLParseNode* pPredicateNode)
DBG_ERROR("OPredicateCompiler: Fehler im Parse Tree");
}
}
+ else if (SQL_ISRULE(pPredicateNode,boolean_factor))
+ {
+ execute(pPredicateNode->getChild(1));
+ m_aCodeList.push_back(new OOp_NOT());
+ }
else if (SQL_ISRULE(pPredicateNode,comparison_predicate))
{
execute_COMPARE(pPredicateNode);
diff --git a/connectivity/source/drivers/file/quotedstring.cxx b/connectivity/source/drivers/file/quotedstring.cxx
index 5cf56aec9375..abd2d3b51e44 100644
--- a/connectivity/source/drivers/file/quotedstring.cxx
+++ b/connectivity/source/drivers/file/quotedstring.cxx
@@ -113,7 +113,7 @@ namespace connectivity
if ( nStartPos >= nLen )
return;
- sal_Unicode* pData = _rStr.AllocBuffer(nLen - nStartPos);
+ sal_Unicode* pData = _rStr.AllocBuffer( nLen - nStartPos + 1 );
const sal_Unicode* pStart = pData;
// Suche bis Stringende nach dem ersten nicht uebereinstimmenden Zeichen
for( xub_StrLen i = nStartPos; i < nLen; ++i )
@@ -135,6 +135,7 @@ namespace connectivity
{
// String-Ende
bInString = FALSE;
+ *pData = 0;
}
}
else
@@ -151,6 +152,7 @@ namespace connectivity
// Vorzeitiger Abbruch der Schleife moeglich, denn
// wir haben, was wir wollten.
nStartPos = i+1;
+ *pData = 0;
break;
}
else
diff --git a/connectivity/source/drivers/flat/ETable.cxx b/connectivity/source/drivers/flat/ETable.cxx
index 75a89df55bc0..fa4f281ea794 100644
--- a/connectivity/source/drivers/flat/ETable.cxx
+++ b/connectivity/source/drivers/flat/ETable.cxx
@@ -660,7 +660,10 @@ sal_Bool OFlatTable::fetchRow(OValueRefRow& _rRow,const OSQLColumns & _rCols,sal
}
return sal_True;
}
-
+void OFlatTable::refreshHeader()
+{
+ m_nRowPos = 0;
+}
// -----------------------------------------------------------------------------
sal_Bool OFlatTable::seekRow(IResultSetHelper::Movement eCursorPosition, sal_Int32 nOffset, sal_Int32& nCurPos)
{
@@ -692,7 +695,7 @@ sal_Bool OFlatTable::seekRow(IResultSetHelper::Movement eCursorPosition, sal_Int
m_pFileStream->Seek(m_nFilePos);
if ( m_pFileStream->IsEof() || !readLine(nCurPos) /*|| !checkHeaderLine()*/)
{
- m_nMaxRowCount = m_nRowPos;
+ m_nMaxRowCount = m_nRowPos -1;
return sal_False;
} // if ( m_pFileStream->IsEof() || !readLine(nCurPos) /*|| !checkHeaderLine()*/)
@@ -797,7 +800,10 @@ sal_Bool OFlatTable::seekRow(IResultSetHelper::Movement eCursorPosition, sal_Int
TRowPositionsInFile::const_iterator aFind = m_aFilePosToEndLinePos.find(nOffset);
m_bNeedToReadLine = aFind != m_aFilePosToEndLinePos.end();
if ( m_bNeedToReadLine )
+ {
+ m_nFilePos = aFind->first;
nCurPos = aFind->second;
+ }
else
{
m_nFilePos = nOffset;
diff --git a/connectivity/source/drivers/flat/flat.xcu b/connectivity/source/drivers/flat/flat.xcu
index e70996e8ffa0..953d1179aa64 100755
--- a/connectivity/source/drivers/flat/flat.xcu
+++ b/connectivity/source/drivers/flat/flat.xcu
@@ -104,7 +104,7 @@
</node>
<node oor:name="MediaType" oor:op="replace">
<prop oor:name="Value" oor:type="xs:string">
- <value>application/csv</value>
+ <value>text/csv</value>
</prop>
</node>
</node>
diff --git a/connectivity/source/inc/file/fcode.hxx b/connectivity/source/inc/file/fcode.hxx
index f916beb91aae..1869a45ca4c5 100644
--- a/connectivity/source/inc/file/fcode.hxx
+++ b/connectivity/source/inc/file/fcode.hxx
@@ -236,6 +236,16 @@ namespace connectivity
virtual sal_Bool operate(const OOperand*, const OOperand*) const;
};
+ class OOp_NOT : public OBoolOperator
+ {
+ public:
+ TYPEINFO();
+
+ protected:
+ virtual void Exec(OCodeStack&);
+ virtual sal_Bool operate(const OOperand*, const OOperand* = NULL) const;
+ virtual sal_uInt16 getRequestedOperands() const;
+ };
class OOp_AND : public OBoolOperator
{
diff --git a/connectivity/source/inc/flat/ETable.hxx b/connectivity/source/inc/flat/ETable.hxx
index b52898655111..5d34cfd75b1d 100644
--- a/connectivity/source/inc/flat/ETable.hxx
+++ b/connectivity/source/inc/flat/ETable.hxx
@@ -87,6 +87,7 @@ namespace connectivity
virtual sal_Bool seekRow(IResultSetHelper::Movement eCursorPosition, sal_Int32 nOffset, sal_Int32& nCurPos);
virtual sal_Bool fetchRow(OValueRefRow& _rRow,const OSQLColumns& _rCols, sal_Bool bIsTable,sal_Bool bRetrieveData);
+ virtual void refreshHeader();
virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException);
//XTypeProvider
diff --git a/connectivity/source/parse/sqlflex.l b/connectivity/source/parse/sqlflex.l
index 6159f79e1b28..e365fdec1eca 100644
--- a/connectivity/source/parse/sqlflex.l
+++ b/connectivity/source/parse/sqlflex.l
@@ -483,7 +483,7 @@ sal_Int32 gatherString( sal_Int32 delim, sal_Int32 nTyp)
}
}
- else if (ch == '\r' || ch == '\n')
+ else if (nTyp != 1 && (ch == '\r' || ch == '\n') )
break;
else
{
diff --git a/connectivity/source/resource/conn_shared_res.src b/connectivity/source/resource/conn_shared_res.src
index 92b3e5814f4e..d143dad1ba0f 100644
--- a/connectivity/source/resource/conn_shared_res.src
+++ b/connectivity/source/resource/conn_shared_res.src
@@ -407,7 +407,7 @@ String STR_COULD_NOT_CREATE_INDEX_NAME
};
String STR_COULD_NOT_CREATE_INDEX_KEYSIZE
{
- Text [ en-US ] = "The index could not be created. The size of the choosen column is to big.";
+ Text [ en-US ] = "The index could not be created. The size of the chosen column is to big.";
};
String STR_SQL_NAME_ERROR
diff --git a/formula/source/ui/dlg/formula.cxx b/formula/source/ui/dlg/formula.cxx
index 1e5b55b7b67f..37db1d2eb3cb 100644
--- a/formula/source/ui/dlg/formula.cxx
+++ b/formula/source/ui/dlg/formula.cxx
@@ -1605,6 +1605,7 @@ void FormulaDlg_Impl::Update()
{
FormEditData* pData = m_pHelper->getFormEditData();
const String sExpression = pMEdit->GetText();
+ aOldFormula = String();
UpdateTokenArray(sExpression);
FormulaCursorHdl(&aMEFormula);
CalcStruct(sExpression);
diff --git a/sfx2/source/dialog/templdlg.cxx b/sfx2/source/dialog/templdlg.cxx
index 2f3ccf86e344..706739cd0571 100644
--- a/sfx2/source/dialog/templdlg.cxx
+++ b/sfx2/source/dialog/templdlg.cxx
@@ -102,8 +102,8 @@ using namespace ::com::sun::star::uno;
static USHORT nLastItemId = USHRT_MAX;
-// filter box has maximum 7 entries visible
-#define MAX_FILTER_ENTRIES 7
+// filter box has maximum 12 entries visible
+#define MAX_FILTER_ENTRIES 12
//=========================================================================
@@ -1299,7 +1299,7 @@ void SfxCommonTemplateDialog_Impl::UpdateStyles_Impl(USHORT nFlags) // Flags
if(pTreeBox)
aFilterLb.SelectEntry(String(SfxResId(STR_STYLE_FILTER_HIERARCHICAL)));
- // show maximum seven entries
+ // show maximum 12 entries
aFilterLb.SetDropDownLineCount( MAX_FILTER_ENTRIES );
aFilterLb.SetUpdateMode(TRUE);
}