summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrank Schoenheit [fs] <frank.schoenheit@sun.com>2009-11-17 10:27:21 +0100
committerFrank Schoenheit [fs] <frank.schoenheit@sun.com>2009-11-17 10:27:21 +0100
commit0d19f60a924fe972715406360b4da7db71118c5e (patch)
tree2191c987e18e36c9c4594a5e7d628de0bde4bca2
parent877586efd2344e76cdb924b86faaef642858d9ba (diff)
parent01da86c29a23c3260f54774929b11897784cef0a (diff)
merge
-rw-r--r--connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeInputStreamHelper.java31
-rw-r--r--connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageNativeInputStream.java29
-rw-r--r--connectivity/inc/connectivity/BlobHelper.hxx54
-rw-r--r--connectivity/inc/connectivity/dbtools.hxx15
-rw-r--r--connectivity/inc/connectivity/sqliterator.hxx3
-rw-r--r--connectivity/inc/connectivity/sqlnode.hxx4
-rw-r--r--connectivity/qa/connectivity/GeneralTest.java10
-rwxr-xr-xconnectivity/qa/connectivity/tools/AbstractDatabase.java31
-rw-r--r--connectivity/qa/connectivity/tools/CRMDatabase.java295
-rw-r--r--connectivity/qa/connectivity/tools/DataSource.java40
-rwxr-xr-xconnectivity/qa/connectivity/tools/DatabaseAccess.java4
-rw-r--r--connectivity/qa/connectivity/tools/HsqlDatabase.java13
-rw-r--r--connectivity/qa/connectivity/tools/HsqlTableDescriptor.java16
-rw-r--r--connectivity/qa/connectivity/tools/makefile.mk14
-rw-r--r--connectivity/qa/connectivity/tools/sdb/Connection.java93
-rw-r--r--connectivity/source/commontools/BlobHelper.cxx72
-rw-r--r--connectivity/source/commontools/FValue.cxx125
-rw-r--r--connectivity/source/commontools/dbtools.cxx103
-rw-r--r--connectivity/source/commontools/makefile.mk1
-rw-r--r--connectivity/source/commontools/predicateinput.cxx5
-rw-r--r--connectivity/source/drivers/ado/AResultSet.cxx24
-rw-r--r--connectivity/source/drivers/ado/Aolevariant.cxx93
-rw-r--r--connectivity/source/drivers/ado/adoimp.cxx2
-rw-r--r--connectivity/source/drivers/file/FStatement.cxx17
-rw-r--r--connectivity/source/drivers/jdbc/Boolean.cxx10
-rw-r--r--connectivity/source/drivers/jdbc/CallableStatement.cxx12
-rw-r--r--connectivity/source/drivers/jdbc/Clob.cxx7
-rw-r--r--connectivity/source/drivers/jdbc/InputStream.cxx8
-rw-r--r--connectivity/source/drivers/jdbc/JConnection.cxx27
-rw-r--r--connectivity/source/drivers/jdbc/Object.cxx12
-rw-r--r--connectivity/source/drivers/jdbc/PreparedStatement.cxx7
-rw-r--r--connectivity/source/drivers/jdbc/ResultSet.cxx114
-rw-r--r--connectivity/source/drivers/jdbc/Timestamp.cxx14
-rw-r--r--connectivity/source/drivers/jdbc/makefile.mk1
-rw-r--r--connectivity/source/drivers/jdbc/tools.cxx57
-rw-r--r--connectivity/source/drivers/odbcbase/ODatabaseMetaData.cxx10
-rw-r--r--connectivity/source/drivers/odbcbase/OPreparedStatement.cxx37
-rw-r--r--connectivity/source/drivers/odbcbase/OResultSet.cxx8
-rw-r--r--connectivity/source/drivers/odbcbase/OTools.cxx3
-rw-r--r--connectivity/source/inc/ado/Aolevariant.hxx1
-rw-r--r--connectivity/source/inc/java/lang/Boolean.hxx1
-rw-r--r--connectivity/source/inc/java/sql/Connection.hxx5
-rw-r--r--connectivity/source/inc/java/sql/Timestamp.hxx3
-rw-r--r--connectivity/source/inc/java/tools.hxx4
-rw-r--r--connectivity/source/inc/odbc/OPreparedStatement.hxx3
-rw-r--r--connectivity/source/parse/sqlbison.y6
-rw-r--r--connectivity/source/parse/sqliterator.cxx98
-rw-r--r--connectivity/source/parse/sqlnode.cxx38
-rw-r--r--desktop/source/app/app.cxx7
-rw-r--r--officecfg/registry/data/org/openoffice/Office/DataAccess.xcu2
-rw-r--r--officecfg/registry/schema/org/openoffice/Office/DataAccess.xcs8
-rw-r--r--scripting/source/dlgprov/dlgevtatt.cxx142
-rw-r--r--svx/inc/svx/fmgridcl.hxx5
-rw-r--r--svx/inc/svx/gridctrl.hxx7
-rw-r--r--svx/source/cui/dbregister.cxx147
-rw-r--r--svx/source/cui/dbregister.hxx2
-rw-r--r--svx/source/cui/dbregisterednamesconfig.cxx176
-rw-r--r--svx/source/cui/dbregistersettings.cxx18
-rw-r--r--svx/source/cui/dbregistersettings.hxx40
-rw-r--r--svx/source/fmcomp/fmgridcl.cxx14
-rw-r--r--svx/source/fmcomp/fmgridif.cxx66
-rw-r--r--svx/source/fmcomp/gridctrl.cxx46
-rw-r--r--svx/source/form/fmvwimp.cxx6
-rw-r--r--svx/source/form/formcontrolfactory.cxx3
-rw-r--r--svx/source/src/app.src19
65 files changed, 1674 insertions, 614 deletions
diff --git a/connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeInputStreamHelper.java b/connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeInputStreamHelper.java
index 60b5bed9dc..53a83c4425 100644
--- a/connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeInputStreamHelper.java
+++ b/connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeInputStreamHelper.java
@@ -1,4 +1,33 @@
-/*
+/*************************************************************************
+ *
+ * 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: StorageFileAccess.java,v $
+ * $Revision: 1.11 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+ /*
* NativeInputStreamHelper.java
*
* Created on 9. September 2004, 11:51
diff --git a/connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageNativeInputStream.java b/connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageNativeInputStream.java
index 55439f2c3b..38caa8bd96 100644
--- a/connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageNativeInputStream.java
+++ b/connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageNativeInputStream.java
@@ -1,3 +1,32 @@
+/*************************************************************************
+ *
+ * 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: StorageFileAccess.java,v $
+ * $Revision: 1.11 $
+ *
+ * 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.
+ *
+ ************************************************************************/
/*
* StorageNativeInputStream.java
*
diff --git a/connectivity/inc/connectivity/BlobHelper.hxx b/connectivity/inc/connectivity/BlobHelper.hxx
new file mode 100644
index 0000000000..10142513ed
--- /dev/null
+++ b/connectivity/inc/connectivity/BlobHelper.hxx
@@ -0,0 +1,54 @@
+/*************************************************************************
+ *
+ * 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: FValue.cxx,v $
+ * $Revision: 1.34 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef _CONNECTIVITY_BLOBHELPER_HXX_
+#define _CONNECTIVITY_BLOBHELPER_HXX_
+
+#include "connectivity/dbtoolsdllapi.hxx"
+#include <com/sun/star/sdbc/XBlob.hpp>
+#include <cppuhelper/implbase1.hxx>
+
+namespace connectivity
+{
+ class OOO_DLLPUBLIC_DBTOOLS BlobHelper : public ::cppu::WeakImplHelper1< com::sun::star::sdbc::XBlob >
+ {
+ ::com::sun::star::uno::Sequence< sal_Int8 > m_aValue;
+ public:
+ BlobHelper(const ::com::sun::star::uno::Sequence< sal_Int8 >& _val);
+ private:
+ virtual ::sal_Int64 SAL_CALL length( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::sal_Int8 > SAL_CALL getBytes( ::sal_Int64 pos, ::sal_Int32 length ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getBinaryStream( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Int64 SAL_CALL position( const ::com::sun::star::uno::Sequence< ::sal_Int8 >& pattern, ::sal_Int64 start ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Int64 SAL_CALL positionOfBlob( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XBlob >& pattern, ::sal_Int64 start ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ };
+}
+
+#endif //_CONNECTIVITY_BLOBHELPER_HXX_
+
diff --git a/connectivity/inc/connectivity/dbtools.hxx b/connectivity/inc/connectivity/dbtools.hxx
index 8afd0b7fa6..b0b7550611 100644
--- a/connectivity/inc/connectivity/dbtools.hxx
+++ b/connectivity/inc/connectivity/dbtools.hxx
@@ -37,6 +37,7 @@
#include <comphelper/stl_types.hxx>
#include <unotools/sharedunocomponent.hxx>
#include "connectivity/dbtoolsdllapi.hxx"
+#include "connectivity/FValue.hxx"
namespace com { namespace sun { namespace star {
@@ -593,6 +594,20 @@ namespace dbtools
sal_Int32 sqlType,
sal_Int32 scale=0) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ /** call the appropiate set method for the specific sql type @see com::sun::star::sdbc::DataType
+ @param _xParams the parameters where to set the value
+ @param parameterIndex the index of the parameter, 1 based
+ @param x the value to set
+ @param sqlType the corresponding sql type @see com::sun::star::sdbc::DataType
+ @param scale the scale of the sql type can be 0
+ */
+ OOO_DLLPUBLIC_DBTOOLS
+ void setObjectWithInfo( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XParameters>& _xParameters,
+ sal_Int32 parameterIndex,
+ const ::connectivity::ORowSetValue& x,
+ sal_Int32 sqlType,
+ sal_Int32 scale=0) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
/** implements <method scope="com.sun.star.sdb">XParameters::setObject</method>
<p>The object which is to be set is analyzed, and in case it is a simlpe scalar type for which there
diff --git a/connectivity/inc/connectivity/sqliterator.hxx b/connectivity/inc/connectivity/sqliterator.hxx
index 9d39e2a997..ea11a64c7e 100644
--- a/connectivity/inc/connectivity/sqliterator.hxx
+++ b/connectivity/inc/connectivity/sqliterator.hxx
@@ -279,6 +279,9 @@ namespace connectivity
// return true when the tableNode is a rule like catalog_name, schema_name or table_name
sal_Bool isTableNode(const OSQLParseNode* _pTableNode) const;
+
+ // tries to find the correct type of the function
+ sal_Int32 getFunctionReturnType(const OSQLParseNode* _pNode );
private:
/** traverses the list of table names, and filles _rTables
*/
diff --git a/connectivity/inc/connectivity/sqlnode.hxx b/connectivity/inc/connectivity/sqlnode.hxx
index ad04cd29f4..637fb1a8f3 100644
--- a/connectivity/inc/connectivity/sqlnode.hxx
+++ b/connectivity/inc/connectivity/sqlnode.hxx
@@ -225,6 +225,10 @@ namespace connectivity
as,
op_column_commalist,
table_primary_as_range_column,
+ datetime_primary,
+ concatenation,
+ char_factor,
+ bit_value_fct,
rule_count, // letzter_wert
UNKNOWN_RULE // ID indicating that a node is no rule with a matching Rule-enum value (see getKnownRuleID)
};
diff --git a/connectivity/qa/connectivity/GeneralTest.java b/connectivity/qa/connectivity/GeneralTest.java
index f6284ff390..29c8dc15fb 100644
--- a/connectivity/qa/connectivity/GeneralTest.java
+++ b/connectivity/qa/connectivity/GeneralTest.java
@@ -30,21 +30,13 @@
package complex.connectivity;
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 complex.connectivity.DBaseStringFunctions;
public class GeneralTest extends ComplexTestCase {
@@ -63,7 +55,7 @@ public class GeneralTest extends ComplexTestCase {
public void test() throws com.sun.star.uno.Exception,com.sun.star.beans.UnknownPropertyException {
try
{
- XDriverManager driverManager = (XDriverManager)UnoRuntime.queryInterface(XDriverManager.class,((XMultiServiceFactory)param.getMSF()).createInstance("com.sun.star.sdbc.DriverManager"));
+ XDriverManager driverManager = UnoRuntime.queryInterface( XDriverManager.class, ((XMultiServiceFactory)param.getMSF()).createInstance( "com.sun.star.sdbc.DriverManager" ) );
String databaseURL = "sdbc:calc:singin' in the rain" ;
XConnection catalogConnection = driverManager.getConnection(databaseURL);
failed();
diff --git a/connectivity/qa/connectivity/tools/AbstractDatabase.java b/connectivity/qa/connectivity/tools/AbstractDatabase.java
index 60a35c1d3d..fca1e60b41 100755
--- a/connectivity/qa/connectivity/tools/AbstractDatabase.java
+++ b/connectivity/qa/connectivity/tools/AbstractDatabase.java
@@ -38,10 +38,10 @@ 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 connectivity.tools.sdb.Connection;
import java.io.File;
/**
@@ -60,7 +60,7 @@ public abstract class AbstractDatabase implements DatabaseAccess
// the data source belonging to the database document
protected DataSource m_dataSource;
// the default connection
- protected XConnection m_connection;
+ protected Connection m_connection;
public AbstractDatabase(final XMultiServiceFactory orb) throws Exception
{
@@ -80,12 +80,10 @@ public abstract class AbstractDatabase implements DatabaseAccess
* the ownership of the connection, so you don't need to (and should not) dispose/close it.
*
*/
- public XConnection defaultConnection() throws SQLException
+ public Connection defaultConnection() throws SQLException
{
- if (m_connection == null)
- {
- m_connection = m_databaseDocument.getDataSource().getConnection("", "");
- }
+ if ( m_connection == null )
+ m_connection = new Connection( m_databaseDocument.getDataSource().getConnection("", "") );
return m_connection;
}
@@ -104,8 +102,7 @@ public abstract class AbstractDatabase implements DatabaseAccess
{
if (m_databaseDocument != null)
{
- final XStorable storeDoc = (XStorable) UnoRuntime.queryInterface(XStorable.class,
- m_databaseDocument);
+ final XStorable storeDoc = UnoRuntime.queryInterface(XStorable.class, m_databaseDocument);
storeDoc.store();
}
}
@@ -118,8 +115,8 @@ public abstract class AbstractDatabase implements DatabaseAccess
public void close()
{
// close connection
- final XCloseable closeConn = (XCloseable) UnoRuntime.queryInterface(XCloseable.class,
- m_connection);
+ final XCloseable closeConn = UnoRuntime.queryInterface( XCloseable.class,
+ m_connection != null ? m_connection.getXConnection() : null );
if (closeConn != null)
{
try
@@ -133,8 +130,7 @@ public abstract class AbstractDatabase implements DatabaseAccess
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);
+ final com.sun.star.util.XCloseable closeDoc = UnoRuntime.queryInterface( com.sun.star.util.XCloseable.class, m_databaseDocument );
if (closeDoc != null)
{
try
@@ -178,7 +174,7 @@ public abstract class AbstractDatabase implements DatabaseAccess
*/
public XModel getModel()
{
- return (XModel) UnoRuntime.queryInterface(XModel.class, m_databaseDocument);
+ return UnoRuntime.queryInterface( XModel.class, m_databaseDocument );
}
public XMultiServiceFactory getORB()
@@ -191,10 +187,9 @@ public abstract class AbstractDatabase implements DatabaseAccess
{
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));
+ final XNameAccess dbContext = UnoRuntime.queryInterface( XNameAccess.class,
+ m_orb.createInstance( "com.sun.star.sdb.DatabaseContext" ) );
+ final XDocumentDataSource dataSource = UnoRuntime.queryInterface( XDocumentDataSource.class, dbContext.getByName( _docURL ) );
m_databaseDocument = dataSource.getDatabaseDocument();
m_dataSource = new DataSource(m_orb, m_databaseDocument.getDataSource());
diff --git a/connectivity/qa/connectivity/tools/CRMDatabase.java b/connectivity/qa/connectivity/tools/CRMDatabase.java
new file mode 100644
index 0000000000..3b840f3deb
--- /dev/null
+++ b/connectivity/qa/connectivity/tools/CRMDatabase.java
@@ -0,0 +1,295 @@
+/*************************************************************************
+ *
+ * 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: CRMDatabase.java,v $
+ * $Revision: 1.6.2.1 $
+ *
+ * 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.PropertyState;
+import com.sun.star.container.ElementExistException;
+import com.sun.star.container.NoSuchElementException;
+import com.sun.star.frame.XComponentLoader;
+import com.sun.star.frame.XController;
+import com.sun.star.frame.XModel;
+import com.sun.star.io.IOException;
+import com.sun.star.lang.IllegalArgumentException;
+import com.sun.star.lang.WrappedTargetException;
+import com.sun.star.lang.XComponent;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.sdb.XSingleSelectQueryComposer;
+import com.sun.star.sdb.application.XDatabaseDocumentUI;
+import com.sun.star.sdbc.SQLException;
+import com.sun.star.sdbcx.XTablesSupplier;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.util.XRefreshable;
+import connectivity.tools.sdb.Connection;
+
+/** implements a small Customer Relationship Management database
+ *
+ * Not finished, by far. Feel free to add features as you need them.
+ */
+public class CRMDatabase
+{
+ private static final String INTEGER = "INTEGER";
+ private static final String VARCHAR50 = "VARCHAR(50)";
+ private final XMultiServiceFactory m_orb;
+ private final HsqlDatabase m_database;
+ private final DataSource m_dataSource;
+ private final Connection m_connection;
+
+ /** constructs the CRM database
+ */
+ public CRMDatabase( XMultiServiceFactory _orb, boolean _withUI ) throws Exception
+ {
+ m_orb = _orb;
+
+ m_database = new HsqlDatabase( m_orb );
+ m_dataSource = m_database.getDataSource();
+
+ if ( _withUI )
+ {
+ final XComponentLoader loader = UnoRuntime.queryInterface( XComponentLoader.class,
+ m_orb.createInstance( "com.sun.star.frame.Desktop" ) );
+ PropertyValue[] loadArgs = new PropertyValue[] {
+ new PropertyValue( "PickListEntry", 0, false, PropertyState.DIRECT_VALUE )
+ };
+ loader.loadComponentFromURL( m_database.getDocumentURL(), "_blank", 0, loadArgs );
+ getDocumentUI().connect();
+ m_connection = new Connection( getDocumentUI().getActiveConnection() );
+ }
+ else
+ {
+ m_connection = m_database.defaultConnection();
+ }
+
+ createTables();
+ createQueries();
+ }
+
+ /**
+ * creates a CRMDatabase from an existing document, given by URL
+ * @param _orb
+ * @param _existingDocumentURL
+ * @throws Exceptio
+ */
+ public CRMDatabase( XMultiServiceFactory _orb, final String _existingDocumentURL ) throws Exception
+ {
+ m_orb = _orb;
+
+ m_database = new HsqlDatabase( m_orb, _existingDocumentURL );
+ m_dataSource = m_database.getDataSource();
+ m_connection = m_database.defaultConnection();
+ }
+
+ // --------------------------------------------------------------------------------------------------------
+ /** returns the database document underlying the CRM database
+ */
+ public final HsqlDatabase getDatabase()
+ {
+ return m_database;
+ }
+
+ // --------------------------------------------------------------------------------------------------------
+ /** returns the default connection to the database
+ */
+ public final Connection getConnection()
+ {
+ return m_connection;
+ }
+
+ // --------------------------------------------------------------------------------------------------------
+ public void saveAndClose() throws SQLException, IOException
+ {
+ XDatabaseDocumentUI ui = getDocumentUI();
+ if ( ui != null )
+ ui.closeSubComponents();
+ m_database.store();
+ m_database.closeAndDelete();
+ }
+
+ // --------------------------------------------------------------------------------------------------------
+ public XDatabaseDocumentUI getDocumentUI()
+ {
+ XModel docModel = UnoRuntime.queryInterface( XModel.class, m_database.getDatabaseDocument() );
+ return UnoRuntime.queryInterface( XDatabaseDocumentUI.class, docModel.getCurrentController() );
+ }
+
+ // --------------------------------------------------------------------------------------------------------
+ public XController loadSubComponent( final int _objectType, final String _name ) throws IllegalArgumentException, SQLException, NoSuchElementException
+ {
+ XDatabaseDocumentUI docUI = getDocumentUI();
+ if ( !docUI.isConnected() )
+ docUI.connect();
+
+ XComponent subComponent = docUI.loadComponent( _objectType, _name, false );
+ XController controller = UnoRuntime.queryInterface( XController.class, subComponent );
+ if ( controller != null )
+ return controller;
+ XModel document = UnoRuntime.queryInterface( XModel.class, subComponent );
+ return document.getCurrentController();
+ }
+
+ // --------------------------------------------------------------------------------------------------------
+ private void createTables() throws SQLException
+ {
+ HsqlTableDescriptor table = new HsqlTableDescriptor( "categories",
+ new HsqlColumnDescriptor[] {
+ new HsqlColumnDescriptor( "ID",INTEGER, HsqlColumnDescriptor.PRIMARY ),
+ new HsqlColumnDescriptor( "Name",VARCHAR50),
+ new HsqlColumnDescriptor( "Description", "VARCHAR(1024)" ),
+ new HsqlColumnDescriptor( "Image", "LONGVARBINARY" ) } );
+ m_database.createTable( table, true );
+
+ m_database.executeSQL( "INSERT INTO \"categories\" ( \"ID\", \"Name\" ) VALUES ( 1, 'Food' )" );
+ m_database.executeSQL( "INSERT INTO \"categories\" ( \"ID\", \"Name\" ) VALUES ( 2, 'Furniture' )" );
+
+ table = new HsqlTableDescriptor( "products",
+ new HsqlColumnDescriptor[] {
+ new HsqlColumnDescriptor( "ID",INTEGER, HsqlColumnDescriptor.PRIMARY ),
+ new HsqlColumnDescriptor( "Name",VARCHAR50),
+ new HsqlColumnDescriptor( "CategoryID",INTEGER, HsqlColumnDescriptor.REQUIRED, "categories", "ID" ) } );
+ m_database.createTable( table, true );
+
+ m_database.executeSQL( "INSERT INTO \"products\" VALUES ( 1, 'Oranges', 1 )" );
+ m_database.executeSQL( "INSERT INTO \"products\" VALUES ( 2, 'Apples', 1 )" );
+ m_database.executeSQL( "INSERT INTO \"products\" VALUES ( 3, 'Pears', 1 )" );
+ m_database.executeSQL( "INSERT INTO \"products\" VALUES ( 4, 'Strawberries', 1 )" );
+
+ table = new HsqlTableDescriptor( "customers",
+ new HsqlColumnDescriptor[] {
+ new HsqlColumnDescriptor( "ID",INTEGER, HsqlColumnDescriptor.PRIMARY ),
+ new HsqlColumnDescriptor( "Name",VARCHAR50),
+ new HsqlColumnDescriptor( "Address",VARCHAR50),
+ new HsqlColumnDescriptor( "City",VARCHAR50),
+ new HsqlColumnDescriptor( "Postal",VARCHAR50),
+ new HsqlColumnDescriptor( "Comment","LONGVARCHAR")} );
+ m_database.createTable( table, true );
+
+ m_database.executeSQL( "INSERT INTO \"customers\" VALUES(1,'Food, Inc.','Down Under','Melbourne','509','Prefered') " );
+ m_database.executeSQL( "INSERT INTO \"customers\" VALUES(2,'Simply Delicious','Down Under','Melbourne','518',null) " );
+ m_database.executeSQL( "INSERT INTO \"customers\" VALUES(3,'Pure Health','10 Fish St.','San Francisco','94107',null) " );
+ m_database.executeSQL( "INSERT INTO \"customers\" VALUES(4,'Milk And More','Arlington Road 21','Dublin','31021','Good one.') " );
+
+ table = new HsqlTableDescriptor( "orders",
+ new HsqlColumnDescriptor[] {
+ new HsqlColumnDescriptor( "ID",INTEGER, HsqlColumnDescriptor.PRIMARY ),
+ new HsqlColumnDescriptor( "CustomerID",INTEGER, HsqlColumnDescriptor.REQUIRED, "customers", "ID" ),
+ new HsqlColumnDescriptor( "OrderDate", "DATE" ),
+ new HsqlColumnDescriptor( "ShipDate", "DATE" ) } );
+ m_database.createTable( table, true );
+
+ m_database.executeSQL( "INSERT INTO \"orders\" (\"ID\", \"CustomerID\", \"OrderDate\") VALUES(1, 1, {D '2009-01-01'})" );
+ m_database.executeSQL( "INSERT INTO \"orders\" VALUES(2, 2, {D '2009-01-01'}, {D '2009-01-23'})" );
+
+ table = new HsqlTableDescriptor( "orders_details",
+ new HsqlColumnDescriptor[] {
+ new HsqlColumnDescriptor( "OrderID",INTEGER, HsqlColumnDescriptor.PRIMARY, "orders", "ID" ),
+ new HsqlColumnDescriptor( "ProductID",INTEGER, HsqlColumnDescriptor.PRIMARY, "products", "ID" ),
+ new HsqlColumnDescriptor( "Quantity",INTEGER) } );
+ m_database.createTable( table, true );
+
+ m_database.executeSQL( "INSERT INTO \"orders_details\" VALUES(1, 1, 100)" );
+ m_database.executeSQL( "INSERT INTO \"orders_details\" VALUES(1, 2, 100)" );
+ m_database.executeSQL( "INSERT INTO \"orders_details\" VALUES(2, 2, 2000)" );
+ m_database.executeSQL( "INSERT INTO \"orders_details\" VALUES(2, 3, 2000)" );
+ m_database.executeSQL( "INSERT INTO \"orders_details\" VALUES(2, 4, 2000)" );
+
+ // since we created the tables by directly executing the SQL statements, we need to refresh
+ // the tables container
+ m_connection.refreshTables();
+ }
+
+ // --------------------------------------------------------------------------------------------------------
+ private void validateUnparseable()
+ {
+ // The "unparseable" query should be indeed be unparseable by OOo (though a valid HSQL query)
+ XSingleSelectQueryComposer composer;
+ QueryDefinition unparseableQuery;
+ try
+ {
+ final XMultiServiceFactory factory = UnoRuntime.queryInterface(
+ XMultiServiceFactory.class, m_database.defaultConnection().getXConnection() );
+ composer = UnoRuntime.queryInterface(
+ XSingleSelectQueryComposer.class, factory.createInstance( "com.sun.star.sdb.SingleSelectQueryComposer" ) );
+ unparseableQuery = m_dataSource.getQueryDefinition( "unparseable" );
+ }
+ catch( Exception e )
+ {
+ throw new RuntimeException( "caught an unexpected exception: " + e.getMessage() );
+ }
+
+ boolean caughtExpected = false;
+ try
+ {
+ composer.setQuery( unparseableQuery.getCommand() );
+ }
+ catch (WrappedTargetException e) { }
+ catch( SQLException e )
+ {
+ caughtExpected = true;
+ }
+
+ if ( !caughtExpected )
+ throw new RuntimeException( "Somebody improved the parser! This is bad :), since we need an unparsable query here!" );
+ }
+
+ // --------------------------------------------------------------------------------------------------------
+ private void createQueries() throws ElementExistException, WrappedTargetException, com.sun.star.lang.IllegalArgumentException
+ {
+ m_database.getDataSource().createQuery(
+ "all orders",
+ "SELECT \"orders\".\"ID\" AS \"Order No.\", " +
+ "\"customers\".\"Name\" AS \"Customer Name\", " +
+ "\"orders\".\"OrderDate\" AS \"Order Date\", " +
+ "\"orders\".\"ShipDate\" AS \"Ship Date\", " +
+ "\"orders_details\".\"Quantity\", " +
+ "\"products\".\"Name\" AS \"Product Name\" " +
+ "FROM \"orders_details\" AS \"orders_details\", " +
+ "\"orders\" AS \"orders\", " +
+ "\"products\" AS \"products\", " +
+ "\"customers\" AS \"customers\" " +
+ "WHERE ( \"orders_details\".\"OrderID\" = \"orders\".\"ID\" " +
+ "AND \"orders_details\".\"ProductID\" = \"products\".\"ID\" " +
+ "AND \"orders\".\"CustomerID\" = \"customers\".\"ID\" )"
+ );
+
+ m_database.getDataSource().createQuery(
+ "unshipped orders",
+ "SELECT * " +
+ "FROM \"all orders\"" +
+ "WHERE ( \"ShipDate\" IS NULL )"
+ );
+
+ m_database.getDataSource().createQuery( "parseable", "SELECT * FROM \"customers\"" );
+ m_database.getDataSource().createQuery( "parseable native", "SELECT * FROM INFORMATION_SCHEMA.SYSTEM_VIEWS", false );
+ m_database.getDataSource().createQuery( "unparseable",
+ "SELECT CAST( \"ID\" AS VARCHAR(3) ) AS \"ID_VARCHAR\" FROM \"products\"", false );
+
+ validateUnparseable();
+ }
+}
diff --git a/connectivity/qa/connectivity/tools/DataSource.java b/connectivity/qa/connectivity/tools/DataSource.java
index 578d906fb2..df43ee5eee 100644
--- a/connectivity/qa/connectivity/tools/DataSource.java
+++ b/connectivity/qa/connectivity/tools/DataSource.java
@@ -39,10 +39,8 @@ import com.sun.star.lang.XMultiServiceFactory;
import com.sun.star.beans.XPropertySet;
import com.sun.star.sdb.XQueryDefinitionsSupplier;
import com.sun.star.sdbc.XDataSource;
-import com.sun.star.sdbcx.XTablesSupplier;
import com.sun.star.uno.Exception;
import com.sun.star.uno.UnoRuntime;
-import com.sun.star.util.XRefreshable;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -57,11 +55,10 @@ public class DataSource
{
m_orb = _orb;
- final XNameAccess dbContext = (XNameAccess) UnoRuntime.queryInterface(XNameAccess.class,
- _orb.createInstance("com.sun.star.sdb.DatabaseContext"));
+ final XNameAccess dbContext = UnoRuntime.queryInterface(
+ XNameAccess.class, _orb.createInstance( "com.sun.star.sdb.DatabaseContext" ) );
- m_dataSource = (XDataSource) UnoRuntime.queryInterface(XDataSource.class,
- dbContext.getByName(_registeredName));
+ m_dataSource = UnoRuntime.queryInterface( XDataSource.class, dbContext.getByName( _registeredName ) );
}
public DataSource(final XMultiServiceFactory _orb,final XDataSource _dataSource)
@@ -86,13 +83,11 @@ public class DataSource
*/
public void createQuery(final String _name, final String _sqlCommand, final boolean _escapeProcessing) throws ElementExistException, WrappedTargetException, com.sun.star.lang.IllegalArgumentException
{
- final XSingleServiceFactory queryDefsFac = (XSingleServiceFactory) UnoRuntime.queryInterface(
- XSingleServiceFactory.class, getQueryDefinitions());
+ final XSingleServiceFactory queryDefsFac = UnoRuntime.queryInterface( XSingleServiceFactory.class, getQueryDefinitions() );
XPropertySet queryDef = null;
try
{
- queryDef = (XPropertySet) UnoRuntime.queryInterface(
- XPropertySet.class, queryDefsFac.createInstance());
+ queryDef = UnoRuntime.queryInterface( XPropertySet.class, queryDefsFac.createInstance() );
queryDef.setPropertyValue("Command", _sqlCommand);
queryDef.setPropertyValue("EscapeProcessing", Boolean.valueOf(_escapeProcessing));
}
@@ -101,8 +96,7 @@ public class DataSource
e.printStackTrace(System.err);
}
- final XNameContainer queryDefsContainer = (XNameContainer) UnoRuntime.queryInterface(
- XNameContainer.class, getQueryDefinitions());
+ final XNameContainer queryDefsContainer = UnoRuntime.queryInterface( XNameContainer.class, getQueryDefinitions() );
queryDefsContainer.insertByName(_name, queryDef);
}
@@ -113,8 +107,7 @@ public class DataSource
final XNameAccess allDefs = getQueryDefinitions();
try
{
- return new QueryDefinition(
- (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, allDefs.getByName(_name)));
+ return new QueryDefinition( UnoRuntime.queryInterface( XPropertySet.class, allDefs.getByName( _name) ) );
}
catch (WrappedTargetException e)
{
@@ -126,25 +119,11 @@ public class DataSource
*/
public XNameAccess getQueryDefinitions()
{
- final XQueryDefinitionsSupplier suppQueries = (XQueryDefinitionsSupplier) UnoRuntime.queryInterface(
+ final XQueryDefinitionsSupplier suppQueries = UnoRuntime.queryInterface(
XQueryDefinitionsSupplier.class, m_dataSource);
return suppQueries.getQueryDefinitions();
}
- /** refreshs the table container of a given connection
- *
- * This is usually necessary if you created tables by directly executing SQL statements,
- * bypassing the SDBCX layer.
- */
- public void refreshTables(final com.sun.star.sdbc.XConnection _connection)
- {
- final XTablesSupplier suppTables = (XTablesSupplier) UnoRuntime.queryInterface(
- XTablesSupplier.class, _connection);
- final XRefreshable refreshTables = (XRefreshable) UnoRuntime.queryInterface(
- XRefreshable.class, suppTables.getTables());
- refreshTables.refresh();
- }
-
/** returns the name of the data source
*
* If a data source is registered at the database context, the name is the registration
@@ -157,8 +136,7 @@ public class DataSource
String name = null;
try
{
- final XPropertySet dataSourceProps = (XPropertySet) UnoRuntime.queryInterface(
- XPropertySet.class, m_dataSource);
+ final XPropertySet dataSourceProps = 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
index bc39bb0990..78608063e6 100755
--- a/connectivity/qa/connectivity/tools/DatabaseAccess.java
+++ b/connectivity/qa/connectivity/tools/DatabaseAccess.java
@@ -34,7 +34,7 @@ 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;
+import connectivity.tools.sdb.Connection;
/**
*
@@ -42,7 +42,7 @@ import com.sun.star.sdbc.XConnection;
*/
public interface DatabaseAccess
{
- XConnection defaultConnection() throws SQLException;
+ Connection defaultConnection() throws SQLException;
void executeSQL(final String statementString) throws SQLException;
diff --git a/connectivity/qa/connectivity/tools/HsqlDatabase.java b/connectivity/qa/connectivity/tools/HsqlDatabase.java
index b1af0c118e..8c02750b3e 100644
--- a/connectivity/qa/connectivity/tools/HsqlDatabase.java
+++ b/connectivity/qa/connectivity/tools/HsqlDatabase.java
@@ -30,6 +30,7 @@
package connectivity.tools;
import com.sun.star.beans.PropertyValue;
+import com.sun.star.beans.PropertyState;
import com.sun.star.beans.XPropertySet;
import com.sun.star.container.ElementExistException;
import com.sun.star.frame.XStorable;
@@ -82,9 +83,9 @@ public class HsqlDatabase extends AbstractDatabase
dsProperties.setPropertyValue("URL", "sdbc:embedded:hsqldb");
final XStorable storable = (XStorable) UnoRuntime.queryInterface(XStorable.class, m_databaseDocument);
- storable.storeAsURL(m_databaseDocumentFile, new PropertyValue[]
- {
- });
+ storable.storeAsURL( m_databaseDocumentFile, new PropertyValue[]
+ { new PropertyValue( "PickListEntry", 0, false, PropertyState.DIRECT_VALUE )
+ } );
}
/** drops the table with a given name
@@ -207,10 +208,8 @@ public class HsqlDatabase extends AbstractDatabase
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());
+ final XTablesSupplier suppTables = UnoRuntime.queryInterface( XTablesSupplier.class, defaultConnection().getXConnection() );
+ final XAppend appendTable = UnoRuntime.queryInterface( XAppend.class, suppTables.getTables() );
appendTable.appendByDescriptor(sdbcxDescriptor);
}
}
diff --git a/connectivity/qa/connectivity/tools/HsqlTableDescriptor.java b/connectivity/qa/connectivity/tools/HsqlTableDescriptor.java
index 483241904b..4b900c7056 100644
--- a/connectivity/qa/connectivity/tools/HsqlTableDescriptor.java
+++ b/connectivity/qa/connectivity/tools/HsqlTableDescriptor.java
@@ -33,11 +33,11 @@ package connectivity.tools;
import com.sun.star.beans.XPropertySet;
import com.sun.star.container.XNameAccess;
import com.sun.star.sdbc.ColumnValue;
-import com.sun.star.sdbc.XConnection;
import com.sun.star.sdbcx.XColumnsSupplier;
import com.sun.star.sdbcx.XDataDescriptorFactory;
import com.sun.star.sdbcx.XTablesSupplier;
import com.sun.star.uno.UnoRuntime;
+import connectivity.tools.sdb.Connection;
/** is a very simply descriptor of a HSQL table, to be used with a HsqlDatabase.createTable method
*/
@@ -67,12 +67,10 @@ public class HsqlTableDescriptor
return m_columns;
}
- public XPropertySet createSdbcxDescriptor( XConnection _forConnection )
+ public XPropertySet createSdbcxDescriptor( Connection _forConnection )
{
- XTablesSupplier suppTables = (XTablesSupplier)UnoRuntime.queryInterface(
- XTablesSupplier.class, _forConnection );
- XDataDescriptorFactory tableDescFac = (XDataDescriptorFactory)UnoRuntime.queryInterface(
- XDataDescriptorFactory.class, suppTables.getTables() );
+ XTablesSupplier suppTables = UnoRuntime.queryInterface( XTablesSupplier.class, _forConnection.getXConnection() );
+ XDataDescriptorFactory tableDescFac = UnoRuntime.queryInterface( XDataDescriptorFactory.class, suppTables.getTables() );
XPropertySet tableDesc = tableDescFac.createDataDescriptor();
try
@@ -81,12 +79,10 @@ public class HsqlTableDescriptor
}
catch ( Exception e ) { e.printStackTrace( System.err ); }
- XColumnsSupplier suppDescCols = (XColumnsSupplier)UnoRuntime.queryInterface(
- XColumnsSupplier.class, tableDesc );
+ XColumnsSupplier suppDescCols = UnoRuntime.queryInterface( XColumnsSupplier.class, tableDesc );
XNameAccess descColumns = suppDescCols.getColumns();
- XDataDescriptorFactory columnDescFac = (XDataDescriptorFactory)UnoRuntime.queryInterface(
- XDataDescriptorFactory.class, descColumns );
+ XDataDescriptorFactory columnDescFac = UnoRuntime.queryInterface( XDataDescriptorFactory.class, descColumns );
HsqlColumnDescriptor[] myColumns = getColumns();
for ( int i = 0; i < myColumns.length; ++i )
diff --git a/connectivity/qa/connectivity/tools/makefile.mk b/connectivity/qa/connectivity/tools/makefile.mk
index 589a85ea38..c4f2b68f53 100644
--- a/connectivity/qa/connectivity/tools/makefile.mk
+++ b/connectivity/qa/connectivity/tools/makefile.mk
@@ -29,10 +29,10 @@
#
#*************************************************************************
-PRJ = ..$/..$/..
+PRJ = ../../..
TARGET = ConnectivityTools
PRJNAME = connectivity
-PACKAGE = connectivity$/tools
+PACKAGE = connectivity/tools
# --- Settings -----------------------------------------------------
.INCLUDE: settings.mk
@@ -46,14 +46,8 @@ all:
#----- compile .java files -----------------------------------------
JARFILES = ridl.jar unoil.jar jurt.jar juh.jar java_uno.jar OOoRunnerLight.jar
-# Do not use $/ with the $(FIND) command as for W32-4nt this leads to a backslash
-# in a posix command. In this special case use / instead of $/
-.IF "$(GUI)"=="OS2"
-JAVAFILES := $(shell @ls ./*.java)
-.ELSE
-JAVAFILES := $(shell @$(FIND) ./*.java)
-.ENDIF
-JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class)
+JAVAFILES := $(shell @$(FIND) -name "*.java")
+JAVACLASSFILES := $(foreach,i,$(JAVAFILES) $(CLASSDIR)/$(PACKAGE)/$(i:d)$(i:b).class)
#----- make a jar from compiled files ------------------------------
diff --git a/connectivity/qa/connectivity/tools/sdb/Connection.java b/connectivity/qa/connectivity/tools/sdb/Connection.java
new file mode 100644
index 0000000000..aac120fb1e
--- /dev/null
+++ b/connectivity/qa/connectivity/tools/sdb/Connection.java
@@ -0,0 +1,93 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package connectivity.tools.sdb;
+
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.sdb.XSingleSelectQueryComposer;
+import com.sun.star.sdbc.SQLException;
+import com.sun.star.sdbc.XConnection;
+import com.sun.star.sdbc.XDatabaseMetaData;
+import com.sun.star.sdbc.XPreparedStatement;
+import com.sun.star.sdbc.XResultSet;
+import com.sun.star.sdbc.XStatement;
+import com.sun.star.sdbcx.XTablesSupplier;
+import com.sun.star.uno.Exception;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.util.XRefreshable;
+
+/**
+ * is a convenience wrapper around a SDB-level connection object
+ */
+public class Connection
+{
+ private final XConnection m_connection;
+
+ public Connection( final XConnection _connection )
+ {
+ m_connection = _connection;
+ }
+
+ public XConnection getXConnection()
+ {
+ return m_connection;
+ }
+
+ public boolean execute( final String _sql ) throws SQLException
+ {
+ XStatement statement = createStatement();
+ return statement.execute( _sql );
+ }
+
+ public XResultSet executeQuery( final String _sql ) throws SQLException
+ {
+ XStatement statement = createStatement();
+ return statement.executeQuery( _sql );
+ }
+
+ public int executeUpdate( final String _sql ) throws SQLException
+ {
+ XStatement statement = createStatement();
+ return statement.executeUpdate( _sql );
+ }
+
+ public void refreshTables()
+ {
+ final XTablesSupplier suppTables = UnoRuntime.queryInterface(XTablesSupplier.class, m_connection);
+ final XRefreshable refresh = UnoRuntime.queryInterface( XRefreshable.class, suppTables.getTables() );
+ refresh.refresh();
+ }
+
+ public XSingleSelectQueryComposer createSingleSelectQueryComposer() throws Exception
+ {
+ final XMultiServiceFactory connectionFactory = UnoRuntime.queryInterface( XMultiServiceFactory.class, m_connection );
+ return UnoRuntime.queryInterface(
+ XSingleSelectQueryComposer.class, connectionFactory.createInstance( "com.sun.star.sdb.SingleSelectQueryComposer" ) );
+ }
+
+ public
+ XStatement createStatement() throws SQLException
+ {
+ return m_connection.createStatement();
+ }
+
+ public
+ XPreparedStatement prepareStatement( String _sql ) throws SQLException
+ {
+ return m_connection.prepareStatement( _sql );
+ }
+
+ public
+ XDatabaseMetaData getMetaData() throws SQLException
+ {
+ return m_connection.getMetaData();
+ }
+
+ public
+ void close() throws SQLException
+ {
+ m_connection.close();
+ }
+}
diff --git a/connectivity/source/commontools/BlobHelper.cxx b/connectivity/source/commontools/BlobHelper.cxx
new file mode 100644
index 0000000000..ba6aaf2715
--- /dev/null
+++ b/connectivity/source/commontools/BlobHelper.cxx
@@ -0,0 +1,72 @@
+/*************************************************************************
+ *
+ * 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: FValue.cxx,v $
+ * $Revision: 1.34 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "connectivity/BlobHelper.hxx"
+#include <comphelper/seqstream.hxx>
+#include "connectivity/dbexception.hxx"
+
+using namespace connectivity;
+using namespace dbtools;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::uno;
+
+BlobHelper::BlobHelper(const ::com::sun::star::uno::Sequence< sal_Int8 >& _val) : m_aValue(_val)
+{
+}
+// -----------------------------------------------------------------------------
+::sal_Int64 SAL_CALL BlobHelper::length( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ return m_aValue.getLength();
+}
+// -----------------------------------------------------------------------------
+::com::sun::star::uno::Sequence< ::sal_Int8 > SAL_CALL BlobHelper::getBytes( ::sal_Int64 pos, ::sal_Int32 _length ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ if ( sal_Int32(pos + _length) > m_aValue.getLength() )
+ throw ::com::sun::star::sdbc::SQLException();
+ return ::com::sun::star::uno::Sequence< ::sal_Int8 >(m_aValue.getConstArray() + sal_Int32(pos),_length);
+}
+// -----------------------------------------------------------------------------
+::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL BlobHelper::getBinaryStream( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ return new ::comphelper::SequenceInputStream(m_aValue);
+}
+// -----------------------------------------------------------------------------
+::sal_Int64 SAL_CALL BlobHelper::position( const ::com::sun::star::uno::Sequence< ::sal_Int8 >& /*pattern*/, ::sal_Int64 /*start*/ ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "XBlob::position", *this );
+ return 0;
+}
+// -----------------------------------------------------------------------------
+::sal_Int64 SAL_CALL BlobHelper::positionOfBlob( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XBlob >& /*pattern*/, ::sal_Int64 /*start*/ ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "XBlob::positionOfBlob", *this );
+ return 0;
+}
diff --git a/connectivity/source/commontools/FValue.cxx b/connectivity/source/commontools/FValue.cxx
index 37e91d22c8..86b30e572c 100644
--- a/connectivity/source/commontools/FValue.cxx
+++ b/connectivity/source/commontools/FValue.cxx
@@ -254,6 +254,7 @@ void ORowSetValue::setTypeKind(sal_Int32 _eType)
case DataType::BLOB:
case DataType::CLOB:
case DataType::OBJECT:
+ case DataType::OTHER:
(*this) = getAny();
break;
default:
@@ -844,6 +845,7 @@ bool ORowSetValue::operator==(const ORowSetValue& _rRH) const
case DataType::BLOB:
case DataType::CLOB:
case DataType::OBJECT:
+ case DataType::OTHER:
bRet = false;
break;
default:
@@ -910,6 +912,7 @@ Any ORowSetValue::makeAny() const
case DataType::BLOB:
case DataType::CLOB:
case DataType::OBJECT:
+ case DataType::OTHER:
rValue = getAny();
break;
case DataType::BIT:
@@ -1016,6 +1019,19 @@ Any ORowSetValue::makeAny() const
else
aRet = ::rtl::OUString::valueOf((sal_Int64)*this);
break;
+ case DataType::CLOB:
+ {
+ Any aValue( getAny() );
+ Reference< XClob > xClob;
+ if ( aValue >>= xClob )
+ {
+ if ( xClob.is() )
+ {
+ aRet = xClob->getSubString(1,(sal_Int32)xClob->length() );
+ }
+ }
+ }
+ break;
}
}
return aRet;
@@ -1087,6 +1103,9 @@ sal_Bool ORowSetValue::getBool() const
case DataType::INTEGER:
bRet = m_bSigned ? (m_aValue.m_nInt32 != 0) : (*static_cast<sal_Int64*>(m_aValue.m_pValue) != sal_Int64(0));
break;
+ default:
+ OSL_ENSURE(0,"Illegal conversion!");
+ break;
}
}
return bRet;
@@ -1128,6 +1147,8 @@ sal_Int8 ORowSetValue::getInt8() const
case DataType::BINARY:
case DataType::VARBINARY:
case DataType::LONGVARBINARY:
+ case DataType::BLOB:
+ case DataType::CLOB:
OSL_ASSERT(!"getInt8() for this type is not allowed!");
break;
case DataType::BIT:
@@ -1152,6 +1173,9 @@ sal_Int8 ORowSetValue::getInt8() const
else
nRet = static_cast<sal_Int8>(*static_cast<sal_Int64*>(m_aValue.m_pValue));
break;
+ default:
+ OSL_ENSURE(0,"Illegal conversion!");
+ break;
}
}
return nRet;
@@ -1193,6 +1217,8 @@ sal_Int16 ORowSetValue::getInt16() const
case DataType::BINARY:
case DataType::VARBINARY:
case DataType::LONGVARBINARY:
+ case DataType::BLOB:
+ case DataType::CLOB:
OSL_ASSERT(!"getInt16() for this type is not allowed!");
break;
case DataType::BIT:
@@ -1217,6 +1243,9 @@ sal_Int16 ORowSetValue::getInt16() const
else
nRet = static_cast<sal_Int16>(*static_cast<sal_Int64*>(m_aValue.m_pValue));
break;
+ default:
+ OSL_ENSURE(0,"Illegal conversion!");
+ break;
}
}
return nRet;
@@ -1258,6 +1287,8 @@ sal_Int32 ORowSetValue::getInt32() const
case DataType::BINARY:
case DataType::VARBINARY:
case DataType::LONGVARBINARY:
+ case DataType::BLOB:
+ case DataType::CLOB:
OSL_ASSERT(!"getInt32() for this type is not allowed!");
break;
case DataType::BIT:
@@ -1282,6 +1313,9 @@ sal_Int32 ORowSetValue::getInt32() const
else
nRet = static_cast<sal_Int32>(*static_cast<sal_Int64*>(m_aValue.m_pValue));
break;
+ default:
+ OSL_ENSURE(0,"Illegal conversion!");
+ break;
}
}
return nRet;
@@ -1323,6 +1357,8 @@ sal_Int64 ORowSetValue::getLong() const
case DataType::BINARY:
case DataType::VARBINARY:
case DataType::LONGVARBINARY:
+ case DataType::BLOB:
+ case DataType::CLOB:
OSL_ASSERT(!"getInt32() for this type is not allowed!");
break;
case DataType::BIT:
@@ -1347,6 +1383,9 @@ sal_Int64 ORowSetValue::getLong() const
else
nRet = *(sal_Int64*)m_aValue.m_pValue;
break;
+ default:
+ OSL_ENSURE(0,"Illegal conversion!");
+ break;
}
}
return nRet;
@@ -1392,6 +1431,8 @@ float ORowSetValue::getFloat() const
case DataType::BINARY:
case DataType::VARBINARY:
case DataType::LONGVARBINARY:
+ case DataType::BLOB:
+ case DataType::CLOB:
OSL_ASSERT(!"getDouble() for this type is not allowed!");
break;
case DataType::BIT:
@@ -1416,6 +1457,9 @@ float ORowSetValue::getFloat() const
else
nRet = float(*(sal_Int64*)m_aValue.m_pValue);
break;
+ default:
+ OSL_ENSURE(0,"Illegal conversion!");
+ break;
}
}
return nRet;
@@ -1463,6 +1507,8 @@ double ORowSetValue::getDouble() const
case DataType::BINARY:
case DataType::VARBINARY:
case DataType::LONGVARBINARY:
+ case DataType::BLOB:
+ case DataType::CLOB:
OSL_ASSERT(!"getDouble() for this type is not allowed!");
break;
case DataType::BIT:
@@ -1487,6 +1533,9 @@ double ORowSetValue::getDouble() const
else
nRet = double(*(sal_Int64*)m_aValue.m_pValue);
break;
+ default:
+ OSL_ENSURE(0,"Illegal conversion!");
+ break;
}
}
return nRet;
@@ -1548,6 +1597,8 @@ void ORowSetValue::setFromDouble(const double& _rVal,sal_Int32 _nDatatype)
case DataType::BINARY:
case DataType::VARBINARY:
case DataType::LONGVARBINARY:
+ case DataType::BLOB:
+ case DataType::CLOB:
OSL_ASSERT(!"setFromDouble() for this type is not allowed!");
break;
case DataType::BIT:
@@ -1592,12 +1643,39 @@ Sequence<sal_Int8> ORowSetValue::getSequence() const
case DataType::BLOB:
{
Reference<XInputStream> xStream;
- Any aValue = getAny();
+ const Any aValue = makeAny();
if(aValue.hasValue())
{
- aValue >>= xStream;
+ Reference<XBlob> xBlob(aValue,UNO_QUERY);
+ if ( xBlob.is() )
+ xStream = xBlob->getBinaryStream();
+ else
+ {
+ Reference<XClob> xClob(aValue,UNO_QUERY);
+ if ( xClob.is() )
+ xStream = xClob->getCharacterStream();
+ }
if(xStream.is())
- xStream->readBytes(aSeq,xStream->available());
+ {
+ const sal_uInt32 nBytesToRead = 65535;
+ sal_uInt32 nRead;
+
+ do
+ {
+ ::com::sun::star::uno::Sequence< sal_Int8 > aReadSeq;
+
+ nRead = xStream->readSomeBytes( aReadSeq, nBytesToRead );
+
+ if( nRead )
+ {
+ const sal_uInt32 nOldLength = aSeq.getLength();
+ aSeq.realloc( nOldLength + nRead );
+ rtl_copyMemory( aSeq.getArray() + nOldLength, aReadSeq.getConstArray(), aReadSeq.getLength() );
+ }
+ }
+ while( nBytesToRead == nRead );
+ xStream->closeInput();
+ }
}
}
break;
@@ -1655,6 +1733,9 @@ Sequence<sal_Int8> ORowSetValue::getSequence() const
aValue.Year = pDateTime->Year;
}
break;
+ default:
+ OSL_ENSURE(0,"Illegal conversion!");
+ break;
}
}
return aValue;
@@ -1693,6 +1774,10 @@ Sequence<sal_Int8> ORowSetValue::getSequence() const
break;
case DataType::TIME:
aValue = *static_cast< ::com::sun::star::util::Time*>(m_aValue.m_pValue);
+ break;
+ default:
+ OSL_ENSURE(0,"Illegal conversion!");
+ break;
}
}
return aValue;
@@ -1740,6 +1825,9 @@ Sequence<sal_Int8> ORowSetValue::getSequence() const
case DataType::TIMESTAMP:
aValue = *static_cast< ::com::sun::star::util::DateTime*>(m_aValue.m_pValue);
break;
+ default:
+ OSL_ENSURE(0,"Illegal conversion!");
+ break;
}
}
return aValue;
@@ -1885,13 +1973,17 @@ void ORowSetValue::fill(sal_Int32 _nPos,
(*this) = _xRow->getLong(_nPos);
break;
case DataType::CLOB:
- (*this) = ::com::sun::star::uno::makeAny(_xRow->getCharacterStream(_nPos));
+ (*this) = ::com::sun::star::uno::makeAny(_xRow->getClob(_nPos));
setTypeKind(DataType::CLOB);
break;
case DataType::BLOB:
- (*this) = ::com::sun::star::uno::makeAny(_xRow->getBinaryStream(_nPos));
+ (*this) = ::com::sun::star::uno::makeAny(_xRow->getBlob(_nPos));
setTypeKind(DataType::BLOB);
break;
+ case DataType::OTHER:
+ (*this) = _xRow->getObject(_nPos,NULL);
+ setTypeKind(DataType::OTHER);
+ break;
default:
OSL_ENSURE( false, "ORowSetValue::fill: unsupported type!" );
bReadData = false;
@@ -2037,6 +2129,29 @@ void ORowSetValue::fill(const Any& _rValue)
break;
}
+ case TypeClass_INTERFACE:
+ {
+ Reference< XClob > xClob;
+ if ( _rValue >>= xClob )
+ {
+ (*this) = _rValue;
+ setTypeKind(DataType::CLOB);
+ }
+ else
+ {
+ Reference< XBlob > xBlob;
+ if ( _rValue >>= xBlob )
+ {
+ (*this) = _rValue;
+ setTypeKind(DataType::BLOB);
+ }
+ else
+ {
+ (*this) = _rValue;
+ }
+ }
+ }
+ break;
default:
OSL_ENSURE(0,"Unknown type");
diff --git a/connectivity/source/commontools/dbtools.cxx b/connectivity/source/commontools/dbtools.cxx
index eaf1d6fe8e..672d4d8971 100644
--- a/connectivity/source/commontools/dbtools.cxx
+++ b/connectivity/source/commontools/dbtools.cxx
@@ -213,6 +213,7 @@ sal_Int32 getDefaultNumberFormat(sal_Int32 _nDataType,
case DataType::CHAR:
case DataType::VARCHAR:
case DataType::LONGVARCHAR:
+ case DataType::CLOB:
nFormat = _xTypes->getStandardFormat(NumberFormat::TEXT, _rLocale);
break;
case DataType::DATE:
@@ -234,10 +235,10 @@ sal_Int32 getDefaultNumberFormat(sal_Int32 _nDataType,
case DataType::STRUCT:
case DataType::ARRAY:
case DataType::BLOB:
- case DataType::CLOB:
case DataType::REF:
default:
- nFormat = NumberFormat::UNDEFINED;
+ nFormat = _xTypes->getStandardFormat(NumberFormat::UNDEFINED, _rLocale);
+ //nFormat = NumberFormat::UNDEFINED;
}
return nFormat;
}
@@ -1850,9 +1851,20 @@ void setObjectWithInfo(const Reference<XParameters>& _xParams,
sal_Int32 parameterIndex,
const Any& x,
sal_Int32 sqlType,
- sal_Int32 /*scale*/) throw(SQLException, RuntimeException)
+ sal_Int32 scale) throw(SQLException, RuntimeException)
+{
+ ORowSetValue aVal;
+ aVal.fill(x);
+ setObjectWithInfo(_xParams,parameterIndex,aVal,sqlType,scale);
+}
+// -----------------------------------------------------------------------------
+void setObjectWithInfo(const Reference<XParameters>& _xParams,
+ sal_Int32 parameterIndex,
+ const ::connectivity::ORowSetValue& _rValue,
+ sal_Int32 sqlType,
+ sal_Int32 scale) throw(SQLException, RuntimeException)
{
- if(!x.hasValue())
+ if ( _rValue.isNull() )
_xParams->setNull(parameterIndex,sqlType);
else
{
@@ -1860,65 +1872,62 @@ void setObjectWithInfo(const Reference<XParameters>& _xParams,
{
case DataType::DECIMAL:
case DataType::NUMERIC:
- _xParams->setObjectWithInfo(parameterIndex,x,sqlType,0);
+ _xParams->setObjectWithInfo(parameterIndex,_rValue.makeAny(),sqlType,scale);
break;
case DataType::CHAR:
case DataType::VARCHAR:
- //case DataType::DECIMAL:
- //case DataType::NUMERIC:
case DataType::LONGVARCHAR:
- _xParams->setString(parameterIndex,::comphelper::getString(x));
+ _xParams->setString(parameterIndex,_rValue);
break;
- case DataType::BIGINT:
+ case DataType::CLOB:
{
- sal_Int64 nValue = 0;
- if(x >>= nValue)
+ Any x(_rValue.makeAny());
+ ::rtl::OUString sValue;
+ if ( x >>= sValue )
+ _xParams->setString(parameterIndex,sValue);
+ else
{
- _xParams->setLong(parameterIndex,nValue);
- break;
+ Reference< XClob > xClob;
+ if(x >>= xClob)
+ _xParams->setClob(parameterIndex,xClob);
+ else
+ {
+ Reference< ::com::sun::star::io::XInputStream > xStream;
+ if(x >>= xStream)
+ _xParams->setCharacterStream(parameterIndex,xStream,xStream->available());
+ }
}
}
break;
+ case DataType::BIGINT:
+ if ( _rValue.isSigned() )
+ _xParams->setLong(parameterIndex,_rValue);
+ else
+ _xParams->setString(parameterIndex,_rValue);
+ break;
case DataType::FLOAT:
+ _xParams->setFloat(parameterIndex,_rValue);
+ break;
case DataType::REAL:
- {
- float nValue = 0;
- if(x >>= nValue)
- {
- _xParams->setFloat(parameterIndex,nValue);
- break;
- }
- }
- // run through if we couldn't set a float value
case DataType::DOUBLE:
- _xParams->setDouble(parameterIndex,::comphelper::getDouble(x));
+ _xParams->setDouble(parameterIndex,_rValue);
break;
case DataType::DATE:
- {
- ::com::sun::star::util::Date aValue;
- if(x >>= aValue)
- _xParams->setDate(parameterIndex,aValue);
- }
+ _xParams->setDate(parameterIndex,_rValue);
break;
case DataType::TIME:
- {
- ::com::sun::star::util::Time aValue;
- if(x >>= aValue)
- _xParams->setTime(parameterIndex,aValue);
- }
+ _xParams->setTime(parameterIndex,_rValue);
break;
case DataType::TIMESTAMP:
- {
- ::com::sun::star::util::DateTime aValue;
- if(x >>= aValue)
- _xParams->setTimestamp(parameterIndex,aValue);
- }
+ _xParams->setTimestamp(parameterIndex,_rValue);
break;
case DataType::BINARY:
case DataType::VARBINARY:
case DataType::LONGVARBINARY:
+ case DataType::BLOB:
{
+ Any x(_rValue.makeAny());
Sequence< sal_Int8> aBytes;
if(x >>= aBytes)
_xParams->setBytes(parameterIndex,aBytes);
@@ -1944,16 +1953,24 @@ void setObjectWithInfo(const Reference<XParameters>& _xParams,
break;
case DataType::BIT:
case DataType::BOOLEAN:
- _xParams->setBoolean(parameterIndex,::cppu::any2bool(x));
+ _xParams->setBoolean(parameterIndex,_rValue);
break;
- case DataType::TINYINT:
- _xParams->setByte(parameterIndex,(sal_Int8)::comphelper::getINT32(x));
+ if ( _rValue.isSigned() )
+ _xParams->setByte(parameterIndex,_rValue);
+ else
+ _xParams->setShort(parameterIndex,_rValue);
break;
case DataType::SMALLINT:
- _xParams->setShort(parameterIndex,(sal_Int16)::comphelper::getINT32(x));
+ if ( _rValue.isSigned() )
+ _xParams->setShort(parameterIndex,_rValue);
+ else
+ _xParams->setInt(parameterIndex,_rValue);
break;
case DataType::INTEGER:
- _xParams->setInt(parameterIndex,::comphelper::getINT32(x));
+ if ( _rValue.isSigned() )
+ _xParams->setInt(parameterIndex,_rValue);
+ else
+ _xParams->setLong(parameterIndex,_rValue);
break;
default:
{
diff --git a/connectivity/source/commontools/makefile.mk b/connectivity/source/commontools/makefile.mk
index cb5a4ad3f7..1cc6cf4949 100644
--- a/connectivity/source/commontools/makefile.mk
+++ b/connectivity/source/commontools/makefile.mk
@@ -89,6 +89,7 @@ EXCEPTIONSFILES=\
$(SLO)$/ParamterSubstitution.obj \
$(SLO)$/DriversConfig.obj \
$(SLO)$/formattedcolumnvalue.obj \
+ $(SLO)$/BlobHelper.obj \
$(SLO)$/warningscontainer.obj
SLOFILES=\
diff --git a/connectivity/source/commontools/predicateinput.cxx b/connectivity/source/commontools/predicateinput.cxx
index 94d269955b..8bb6b79974 100644
--- a/connectivity/source/commontools/predicateinput.cxx
+++ b/connectivity/source/commontools/predicateinput.cxx
@@ -148,9 +148,10 @@ namespace dbtools
sal_Int32 nType = DataType::OTHER;
_rxField->getPropertyValue( ::rtl::OUString::createFromAscii( "Type" ) ) >>= nType;
- if ( ( DataType::CHAR == nType )
- || ( DataType::VARCHAR == nType )
+ if ( ( DataType::CHAR == nType )
+ || ( DataType::VARCHAR == nType )
|| ( DataType::LONGVARCHAR == nType )
+ || ( DataType::CLOB == nType )
)
{ // yes -> force a quoted text and try again
::rtl::OUString sQuoted( _rStatement );
diff --git a/connectivity/source/drivers/ado/AResultSet.cxx b/connectivity/source/drivers/ado/AResultSet.cxx
index 10295db9a4..142286adca 100644
--- a/connectivity/source/drivers/ado/AResultSet.cxx
+++ b/connectivity/source/drivers/ado/AResultSet.cxx
@@ -334,11 +334,9 @@ Reference< XRef > SAL_CALL OResultSet::getRef( sal_Int32 /*columnIndex*/ ) throw
}
// -------------------------------------------------------------------------
-Any SAL_CALL OResultSet::getObject( sal_Int32 /*columnIndex*/, const Reference< ::com::sun::star::container::XNameAccess >& /*typeMap*/ ) throw(SQLException, RuntimeException)
+Any SAL_CALL OResultSet::getObject( sal_Int32 columnIndex, const Reference< ::com::sun::star::container::XNameAccess >& /*typeMap*/ ) throw(SQLException, RuntimeException)
{
-
- ::dbtools::throwFeatureNotImplementedException( "XRow::getObject", *this );
- return Any();
+ return getValue(columnIndex).makeAny();
}
// -------------------------------------------------------------------------
@@ -786,14 +784,24 @@ void SAL_CALL OResultSet::updateTimestamp( sal_Int32 columnIndex, const ::com::s
}
// -------------------------------------------------------------------------
-void SAL_CALL OResultSet::updateBinaryStream( sal_Int32 /*columnIndex*/, const Reference< ::com::sun::star::io::XInputStream >& /*x*/, sal_Int32 /*length*/ ) throw(SQLException, RuntimeException)
+void SAL_CALL OResultSet::updateBinaryStream( sal_Int32 columnIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(SQLException, RuntimeException)
{
- ::dbtools::throwFeatureNotImplementedException( "XRowUpdate::updateBinaryStream", *this );
+ if(!x.is())
+ ::dbtools::throwFunctionSequenceException(*this);
+
+ Sequence<sal_Int8> aSeq;
+ x->readBytes(aSeq,length);
+ updateBytes(columnIndex,aSeq);
}
// -------------------------------------------------------------------------
-void SAL_CALL OResultSet::updateCharacterStream( sal_Int32 /*columnIndex*/, const Reference< ::com::sun::star::io::XInputStream >& /*x*/, sal_Int32 /*length*/ ) throw(SQLException, RuntimeException)
+void SAL_CALL OResultSet::updateCharacterStream( sal_Int32 columnIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(SQLException, RuntimeException)
{
- ::dbtools::throwFeatureNotImplementedException( "XRowUpdate::updateCharacterStream", *this );
+ if(!x.is())
+ ::dbtools::throwFunctionSequenceException(*this);
+
+ Sequence<sal_Int8> aSeq;
+ x->readBytes(aSeq,length);
+ updateBytes(columnIndex,aSeq);
}
// -------------------------------------------------------------------------
void SAL_CALL OResultSet::refreshRow( ) throw(SQLException, RuntimeException)
diff --git a/connectivity/source/drivers/ado/Aolevariant.cxx b/connectivity/source/drivers/ado/Aolevariant.cxx
index 650c77a244..b98cf943f5 100644
--- a/connectivity/source/drivers/ado/Aolevariant.cxx
+++ b/connectivity/source/drivers/ado/Aolevariant.cxx
@@ -39,8 +39,17 @@
#include "diagnose_ex.h"
#include "resource/sharedresources.hxx"
#include "resource/ado_res.hrc"
-
+#include "com/sun/star/bridge/oleautomation/Date.hpp"
+#include "com/sun/star/bridge/oleautomation/Currency.hpp"
+#include "com/sun/star/bridge/oleautomation/SCode.hpp"
+#include "com/sun/star/bridge/oleautomation/Decimal.hpp"
+
+using namespace com::sun::star::beans;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::bridge::oleautomation;
using namespace connectivity::ado;
+using ::rtl::OUString;
+
OLEString::OLEString()
:m_sStr(NULL)
{
@@ -698,6 +707,88 @@ SAFEARRAY* OLEVariant::getUI1SAFEARRAYPtr() const
return V_ARRAY(&varDest);
}
// -----------------------------------------------------------------------------
+::com::sun::star::uno::Any OLEVariant::makeAny() const
+{
+ ::com::sun::star::uno::Any aValue;
+ switch (V_VT(this))
+ {
+ case VT_EMPTY:
+ case VT_NULL:
+ aValue.setValue(NULL, Type());
+ break;
+ case VT_I2:
+ aValue.setValue( & iVal, getCppuType( (sal_Int16*)0));
+ break;
+ case VT_I4:
+ aValue.setValue( & lVal, getCppuType( (sal_Int32*)0));
+ break;
+ case VT_R4:
+ aValue.setValue( & fltVal, getCppuType( (float*)0));
+ break;
+ case VT_R8:
+ aValue.setValue(& dblVal, getCppuType( (double*)0));
+ break;
+ case VT_CY:
+ {
+ Currency cy(cyVal.int64);
+ aValue <<= cy;
+ break;
+ }
+ case VT_DATE:
+ {
+ aValue <<= (::com::sun::star::util::Date)*this;
+ break;
+ }
+ case VT_BSTR:
+ {
+ OUString b(reinterpret_cast<const sal_Unicode*>(bstrVal));
+ aValue.setValue( &b, getCppuType( &b));
+ break;
+ }
+ case VT_BOOL:
+ {
+ sal_Bool b= boolVal == VARIANT_TRUE;
+ aValue.setValue( &b, getCppuType( &b));
+ break;
+ }
+ case VT_I1:
+ aValue.setValue( & cVal, getCppuType((sal_Int8*)0));
+ break;
+ case VT_UI1: // there is no unsigned char in UNO
+ aValue.setValue( & bVal, getCppuType( (sal_Int8*)0));
+ break;
+ case VT_UI2:
+ aValue.setValue( & uiVal, getCppuType( (sal_uInt16*)0));
+ break;
+ case VT_UI4:
+ aValue.setValue( & ulVal, getCppuType( (sal_uInt32*)0));
+ break;
+ case VT_INT:
+ aValue.setValue( & intVal, getCppuType( (sal_Int32*)0));
+ break;
+ case VT_UINT:
+ aValue.setValue( & uintVal, getCppuType( (sal_uInt32*)0));
+ break;
+ case VT_VOID:
+ aValue.setValue( NULL, Type());
+ break;
+ case VT_DECIMAL:
+ {
+ Decimal dec;
+ dec.Scale = decVal.scale;
+ dec.Sign = decVal.sign;
+ dec.LowValue = decVal.Lo32;
+ dec.MiddleValue = decVal.Mid32;
+ dec.HighValue = decVal.Hi32;
+ aValue <<= dec;
+ break;
+ }
+
+ default:
+ break;
+ }
+ return aValue;
+}
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
diff --git a/connectivity/source/drivers/ado/adoimp.cxx b/connectivity/source/drivers/ado/adoimp.cxx
index cd89c61711..def609be32 100644
--- a/connectivity/source/drivers/ado/adoimp.cxx
+++ b/connectivity/source/drivers/ado/adoimp.cxx
@@ -157,8 +157,10 @@ DataTypeEnum ADOS::MapJdbc2ADOType(sal_Int32 _nType,sal_Int32 _nJetEngine)
case DataType::BIT: return adBoolean; break;
case DataType::BINARY: return adBinary; break;
case DataType::VARCHAR: return adVarWChar; break;
+ case DataType::CLOB:
case DataType::LONGVARCHAR: return adLongVarWChar; break;
case DataType::VARBINARY: return adVarBinary; break;
+ case DataType::BLOB:
case DataType::LONGVARBINARY: return adLongVarBinary; break;
case DataType::CHAR: return adWChar; break;
case DataType::TINYINT: return isJetEngine(_nJetEngine) ? adUnsignedTinyInt : adTinyInt;break;
diff --git a/connectivity/source/drivers/file/FStatement.cxx b/connectivity/source/drivers/file/FStatement.cxx
index 6d82486dae..652d41d886 100644
--- a/connectivity/source/drivers/file/FStatement.cxx
+++ b/connectivity/source/drivers/file/FStatement.cxx
@@ -497,13 +497,16 @@ void OStatement_Base::construct(const ::rtl::OUString& sql) throw(SQLException,
// SELECT statement without columns -> error
m_pConnection->throwGenericSQLException(STR_QUERY_NO_COLUMN,*this);
- if ( m_aSQLIterator.getStatementType() == SQL_STATEMENT_CREATE_TABLE )
- // CREATE TABLE is not supported at all
- m_pConnection->throwGenericSQLException(STR_QUERY_TOO_COMPLEX,*this);
-
- if ( ( m_aSQLIterator.getStatementType() == SQL_STATEMENT_ODBC_CALL ) || ( m_aSQLIterator.getStatementType() == SQL_STATEMENT_UNKNOWN ) )
- // ODBC call or unknown statement type -> error
- m_pConnection->throwGenericSQLException(STR_QUERY_TOO_COMPLEX,*this);
+ switch(m_aSQLIterator.getStatementType())
+ {
+ case SQL_STATEMENT_CREATE_TABLE:
+ case SQL_STATEMENT_ODBC_CALL:
+ case SQL_STATEMENT_UNKNOWN:
+ m_pConnection->throwGenericSQLException(STR_QUERY_TOO_COMPLEX,*this);
+ break;
+ default:
+ break;
+ }
// at this moment we support only one table per select statement
Reference< ::com::sun::star::lang::XUnoTunnel> xTunnel(xTabs.begin()->second,UNO_QUERY);
diff --git a/connectivity/source/drivers/jdbc/Boolean.cxx b/connectivity/source/drivers/jdbc/Boolean.cxx
index 4e17033cee..c9f222827b 100644
--- a/connectivity/source/drivers/jdbc/Boolean.cxx
+++ b/connectivity/source/drivers/jdbc/Boolean.cxx
@@ -40,17 +40,19 @@ jclass java_lang_Boolean::theClass = 0;
java_lang_Boolean::~java_lang_Boolean()
{}
-
-jclass java_lang_Boolean::getMyClass() const
+jclass java_lang_Boolean::st_getMyClass()
{
// die Klasse muss nur einmal geholt werden, daher statisch
if( !theClass )
- {
theClass = findMyClass("java/lang/Boolean");
- }
return theClass;
}
+jclass java_lang_Boolean::getMyClass() const
+{
+ return st_getMyClass();
+}
+
java_lang_Boolean::java_lang_Boolean( sal_Bool _par0 ): java_lang_Object( NULL, (jobject)NULL )
{
SDBThreadAttach t;
diff --git a/connectivity/source/drivers/jdbc/CallableStatement.cxx b/connectivity/source/drivers/jdbc/CallableStatement.cxx
index 8167c0ee8a..94cf7f58ea 100644
--- a/connectivity/source/drivers/jdbc/CallableStatement.cxx
+++ b/connectivity/source/drivers/jdbc/CallableStatement.cxx
@@ -227,9 +227,8 @@ void SAL_CALL java_sql_CallableStatement::registerOutParameter( sal_Int32 parame
static jmethodID mID(NULL);
obtainMethodId(t.pEnv, cMethodName,cSignature, mID);
// Parameter konvertieren
- jstring str = convertwchar_tToJavaString(t.pEnv,typeName);
- t.pEnv->CallVoidMethod( object, mID, parameterIndex,sqlType,str);
- t.pEnv->DeleteLocalRef(str);
+ jdbc::LocalRef< jstring > str( t.env(),convertwchar_tToJavaString(t.pEnv,typeName));
+ t.pEnv->CallVoidMethod( object, mID, parameterIndex,sqlType,str.get());
ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
}
}
@@ -336,23 +335,22 @@ void java_sql_CallableStatement::createStatement(JNIEnv* /*_pEnv*/)
// Java-Call absetzen
jobject out = NULL;
// Parameter konvertieren
- jstring str = convertwchar_tToJavaString(t.pEnv,m_sSqlStatement);
+ jdbc::LocalRef< jstring > str( t.env(),convertwchar_tToJavaString(t.pEnv,m_sSqlStatement));
static jmethodID mID(NULL);
if ( !mID )
mID = t.pEnv->GetMethodID( m_pConnection->getMyClass(), cMethodName, cSignature );
if( mID ){
- out = t.pEnv->CallObjectMethod( m_pConnection->getJavaObject(), mID, str ,m_nResultSetType,m_nResultSetConcurrency);
+ out = t.pEnv->CallObjectMethod( m_pConnection->getJavaObject(), mID, str.get() ,m_nResultSetType,m_nResultSetConcurrency);
} //mID
else
{
static const char * cSignature2 = "(Ljava/lang/String;)Ljava/sql/CallableStatement;";
static jmethodID mID2 = t.pEnv->GetMethodID( m_pConnection->getMyClass(), cMethodName, cSignature2 );OSL_ENSURE(mID2,"Unknown method id!");
if( mID2 ){
- out = t.pEnv->CallObjectMethod( m_pConnection->getJavaObject(), mID2, str );
+ out = t.pEnv->CallObjectMethod( m_pConnection->getJavaObject(), mID2, str.get() );
} //mID
}
- t.pEnv->DeleteLocalRef(str);
ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
if ( out )
diff --git a/connectivity/source/drivers/jdbc/Clob.cxx b/connectivity/source/drivers/jdbc/Clob.cxx
index c3c53d5809..a1bbc0710a 100644
--- a/connectivity/source/drivers/jdbc/Clob.cxx
+++ b/connectivity/source/drivers/jdbc/Clob.cxx
@@ -34,6 +34,8 @@
#include "java/tools.hxx"
#include "java/io/Reader.hxx"
#include <connectivity/dbexception.hxx>
+#include <rtl/logfile.hxx>
+
using namespace connectivity;
//**************************************************************
//************ Class: java.sql.Clob
@@ -61,6 +63,7 @@ jclass java_sql_Clob::getMyClass() const
sal_Int64 SAL_CALL java_sql_Clob::length( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_Clob::length" );
jlong out(0);
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
@@ -79,6 +82,7 @@ sal_Int64 SAL_CALL java_sql_Clob::length( ) throw(::com::sun::star::sdbc::SQLEx
::rtl::OUString SAL_CALL java_sql_Clob::getSubString( sal_Int64 pos, sal_Int32 subStringLength ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_Clob::getSubString" );
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
::rtl::OUString aStr;
{
@@ -98,6 +102,7 @@ sal_Int64 SAL_CALL java_sql_Clob::length( ) throw(::com::sun::star::sdbc::SQLEx
::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL java_sql_Clob::getCharacterStream( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_Clob::getCharacterStream" );
SDBThreadAttach t;
static jmethodID mID(NULL);
jobject out = callObjectMethod(t.pEnv,"getCharacterStream","()Ljava/io/Reader;", mID);
@@ -108,6 +113,7 @@ sal_Int64 SAL_CALL java_sql_Clob::length( ) throw(::com::sun::star::sdbc::SQLEx
sal_Int64 SAL_CALL java_sql_Clob::position( const ::rtl::OUString& searchstr, sal_Int32 start ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_Clob::position" );
jlong out(0);
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
@@ -130,6 +136,7 @@ sal_Int64 SAL_CALL java_sql_Clob::position( const ::rtl::OUString& searchstr, sa
sal_Int64 SAL_CALL java_sql_Clob::positionOfClob( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XClob >& /*pattern*/, sal_Int64 /*start*/ ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_Clob::positionOfClob" );
::dbtools::throwFeatureNotImplementedException( "XClob::positionOfClob", *this );
// this was put here in CWS warnings01. The previous implementation was defective, as it did ignore
// the pattern parameter. Since the effort for proper implementation is rather high - we would need
diff --git a/connectivity/source/drivers/jdbc/InputStream.cxx b/connectivity/source/drivers/jdbc/InputStream.cxx
index 0236c7f350..17c9b54152 100644
--- a/connectivity/source/drivers/jdbc/InputStream.cxx
+++ b/connectivity/source/drivers/jdbc/InputStream.cxx
@@ -84,8 +84,9 @@ void SAL_CALL java_io_InputStream::closeInput( ) throw(::com::sun::star::io::No
// -----------------------------------------------------
sal_Int32 SAL_CALL java_io_InputStream::readBytes( ::com::sun::star::uno::Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead ) throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException)
{
- if ( aData.getLength() < nBytesToRead )
- throw ::com::sun::star::io::BufferSizeExceededException();
+ if (nBytesToRead < 0)
+ throw ::com::sun::star::io::BufferSizeExceededException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), *this );
+
jint out(0);
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
@@ -102,7 +103,8 @@ sal_Int32 SAL_CALL java_io_InputStream::readBytes( ::com::sun::star::uno::Sequen
if(out > 0)
{
jboolean p = sal_False;
- memcpy(aData.getArray(),t.pEnv->GetByteArrayElements(pByteArray,&p),out);
+ aData.realloc ( out );
+ rtl_copyMemory(aData.getArray(),t.pEnv->GetByteArrayElements(pByteArray,&p),out);
}
t.pEnv->DeleteLocalRef((jbyteArray)pByteArray);
} //t.pEnv
diff --git a/connectivity/source/drivers/jdbc/JConnection.cxx b/connectivity/source/drivers/jdbc/JConnection.cxx
index e2f1afcb77..17e8d2dbbe 100644
--- a/connectivity/source/drivers/jdbc/JConnection.cxx
+++ b/connectivity/source/drivers/jdbc/JConnection.cxx
@@ -56,6 +56,7 @@
#include <rtl/ustrbuf.hxx>
#include <jni.h>
#include "resource/common_res.hrc"
+#include <unotools/confignode.hxx>
#include <list>
#include <memory>
@@ -553,10 +554,9 @@ Reference< XPreparedStatement > SAL_CALL java_sql_Connection::prepareCall( const
static jmethodID mID(NULL);
obtainMethodId(t.pEnv, cMethodName,cSignature, mID);
// Parameter konvertieren
- jstring str = convertwchar_tToJavaString(t.pEnv,sql);
+ jdbc::LocalRef< jstring > str( t.env(),convertwchar_tToJavaString(t.pEnv,sql));
- jobject out = t.pEnv->CallObjectMethod( object, mID, str );
- t.pEnv->DeleteLocalRef(str);
+ jobject out = t.pEnv->CallObjectMethod( object, mID, str.get() );
aStr = JavaString2String(t.pEnv, (jstring)out );
ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
} //t.pEnv
@@ -767,7 +767,20 @@ void java_sql_Connection::loadDriverFromProperties( const ::rtl::OUString& _sDri
enableAutoRetrievingEnabled( bAutoRetrievingEnabled );
setAutoRetrievingStatement( sGeneratedValueStatement );
}
-
+// -----------------------------------------------------------------------------
+::rtl::OUString java_sql_Connection::impl_getJavaDriverClassPath_nothrow(const ::rtl::OUString& _sDriverClass)
+{
+ static const ::rtl::OUString s_sNodeName(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.Office.DataAccess/JDBC/DriverClassPaths"));
+ ::utl::OConfigurationTreeRoot aNamesRoot = ::utl::OConfigurationTreeRoot::createWithServiceFactory(
+ m_pDriver->getContext().getLegacyServiceFactory(), s_sNodeName, -1, ::utl::OConfigurationTreeRoot::CM_READONLY);
+ ::rtl::OUString sURL;
+ if ( aNamesRoot.isValid() && aNamesRoot.hasByName( _sDriverClass ) )
+ {
+ ::utl::OConfigurationNode aRegisterObj = aNamesRoot.openNode( _sDriverClass );
+ OSL_VERIFY( aRegisterObj.getNodeValue( "Path" ) >>= sURL );
+ }
+ return sURL;
+}
// -----------------------------------------------------------------------------
sal_Bool java_sql_Connection::construct(const ::rtl::OUString& url,
const Sequence< PropertyValue >& info)
@@ -790,6 +803,8 @@ sal_Bool java_sql_Connection::construct(const ::rtl::OUString& url,
::comphelper::NamedValueCollection aSettings( info );
sDriverClass = aSettings.getOrDefault( "JavaDriverClass", sDriverClass );
sDriverClassPath = aSettings.getOrDefault( "JavaDriverClassPath", sDriverClassPath);
+ if ( !sDriverClassPath.getLength() )
+ sDriverClassPath = impl_getJavaDriverClassPath_nothrow(sDriverClass);
bAutoRetrievingEnabled = aSettings.getOrDefault( "IsAutoRetrievingEnabled", bAutoRetrievingEnabled );
sGeneratedValueStatement = aSettings.getOrDefault( "AutoRetrievingStatement", sGeneratedValueStatement );
m_bParameterSubstitution = aSettings.getOrDefault( "ParameterNameSubstitution", m_bParameterSubstitution );
@@ -810,8 +825,8 @@ sal_Bool java_sql_Connection::construct(const ::rtl::OUString& url,
static const char * cSignature = "(Ljava/lang/String;Ljava/util/Properties;)Ljava/sql/Connection;";
static const char * cMethodName = "connect";
// Java-Call absetzen
- jmethodID mID = NULL;
- if ( !mID )
+ static jmethodID mID = NULL;
+ if ( !mID )
mID = t.pEnv->GetMethodID( m_Driver_theClass, cMethodName, cSignature );
if ( mID )
{
diff --git a/connectivity/source/drivers/jdbc/Object.cxx b/connectivity/source/drivers/jdbc/Object.cxx
index b8e8c87954..72f3731f5a 100644
--- a/connectivity/source/drivers/jdbc/Object.cxx
+++ b/connectivity/source/drivers/jdbc/Object.cxx
@@ -43,7 +43,7 @@
#include <vos/mutex.hxx>
#include <osl/thread.h>
#include <com/sun/star/uno/Sequence.hxx>
-
+#include "java/LocalRef.hxx"
#include "resource/jdbc_log.hrc"
#include <rtl/logfile.hxx>
#include <comphelper/logging.hxx>
@@ -395,10 +395,9 @@ void java_lang_Object::callVoidMethodWithStringArg( const char* _pMethodName, jm
OSL_ENSURE( t.pEnv, "java_lang_Object::callIntMethod: no Java enviroment anymore!" );
obtainMethodId(t.pEnv, _pMethodName,"(Ljava/lang/String;)V", _inout_MethodID);
- jstring str = convertwchar_tToJavaString(t.pEnv,_nArgument);
+ jdbc::LocalRef< jstring > str( t.env(),convertwchar_tToJavaString(t.pEnv,_nArgument));
// call method
- t.pEnv->CallVoidMethod( object, _inout_MethodID , str);
- t.pEnv->DeleteLocalRef(str);
+ t.pEnv->CallVoidMethod( object, _inout_MethodID , str.get());
ThrowSQLException( t.pEnv, NULL );
}
// -------------------------------------------------------------------------
@@ -417,10 +416,9 @@ sal_Int32 java_lang_Object::callIntMethodWithStringArg( const char* _pMethodName
// *this
// );
- jstring str = convertwchar_tToJavaString(t.pEnv,_nArgument);
+ jdbc::LocalRef< jstring > str( t.env(),convertwchar_tToJavaString(t.pEnv,_nArgument));
// call method
- jint out = t.pEnv->CallIntMethod( object, _inout_MethodID , str);
- t.pEnv->DeleteLocalRef(str);
+ jint out = t.pEnv->CallIntMethod( object, _inout_MethodID , str.get());
ThrowSQLException( t.pEnv, NULL );
return (sal_Int32)out;
}
diff --git a/connectivity/source/drivers/jdbc/PreparedStatement.cxx b/connectivity/source/drivers/jdbc/PreparedStatement.cxx
index 62e12c42a5..7639357a41 100644
--- a/connectivity/source/drivers/jdbc/PreparedStatement.cxx
+++ b/connectivity/source/drivers/jdbc/PreparedStatement.cxx
@@ -45,7 +45,7 @@
#include "resource/jdbc_log.hrc"
#include "resource/common_res.hrc"
#include "resource/sharedresources.hxx"
-
+#include "java/LocalRef.hxx"
#include <string.h>
using namespace connectivity;
@@ -138,10 +138,9 @@ void SAL_CALL java_sql_PreparedStatement::setString( sal_Int32 parameterIndex, c
// Java-Call absetzen
static jmethodID mID(NULL);
obtainMethodId(t.pEnv, cMethodName,cSignature, mID);
- jstring str = convertwchar_tToJavaString(t.pEnv,x);
- t.pEnv->CallVoidMethod( object, mID, parameterIndex,str);
+ jdbc::LocalRef< jstring > str( t.env(),convertwchar_tToJavaString(t.pEnv,x));
+ t.pEnv->CallVoidMethod( object, mID, parameterIndex,str.get());
// und aufraeumen
- t.pEnv->DeleteLocalRef(str);
ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
} //t.pEnv
}
diff --git a/connectivity/source/drivers/jdbc/ResultSet.cxx b/connectivity/source/drivers/jdbc/ResultSet.cxx
index 8a5a9a22a0..144ee27c7c 100644
--- a/connectivity/source/drivers/jdbc/ResultSet.cxx
+++ b/connectivity/source/drivers/jdbc/ResultSet.cxx
@@ -30,10 +30,13 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_connectivity.hxx"
+#include "java/lang/String.hxx"
+#include "java/lang/Boolean.hxx"
#include "java/sql/ResultSet.hxx"
#include "java/math/BigDecimal.hxx"
#include "java/sql/JStatement.hxx"
#include "java/sql/SQLWarning.hxx"
+#include "java/sql/Timestamp.hxx"
#include "java/sql/Array.hxx"
#include "java/sql/Ref.hxx"
#include "java/sql/Clob.hxx"
@@ -54,6 +57,7 @@
#include "connectivity/dbexception.hxx"
#include "resource/common_res.hrc"
#include "resource/sharedresources.hxx"
+#include "java/LocalRef.hxx"
#include <rtl/logfile.hxx>
#include <string.h>
@@ -324,6 +328,7 @@ Any SAL_CALL java_sql_ResultSet::getObject( sal_Int32 columnIndex, const Referen
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::getObject" );
jobject out(0);
+ Any aRet;
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
{
jvalue args[2];
@@ -341,15 +346,43 @@ Any SAL_CALL java_sql_ResultSet::getObject( sal_Int32 columnIndex, const Referen
obtainMethodId(t.pEnv, cMethodName,cSignature, mID);
}
- out = t.pEnv->CallObjectMethodA( object, mID, args);
- t.pEnv->DeleteLocalRef((jstring)args[1].l);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- // und aufraeumen
-
+ out = t.pEnv->CallObjectMethodA( object, mID, args);
+ t.pEnv->DeleteLocalRef((jstring)args[1].l);
+ ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
+ // und aufraeumen
+ if ( out )
+ {
+ if ( t.pEnv->IsInstanceOf(out,java_lang_String::st_getMyClass()) )
+ {
+ java_lang_String aVal(t.pEnv,out);
+ aRet <<= (::rtl::OUString)aVal;
+ }
+ else if ( t.pEnv->IsInstanceOf(out,java_lang_Boolean::st_getMyClass()) )
+ {
+ java_lang_Boolean aVal(t.pEnv,out);
+ static jmethodID methodID = NULL;
+ aRet <<= aVal.callBooleanMethod("booleanValue",methodID);
+ }
+ else if ( t.pEnv->IsInstanceOf(out,java_sql_Date::st_getMyClass()) )
+ {
+ java_sql_Date aVal(t.pEnv,out);
+ aRet <<= (::com::sun::star::util::Date)aVal;
+ }
+ else if ( t.pEnv->IsInstanceOf(out,java_sql_Time::st_getMyClass()) )
+ {
+ java_sql_Time aVal(t.pEnv,out);
+ aRet <<= (::com::sun::star::util::Time)aVal;
+ }
+ else if ( t.pEnv->IsInstanceOf(out,java_sql_Timestamp::st_getMyClass()) )
+ {
+ java_sql_Timestamp aVal(t.pEnv,out);
+ aRet <<= (::com::sun::star::util::DateTime)aVal;
+ }
+ else
+ t.pEnv->DeleteLocalRef(out);
+ }
} //t.pEnv
- // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!!
- ::dbtools::throwFunctionNotSupportedException( "XRow::getObject", *this );
- return out==0 ? Any() : Any();//new java_lang_Object( t.pEnv, out );
+ return aRet;
}
// -------------------------------------------------------------------------
@@ -689,9 +722,8 @@ void SAL_CALL java_sql_ResultSet::updateString( sal_Int32 columnIndex, const ::r
{
// Parameter konvertieren
- jstring str = convertwchar_tToJavaString(t.pEnv,x);
- t.pEnv->CallVoidMethod( object, mID,columnIndex,str);
- t.pEnv->DeleteLocalRef(str);
+ jdbc::LocalRef< jstring > str( t.env(),convertwchar_tToJavaString(t.pEnv,x));
+ t.pEnv->CallVoidMethod( object, mID,columnIndex,str.get());
ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
}
}
@@ -754,16 +786,68 @@ void SAL_CALL java_sql_ResultSet::updateTimestamp( sal_Int32 columnIndex, const
}
// -------------------------------------------------------------------------
-void SAL_CALL java_sql_ResultSet::updateBinaryStream( sal_Int32 /*columnIndex*/, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& /*x*/, sal_Int32 /*length*/ ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+void SAL_CALL java_sql_ResultSet::updateBinaryStream( sal_Int32 columnIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::updateBinaryStream" );
- ::dbtools::throwFeatureNotImplementedException( "XParameters::updateBinaryStream", *this );
+ try
+ {
+ SDBThreadAttach t;
+ {
+
+ // temporaere Variable initialisieren
+ // Java-Call absetzen
+ static jmethodID mID(NULL);
+ if ( !mID )
+ {
+ static const char * cSignature = "(ILjava/io/InputStream;I)V";
+ static const char * cMethodName = "updateBinaryStream";
+ obtainMethodId(t.pEnv, cMethodName,cSignature, mID);
+ }
+
+ {
+ // Parameter konvertieren
+ jobject obj = createByteInputStream(x,length);
+ t.pEnv->CallVoidMethod( object, mID, columnIndex,obj,length);
+ ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
+ }
+ }
+ }
+ catch(Exception)
+ {
+ ::dbtools::throwFeatureNotImplementedException( "XRowUpdate::updateBinaryStream", *this );
+ }
}
// -------------------------------------------------------------------------
-void SAL_CALL java_sql_ResultSet::updateCharacterStream( sal_Int32 /*columnIndex*/, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& /*x*/, sal_Int32 /*length*/ ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+void SAL_CALL java_sql_ResultSet::updateCharacterStream( sal_Int32 columnIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::updateCharacterStream" );
- ::dbtools::throwFeatureNotImplementedException( "XRowUpdate::updateCharacterStream", *this );
+ try
+ {
+ SDBThreadAttach t;
+ {
+
+ // temporaere Variable initialisieren
+ // Java-Call absetzen
+ static jmethodID mID(NULL);
+ if ( !mID )
+ {
+ static const char * cSignature = "(ILjava/io/Reader;I)V";
+ static const char * cMethodName = "updateCharacterStream";
+ obtainMethodId(t.pEnv, cMethodName,cSignature, mID);
+ }
+
+ {
+ // Parameter konvertieren
+ jobject obj = createCharArrayReader(x,length);
+ t.pEnv->CallVoidMethod( object, mID, columnIndex,obj,length);
+ ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
+ }
+ }
+ }
+ catch(Exception)
+ {
+ ::dbtools::throwFeatureNotImplementedException( "XRowUpdate::updateCharacterStream", *this );
+ }
}
// -------------------------------------------------------------------------
void SAL_CALL java_sql_ResultSet::updateObject( sal_Int32 columnIndex, const ::com::sun::star::uno::Any& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
diff --git a/connectivity/source/drivers/jdbc/Timestamp.cxx b/connectivity/source/drivers/jdbc/Timestamp.cxx
index 5a014d12a5..fe66e881a7 100644
--- a/connectivity/source/drivers/jdbc/Timestamp.cxx
+++ b/connectivity/source/drivers/jdbc/Timestamp.cxx
@@ -71,6 +71,10 @@ java_sql_Date::~java_sql_Date()
jclass java_sql_Date::getMyClass() const
{
+ return st_getMyClass();
+}
+jclass java_sql_Date::st_getMyClass()
+{
// die Klasse muss nur einmal geholt werden, daher statisch
if( !theClass )
theClass = findMyClass("java/sql/Date");
@@ -94,12 +98,15 @@ java_sql_Time::~java_sql_Time()
jclass java_sql_Time::getMyClass() const
{
+ return st_getMyClass();
+}
+jclass java_sql_Time::st_getMyClass()
+{
// die Klasse muss nur einmal geholt werden, daher statisch
if( !theClass )
theClass = findMyClass("java/sql/Time");
return theClass;
}
-
java_sql_Time::java_sql_Time( const ::com::sun::star::util::Time& _rOut ): java_util_Date( NULL, (jobject)NULL )
{
SDBThreadAttach t;
@@ -140,12 +147,15 @@ java_sql_Timestamp::~java_sql_Timestamp()
jclass java_sql_Timestamp::getMyClass() const
{
+ return st_getMyClass();
+}
+jclass java_sql_Timestamp::st_getMyClass()
+{
// die Klasse muss nur einmal geholt werden, daher statisch
if( !theClass )
theClass = findMyClass("java/sql/Timestamp");
return theClass;
}
-
java_sql_Timestamp::java_sql_Timestamp(const ::com::sun::star::util::DateTime& _rOut)
:java_util_Date( NULL, (jobject)NULL )
{
diff --git a/connectivity/source/drivers/jdbc/makefile.mk b/connectivity/source/drivers/jdbc/makefile.mk
index 831a6755af..fb37a30777 100644
--- a/connectivity/source/drivers/jdbc/makefile.mk
+++ b/connectivity/source/drivers/jdbc/makefile.mk
@@ -95,6 +95,7 @@ SHL1STDLIBS=\
$(SALLIB) \
$(JVMACCESSLIB) \
$(DBTOOLSLIB) \
+ $(UNOTOOLSLIB) \
$(JVMFWKLIB) \
$(COMPHELPERLIB)
diff --git a/connectivity/source/drivers/jdbc/tools.cxx b/connectivity/source/drivers/jdbc/tools.cxx
index 8a3ca446dc..f9de90d92f 100644
--- a/connectivity/source/drivers/jdbc/tools.cxx
+++ b/connectivity/source/drivers/jdbc/tools.cxx
@@ -218,5 +218,58 @@ sal_Bool connectivity::isExceptionOccured(JNIEnv *pEnv,sal_Bool _bClear)
return bRet;
}
-
-
+// -----------------------------------------------------------------------------
+jobject connectivity::createByteInputStream(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x,sal_Int32 length)
+{
+ SDBThreadAttach t;
+ if( !t.pEnv || !x.is() )
+ return NULL;
+ // Java-Call fuer den Konstruktor absetzen
+ // temporaere Variable initialisieren
+ jclass clazz = java_lang_Object::findMyClass("java/io/ByteArrayInputStream");
+ static jmethodID mID(NULL);
+ if ( !mID )
+ {
+ static const char * cSignature = "([B)V";
+ mID = t.pEnv->GetMethodID( clazz, "<init>", cSignature );
+ OSL_ENSURE( mID, cSignature );
+ if ( !mID )
+ throw SQLException();
+ } // if ( !_inout_MethodID )
+ jbyteArray pByteArray = t.pEnv->NewByteArray(length);
+ Sequence< sal_Int8 > aData;
+ x->readBytes(aData,length);
+ jboolean p = sal_False;
+ rtl_copyMemory(t.pEnv->GetByteArrayElements(pByteArray,&p),aData.getArray(),aData.getLength());
+ jobject out = t.pEnv->NewObject( clazz, mID,pByteArray);
+ t.pEnv->DeleteLocalRef((jbyteArray)pByteArray);
+ return out;
+}
+// -----------------------------------------------------------------------------
+jobject connectivity::createCharArrayReader(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x,sal_Int32 length)
+{
+ SDBThreadAttach t;
+ if( !t.pEnv || !x.is() )
+ return NULL;
+ // Java-Call fuer den Konstruktor absetzen
+ // temporaere Variable initialisieren
+ jclass clazz = java_lang_Object::findMyClass("java/io/CharArrayReader");
+ static jmethodID mID(NULL);
+ if ( !mID )
+ {
+ static const char * cSignature = "([C)V";
+ mID = t.pEnv->GetMethodID( clazz, "<init>", cSignature );
+ OSL_ENSURE( mID, cSignature );
+ if ( !mID )
+ throw SQLException();
+ } // if ( !_inout_MethodID )
+ jcharArray pCharArray = t.pEnv->NewCharArray(length);
+ Sequence< sal_Int8 > aData;
+ x->readBytes(aData,length);
+ jboolean p = sal_False;
+ rtl_copyMemory(t.pEnv->GetCharArrayElements(pCharArray,&p),aData.getArray(),aData.getLength());
+ jobject out = t.pEnv->NewObject( clazz, mID,pCharArray);
+ t.pEnv->DeleteLocalRef((jcharArray)pCharArray);
+ return out;
+}
+// -----------------------------------------------------------------------------
diff --git a/connectivity/source/drivers/odbcbase/ODatabaseMetaData.cxx b/connectivity/source/drivers/odbcbase/ODatabaseMetaData.cxx
index 97edeeffeb..6874e4e69f 100644
--- a/connectivity/source/drivers/odbcbase/ODatabaseMetaData.cxx
+++ b/connectivity/source/drivers/odbcbase/ODatabaseMetaData.cxx
@@ -921,6 +921,7 @@ sal_Bool SAL_CALL ODatabaseMetaData::supportsConvert( sal_Int32 fromType, sal_In
OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CONVERT_VARCHAR,nValue,*this);
break;
case DataType::LONGVARCHAR:
+ case DataType::CLOB:
OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CONVERT_LONGVARCHAR,nValue,*this);
break;
case DataType::DATE:
@@ -939,6 +940,7 @@ sal_Bool SAL_CALL ODatabaseMetaData::supportsConvert( sal_Int32 fromType, sal_In
OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CONVERT_VARBINARY,nValue,*this);
break;
case DataType::LONGVARBINARY:
+ case DataType::BLOB:
OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CONVERT_LONGVARBINARY,nValue,*this);
break;
case DataType::SQLNULL:
@@ -959,12 +961,6 @@ sal_Bool SAL_CALL ODatabaseMetaData::supportsConvert( sal_Int32 fromType, sal_In
case DataType::ARRAY:
// OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CORRELATION_NAME,nValue,*this);
break;
- case DataType::BLOB:
- // OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CORRELATION_NAME,nValue,*this);
- break;
- case DataType::CLOB:
- // OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CORRELATION_NAME,nValue,*this);
- break;
case DataType::REF:
// OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CORRELATION_NAME,nValue,*this);
break;
@@ -1009,6 +1005,7 @@ sal_Bool SAL_CALL ODatabaseMetaData::supportsConvert( sal_Int32 fromType, sal_In
bConvert = (nValue & SQL_CVT_VARCHAR) == SQL_CVT_VARCHAR;
break;
case DataType::LONGVARCHAR:
+ case DataType::CLOB:
bConvert = (nValue & SQL_CVT_LONGVARCHAR) == SQL_CVT_LONGVARCHAR;
break;
case DataType::DATE:
@@ -1027,6 +1024,7 @@ sal_Bool SAL_CALL ODatabaseMetaData::supportsConvert( sal_Int32 fromType, sal_In
bConvert = (nValue & SQL_CVT_VARBINARY) == SQL_CVT_VARBINARY;
break;
case DataType::LONGVARBINARY:
+ case DataType::BLOB:
bConvert = (nValue & SQL_CVT_LONGVARBINARY) == SQL_CVT_LONGVARBINARY;
break;
}
diff --git a/connectivity/source/drivers/odbcbase/OPreparedStatement.cxx b/connectivity/source/drivers/odbcbase/OPreparedStatement.cxx
index 24b8bf5068..1fe1e3525e 100644
--- a/connectivity/source/drivers/odbcbase/OPreparedStatement.cxx
+++ b/connectivity/source/drivers/odbcbase/OPreparedStatement.cxx
@@ -343,9 +343,9 @@ void OPreparedStatement::setParameter(sal_Int32 parameterIndex,sal_Int32 _nType,
case SQL_NUMERIC:
++nRealSize;
break;
- case SQL_BINARY:
- case SQL_VARBINARY:
- nRealSize=1; //dummy buffer, binary data isn't copied
+ case SQL_BINARY:
+ case SQL_VARBINARY:
+ nRealSize=1; //dummy buffer, binary data isn't copied
break;
default:
break;
@@ -474,15 +474,17 @@ void SAL_CALL OPreparedStatement::setNull( sal_Int32 parameterIndex, sal_Int32 s
}
// -------------------------------------------------------------------------
-void SAL_CALL OPreparedStatement::setClob( sal_Int32 /*parameterIndex*/, const Reference< XClob >& /*x*/ ) throw(SQLException, RuntimeException)
+void SAL_CALL OPreparedStatement::setClob( sal_Int32 parameterIndex, const Reference< XClob >& x ) throw(SQLException, RuntimeException)
{
- ::dbtools::throwFunctionNotSupportedException( "XParameters::setClob", *this );
+ if ( x.is() )
+ setStream(parameterIndex, x->getCharacterStream(), (SQLLEN)x->length(), DataType::LONGVARCHAR);
}
// -------------------------------------------------------------------------
-void SAL_CALL OPreparedStatement::setBlob( sal_Int32 /*parameterIndex*/, const Reference< XBlob >& /*x*/ ) throw(SQLException, RuntimeException)
+void SAL_CALL OPreparedStatement::setBlob( sal_Int32 parameterIndex, const Reference< XBlob >& x ) throw(SQLException, RuntimeException)
{
- ::dbtools::throwFunctionNotSupportedException( "XParameters::setBlob", *this );
+ if ( x.is() )
+ setStream(parameterIndex, x->getBinaryStream(), (SQLLEN)x->length(), DataType::LONGVARCHAR);
}
// -------------------------------------------------------------------------
@@ -497,7 +499,12 @@ void SAL_CALL OPreparedStatement::setRef( sal_Int32 /*parameterIndex*/, const Re
::dbtools::throwFunctionNotSupportedException( "XParameters::setRef", *this );
}
// -------------------------------------------------------------------------
-
+void OPreparedStatement::setDecimal( sal_Int32 parameterIndex, const ::rtl::OUString& x )
+{
+ ::rtl::OString aString(::rtl::OUStringToOString(x,getOwnConnection()->getTextEncoding()));
+ setParameter(parameterIndex,DataType::DECIMAL,aString.getLength(),(void*)&x);
+}
+// -------------------------------------------------------------------------
void SAL_CALL OPreparedStatement::setObjectWithInfo( sal_Int32 parameterIndex, const Any& x, sal_Int32 sqlType, sal_Int32 scale ) throw(SQLException, RuntimeException)
{
checkDisposed(OStatement_BASE::rBHelper.bDisposed);
@@ -522,6 +529,12 @@ void SAL_CALL OPreparedStatement::setObjectWithInfo( sal_Int32 parameterIndex, c
setNull(parameterIndex,sqlType);
break;
case DataType::DECIMAL:
+ {
+ ORowSetValue aValue;
+ aValue.fill(x);
+ setDecimal(parameterIndex,aValue);
+ }
+ break;
case DataType::NUMERIC:
{
ORowSetValue aValue;
@@ -569,13 +582,13 @@ void SAL_CALL OPreparedStatement::setBytes( sal_Int32 parameterIndex, const Sequ
void SAL_CALL OPreparedStatement::setCharacterStream( sal_Int32 parameterIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(SQLException, RuntimeException)
{
- setStream (parameterIndex, x, length, DataType::LONGVARCHAR);
+ setStream(parameterIndex, x, length, DataType::LONGVARCHAR);
}
// -------------------------------------------------------------------------
void SAL_CALL OPreparedStatement::setBinaryStream( sal_Int32 parameterIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(SQLException, RuntimeException)
{
- setStream (parameterIndex, x, length, DataType::LONGVARBINARY);
+ setStream(parameterIndex, x, length, DataType::LONGVARBINARY);
}
// -------------------------------------------------------------------------
@@ -834,10 +847,10 @@ sal_Int32 OPreparedStatement::getPrecision ( sal_Int32 sqlType)
// Sets an input stream as a parameter, using the given SQL type
//--------------------------------------------------------------------
-void OPreparedStatement::setStream (
+void OPreparedStatement::setStream(
sal_Int32 ParameterIndex,
const Reference< XInputStream>& x,
- sal_Int32 length,
+ SQLLEN length,
sal_Int32 SQLtype)
throw(SQLException)
{
diff --git a/connectivity/source/drivers/odbcbase/OResultSet.cxx b/connectivity/source/drivers/odbcbase/OResultSet.cxx
index e48cfe0259..8e2254fa28 100644
--- a/connectivity/source/drivers/odbcbase/OResultSet.cxx
+++ b/connectivity/source/drivers/odbcbase/OResultSet.cxx
@@ -223,9 +223,11 @@ SQLRETURN OResultSet::unbind(sal_Bool _bUnbindHandle)
delete static_cast< double* >(reinterpret_cast< void * >(pValue->first));
break;
case DataType::LONGVARCHAR:
+ case DataType::CLOB:
delete [] static_cast< char* >(reinterpret_cast< void * >(pValue->first));
break;
case DataType::LONGVARBINARY:
+ case DataType::BLOB:
delete [] static_cast< char* >(reinterpret_cast< void * >(pValue->first));
break;
case DataType::DATE:
@@ -284,9 +286,11 @@ TVoidPtr OResultSet::allocBindColumn(sal_Int32 _nType,sal_Int32 _nColumnIndex)
aPair = TVoidPtr(reinterpret_cast< sal_Int64 >(new double(0.0)),_nType);
break;
case DataType::LONGVARCHAR:
+ case DataType::CLOB:
aPair = TVoidPtr(reinterpret_cast< sal_Int64 >(new char[2]),_nType); // dient nur zum auffinden
break;
case DataType::LONGVARBINARY:
+ case DataType::BLOB:
aPair = TVoidPtr(reinterpret_cast< sal_Int64 >(new char[2]),_nType); // dient nur zum auffinden
break;
case DataType::DATE:
@@ -1499,6 +1503,7 @@ void OResultSet::fillRow(sal_Int32 _nToColumn)
case DataType::DECIMAL:
case DataType::NUMERIC:
case DataType::LONGVARCHAR:
+ case DataType::CLOB:
{
::std::map<sal_Int32,SWORD>::iterator aFind = m_aODBCColumnTypes.find(nColumn);
if ( aFind == m_aODBCColumnTypes.end() )
@@ -1514,6 +1519,7 @@ void OResultSet::fillRow(sal_Int32 _nToColumn)
*pColumn = getDouble(nColumn);
break;
case DataType::LONGVARBINARY:
+ case DataType::BLOB:
*pColumn = getBytes(nColumn);
break;
case DataType::DATE:
@@ -1719,6 +1725,7 @@ void OResultSet::fillNeededData(SQLRETURN _nRet)
case DataType::BINARY:
case DataType::VARBINARY:
case DataType::LONGVARBINARY:
+ case DataType::BLOB:
aSeq = m_aRow[nColumnIndex];
N3SQLPutData (m_aStatementHandle, aSeq.getArray(), aSeq.getLength());
break;
@@ -1730,6 +1737,7 @@ void OResultSet::fillNeededData(SQLRETURN _nRet)
break;
}
case DataType::LONGVARCHAR:
+ case DataType::CLOB:
{
::rtl::OUString sRet;
sRet = m_aRow[nColumnIndex].getString();
diff --git a/connectivity/source/drivers/odbcbase/OTools.cxx b/connectivity/source/drivers/odbcbase/OTools.cxx
index e174552174..c5506533ae 100644
--- a/connectivity/source/drivers/odbcbase/OTools.cxx
+++ b/connectivity/source/drivers/odbcbase/OTools.cxx
@@ -135,6 +135,7 @@ void OTools::bindData( SQLSMALLINT _nOdbcType,
{
case SQL_CHAR:
case SQL_VARCHAR:
+ case SQL_DECIMAL:
if(_bUseWChar)
{
*pLen = SQL_NTS;
@@ -160,7 +161,7 @@ void OTools::bindData( SQLSMALLINT _nOdbcType,
*pLen = sizeof(sal_Int64);
_nColumnSize = *pLen;
break;
- case SQL_DECIMAL:
+
case SQL_NUMERIC:
if(_bUseWChar)
{
diff --git a/connectivity/source/inc/ado/Aolevariant.hxx b/connectivity/source/inc/ado/Aolevariant.hxx
index ddacefec17..f53985d007 100644
--- a/connectivity/source/inc/ado/Aolevariant.hxx
+++ b/connectivity/source/inc/ado/Aolevariant.hxx
@@ -161,6 +161,7 @@ namespace connectivity
double getDate() const;
CY getCurrency() const;
SAFEARRAY* getUI1SAFEARRAYPtr() const;
+ ::com::sun::star::uno::Any makeAny() const;
static VARIANT_BOOL VariantBool(sal_Bool bEinBoolean);
diff --git a/connectivity/source/inc/java/lang/Boolean.hxx b/connectivity/source/inc/java/lang/Boolean.hxx
index 9bc7dc7d61..8a4cacdc63 100644
--- a/connectivity/source/inc/java/lang/Boolean.hxx
+++ b/connectivity/source/inc/java/lang/Boolean.hxx
@@ -48,6 +48,7 @@ namespace connectivity
java_lang_Boolean( JNIEnv * pEnv, jobject myObj ) : java_lang_Object( pEnv, myObj ){}
java_lang_Boolean( sal_Bool _par0 );
+ static jclass st_getMyClass();
};
}
diff --git a/connectivity/source/inc/java/sql/Connection.hxx b/connectivity/source/inc/java/sql/Connection.hxx
index 55244525da..713433d842 100644
--- a/connectivity/source/inc/java/sql/Connection.hxx
+++ b/connectivity/source/inc/java/sql/Connection.hxx
@@ -80,6 +80,11 @@ namespace connectivity
const ::rtl::OUString& _sDriverClassPath,
const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >& _rSystemProperties
);
+ /** load driver class path from system configuration.
+ @param _sDriverClass
+ The driver class name to look for in the configuration.
+ */
+ ::rtl::OUString impl_getJavaDriverClassPath_nothrow(const ::rtl::OUString& _sDriverClass);
protected:
// statische Daten fuer die Klasse
diff --git a/connectivity/source/inc/java/sql/Timestamp.hxx b/connectivity/source/inc/java/sql/Timestamp.hxx
index 2af09c2f02..83e6a728f9 100644
--- a/connectivity/source/inc/java/sql/Timestamp.hxx
+++ b/connectivity/source/inc/java/sql/Timestamp.hxx
@@ -54,6 +54,7 @@ namespace connectivity
java_sql_Date( const ::com::sun::star::util::Date& _rOut );
operator ::com::sun::star::util::Date();
+ static jclass st_getMyClass();
};
@@ -73,6 +74,7 @@ namespace connectivity
java_sql_Time( JNIEnv * pEnv, jobject myObj ) : java_util_Date( pEnv, myObj ){}
java_sql_Time( const ::com::sun::star::util::Time& _rOut );
operator ::com::sun::star::util::Time();
+ static jclass st_getMyClass();
};
//**************************************************************
@@ -93,6 +95,7 @@ namespace connectivity
sal_Int32 getNanos();
void setNanos(sal_Int32 n);
+ static jclass st_getMyClass();
};
}
#endif // _CONNECTIVITY_JAVA_SQL_TIMESTAMP_HXX_
diff --git a/connectivity/source/inc/java/tools.hxx b/connectivity/source/inc/java/tools.hxx
index 098126895a..897a5ac572 100644
--- a/connectivity/source/inc/java/tools.hxx
+++ b/connectivity/source/inc/java/tools.hxx
@@ -41,6 +41,7 @@
#include <comphelper/uno3.hxx>
#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/io/XInputStream.hpp>
#include <com/sun/star/util/Time.hpp>
#include <com/sun/star/util/Date.hpp>
#include <com/sun/star/util/DateTime.hpp>
@@ -85,6 +86,9 @@ namespace connectivity
<TRUE/> if an exception is occured
*/
sal_Bool isExceptionOccured(JNIEnv *pEnv,sal_Bool _bClear);
+
+ jobject createByteInputStream(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x,sal_Int32 length);
+ jobject createCharArrayReader(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x,sal_Int32 length);
}
#endif // _CONNECTIVITY_JAVA_TOOLS_HXX_
diff --git a/connectivity/source/inc/odbc/OPreparedStatement.hxx b/connectivity/source/inc/odbc/OPreparedStatement.hxx
index dfd2a62830..e3b3592773 100644
--- a/connectivity/source/inc/odbc/OPreparedStatement.hxx
+++ b/connectivity/source/inc/odbc/OPreparedStatement.hxx
@@ -89,7 +89,7 @@ namespace connectivity
void FreeParams();
void putParamData (sal_Int32 index) throw(::com::sun::star::sdbc::SQLException);
void setStream (sal_Int32 ParameterIndex,const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream>& x,
- sal_Int32 length,sal_Int32 SQLtype) throw(::com::sun::star::sdbc::SQLException);
+ SQLLEN length,sal_Int32 SQLtype) throw(::com::sun::star::sdbc::SQLException);
sal_Int32 getParamLength ( sal_Int32 index);
sal_Int8* getLengthBuf (sal_Int32 index);
sal_Int8* getDataBuf (sal_Int32 index);
@@ -102,6 +102,7 @@ namespace connectivity
sal_Bool isPrepared() const { return m_bPrepared;}
void prepareStatement();
void checkParameterIndex(sal_Int32 _parameterIndex);
+ void setDecimal( sal_Int32 parameterIndex, const ::rtl::OUString& x );
/**
creates the driver specific resultset (factory)
diff --git a/connectivity/source/parse/sqlbison.y b/connectivity/source/parse/sqlbison.y
index 97875dfd4d..1680516e8d 100644
--- a/connectivity/source/parse/sqlbison.y
+++ b/connectivity/source/parse/sqlbison.y
@@ -107,7 +107,6 @@ static connectivity::OSQLInternalNode* newNode(const sal_Char* pNewValue,
const connectivity::SQLNodeType eNodeType,
const sal_uInt32 nNodeID = 0)
{
- OSL_TRACE("connectivity: Rule Number: %d,%d",eNodeType,nNodeID);
return new connectivity::OSQLInternalNode(pNewValue, eNodeType, nNodeID);
}
@@ -115,7 +114,6 @@ static connectivity::OSQLInternalNode* newNode(const ::rtl::OString& _NewValue,
const connectivity::SQLNodeType eNodeType,
const sal_uInt32 nNodeID = 0)
{
- OSL_TRACE("connectivity: Rule Number: %d,%d",eNodeType,nNodeID);
return new connectivity::OSQLInternalNode(_NewValue, eNodeType, nNodeID);
}
@@ -123,7 +121,6 @@ static connectivity::OSQLInternalNode* newNode(const ::rtl::OUString& _NewValue,
const connectivity::SQLNodeType eNodeType,
const sal_uInt32 nNodeID = 0)
{
- OSL_TRACE("connectivity: Rule Number: %d,%d",eNodeType,nNodeID);
return new connectivity::OSQLInternalNode(_NewValue, eNodeType, nNodeID);
}
@@ -2043,7 +2040,8 @@ join_spec:
| named_columns_join
;
join_type:
- SQL_TOKEN_INNER
+ /* empty */ {$$ = SQL_NEW_RULE;}
+ | SQL_TOKEN_INNER
{
$$ = SQL_NEW_RULE;
$$->append($1);
diff --git a/connectivity/source/parse/sqliterator.cxx b/connectivity/source/parse/sqliterator.cxx
index c92fc9b709..3cb4b821cd 100644
--- a/connectivity/source/parse/sqliterator.cxx
+++ b/connectivity/source/parse/sqliterator.cxx
@@ -952,21 +952,7 @@ bool OSQLParseTreeIterator::traverseSelectColumnNames(const OSQLParseNode* pSele
if ( pColumnRef->isRule() )
{
bFkt = sal_True;
- if ( SQL_ISRULE(pColumnRef,num_value_exp) || SQL_ISRULE(pColumnRef,term) || SQL_ISRULE(pColumnRef,factor) )
- {
- nType = DataType::DOUBLE;
- }
- else
- {
- ::rtl::OUString sFunctionName;
- if ( SQL_ISRULE(pColumnRef,length_exp) )
- pColumnRef->getChild(0)->getChild(0)->parseNodeToStr(
- sFunctionName, m_pImpl->m_xConnection, NULL, sal_False, sal_False );
- else
- pColumnRef->getChild(0)->parseNodeToStr(
- sFunctionName, m_pImpl->m_xConnection, NULL, sal_False, sal_False );
- nType = ::connectivity::OSQLParser::getFunctionReturnType( sFunctionName, &m_rParser.getContext() );
- }
+ nType = getFunctionReturnType(pColumnRef);
}
}
/*
@@ -1601,7 +1587,6 @@ void OSQLParseTreeIterator::impl_traverse( sal_uInt32 _nIncludeMask )
case SQL_STATEMENT_INSERT:
break;
default:
- OSL_ENSURE( false, "OSQLParseTreeIterator::traverseAll: not yet implemented for this statement type!" );
break;
}
}
@@ -2104,3 +2089,84 @@ void OSQLParseTreeIterator::impl_appendError( const SQLException& _rError )
m_aErrors = _rError;
}
// -----------------------------------------------------------------------------
+sal_Int32 OSQLParseTreeIterator::getFunctionReturnType(const OSQLParseNode* _pNode )
+{
+ sal_Int32 nType = DataType::OTHER;
+ ::rtl::OUString sFunctionName;
+ if ( SQL_ISRULE(_pNode,length_exp) )
+ {
+ _pNode->getChild(0)->getChild(0)->parseNodeToStr(sFunctionName, m_pImpl->m_xConnection, NULL, sal_False, sal_False );
+ nType = ::connectivity::OSQLParser::getFunctionReturnType( sFunctionName, &m_rParser.getContext() );
+ }
+ else if ( SQL_ISRULE(_pNode,num_value_exp) || SQL_ISRULE(_pNode,term) || SQL_ISRULE(_pNode,factor) )
+ {
+ nType = DataType::DOUBLE;
+ }
+ else
+ {
+ _pNode->getChild(0)->parseNodeToStr(sFunctionName, m_pImpl->m_xConnection, NULL, sal_False, sal_False );
+
+ // MIN and MAX have another return type, we have to check the expression itself.
+ // @see http://qa.openoffice.org/issues/show_bug.cgi?id=99566
+ if ( SQL_ISRULE(_pNode,general_set_fct) && (SQL_ISTOKEN(_pNode->getChild(0),MIN) || SQL_ISTOKEN(_pNode->getChild(0),MAX) ))
+ {
+ const OSQLParseNode* pValueExp = _pNode->getChild(3);
+ if (SQL_ISRULE(pValueExp,column_ref))
+ {
+ ::rtl::OUString sColumnName;
+ ::rtl::OUString aTableRange;
+ getColumnRange(pValueExp,sColumnName,aTableRange);
+ OSL_ENSURE(sColumnName.getLength(),"Columnname darf nicht leer sein");
+ Reference<XPropertySet> xColumn = findColumn( sColumnName, aTableRange, true );
+
+ if ( xColumn.is() )
+ {
+ xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex( PROPERTY_ID_TYPE)) >>= nType;
+ }
+ }
+ else
+ {
+ if ( SQL_ISRULE(pValueExp,num_value_exp) || SQL_ISRULE(pValueExp,term) || SQL_ISRULE(pValueExp,factor) )
+ {
+ nType = DataType::DOUBLE;
+ }
+ else if ( SQL_ISRULE(pValueExp,datetime_primary) )
+ {
+ switch(pValueExp->getChild(0)->getTokenID() )
+ {
+ case SQL_TOKEN_CURRENT_DATE:
+ nType = DataType::DATE;
+ break;
+ case SQL_TOKEN_CURRENT_TIME:
+ nType = DataType::TIME;
+ break;
+ case SQL_TOKEN_CURRENT_TIMESTAMP:
+ nType = DataType::TIMESTAMP;
+ break;
+ }
+ }
+ else if ( SQL_ISRULE(pValueExp,value_exp_primary) )
+ {
+ nType = getFunctionReturnType(pValueExp->getChild(1));
+ }
+ else if ( SQL_ISRULE(pValueExp,concatenation)
+ || SQL_ISRULE(pValueExp,char_factor)
+ || SQL_ISRULE(pValueExp,bit_value_fct)
+ || SQL_ISRULE(pValueExp,char_value_fct)
+ || SQL_ISRULE(pValueExp,char_substring_fct)
+ || SQL_ISRULE(pValueExp,fold)
+ || SQL_ISTOKEN(pValueExp,STRING) )
+ {
+ nType = DataType::VARCHAR;
+ }
+ }
+ if ( nType == DataType::OTHER )
+ nType = DataType::DOUBLE;
+ }
+ else
+ nType = ::connectivity::OSQLParser::getFunctionReturnType( sFunctionName, &m_rParser.getContext() );
+ }
+
+ return nType;
+}
+
diff --git a/connectivity/source/parse/sqlnode.cxx b/connectivity/source/parse/sqlnode.cxx
index b4da3ba026..e0a08ca1c7 100644
--- a/connectivity/source/parse/sqlnode.cxx
+++ b/connectivity/source/parse/sqlnode.cxx
@@ -813,8 +813,9 @@ OSQLParseNode* OSQLParser::convertNode(sal_Int32 nType,OSQLParseNode*& pLiteral)
case DataType::CHAR:
case DataType::VARCHAR:
case DataType::LONGVARCHAR:
- if ( !SQL_ISRULE(pReturn,char_value_exp) && !buildStringNodes(pReturn) )
- pReturn = NULL;
+ case DataType::CLOB:
+ if ( !SQL_ISRULE(pReturn,char_value_exp) && !buildStringNodes(pReturn) )
+ pReturn = NULL;
default:
break;
}
@@ -829,6 +830,7 @@ OSQLParseNode* OSQLParser::convertNode(sal_Int32 nType,OSQLParseNode*& pLiteral)
case DataType::CHAR:
case DataType::VARCHAR:
case DataType::LONGVARCHAR:
+ case DataType::CLOB:
break;
case DataType::DATE:
case DataType::TIME:
@@ -872,12 +874,13 @@ OSQLParseNode* OSQLParser::convertNode(sal_Int32 nType,OSQLParseNode*& pLiteral)
case DataType::REAL:
case DataType::DOUBLE:
// kill thousand seperators if any
- killThousandSeparator(pReturn);
+ killThousandSeparator(pReturn);
break;
case DataType::CHAR:
case DataType::VARCHAR:
case DataType::LONGVARCHAR:
- pReturn = buildNode_STR_NUM(pReturn);
+ case DataType::CLOB:
+ pReturn = buildNode_STR_NUM(pReturn);
break;
default:
m_sErrorMessage = m_pContext->getErrorMessage(IParseContext::ERROR_INVALID_INT_COMPARE);
@@ -893,12 +896,13 @@ OSQLParseNode* OSQLParser::convertNode(sal_Int32 nType,OSQLParseNode*& pLiteral)
case DataType::REAL:
case DataType::DOUBLE:
// kill thousand seperators if any
- killThousandSeparator(pReturn);
+ killThousandSeparator(pReturn);
break;
case DataType::CHAR:
case DataType::VARCHAR:
case DataType::LONGVARCHAR:
- pReturn = buildNode_STR_NUM(pReturn);
+ case DataType::CLOB:
+ pReturn = buildNode_STR_NUM(pReturn);
break;
case DataType::INTEGER:
default:
@@ -967,6 +971,7 @@ sal_Int16 OSQLParser::buildLikeRule(OSQLParseNode*& pAppend, OSQLParseNode*& pLi
case DataType::CHAR:
case DataType::VARCHAR:
case DataType::LONGVARCHAR:
+ case DataType::CLOB:
if(pLiteral->isRule())
{
pAppend->append(pLiteral);
@@ -1228,6 +1233,7 @@ OSQLParseNode* OSQLParser::predicateTree(::rtl::OUString& rErrorMessage, const :
case DataType::CHAR:
case DataType::VARCHAR:
case DataType::LONGVARCHAR:
+ case DataType::CLOB:
s_pScanner->SetRule(s_pScanner->GetSTRINGRule());
break;
default:
@@ -1415,7 +1421,11 @@ OSQLParser::OSQLParser(const ::com::sun::star::uno::Reference< ::com::sun::star:
{ OSQLParseNode::table_node, "table_node" },
{ OSQLParseNode::as, "as" },
{ OSQLParseNode::op_column_commalist, "op_column_commalist" },
- { OSQLParseNode::table_primary_as_range_column, "table_primary_as_range_column" }
+ { OSQLParseNode::table_primary_as_range_column, "table_primary_as_range_column" },
+ { OSQLParseNode::datetime_primary, "datetime_primary" },
+ { OSQLParseNode::concatenation, "concatenation" },
+ { OSQLParseNode::char_factor, "char_factor" },
+ { OSQLParseNode::bit_value_fct, "bit_value_fct" }
};
size_t nRuleMapCount = sizeof( aRuleDescriptions ) / sizeof( aRuleDescriptions[0] );
OSL_ENSURE( nRuleMapCount == size_t( OSQLParseNode::rule_count ), "OSQLParser::OSQLParser: added a new rule? Adjust this map!" );
@@ -2074,18 +2084,18 @@ void OSQLParseNode::absorptions(OSQLParseNode*& pSearchCondition)
if ( SQL_ISRULE(p2ndSearch,boolean_primary) )
p2ndSearch = p2ndSearch->getChild(1);
- if ( *p2ndSearch->getChild(0) == *pSearchCondition->getChild(2-nPos) )
+ if ( *p2ndSearch->getChild(0) == *pSearchCondition->getChild(2-nPos) ) // a and ( a or b) -> a or b
{
pNewNode = pSearchCondition->removeAt((sal_uInt32)0);
replaceAndReset(pSearchCondition,pNewNode);
}
- else if ( *p2ndSearch->getChild(2) == *pSearchCondition->getChild(2-nPos) )
+ else if ( *p2ndSearch->getChild(2) == *pSearchCondition->getChild(2-nPos) ) // a and ( b or a) -> a or b
{
pNewNode = pSearchCondition->removeAt((sal_uInt32)2);
replaceAndReset(pSearchCondition,pNewNode);
}
- else if ( p2ndSearch->getByRule(OSQLParseNode::boolean_term) )
+ else if ( p2ndSearch->getByRule(OSQLParseNode::search_condition) )
{
// a and ( b or c ) -> ( a and b ) or ( a and c )
// ( b or c ) and a -> ( a and b ) or ( a and c )
@@ -2096,7 +2106,13 @@ void OSQLParseNode::absorptions(OSQLParseNode*& pSearchCondition)
OSQLParseNode* p1stAnd = MakeANDNode(pA,pB);
OSQLParseNode* p2ndAnd = MakeANDNode(new OSQLParseNode(*pA),pC);
pNewNode = MakeORNode(p1stAnd,p2ndAnd);
- replaceAndReset(pSearchCondition,pNewNode);
+ OSQLParseNode* pNode = new OSQLParseNode(::rtl::OUString(),SQL_NODE_RULE,OSQLParser::RuleID(OSQLParseNode::boolean_primary));
+ pNode->append(new OSQLParseNode(::rtl::OUString::createFromAscii("("),SQL_NODE_PUNCTUATION));
+ pNode->append(pNewNode);
+ pNode->append(new OSQLParseNode(::rtl::OUString::createFromAscii(")"),SQL_NODE_PUNCTUATION));
+ OSQLParseNode::eraseBraces(p1stAnd);
+ OSQLParseNode::eraseBraces(p2ndAnd);
+ replaceAndReset(pSearchCondition,pNode);
}
}
// a or a and b || a or b and a
diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx
index a8ebfee188..ac93a2695c 100644
--- a/desktop/source/app/app.cxx
+++ b/desktop/source/app/app.cxx
@@ -1468,6 +1468,13 @@ void Desktop::Main()
xContainerWindow = xBackingFrame->getContainerWindow();
if (xContainerWindow.is())
{
+ // set the WB_EXT_DOCUMENT style. Normally, this is done by the TaskCreator service when a "_blank"
+ // frame/window is created. Since we do not use the TaskCreator here, we need to mimic its behavior,
+ // otherwise documents loaded into this frame will later on miss functionality depending on the style.
+ Window* pContainerWindow = VCLUnoHelper::GetWindow( xContainerWindow );
+ OSL_ENSURE( pContainerWindow, "Desktop::Main: no implementation access to the frame's container window!" );
+ pContainerWindow->SetExtendedStyle( pContainerWindow->GetExtendedStyle() | WB_EXT_DOCUMENT );
+
SetSplashScreenProgress(75);
Sequence< Any > lArgs(1);
lArgs[0] <<= xContainerWindow;
diff --git a/officecfg/registry/data/org/openoffice/Office/DataAccess.xcu b/officecfg/registry/data/org/openoffice/Office/DataAccess.xcu
index a426891272..9078b3ef61 100644
--- a/officecfg/registry/data/org/openoffice/Office/DataAccess.xcu
+++ b/officecfg/registry/data/org/openoffice/Office/DataAccess.xcu
@@ -156,7 +156,7 @@
</node>
</node>
<node oor:name="RegisteredNames">
- <node oor:name="Bibliography" oor:op="replace">
+ <node oor:name="org.openoffice.Bibliography" oor:op="replace">
<prop oor:name="Location" oor:type="xs:string">
<value>$(userurl)/database/biblio.odb</value>
</prop>
diff --git a/officecfg/registry/schema/org/openoffice/Office/DataAccess.xcs b/officecfg/registry/schema/org/openoffice/Office/DataAccess.xcs
index cb684017c7..3755945df3 100644
--- a/officecfg/registry/schema/org/openoffice/Office/DataAccess.xcs
+++ b/officecfg/registry/schema/org/openoffice/Office/DataAccess.xcs
@@ -38,9 +38,9 @@
<info>
<author>OJ</author>
</info>
- <group oor:name="DatabaseNameSetting">
+ <group oor:name="DatabaseDocumentRegistration">
<info>
- <desc>Describes how to establish a database connection and how to filter and layout the database data.</desc>
+ <desc>describes a single database document registration.</desc>
</info>
<prop oor:name="Name" oor:type="xs:string">
<info>
@@ -310,9 +310,9 @@
</set>
</group>
- <set oor:name="RegisteredNames" oor:node-type="DatabaseNameSetting">
+ <set oor:name="RegisteredNames" oor:node-type="DatabaseDocumentRegistration">
<info>
- <desc>Specifies all names which are registered.</desc>
+ <desc>Specifies the database documents registered within OpenOffice.org, for quick access by a programmatic name.</desc>
</info>
</set>
diff --git a/scripting/source/dlgprov/dlgevtatt.cxx b/scripting/source/dlgprov/dlgevtatt.cxx
index 2284884e36..60d53d1562 100644
--- a/scripting/source/dlgprov/dlgevtatt.cxx
+++ b/scripting/source/dlgprov/dlgevtatt.cxx
@@ -1,7 +1,7 @@
/*************************************************************************
*
* 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
@@ -32,14 +32,13 @@
#include "precompiled_scripting.hxx"
#include "dlgevtatt.hxx"
-#ifndef SCRIPTING_DLGPROV_HXX
#include "dlgprov.hxx"
-#endif
+
#include <sfx2/sfx.hrc>
#include <sfx2/app.hxx>
-#ifndef _MSGBOX_HXX //autogen
#include <vcl/msgbox.hxx>
-#endif
+#include <tools/diagnose_ex.h>
+
#include <com/sun/star/awt/XControl.hpp>
#include <com/sun/star/awt/XDialogEventHandler.hpp>
#include <com/sun/star/awt/XContainerWindowEventHandler.hpp>
@@ -53,6 +52,7 @@
#include <com/sun/star/reflection/XIdlMethod.hpp>
#include <com/sun/star/beans/MethodConcept.hpp>
#include <com/sun/star/beans/XMaterialHolder.hpp>
+
#ifdef FAKE_VBA_EVENT_SUPPORT
#include <ooo/vba/XVBAToOOEventDescGen.hpp>
#endif
@@ -98,7 +98,7 @@ namespace dlgprov
virtual void firing_impl( const script::ScriptEvent& aScriptEvent, uno::Any* pRet );
public:
- DialogUnoScriptListenerImpl( const Reference< XComponentContext >& rxContext,
+ DialogUnoScriptListenerImpl( const Reference< XComponentContext >& rxContext,
const Reference< frame::XModel >& rxModel,
const Reference< awt::XControl >& rxControl,
const Reference< XInterface >& rxHandler,
@@ -133,10 +133,13 @@ namespace dlgprov
try
{
xProps->getPropertyValue( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Name") ) ) >>= msDialogCodeName;
- }
- catch ( Exception& ) {}
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
}
-
+
}
void DialogVBAScriptListenerImpl::firing_impl( const script::ScriptEvent& aScriptEvent, uno::Any* )
@@ -149,7 +152,10 @@ namespace dlgprov
{
mxListener->firing( aScriptEventCopy );
}
- catch( Exception& ) {}
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
}
}
#endif
@@ -184,13 +190,13 @@ namespace dlgprov
}
// -----------------------------------------------------------------------------
- Reference< script::XScriptListener >
+ Reference< script::XScriptListener >
DialogEventsAttacherImpl::getScriptListenerForKey( const rtl::OUString& sKey ) throw ( RuntimeException )
{
ListenerHash::iterator it = listernersForTypes.find( sKey );
if ( it == listernersForTypes.end() )
throw RuntimeException(); // more text info here please
- return it->second;
+ return it->second;
}
#ifdef FAKE_VBA_EVENT_SUPPORT
Reference< XScriptEventsSupplier > DialogEventsAttacherImpl::getFakeVbaEventsSupplier( const Reference< XControl >& xControl )
@@ -202,7 +208,7 @@ namespace dlgprov
Reference< ooo::vba::XVBAToOOEventDescGen > xVBAToOOEvtDesc( xSMgr->createInstanceWithContext( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.VBAToOOEventDesc" ) ), m_xContext ), UNO_QUERY );
if ( xVBAToOOEvtDesc.is() )
xEventsSupplier.set( xVBAToOOEvtDesc->getEventSupplier( xControl ), UNO_QUERY );
-
+
}
return xEventsSupplier;
}
@@ -221,46 +227,38 @@ namespace dlgprov
Sequence< ::rtl::OUString > aNames = xEventCont->getElementNames();
const ::rtl::OUString* pNames = aNames.getConstArray();
sal_Int32 nNameCount = aNames.getLength();
-
+
for ( sal_Int32 j = 0; j < nNameCount; ++j )
{
ScriptEventDescriptor aDesc;
-
+
Any aElement = xEventCont->getByName( pNames[ j ] );
aElement >>= aDesc;
rtl::OUString sKey = aDesc.ScriptType;
if ( aDesc.ScriptType.equals( rtl::OUString::createFromAscii("Script" ) ) || aDesc.ScriptType.equals( rtl::OUString::createFromAscii("UNO" ) ) )
{
sal_Int32 nIndex = aDesc.ScriptCode.indexOf( ':' );
- sKey = aDesc.ScriptCode.copy( 0, nIndex );
+ sKey = aDesc.ScriptCode.copy( 0, nIndex );
}
Reference< XAllListener > xAllListener =
new DialogAllListenerImpl( getScriptListenerForKey( sKey ), aDesc.ScriptType, aDesc.ScriptCode );
-
+
// try first to attach event to the ControlModel
bool bSuccess = false;
try
{
- Reference< XEventListener > xListener_ = m_xEventAttacher->attachSingleEventListener(
- xControlModel, xAllListener, Helper, aDesc.ListenerType,
+ Reference< XEventListener > xListener_ = m_xEventAttacher->attachSingleEventListener(
+ xControlModel, xAllListener, Helper, aDesc.ListenerType,
aDesc.AddListenerParam, aDesc.EventMethod );
-
+
if ( xListener_.is() )
bSuccess = true;
}
- catch ( IllegalArgumentException& )
- {
- }
- catch ( IntrospectionException& )
- {
- }
- catch ( CannotCreateAdapterException& )
+ catch ( const Exception& )
{
+ DBG_UNHANDLED_EXCEPTION();
}
- catch ( ServiceNotRegisteredException& )
- {
- }
-
+
try
{
// if we had no success, try to attach to the control
@@ -271,17 +269,9 @@ namespace dlgprov
aDesc.AddListenerParam, aDesc.EventMethod );
}
}
- catch( IllegalArgumentException& )
- {
- }
- catch( IntrospectionException& )
- {
- }
- catch( CannotCreateAdapterException& )
- {
- }
- catch( ServiceNotRegisteredException& )
+ catch ( const Exception& )
{
+ DBG_UNHANDLED_EXCEPTION();
}
}
}
@@ -294,8 +284,8 @@ namespace dlgprov
void SAL_CALL DialogEventsAttacherImpl::attachEvents( const Sequence< Reference< XInterface > >& Objects,
const com::sun::star::uno::Reference<com::sun::star::script::XScriptListener>&,
- const Any& Helper )
- throw (IllegalArgumentException, IntrospectionException, CannotCreateAdapterException,
+ const Any& Helper )
+ throw (IllegalArgumentException, IntrospectionException, CannotCreateAdapterException,
ServiceNotRegisteredException, RuntimeException)
{
// get EventAttacher
@@ -349,7 +339,7 @@ namespace dlgprov
// DialogAllListenerImpl
// =============================================================================
- DialogAllListenerImpl::DialogAllListenerImpl( const Reference< XScriptListener >& rxListener,
+ DialogAllListenerImpl::DialogAllListenerImpl( const Reference< XScriptListener >& rxListener,
const ::rtl::OUString& rScriptType, const ::rtl::OUString& rScriptCode )
:m_xScriptListener( rxListener )
,m_sScriptType( rScriptType )
@@ -406,7 +396,7 @@ namespace dlgprov
// -----------------------------------------------------------------------------
- Any DialogAllListenerImpl::approveFiring( const AllEventObject& Event )
+ Any DialogAllListenerImpl::approveFiring( const AllEventObject& Event )
throw ( reflection::InvocationTargetException, RuntimeException )
{
::osl::MutexGuard aGuard( getMutex() );
@@ -421,7 +411,7 @@ namespace dlgprov
// DialogScriptListenerImpl
// =============================================================================
- DialogUnoScriptListenerImpl::DialogUnoScriptListenerImpl( const Reference< XComponentContext >& rxContext,
+ DialogUnoScriptListenerImpl::DialogUnoScriptListenerImpl( const Reference< XComponentContext >& rxContext,
const Reference< ::com::sun::star::frame::XModel >& rxModel,
const Reference< ::com::sun::star::awt::XControl >& rxControl,
const Reference< ::com::sun::star::uno::XInterface >& rxHandler,
@@ -443,7 +433,7 @@ namespace dlgprov
// -----------------------------------------------------------------------------
void DialogSFScriptListenerImpl::firing_impl( const ScriptEvent& aScriptEvent, Any* pRet )
- {
+ {
try
{
Reference< provider::XScriptProvider > xScriptProvider;
@@ -461,7 +451,7 @@ namespace dlgprov
{
Reference< provider::XScriptProviderFactory > xFactory(
m_xContext->getValueByName(
- ::rtl::OUString::createFromAscii( "/singletons/com.sun.star.script.provider.theMasterScriptProviderFactory" ) ),
+ ::rtl::OUString::createFromAscii( "/singletons/com.sun.star.script.provider.theMasterScriptProviderFactory" ) ),
UNO_QUERY );
OSL_ENSURE( xFactory.is(), "SFURL_firing_impl: failed to get master script provider factory" );
if ( xFactory.is() )
@@ -476,7 +466,7 @@ namespace dlgprov
OSL_ENSURE( xScriptProvider.is(), "DialogScriptListenerImpl::firing_impl: failed to get script provider" );
if ( xScriptProvider.is() )
- {
+ {
Reference< provider::XScript > xScript = xScriptProvider->getScript( aScriptEvent.ScriptCode );
OSL_ENSURE( xScript.is(), "DialogScriptListenerImpl::firing_impl: failed to get script" );
@@ -487,7 +477,7 @@ namespace dlgprov
Sequence< Any > aOutParams;
// get arguments for script
- aInParams = aScriptEvent.Arguments;
+ aInParams = aScriptEvent.Arguments;
Any aResult = xScript->invoke( aInParams, aOutParamsIndex, aOutParams );
if ( pRet )
@@ -495,38 +485,32 @@ namespace dlgprov
}
}
}
- catch ( RuntimeException& e )
- {
- OSL_TRACE( "DialogScriptListenerImpl::firing_impl: caught RuntimeException reason %s",
- ::rtl::OUStringToOString( e.Message, RTL_TEXTENCODING_ASCII_US ).pData->buffer );
- }
- catch ( Exception& e )
+ catch ( const Exception& )
{
- OSL_TRACE( "DialogScriptListenerImpl::firing_impl: caught Exception reason %s",
- ::rtl::OUStringToOString( e.Message, RTL_TEXTENCODING_ASCII_US ).pData->buffer );
+ DBG_UNHANDLED_EXCEPTION();
}
}
void DialogLegacyScriptListenerImpl::firing_impl( const ScriptEvent& aScriptEvent, Any* pRet )
- {
+ {
::rtl::OUString sScriptURL;
::rtl::OUString sScriptCode( aScriptEvent.ScriptCode );
- if ( aScriptEvent.ScriptType.compareToAscii( "StarBasic" ) == 0 )
- {
- // StarBasic script: convert ScriptCode to scriptURL
- sal_Int32 nIndex = sScriptCode.indexOf( ':' );
- if ( nIndex >= 0 && nIndex < sScriptCode.getLength() )
+ if ( aScriptEvent.ScriptType.compareToAscii( "StarBasic" ) == 0 )
{
- sScriptURL = ::rtl::OUString::createFromAscii( "vnd.sun.star.script:" );
- sScriptURL += sScriptCode.copy( nIndex + 1 );
- sScriptURL += ::rtl::OUString::createFromAscii( "?language=Basic&location=" );
- sScriptURL += sScriptCode.copy( 0, nIndex );
+ // StarBasic script: convert ScriptCode to scriptURL
+ sal_Int32 nIndex = sScriptCode.indexOf( ':' );
+ if ( nIndex >= 0 && nIndex < sScriptCode.getLength() )
+ {
+ sScriptURL = ::rtl::OUString::createFromAscii( "vnd.sun.star.script:" );
+ sScriptURL += sScriptCode.copy( nIndex + 1 );
+ sScriptURL += ::rtl::OUString::createFromAscii( "?language=Basic&location=" );
+ sScriptURL += sScriptCode.copy( 0, nIndex );
+ }
+ ScriptEvent aSFScriptEvent( aScriptEvent );
+ aSFScriptEvent.ScriptCode = sScriptURL;
+ DialogSFScriptListenerImpl::firing_impl( aSFScriptEvent, pRet );
}
- ScriptEvent aSFScriptEvent( aScriptEvent );
- aSFScriptEvent.ScriptCode = sScriptURL;
- DialogSFScriptListenerImpl::firing_impl( aSFScriptEvent, pRet );
- }
}
void DialogUnoScriptListenerImpl::firing_impl( const ScriptEvent& aScriptEvent, Any* pRet )
@@ -603,12 +587,10 @@ namespace dlgprov
bHandled = true;
}
}
- catch( com::sun::star::lang::IllegalArgumentException& )
- {}
- catch( com::sun::star::lang::NoSuchMethodException& )
- {}
- catch( com::sun::star::reflection::InvocationTargetException& )
- {}
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
}
if( bHandled )
@@ -634,7 +616,7 @@ namespace dlgprov
aOUFinal += aQuoteChar;
aOUFinal += aOURes.copy( nIndex + 2 );
- ErrorBox( NULL, WinBits( WB_OK ), aOUFinal ).Execute();
+ ErrorBox( NULL, WinBits( WB_OK ), aOUFinal ).Execute();
}
}
}
@@ -660,7 +642,7 @@ namespace dlgprov
// -----------------------------------------------------------------------------
- Any DialogScriptListenerImpl::approveFiring( const ScriptEvent& aScriptEvent )
+ Any DialogScriptListenerImpl::approveFiring( const ScriptEvent& aScriptEvent )
throw ( reflection::InvocationTargetException, RuntimeException )
{
::osl::MutexGuard aGuard( getMutex() );
diff --git a/svx/inc/svx/fmgridcl.hxx b/svx/inc/svx/fmgridcl.hxx
index 08dd55eb57..54ed0bd5f5 100644
--- a/svx/inc/svx/fmgridcl.hxx
+++ b/svx/inc/svx/fmgridcl.hxx
@@ -31,13 +31,8 @@
#define _SVX_FMGRIDCL_HXX
#include <com/sun/star/container/XIndexContainer.hpp>
-
-#ifndef _COM_SUN_STAR_FORM_XINDEXCONTAINER_HPP_
-#include <com/sun/star/container/XIndexContainer.hpp>
-#endif
#include <com/sun/star/container/XNameContainer.hpp>
-// alles nur fuer stl
#include <svx/gridctrl.hxx>
#include <svtools/transfer.hxx>
#include "svx/svxdllapi.h"
diff --git a/svx/inc/svx/gridctrl.hxx b/svx/inc/svx/gridctrl.hxx
index 7d398e390e..0519050011 100644
--- a/svx/inc/svx/gridctrl.hxx
+++ b/svx/inc/svx/gridctrl.hxx
@@ -584,9 +584,10 @@ protected:
sal_Int32 GetSeekPos() const {return m_nSeekPos;}
sal_Int32 GetTotalCount() const {return m_nTotalCount;}
- const DbGridRowRef& GetEmptyRow() const {return m_xEmptyRow;}
- const DbGridRowRef& GetSeekRow() const {return m_xSeekRow;}
- CursorWrapper* GetSeekCursor() const {return m_pSeekCursor;}
+ const DbGridRowRef& GetEmptyRow() const { return m_xEmptyRow; }
+ const DbGridRowRef& GetSeekRow() const { return m_xSeekRow; }
+ const DbGridRowRef& GetPaintRow() const { return m_xPaintRow; }
+ CursorWrapper* GetSeekCursor() const { return m_pSeekCursor; }
void ConnectToFields();
void DisconnectFromFields();
diff --git a/svx/source/cui/dbregister.cxx b/svx/source/cui/dbregister.cxx
index 0a38f57481..eb5ac61b4c 100644
--- a/svx/source/cui/dbregister.cxx
+++ b/svx/source/cui/dbregister.cxx
@@ -197,7 +197,7 @@ DbRegistrationOptionsPage::~DbRegistrationOptionsPage()
pHeaderBar->Hide();
for ( USHORT i = 0; i < pPathBox->GetEntryCount(); ++i )
- delete static_cast<String*>(pPathBox->GetEntry(i)->GetUserData());
+ delete static_cast< DatabaseRegistration* >( pPathBox->GetEntry(i)->GetUserData() );
delete pPathBox;
delete pHeaderBar;
}
@@ -216,21 +216,22 @@ BOOL DbRegistrationOptionsPage::FillItemSet( SfxItemSet& rCoreSet )
{
// the settings for the single drivers
sal_Bool bModified = sal_False;
- TNameLocationMap aMap;
+ DatabaseRegistrations aRegistrations;
ULONG nCount = pPathBox->GetEntryCount();
for ( ULONG i = 0; i < nCount; ++i )
{
SvLBoxEntry* pEntry = pPathBox->GetEntry(i);
- String* pPath = static_cast<String*>(pEntry->GetUserData());
- if ( pPath && pPath->Len() )
+ DatabaseRegistration* pRegistration = static_cast< DatabaseRegistration* >( pEntry->GetUserData() );
+ if ( pRegistration && pRegistration->sLocation.getLength() )
{
- OFileNotation aTransformer(*pPath);
- aMap.insert(TNameLocationMap::value_type(::rtl::OUString(pPathBox->GetEntryText(pEntry,0)),aTransformer.get(OFileNotation::N_URL)));
+ ::rtl::OUString sName( pPathBox->GetEntryText( pEntry, 0 ) );
+ OFileNotation aTransformer( pRegistration->sLocation );
+ aRegistrations[ sName ] = DatabaseRegistration( aTransformer.get( OFileNotation::N_URL ), pRegistration->bReadOnly );
}
}
- if ( m_nOldCount != aMap.size() || m_bModified )
+ if ( m_nOldCount != aRegistrations.size() || m_bModified )
{
- rCoreSet.Put(DatabaseMapItem(SID_SB_DB_REGISTER, aMap), SID_SB_DB_REGISTER);
+ rCoreSet.Put(DatabaseMapItem( SID_SB_DB_REGISTER, aRegistrations ), SID_SB_DB_REGISTER);
bModified = sal_True;
}
@@ -242,47 +243,44 @@ BOOL DbRegistrationOptionsPage::FillItemSet( SfxItemSet& rCoreSet )
void DbRegistrationOptionsPage::Reset( const SfxItemSet& rSet )
{
// the settings for the single drivers
- SFX_ITEMSET_GET( rSet, pSettings, DatabaseMapItem, SID_SB_DB_REGISTER, sal_True );
+ SFX_ITEMSET_GET( rSet, pRegistrations, DatabaseMapItem, SID_SB_DB_REGISTER, sal_True );
+ if ( !pRegistrations )
+ return;
- if ( pSettings )
+ pPathBox->Clear();
+
+ const DatabaseRegistrations& rRegistrations = pRegistrations->getRegistrations();
+ m_nOldCount = rRegistrations.size();
+ DatabaseRegistrations::const_iterator aIter = rRegistrations.begin();
+ DatabaseRegistrations::const_iterator aEnd = rRegistrations.end();
+ for ( ; aIter != aEnd; ++aIter )
+ {
+ OFileNotation aTransformer( aIter->second.sLocation );
+ insertNewEntry( aIter->first, aTransformer.get( OFileNotation::N_SYSTEM ), aIter->second.bReadOnly );
+ }
+
+ String aUserData = GetUserData();
+ if ( aUserData.Len() )
{
- // TabListBox f"ullen
- pPathBox->Clear();
-
- const TNameLocationMap& rMap = pSettings->getSettings();
- m_nOldCount = rMap.size();
- TNameLocationMap::const_iterator aIter = rMap.begin();
- TNameLocationMap::const_iterator aEnd = rMap.end();
- for (; aIter != aEnd; ++aIter)
+ // Spaltenbreite restaurieren
+ pHeaderBar->SetItemSize( ITEMID_TYPE, aUserData.GetToken(0).ToInt32() );
+ HeaderEndDrag_Impl( NULL );
+ // Sortierrichtung restaurieren
+ BOOL bUp = (BOOL)(USHORT)aUserData.GetToken(1).ToInt32();
+ HeaderBarItemBits nBits = pHeaderBar->GetItemBits(ITEMID_TYPE);
+
+ if ( bUp )
{
- OFileNotation aTransformer(aIter->second);
- insertNewEntry(aIter->first,aTransformer.get(OFileNotation::N_SYSTEM));
+ nBits &= ~HIB_UPARROW;
+ nBits |= HIB_DOWNARROW;
}
-
- String aUserData = GetUserData();
-
- if ( aUserData.Len() )
+ else
{
- // Spaltenbreite restaurieren
- pHeaderBar->SetItemSize( ITEMID_TYPE, aUserData.GetToken(0).ToInt32() );
- HeaderEndDrag_Impl( NULL );
- // Sortierrichtung restaurieren
- BOOL bUp = (BOOL)(USHORT)aUserData.GetToken(1).ToInt32();
- HeaderBarItemBits nBits = pHeaderBar->GetItemBits(ITEMID_TYPE);
-
- if ( bUp )
- {
- nBits &= ~HIB_UPARROW;
- nBits |= HIB_DOWNARROW;
- }
- else
- {
- nBits &= ~HIB_DOWNARROW;
- nBits |= HIB_UPARROW;
- }
- pHeaderBar->SetItemBits( ITEMID_TYPE, nBits );
- HeaderSelect_Impl( NULL );
+ nBits &= ~HIB_DOWNARROW;
+ nBits |= HIB_UPARROW;
}
+ pHeaderBar->SetItemBits( ITEMID_TYPE, nBits );
+ HeaderSelect_Impl( NULL );
}
}
@@ -323,16 +321,19 @@ IMPL_LINK( DbRegistrationOptionsPage, NewHdl, void *, EMPTYARG )
IMPL_LINK( DbRegistrationOptionsPage, EditHdl, void *, EMPTYARG )
{
SvLBoxEntry* pEntry = pPathBox->GetCurEntry();
- if ( pEntry )
- {
- String* pOldLocation = static_cast<String*>(pEntry->GetUserData());
- String sOldName = pPathBox->GetEntryText(pEntry,0);
- m_pCurEntry = pEntry;
- openLinkDialog(sOldName,*pOldLocation,pEntry);
- m_pCurEntry = NULL;
- }
+ if ( !pEntry )
+ return 0L;
- return 0;
+ DatabaseRegistration* pOldRegistration = static_cast< DatabaseRegistration* >( pEntry->GetUserData() );
+ if ( !pOldRegistration || pOldRegistration->bReadOnly )
+ return 0L;
+
+ String sOldName = pPathBox->GetEntryText(pEntry,0);
+ m_pCurEntry = pEntry;
+ openLinkDialog( sOldName, pOldRegistration->sLocation, pEntry );
+ m_pCurEntry = NULL;
+
+ return 1L;
}
// -----------------------------------------------------------------------
@@ -397,28 +398,42 @@ IMPL_LINK( DbRegistrationOptionsPage, HeaderEndDrag_Impl, HeaderBar*, pBar )
// -----------------------------------------------------------------------
IMPL_LINK( DbRegistrationOptionsPage, PathSelect_Impl, SvTabListBox *, EMPTYARG )
-
-/* [Beschreibung]
-
-*/
-
{
SvLBoxEntry* pEntry = pPathBox->FirstSelected();
- m_aEdit.Enable( pEntry != NULL);
- m_aDelete.Enable( pEntry != NULL);
+ bool bReadOnly = true;
+ if ( pEntry )
+ {
+ DatabaseRegistration* pRegistration = static_cast< DatabaseRegistration* >( pEntry->GetUserData() );
+ bReadOnly = pRegistration->bReadOnly;
+ }
+
+ m_aEdit.Enable( !bReadOnly );
+ m_aDelete.Enable( !bReadOnly );
return 0;
}
// -----------------------------------------------------------------------------
-void DbRegistrationOptionsPage::insertNewEntry(const ::rtl::OUString& _sName,const ::rtl::OUString& _sLocation)
+void DbRegistrationOptionsPage::insertNewEntry( const ::rtl::OUString& _sName,const ::rtl::OUString& _sLocation, const bool _bReadOnly )
{
String aStr( _sName );
aStr += '\t';
aStr += String(_sLocation);
- SvLBoxEntry* pEntry = pPathBox->InsertEntry( aStr );
- String* pLocation = new String( _sLocation );
- pEntry->SetUserData( pLocation );
+
+ SvLBoxEntry* pEntry = NULL;
+ if ( _bReadOnly )
+ {
+ sal_Bool bHighContrast = pPathBox->GetDisplayBackground().GetColor().IsDark();
+ Image aLocked( SVX_RES( bHighContrast ? RID_SVXBMP_LOCK_HC : RID_SVXBMP_LOCK ) );
+ pEntry = pPathBox->InsertEntry( aStr, aLocked, aLocked );
+ }
+ else
+ {
+ pEntry = pPathBox->InsertEntry( aStr );
+ }
+
+ pEntry->SetUserData( new DatabaseRegistration( _sLocation, _bReadOnly ) );
}
+
// -----------------------------------------------------------------------------
String DbRegistrationOptionsPage::getFileLocation(const String& _sLocation)
{
@@ -489,10 +504,10 @@ void DbRegistrationOptionsPage::openLinkDialog(const String& _sOldName,const Str
{
if ( _pEntry )
{
- delete static_cast<String*>(_pEntry->GetUserData());
- pPathBox->GetModel()->Remove(_pEntry);
+ delete static_cast< DatabaseRegistration* >( _pEntry->GetUserData() );
+ pPathBox->GetModel()->Remove( _pEntry );
}
- insertNewEntry(sNewName,sNewLocation);
+ insertNewEntry( sNewName, sNewLocation, false );
m_bModified = sal_True;
}
}
diff --git a/svx/source/cui/dbregister.hxx b/svx/source/cui/dbregister.hxx
index 303687300e..b27e153ba2 100644
--- a/svx/source/cui/dbregister.hxx
+++ b/svx/source/cui/dbregister.hxx
@@ -87,7 +87,7 @@ namespace svx
@param _sLocation
The location of the file.
*/
- void insertNewEntry(const ::rtl::OUString& _sName,const ::rtl::OUString& _sLocation);
+ void insertNewEntry( const ::rtl::OUString& _sName,const ::rtl::OUString& _sLocation, const bool bReadOnly );
/** opens the LinkDialog to create a register pair
@param _sOldName
diff --git a/svx/source/cui/dbregisterednamesconfig.cxx b/svx/source/cui/dbregisterednamesconfig.cxx
index 3fdfa74f9d..406835abfd 100644
--- a/svx/source/cui/dbregisterednamesconfig.cxx
+++ b/svx/source/cui/dbregisterednamesconfig.cxx
@@ -35,22 +35,22 @@
#undef SVX_DLLIMPLEMENTATION
#endif
+#include "connpooloptions.hxx"
#include "dbregisterednamesconfig.hxx"
+#include "dbregistersettings.hxx"
+#include "svx/svxids.hrc"
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/sdb/XDatabaseRegistrations.hpp>
-#include <svtools/itemset.hxx>
-#include <tools/diagnose_ex.h>
-
-#include <svx/svxids.hrc>
-#include <unotools/confignode.hxx>
+#include <comphelper/componentcontext.hxx>
#include <comphelper/extract.hxx>
-#include <com/sun/star/container/XNameAccess.hpp>
-#include <com/sun/star/uno/XNamingService.hpp>
-#include <svtools/eitem.hxx>
#include <comphelper/processfactory.hxx>
+#include <svtools/eitem.hxx>
+#include <svtools/itemset.hxx>
#include <svtools/pathoptions.hxx>
-#include "dbregistersettings.hxx"
-#include "connpooloptions.hxx"
+#include <tools/diagnose_ex.h>
+#include <unotools/confignode.hxx>
//........................................................................
namespace svx
@@ -59,136 +59,92 @@ namespace svx
using namespace ::utl;
using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::sdb;
using namespace ::com::sun::star::container;
- //--------------------------------------------------------------------
- static const ::rtl::OUString& getDbRegisteredNamesNodeName()
- {
- static ::rtl::OUString s_sNodeName = ::rtl::OUString::createFromAscii("org.openoffice.Office.DataAccess/RegisteredNames");
- return s_sNodeName;
- }
-
- //--------------------------------------------------------------------
- static const ::rtl::OUString& getDbNameNodeName()
- {
- static ::rtl::OUString s_sNodeName = ::rtl::OUString::createFromAscii("Name");
- return s_sNodeName;
- }
-
- //--------------------------------------------------------------------
- static const ::rtl::OUString& getDbLocationNodeName()
- {
- static ::rtl::OUString s_sNodeName = ::rtl::OUString::createFromAscii("Location");
- return s_sNodeName;
- }
-
//====================================================================
//= DbRegisteredNamesConfig
//====================================================================
//--------------------------------------------------------------------
- void DbRegisteredNamesConfig::GetOptions(SfxItemSet& _rFillItems)
+ void DbRegisteredNamesConfig::GetOptions( SfxItemSet& _rFillItems )
{
- // the config node where all pooling relevant info are stored under
- OConfigurationTreeRoot aDbRegisteredNamesRoot = OConfigurationTreeRoot::createWithServiceFactory(
- ::comphelper::getProcessServiceFactory(), getDbRegisteredNamesNodeName(), -1, OConfigurationTreeRoot::CM_READONLY);
-
- TNameLocationMap aSettings;
+ DatabaseRegistrations aSettings;
- // then look for which of them settings are stored in the configuration
- Sequence< ::rtl::OUString > aDriverKeys = aDbRegisteredNamesRoot.getNodeNames();
- const ::rtl::OUString* pDriverKeys = aDriverKeys.getConstArray();
- const ::rtl::OUString* pDriverKeysEnd = pDriverKeys + aDriverKeys.getLength();
- for (;pDriverKeys != pDriverKeysEnd; ++pDriverKeys)
+ try
{
- // the name of the driver in this round
- OConfigurationNode aThisDriverSettings = aDbRegisteredNamesRoot.openNode(*pDriverKeys);
- ::rtl::OUString sName, sLocation;
- aThisDriverSettings.getNodeValue(getDbNameNodeName()) >>= sName;
- aThisDriverSettings.getNodeValue(getDbLocationNodeName()) >>= sLocation;
- sLocation = SvtPathOptions().SubstituteVariable(sLocation);
-
- aSettings.insert(TNameLocationMap::value_type(sName,sLocation));
+ ::comphelper::ComponentContext aContext( ::comphelper::getProcessServiceFactory() );
+ Reference< XDatabaseRegistrations > xRegistrations(
+ aContext.createComponent( "com.sun.star.sdb.DatabaseContext" ), UNO_QUERY_THROW );
+
+ Sequence< ::rtl::OUString > aRegistrationNames( xRegistrations->getRegistrationNames() );
+ const ::rtl::OUString* pRegistrationName = aRegistrationNames.getConstArray();
+ const ::rtl::OUString* pRegistrationNamesEnd = pRegistrationName + aRegistrationNames.getLength();
+ for ( ; pRegistrationName != pRegistrationNamesEnd; ++pRegistrationName )
+ {
+ ::rtl::OUString sLocation( xRegistrations->getDatabaseLocation( *pRegistrationName ) );
+ aSettings[ *pRegistrationName ] =
+ DatabaseRegistration( sLocation, xRegistrations->isDatabaseRegistrationReadOnly( *pRegistrationName ) );
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
}
- _rFillItems.Put(DatabaseMapItem(SID_SB_DB_REGISTER, aSettings));
+ _rFillItems.Put( DatabaseMapItem( SID_SB_DB_REGISTER, aSettings ) );
}
//--------------------------------------------------------------------
void DbRegisteredNamesConfig::SetOptions(const SfxItemSet& _rSourceItems)
{
- // the config node where all pooling relevant info are stored under
- OConfigurationTreeRoot aDbRegisteredNamesRoot = OConfigurationTreeRoot::createWithServiceFactory(
- ::comphelper::getProcessServiceFactory(), getDbRegisteredNamesNodeName(), -1, OConfigurationTreeRoot::CM_UPDATABLE);
-
- if (!aDbRegisteredNamesRoot.isValid())
- // already asserted by the OConfigurationTreeRoot
+ // the settings for the single drivers
+ SFX_ITEMSET_GET( _rSourceItems, pRegistrations, DatabaseMapItem, SID_SB_DB_REGISTER, sal_True );
+ if ( !pRegistrations )
return;
- sal_Bool bNeedCommit = sal_False;
-
-
- // the settings for the single drivers
- SFX_ITEMSET_GET( _rSourceItems, pDriverSettings, DatabaseMapItem, SID_SB_DB_REGISTER, sal_True );
- if (pDriverSettings)
+ try
{
- Reference< XNameAccess > xDatabaseContext = Reference< XNameAccess >(::comphelper::getProcessServiceFactory()->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdb.DatabaseContext"))), UNO_QUERY);
- Reference< XNamingService> xNamingService(xDatabaseContext,UNO_QUERY);
- ::rtl::OUString sName, sLocation;
- OConfigurationNode aThisDriverSettings;
-
- const TNameLocationMap& rNewSettings = pDriverSettings->getSettings();
- TNameLocationMap::const_iterator aEnd = rNewSettings.end();
- for ( TNameLocationMap::const_iterator aLoop = rNewSettings.begin();
- aLoop != aEnd;
- ++aLoop
+ ::comphelper::ComponentContext aContext( ::comphelper::getProcessServiceFactory() );
+ Reference< XDatabaseRegistrations > xRegistrations(
+ aContext.createComponent( "com.sun.star.sdb.DatabaseContext" ), UNO_QUERY_THROW );
+
+ const DatabaseRegistrations& rNewRegistrations = pRegistrations->getRegistrations();
+ for ( DatabaseRegistrations::const_iterator reg = rNewRegistrations.begin();
+ reg != rNewRegistrations.end();
+ ++reg
)
{
- // need the name as ::rtl::OUString
- sName = aLoop->first;
+ const ::rtl::OUString sName = reg->first;
+ const ::rtl::OUString sLocation = reg->second.sLocation;
- // the sub-node for this driver
- if (aDbRegisteredNamesRoot.hasByName(sName))
- {
- aThisDriverSettings = aDbRegisteredNamesRoot.openNode(sName);
- // set the values
- aThisDriverSettings.setNodeValue(getDbNameNodeName(), makeAny(sName));
- aThisDriverSettings.setNodeValue(getDbLocationNodeName(), makeAny(aLoop->second));
- bNeedCommit = sal_True;
- }
- else
+ if ( xRegistrations->hasRegisteredDatabase( sName ) )
{
- try
- {
- xNamingService->registerObject(sName,Reference< ::com::sun::star::uno::XInterface >(xDatabaseContext->getByName(aLoop->second),UNO_QUERY));
- }
- catch( const Exception& )
+ if ( !xRegistrations->isDatabaseRegistrationReadOnly( sName ) )
+ xRegistrations->changeDatabaseLocation( sName, sLocation );
+ else
{
- DBG_UNHANDLED_EXCEPTION();
+ OSL_ENSURE( xRegistrations->getDatabaseLocation( sName ) == sLocation,
+ "DbRegisteredNamesConfig::SetOptions: somebody changed a read-only registration. How unrespectful." );
}
}
+ else
+ xRegistrations->registerDatabaseLocation( sName, sLocation );
}
- if (bNeedCommit)
- aDbRegisteredNamesRoot.commit();
-
- // delete unused entry
- Sequence< ::rtl::OUString > aDriverKeys = xDatabaseContext->getElementNames();
- const ::rtl::OUString* pDriverKeys = aDriverKeys.getConstArray();
- const ::rtl::OUString* pDriverKeysEnd = pDriverKeys + aDriverKeys.getLength();
- for (;pDriverKeys != pDriverKeysEnd; ++pDriverKeys)
+
+ // delete unused entries
+ Sequence< ::rtl::OUString > aRegistrationNames = xRegistrations->getRegistrationNames();
+ const ::rtl::OUString* pRegistrationName = aRegistrationNames.getConstArray();
+ const ::rtl::OUString* pRegistrationNamesEnd = pRegistrationName + aRegistrationNames.getLength();
+ for ( ; pRegistrationName != pRegistrationNamesEnd; ++pRegistrationName )
{
- if ( rNewSettings.find(*pDriverKeys) == rNewSettings.end() )
- {
- try
- {
- xNamingService->revokeObject(*pDriverKeys);
- }
- catch( const Exception& )
- {
- DBG_UNHANDLED_EXCEPTION();
- }
- }
+ if ( rNewRegistrations.find( *pRegistrationName ) == rNewRegistrations.end() )
+ xRegistrations->revokeDatabaseLocation( *pRegistrationName );
}
}
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
}
//........................................................................
diff --git a/svx/source/cui/dbregistersettings.cxx b/svx/source/cui/dbregistersettings.cxx
index 77aad8c7d2..8a6214644d 100644
--- a/svx/source/cui/dbregistersettings.cxx
+++ b/svx/source/cui/dbregistersettings.cxx
@@ -37,6 +37,8 @@
#include "dbregistersettings.hxx"
+#include <rtl/ustring.hxx>
+
//........................................................................
namespace svx
{
@@ -47,9 +49,9 @@ namespace svx
//====================================================================
TYPEINIT1( DatabaseMapItem, SfxPoolItem )
//--------------------------------------------------------------------
- DatabaseMapItem::DatabaseMapItem( sal_uInt16 _nId, const TNameLocationMap& _rSettings )
- :SfxPoolItem(_nId)
- ,m_aSettings(_rSettings)
+ DatabaseMapItem::DatabaseMapItem( sal_uInt16 _nId, const DatabaseRegistrations& _rRegistrations )
+ :SfxPoolItem( _nId )
+ ,m_aRegistrations( _rRegistrations )
{
}
@@ -57,19 +59,19 @@ namespace svx
int DatabaseMapItem::operator==( const SfxPoolItem& _rCompare ) const
{
const DatabaseMapItem* pItem = PTR_CAST(DatabaseMapItem, &_rCompare);
- if (!pItem)
+ if ( !pItem )
return sal_False;
- if (m_aSettings.size() != pItem->m_aSettings.size())
+ if ( m_aRegistrations.size() != pItem->m_aRegistrations.size() )
return sal_False;
- return m_aSettings != pItem->m_aSettings;
+ return m_aRegistrations == pItem->m_aRegistrations;
}
//--------------------------------------------------------------------
- SfxPoolItem* DatabaseMapItem::Clone( SfxItemPool * ) const
+ SfxPoolItem* DatabaseMapItem::Clone( SfxItemPool* ) const
{
- return new DatabaseMapItem(Which(), m_aSettings);
+ return new DatabaseMapItem( Which(), m_aRegistrations );
}
//--------------------------------------------------------------------
diff --git a/svx/source/cui/dbregistersettings.hxx b/svx/source/cui/dbregistersettings.hxx
index c6639a66bb..237664ba02 100644
--- a/svx/source/cui/dbregistersettings.hxx
+++ b/svx/source/cui/dbregistersettings.hxx
@@ -39,24 +39,56 @@ namespace svx
{
//........................................................................
+ struct DatabaseRegistration
+ {
+ ::rtl::OUString sLocation;
+ bool bReadOnly;
+
+ DatabaseRegistration()
+ :sLocation()
+ ,bReadOnly( true )
+ {
+ }
+
+ DatabaseRegistration( const ::rtl::OUString& _rLocation, const sal_Bool _bReadOnly )
+ :sLocation( _rLocation )
+ ,bReadOnly( _bReadOnly )
+ {
+ }
+
+ bool operator==( const DatabaseRegistration& _rhs ) const
+ {
+ return ( sLocation == _rhs.sLocation );
+ // do not take the read-only-ness into account, this is not maintained everywhere, but only
+ // properly set when filling the struct from the XDatabaseRegistrations data
+ }
+
+ bool operator!=( const DatabaseRegistration& _rhs ) const
+ {
+ return !( this->operator==( _rhs ) );
+ }
+ };
+
+ typedef ::std::map< ::rtl::OUString, DatabaseRegistration, ::comphelper::UStringLess > DatabaseRegistrations;
+
//====================================================================
//= DatabaseMapItem
//====================================================================
- DECLARE_STL_USTRINGACCESS_MAP(::rtl::OUString,TNameLocationMap);
class DatabaseMapItem : public SfxPoolItem
{
protected:
- TNameLocationMap m_aSettings;
+ DatabaseRegistrations m_aRegistrations;
public:
TYPEINFO();
- DatabaseMapItem( sal_uInt16 _nId, const TNameLocationMap& _rSettings );
+ DatabaseMapItem( sal_uInt16 _nId, const DatabaseRegistrations& _rRegistrations );
virtual int operator==( const SfxPoolItem& ) const;
virtual SfxPoolItem* Clone( SfxItemPool *pPool = 0 ) const;
- const TNameLocationMap& getSettings() const { return m_aSettings; }
+ const DatabaseRegistrations&
+ getRegistrations() const { return m_aRegistrations; }
};
//........................................................................
diff --git a/svx/source/fmcomp/fmgridcl.cxx b/svx/source/fmcomp/fmgridcl.cxx
index 4c5fee052e..05cf4c3485 100644
--- a/svx/source/fmcomp/fmgridcl.cxx
+++ b/svx/source/fmcomp/fmgridcl.cxx
@@ -436,6 +436,7 @@ IMPL_LINK( FmGridHeader, OnAsyncExecuteDrop, void*, /*NOTINTERESTEDIN*/ )
// diese Datentypen koennen im Gridcontrol nicht verarbeitet werden
switch (nDataType)
{
+ case DataType::BLOB:
case DataType::LONGVARBINARY:
case DataType::BINARY:
case DataType::VARBINARY:
@@ -1725,6 +1726,7 @@ void FmGridControl::InitColumnByField(
sal_Bool bIllegalType = sal_False;
switch ( nDataType )
{
+ case DataType::BLOB:
case DataType::LONGVARBINARY:
case DataType::BINARY:
case DataType::VARBINARY:
@@ -1769,14 +1771,18 @@ void FmGridControl::InitColumnsByFields(const Reference< ::com::sun::star::conta
Reference< XIndexContainer > xColumns( GetPeer()->getColumns() );
Reference< XNameAccess > xFieldsAsNames( _rxFields, UNO_QUERY );
- // Einfuegen mu� sich an den Column Positionen orientieren
+ // Einfuegen muss sich an den Column Positionen orientieren
for (sal_Int32 i = 0; i < xColumns->getCount(); i++)
{
DbGridColumn* pCol = GetColumns().GetObject(i);
- Reference< XPropertySet > xColumnModel;
- ::cppu::extractInterface( xColumnModel, xColumns->getByIndex( i ) );
+ OSL_ENSURE(pCol,"No grid column!");
+ if ( pCol )
+ {
+ Reference< XPropertySet > xColumnModel;
+ ::cppu::extractInterface( xColumnModel, xColumns->getByIndex( i ) );
- InitColumnByField( pCol, xColumnModel, xFieldsAsNames, _rxFields );
+ InitColumnByField( pCol, xColumnModel, xFieldsAsNames, _rxFields );
+ }
}
}
diff --git a/svx/source/fmcomp/fmgridif.cxx b/svx/source/fmcomp/fmgridif.cxx
index 8fc6b0fb1a..df0df0b94f 100644
--- a/svx/source/fmcomp/fmgridif.cxx
+++ b/svx/source/fmcomp/fmgridif.cxx
@@ -69,6 +69,7 @@
using namespace ::svxform;
using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::sdb;
using namespace ::com::sun::star::sdbc;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::view;
@@ -1393,8 +1394,8 @@ Sequence< Any > SAL_CALL FmXGridPeer::queryFieldData( sal_Int32 nRow, const Type
// don't use GetCurrentRow as this isn't affected by the above SeekRow
// FS - 30.09.99 - 68644
- DbGridRowRef aRow = pGrid->GetSeekRow();
- DBG_ASSERT(aRow.Is(), "FmXGridPeer::queryFieldData : invalid current Row !");
+ DbGridRowRef xPaintRow = pGrid->GetPaintRow();
+ ENSURE_OR_THROW( xPaintRow.Is(), "invalid paint row" );
// die Columns des Controls brauche ich fuer GetFieldText
DbGridColumns aColumns = pGrid->GetColumns();
@@ -1416,39 +1417,40 @@ Sequence< Any > SAL_CALL FmXGridPeer::queryFieldData( sal_Int32 nRow, const Type
// don't use GetCurrentFieldValue to determine the field content as this isn't affected by the above SeekRow
// FS - 30.09.99 - 68644
pCol = aColumns.GetObject(nModelPos);
- const DbGridRowRef xRow = pGrid->GetSeekRow();
- xFieldContent = (xRow.Is() && xRow->HasField(pCol->GetFieldPos())) ? xRow->GetField(pCol->GetFieldPos()).getColumn() : Reference< ::com::sun::star::sdb::XColumn > ();
+ xFieldContent = xPaintRow->HasField( pCol->GetFieldPos() )
+ ? xPaintRow->GetField( pCol->GetFieldPos() ).getColumn()
+ : Reference< XColumn > ();
+
+ if ( !xFieldContent.is() )
+ continue;
- if (xFieldContent.is())
+ if (bRequestedAsAny)
{
- if (bRequestedAsAny)
- {
- Reference< XPropertySet > xFieldSet(xFieldContent, UNO_QUERY);
- pReturnArray[i] = xFieldSet->getPropertyValue(FM_PROP_VALUE);
- }
- else
+ Reference< XPropertySet > xFieldSet(xFieldContent, UNO_QUERY);
+ pReturnArray[i] = xFieldSet->getPropertyValue(FM_PROP_VALUE);
+ }
+ else
+ {
+ switch (xType.getTypeClass())
{
- switch (xType.getTypeClass())
+ // Strings werden direkt ueber das GetFieldText abgehandelt
+ case TypeClass_STRING :
{
- // Strings werden direkt ueber das GetFieldText abgehandelt
- case TypeClass_STRING :
- {
- String sText = aColumns.GetObject(nModelPos)->GetCellText(aRow, pGrid->getNumberFormatter());
- pReturnArray[i] <<= ::rtl::OUString(sText);
- }
- break;
- // alles andere wird an der DatabaseVariant erfragt
- case TypeClass_FLOAT : pReturnArray[i] <<= xFieldContent->getFloat(); break;
- case TypeClass_DOUBLE : pReturnArray[i] <<= xFieldContent->getDouble(); break;
- case TypeClass_SHORT : pReturnArray[i] <<= (sal_Int16)xFieldContent->getShort(); break;
- case TypeClass_LONG : pReturnArray[i] <<= (sal_Int32)xFieldContent->getLong(); break;
- case TypeClass_UNSIGNED_SHORT: pReturnArray[i] <<= (sal_uInt16)xFieldContent->getShort(); break;
- case TypeClass_UNSIGNED_LONG : pReturnArray[i] <<= (sal_uInt32)xFieldContent->getLong(); break;
- case TypeClass_BOOLEAN : ::comphelper::setBOOL(pReturnArray[i],xFieldContent->getBoolean()); break;
- default:
- {
- throw IllegalArgumentException();
- }
+ String sText = aColumns.GetObject(nModelPos)->GetCellText( xPaintRow, pGrid->getNumberFormatter() );
+ pReturnArray[i] <<= ::rtl::OUString(sText);
+ }
+ break;
+ // alles andere wird an der DatabaseVariant erfragt
+ case TypeClass_FLOAT : pReturnArray[i] <<= xFieldContent->getFloat(); break;
+ case TypeClass_DOUBLE : pReturnArray[i] <<= xFieldContent->getDouble(); break;
+ case TypeClass_SHORT : pReturnArray[i] <<= (sal_Int16)xFieldContent->getShort(); break;
+ case TypeClass_LONG : pReturnArray[i] <<= (sal_Int32)xFieldContent->getLong(); break;
+ case TypeClass_UNSIGNED_SHORT : pReturnArray[i] <<= (sal_uInt16)xFieldContent->getShort(); break;
+ case TypeClass_UNSIGNED_LONG : pReturnArray[i] <<= (sal_uInt32)xFieldContent->getLong(); break;
+ case TypeClass_BOOLEAN : ::comphelper::setBOOL(pReturnArray[i],xFieldContent->getBoolean()); break;
+ default:
+ {
+ throw IllegalArgumentException();
}
}
}
@@ -1727,6 +1729,8 @@ void FmXGridPeer::removeColumnListeners(const Reference< XPropertySet >& xCol)
//------------------------------------------------------------------------------
void FmXGridPeer::setColumns(const Reference< XIndexContainer >& Columns) throw( RuntimeException )
{
+ ::vos::OGuard aGuard( Application::GetSolarMutex() );
+
FmGridControl* pGrid = static_cast< FmGridControl* >( GetWindow() );
if (m_xColumns.is())
diff --git a/svx/source/fmcomp/gridctrl.cxx b/svx/source/fmcomp/gridctrl.cxx
index bbd3358d58..d0d0262f5c 100644
--- a/svx/source/fmcomp/gridctrl.cxx
+++ b/svx/source/fmcomp/gridctrl.cxx
@@ -874,7 +874,7 @@ void DbGridRow::SetState(CursorWrapper* pCur, sal_Bool bPaintCursor)
}
catch(SQLException&)
{
- OSL_ENSURE(0,"SQLException catched while getting the bookmark");
+ DBG_UNHANDLED_EXCEPTION();
m_aBookmark = Any();
m_eStatus = GRS_INVALID;
m_bIsNew = sal_False;
@@ -1787,30 +1787,32 @@ void DbGridControl::ColumnMoved(sal_uInt16 nId)
sal_Bool DbGridControl::SeekRow(long nRow)
{
// in filter mode or in insert only mode we don't have any cursor!
- if (SeekCursor(nRow))
+ if ( !SeekCursor( nRow ) )
+ return sal_False;
+
+ if ( IsFilterMode() )
{
- if (m_pSeekCursor)
- {
- // on the current position we have to take the current row for display as we want
- // to have the most recent values for display
- if ((nRow == m_nCurrentPos) && getDisplaySynchron())
- m_xPaintRow = m_xCurrentRow;
- // seek to the empty insert row
- else if (IsInsertionRow(nRow))
- m_xPaintRow = m_xEmptyRow;
- else
- {
- m_xSeekRow->SetState(m_pSeekCursor, sal_True);
- m_xPaintRow = m_xSeekRow;
- }
- }
- else if (IsFilterMode())
- {
- DBG_ASSERT(IsFilterRow(nRow), "DbGridControl::SeekRow(): No filter row, wrong mode");
+ DBG_ASSERT( IsFilterRow( nRow ), "DbGridControl::SeekRow(): No filter row, wrong mode" );
+ m_xPaintRow = m_xEmptyRow;
+ }
+ else
+ {
+ // on the current position we have to take the current row for display as we want
+ // to have the most recent values for display
+ if ( ( nRow == m_nCurrentPos ) && getDisplaySynchron() )
+ m_xPaintRow = m_xCurrentRow;
+ // seek to the empty insert row
+ else if ( IsInsertionRow( nRow ) )
m_xPaintRow = m_xEmptyRow;
+ else
+ {
+ m_xSeekRow->SetState( m_pSeekCursor, sal_True );
+ m_xPaintRow = m_xSeekRow;
}
- DbGridControl_Base::SeekRow(nRow);
}
+
+ DbGridControl_Base::SeekRow(nRow);
+
return m_nSeekPos >= 0;
}
//------------------------------------------------------------------------------
@@ -2382,7 +2384,7 @@ sal_Bool DbGridControl::SeekCursor(long nRow, sal_Bool bAbsolute)
// da der letzte Datensatz bereits erreicht wurde!
if (nRow == m_nCurrentPos)
{
- // auf die aktuelle Zeile bewegt, dann mu� kein abgleich gemacht werden, wenn
+ // auf die aktuelle Zeile bewegt, dann muß kein abgleich gemacht werden, wenn
// gerade ein Datensatz eingefuegt wird
m_nSeekPos = nRow;
}
diff --git a/svx/source/form/fmvwimp.cxx b/svx/source/form/fmvwimp.cxx
index a5125f0406..e73d416aff 100644
--- a/svx/source/form/fmvwimp.cxx
+++ b/svx/source/form/fmvwimp.cxx
@@ -1287,10 +1287,12 @@ SdrObject* FmXFormView::implCreateFieldControl( const ::svx::ODataAccessDescript
else
switch (nDataType)
{
+ case DataType::BLOB:
case DataType::LONGVARBINARY:
nOBJID = OBJ_FM_IMAGECONTROL;
break;
case DataType::LONGVARCHAR:
+ case DataType::CLOB:
nOBJID = OBJ_FM_EDIT;
break;
case DataType::BINARY:
@@ -1622,7 +1624,9 @@ bool FmXFormView::createControlLabelPair( const ::comphelper::ComponentContext&
aControlSize = aDefSize;
break;
case DataType::LONGVARCHAR:
+ case DataType::CLOB:
case DataType::LONGVARBINARY:
+ case DataType::BLOB:
aControlSize = aDefImageSize;
break;
}
@@ -1655,7 +1659,7 @@ bool FmXFormView::createControlLabelPair( const ::comphelper::ComponentContext&
}
}
- if ( nDataType == DataType::LONGVARCHAR && xControlPropInfo->hasPropertyByName( FM_PROP_MULTILINE ) )
+ if ( (nDataType == DataType::LONGVARCHAR || nDataType == DataType::CLOB) && xControlPropInfo->hasPropertyByName( FM_PROP_MULTILINE ) )
{
xControlSet->setPropertyValue( FM_PROP_MULTILINE, makeAny( sal_Bool( sal_True ) ) );
}
diff --git a/svx/source/form/formcontrolfactory.cxx b/svx/source/form/formcontrolfactory.cxx
index 4e28c62a83..fbc869ba9e 100644
--- a/svx/source/form/formcontrolfactory.cxx
+++ b/svx/source/form/formcontrolfactory.cxx
@@ -519,7 +519,8 @@ namespace svxform
case FormComponentType::COMBOBOX:
{
sal_Bool bDropDown = !_rControlBoundRect.IsEmpty() && ( _rControlBoundRect.GetWidth() >= 3 * _rControlBoundRect.GetHeight() );
- _rxControlModel->setPropertyValue( FM_PROP_DROPDOWN, makeAny( (sal_Bool)bDropDown ) );
+ if ( xPSI->hasPropertyByName( FM_PROP_DROPDOWN ) )
+ _rxControlModel->setPropertyValue( FM_PROP_DROPDOWN, makeAny( (sal_Bool)bDropDown ) );
_rxControlModel->setPropertyValue( FM_PROP_LINECOUNT, makeAny( sal_Int16( 20 ) ) );
}
break;
diff --git a/svx/source/src/app.src b/svx/source/src/app.src
index 7001281945..b988d1d67d 100644
--- a/svx/source/src/app.src
+++ b/svx/source/src/app.src
@@ -58,26 +58,9 @@ ErrorBox RID_ERRBOX_MODULENOTINSTALLED
SID_HLINKBAR_SEARCH; \
SID_HLINKBAR_TARGET; \
SID_HYPERLINK_DIALOG; \
- SID_FM_RECORD_ABSOLUTE; \
- SID_FM_RECORD_FIRST; \
- SID_FM_RECORD_PREV; \
- SID_FM_RECORD_NEXT; \
- SID_FM_RECORD_LAST; \
- SID_FM_RECORD_SAVE; \
- SID_FM_RECORD_UNDO; \
- SID_FM_RECORD_NEW; \
- SID_FM_RECORD_DELETE; \
- SID_FM_REFRESH; \
- SID_FM_SORTUP; \
- SID_FM_SORTDOWN; \
- SID_FM_ORDERCRIT; \
- SID_FM_AUTOFILTER; \
- SID_FM_FILTERCRIT; \
- SID_FM_FORM_FILTERED; \
- SID_FM_REMOVE_FILTER_SORT; \
};\
IdCount = {\
- 21;\
+ 4;\
};
ImageList RID_DEFAULTIMAGELIST_SC