summaryrefslogtreecommitdiff
path: root/dbaccess
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
commit1a8ab84d2158c9c444eaeb24abc711db165de128 (patch)
treeea478c8cf96e910b0d440c2b9b1ba37596183a59 /dbaccess
parentf53e28b8a3380ba67bbc7a63ce3e1bc8c3d24994 (diff)
parent2241dfcdf029fcce801d65f4277131e0a5871f72 (diff)
merge
Diffstat (limited to 'dbaccess')
-rw-r--r--dbaccess/qa/complex/dbaccess/ApplicationController.java19
-rw-r--r--dbaccess/qa/complex/dbaccess/CRMBasedTestCase.java10
-rw-r--r--dbaccess/qa/complex/dbaccess/CRMDatabase.java239
-rw-r--r--dbaccess/qa/complex/dbaccess/DataSource.java3
-rw-r--r--dbaccess/qa/complex/dbaccess/Query.java15
-rw-r--r--dbaccess/qa/complex/dbaccess/RowSet.java82
-rw-r--r--dbaccess/qa/complex/dbaccess/TestCase.java19
-rw-r--r--dbaccess/qa/complex/dbaccess/UISettings.java111
-rw-r--r--dbaccess/source/core/api/BookmarkSet.cxx5
-rw-r--r--dbaccess/source/core/api/CacheSet.cxx83
-rw-r--r--dbaccess/source/core/api/KeySet.cxx78
-rw-r--r--dbaccess/source/core/api/KeySet.hxx2
-rw-r--r--dbaccess/source/core/api/RowSet.cxx54
-rw-r--r--dbaccess/source/core/api/RowSetBase.cxx10
-rw-r--r--dbaccess/source/core/api/RowSetCache.cxx38
-rw-r--r--dbaccess/source/core/api/RowSetCache.hxx1
-rw-r--r--dbaccess/source/core/api/SingleSelectQueryComposer.cxx21
-rw-r--r--dbaccess/source/core/api/column.cxx25
-rw-r--r--dbaccess/source/core/api/columnsettings.cxx102
-rw-r--r--dbaccess/source/core/api/definitioncolumn.cxx302
-rw-r--r--dbaccess/source/core/api/query.cxx9
-rw-r--r--dbaccess/source/core/api/querycontainer.cxx4
-rw-r--r--dbaccess/source/core/api/querydescriptor.cxx7
-rw-r--r--dbaccess/source/core/api/tablecontainer.cxx12
-rw-r--r--dbaccess/source/core/dataaccess/ComponentDefinition.cxx2
-rw-r--r--dbaccess/source/core/dataaccess/databasecontext.cxx192
-rw-r--r--dbaccess/source/core/dataaccess/databasecontext.hxx105
-rw-r--r--dbaccess/source/core/dataaccess/databaseregistrations.cxx402
-rw-r--r--dbaccess/source/core/dataaccess/databaseregistrations.hxx50
-rw-r--r--dbaccess/source/core/dataaccess/datasource.cxx25
-rw-r--r--dbaccess/source/core/dataaccess/datasource.hxx2
-rw-r--r--dbaccess/source/core/dataaccess/documentcontainer.cxx84
-rw-r--r--dbaccess/source/core/dataaccess/documentdefinition.cxx361
-rw-r--r--dbaccess/source/core/dataaccess/documentdefinition.hxx34
-rw-r--r--dbaccess/source/core/dataaccess/intercept.cxx130
-rw-r--r--dbaccess/source/core/dataaccess/makefile.mk1
-rw-r--r--dbaccess/source/core/inc/ContainerMediator.hxx17
-rw-r--r--dbaccess/source/core/inc/ContentHelper.hxx2
-rw-r--r--dbaccess/source/core/inc/PropertyForward.hxx36
-rw-r--r--dbaccess/source/core/inc/column.hxx12
-rw-r--r--dbaccess/source/core/inc/columnsettings.hxx8
-rw-r--r--dbaccess/source/core/inc/definitioncolumn.hxx98
-rw-r--r--dbaccess/source/core/inc/querycontainer.hxx2
-rw-r--r--dbaccess/source/core/misc/ContainerMediator.cxx124
-rw-r--r--dbaccess/source/core/misc/PropertyForward.cxx192
-rw-r--r--dbaccess/source/ui/browser/sbagrid.cxx46
-rw-r--r--dbaccess/source/ui/browser/unodatbr.cxx307
-rw-r--r--dbaccess/source/ui/control/FieldDescControl.cxx12
-rw-r--r--dbaccess/source/ui/inc/TypeInfo.hxx1
-rw-r--r--dbaccess/source/ui/inc/unodatbr.hxx20
-rw-r--r--dbaccess/source/ui/misc/RowSetDrop.cxx6
-rw-r--r--dbaccess/source/ui/misc/UITools.cxx12
-rw-r--r--dbaccess/source/ui/misc/WCopyTable.cxx20
-rw-r--r--dbaccess/source/ui/misc/controllerframe.cxx25
-rw-r--r--dbaccess/source/ui/misc/databaseobjectview.cxx49
-rw-r--r--dbaccess/source/ui/misc/linkeddocuments.cxx4
-rw-r--r--dbaccess/source/ui/querydesign/QueryDesignView.cxx53
-rw-r--r--dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx27
-rw-r--r--dbaccess/source/ui/querydesign/SelectionBrowseBox.hxx1
-rw-r--r--dbaccess/source/ui/querydesign/querycontainerwindow.cxx9
-rw-r--r--dbaccess/source/ui/tabledesign/FieldDescriptions.cxx15
-rw-r--r--dbaccess/source/ui/tabledesign/TableController.cxx2
-rw-r--r--dbaccess/source/ui/tabledesign/table.src2
-rw-r--r--dbaccess/source/ui/uno/copytablewizard.cxx14
64 files changed, 2017 insertions, 1738 deletions
diff --git a/dbaccess/qa/complex/dbaccess/ApplicationController.java b/dbaccess/qa/complex/dbaccess/ApplicationController.java
index c3661ef7ffee..fa7615809228 100644
--- a/dbaccess/qa/complex/dbaccess/ApplicationController.java
+++ b/dbaccess/qa/complex/dbaccess/ApplicationController.java
@@ -129,16 +129,16 @@ public class ApplicationController extends complexlib.ComplexTestCase
// load it into a frame
final Object object = getORB().createInstance("com.sun.star.frame.Desktop");
- final XComponentLoader xComponentLoader = (XComponentLoader) UnoRuntime.queryInterface(XComponentLoader.class, object);
+ final XComponentLoader xComponentLoader = UnoRuntime.queryInterface(XComponentLoader.class, object);
final XComponent loadedComponent = xComponentLoader.loadComponentFromURL(m_database.getDocumentURL(), "_blank", FrameSearchFlag.ALL, new PropertyValue[0]);
assure("too many document instances!",
UnoRuntime.areSame(loadedComponent, m_databaseDocument));
// get the controller, which provides access to various UI operations
- final XModel docModel = (XModel) UnoRuntime.queryInterface(XModel.class,
+ final XModel docModel = UnoRuntime.queryInterface(XModel.class,
loadedComponent);
- m_documentUI = (XDatabaseDocumentUI) UnoRuntime.queryInterface(XDatabaseDocumentUI.class,
+ m_documentUI = UnoRuntime.queryInterface(XDatabaseDocumentUI.class,
docModel.getCurrentController());
}
@@ -166,11 +166,8 @@ public class ApplicationController extends complexlib.ComplexTestCase
final String newDocumentURL = URLHelper.getFileURLFromSystemPath(documentFile.getAbsoluteFile());
// store the doc in a new location
- final XStorable storeDoc = (XStorable) UnoRuntime.queryInterface(XStorable.class,
- m_databaseDocument);
- storeDoc.storeAsURL(newDocumentURL, new PropertyValue[]
- {
- });
+ final XStorable storeDoc = UnoRuntime.queryInterface( XStorable.class, m_databaseDocument );
+ storeDoc.storeAsURL( newDocumentURL, new PropertyValue[] { } );
// connect
m_documentUI.connect();
@@ -188,8 +185,7 @@ public class ApplicationController extends complexlib.ComplexTestCase
impl_switchToDocument(oldDocumentURL);
m_documentUI.connect();
assure("could not connect to " + m_database.getDocumentURL(), m_documentUI.isConnected());
- XTablesSupplier suppTables = (XTablesSupplier) UnoRuntime.queryInterface(XTablesSupplier.class,
- m_documentUI.getActiveConnection());
+ XTablesSupplier suppTables = UnoRuntime.queryInterface( XTablesSupplier.class, m_documentUI.getActiveConnection() );
XNameAccess tables = suppTables.getTables();
assure("the table was created in the wrong database", !tables.hasByName("abc"));
@@ -198,8 +194,7 @@ public class ApplicationController extends complexlib.ComplexTestCase
m_documentUI.connect();
assure("could not connect to " + m_database.getDocumentURL(), m_documentUI.isConnected());
- suppTables = (XTablesSupplier) UnoRuntime.queryInterface(XTablesSupplier.class,
- m_documentUI.getActiveConnection());
+ suppTables = UnoRuntime.queryInterface( XTablesSupplier.class, m_documentUI.getActiveConnection() );
tables = suppTables.getTables();
assure("the newly created table has not been written", tables.hasByName("abc"));
}
diff --git a/dbaccess/qa/complex/dbaccess/CRMBasedTestCase.java b/dbaccess/qa/complex/dbaccess/CRMBasedTestCase.java
index eccb48647bae..b7c1ea987968 100644
--- a/dbaccess/qa/complex/dbaccess/CRMBasedTestCase.java
+++ b/dbaccess/qa/complex/dbaccess/CRMBasedTestCase.java
@@ -32,6 +32,7 @@ package complex.dbaccess;
import com.sun.star.lang.XMultiServiceFactory;
import com.sun.star.sdb.XSingleSelectQueryComposer;
import com.sun.star.uno.UnoRuntime;
+import connectivity.tools.CRMDatabase;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -44,7 +45,7 @@ public abstract class CRMBasedTestCase extends TestCase
{
try
{
- m_database = new CRMDatabase( getORB() );
+ m_database = new CRMDatabase( getORB(), false );
}
catch ( Exception e )
{
@@ -67,7 +68,7 @@ public abstract class CRMBasedTestCase extends TestCase
try
{
if ( m_database != null )
- m_database.close();
+ m_database.saveAndClose();
}
catch ( Exception ex )
{
@@ -80,9 +81,6 @@ public abstract class CRMBasedTestCase extends TestCase
*/
protected final XSingleSelectQueryComposer createQueryComposer() throws com.sun.star.uno.Exception
{
- final XMultiServiceFactory connectionFactory = (XMultiServiceFactory)UnoRuntime.queryInterface(
- XMultiServiceFactory.class, m_database.getConnection() );
- return (XSingleSelectQueryComposer)UnoRuntime.queryInterface(
- XSingleSelectQueryComposer.class, connectionFactory.createInstance( "com.sun.star.sdb.SingleSelectQueryComposer" ) );
+ return m_database.getConnection().createSingleSelectQueryComposer();
}
}
diff --git a/dbaccess/qa/complex/dbaccess/CRMDatabase.java b/dbaccess/qa/complex/dbaccess/CRMDatabase.java
deleted file mode 100644
index 77e2dcf6b2e2..000000000000
--- a/dbaccess/qa/complex/dbaccess/CRMDatabase.java
+++ /dev/null
@@ -1,239 +0,0 @@
-/*************************************************************************
- *
- * 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 complex.dbaccess;
-
-import com.sun.star.container.ElementExistException;
-import com.sun.star.io.IOException;
-import com.sun.star.lang.WrappedTargetException;
-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.sdbcx.XTablesSupplier;
-import com.sun.star.uno.UnoRuntime;
-import com.sun.star.util.XRefreshable;
-import connectivity.tools.DataSource;
-import connectivity.tools.HsqlColumnDescriptor;
-import connectivity.tools.HsqlDatabase;
-import connectivity.tools.HsqlTableDescriptor;
-import connectivity.tools.QueryDefinition;
-
-/** 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 XConnection m_connection;
-
- /** constructs the CRM database
- */
- public CRMDatabase( XMultiServiceFactory _orb ) throws Exception
- {
- m_orb = _orb;
-
- m_database = new HsqlDatabase( m_orb );
- m_dataSource = m_database.getDataSource();
- m_connection = m_database.defaultConnection();
- createTables();
- createQueries();
- }
-
- // --------------------------------------------------------------------------------------------------------
- /** returns the database document underlying the CRM database
- */
- public final HsqlDatabase getDatabase()
- {
- return m_database;
- }
-
- // --------------------------------------------------------------------------------------------------------
- /** returns the default connection to the database
- */
- public final XConnection getConnection()
- {
- return m_connection;
- }
-
- // --------------------------------------------------------------------------------------------------------
- public void close() throws SQLException, IOException
- {
- m_database.store();
- m_database.close();
- }
-
- // --------------------------------------------------------------------------------------------------------
- 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
- final XTablesSupplier suppTables = (XTablesSupplier)UnoRuntime.queryInterface(
- XTablesSupplier.class, m_connection );
- final XRefreshable refreshTables = (XRefreshable)UnoRuntime.queryInterface(
- XRefreshable.class, suppTables.getTables() );
- refreshTables.refresh();
- }
-
- // --------------------------------------------------------------------------------------------------------
- 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 = (XMultiServiceFactory)UnoRuntime.queryInterface(
- XMultiServiceFactory.class, m_database.defaultConnection() );
- composer = (XSingleSelectQueryComposer)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/dbaccess/qa/complex/dbaccess/DataSource.java b/dbaccess/qa/complex/dbaccess/DataSource.java
index 29c9d2f2cdd7..6cb0b7ee4b17 100644
--- a/dbaccess/qa/complex/dbaccess/DataSource.java
+++ b/dbaccess/qa/complex/dbaccess/DataSource.java
@@ -34,6 +34,7 @@ import com.sun.star.uno.Exception;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.XNamingService;
import complexlib.ComplexTestCase;
+import connectivity.tools.CRMDatabase;
import connectivity.tools.HsqlDatabase;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -66,7 +67,7 @@ public class DataSource extends ComplexTestCase
{
if (m_database == null)
{
- final CRMDatabase database = new CRMDatabase(getFactory());
+ final CRMDatabase database = new CRMDatabase( getFactory(), false );
m_database = database.getDatabase();
m_dataSource = m_database.getDataSource();
}
diff --git a/dbaccess/qa/complex/dbaccess/Query.java b/dbaccess/qa/complex/dbaccess/Query.java
index 684df2b65a25..f39c37a8fbdb 100644
--- a/dbaccess/qa/complex/dbaccess/Query.java
+++ b/dbaccess/qa/complex/dbaccess/Query.java
@@ -37,6 +37,7 @@ import com.sun.star.lang.XMultiServiceFactory;
import com.sun.star.sdb.XQueriesSupplier;
import com.sun.star.sdbcx.XColumnsSupplier;
import com.sun.star.uno.UnoRuntime;
+import connectivity.tools.CRMDatabase;
public class Query extends complexlib.ComplexTestCase {
@@ -62,7 +63,7 @@ public class Query extends complexlib.ComplexTestCase {
{
if ( m_database == null )
{
- final CRMDatabase database = new CRMDatabase( getFactory() );
+ final CRMDatabase database = new CRMDatabase( getFactory(), false );
m_database = database.getDatabase();
}
}
@@ -87,8 +88,8 @@ public class Query extends complexlib.ComplexTestCase {
try
{
- final XQueriesSupplier suppQueries = (XQueriesSupplier)UnoRuntime.queryInterface(
- XQueriesSupplier.class, m_database.defaultConnection());
+ final XQueriesSupplier suppQueries = UnoRuntime.queryInterface(
+ XQueriesSupplier.class, m_database.defaultConnection().getXConnection() );
final XNameAccess queries = suppQueries.getQueries();
final String[] queryNames = new String[] { "parseable", "parseable native", "unparseable" };
@@ -100,12 +101,12 @@ public class Query extends complexlib.ComplexTestCase {
for ( int i = 0; i < queryNames.length; ++i )
{
- final XPropertySet query = (XPropertySet)UnoRuntime.queryInterface(
+ final XPropertySet query = UnoRuntime.queryInterface(
XPropertySet.class, queries.getByName( queryNames[i] ) );
- final XColumnsSupplier suppCols = (XColumnsSupplier)UnoRuntime.queryInterface(
+ final XColumnsSupplier suppCols = UnoRuntime.queryInterface(
XColumnsSupplier.class, query);
- final XIndexAccess columns = (XIndexAccess)UnoRuntime.queryInterface(
+ final XIndexAccess columns = UnoRuntime.queryInterface(
XIndexAccess.class, suppCols.getColumns());
// check whether the columns supplied by the query match what we expected
@@ -113,7 +114,7 @@ public class Query extends complexlib.ComplexTestCase {
columns.getCount() == expectedColumnNames[i].length );
for ( int col = 0; col < columns.getCount(); ++col )
{
- final XNamed columnName = (XNamed)UnoRuntime.queryInterface(
+ final XNamed columnName = UnoRuntime.queryInterface(
XNamed.class, columns.getByIndex(col) );
assure( "column no. " + col + " of query \"" + queryNames[i] + "\" not matching",
columnName.getName().equals( expectedColumnNames[i][col] ) );
diff --git a/dbaccess/qa/complex/dbaccess/RowSet.java b/dbaccess/qa/complex/dbaccess/RowSet.java
index d9145d7aaee8..6a2b4e49c25a 100644
--- a/dbaccess/qa/complex/dbaccess/RowSet.java
+++ b/dbaccess/qa/complex/dbaccess/RowSet.java
@@ -41,7 +41,6 @@ import com.sun.star.sdb.XParametersSupplier;
import com.sun.star.sdb.XResultSetAccess;
import com.sun.star.sdb.XRowSetApproveBroadcaster;
import com.sun.star.sdbc.SQLException;
-import com.sun.star.sdbc.XConnection;
import com.sun.star.sdbc.XParameters;
import com.sun.star.sdbc.XPreparedStatement;
import com.sun.star.sdbc.XResultSet;
@@ -52,12 +51,12 @@ import com.sun.star.sdbc.XRowUpdate;
import com.sun.star.sdbcx.XColumnsSupplier;
import com.sun.star.sdbcx.XDeleteRows;
import com.sun.star.sdbcx.XRowLocate;
-import com.sun.star.sdbcx.XTablesSupplier;
import com.sun.star.uno.UnoRuntime;
-import com.sun.star.util.XRefreshable;
import complexlib.ComplexTestCase;
+import connectivity.tools.CRMDatabase;
import connectivity.tools.DataSource;
import connectivity.tools.HsqlDatabase;
+import connectivity.tools.sdb.Connection;
import java.lang.reflect.Method;
import java.util.Random;
@@ -89,7 +88,7 @@ public class RowSet extends ComplexTestCase
public ResultSetMovementStress(XResultSet _resultSet, int _id) throws java.lang.Exception
{
m_resultSet = _resultSet;
- m_row = (XRow) UnoRuntime.queryInterface(XRow.class, m_resultSet);
+ m_row = UnoRuntime.queryInterface( XRow.class, m_resultSet );
m_id = _id;
}
@@ -144,7 +143,7 @@ public class RowSet extends ComplexTestCase
{
try
{
- final CRMDatabase database = new CRMDatabase(getFactory());
+ final CRMDatabase database = new CRMDatabase( getFactory(), false );
m_database = database.getDatabase();
m_dataSource = m_database.getDataSource();
}
@@ -204,23 +203,22 @@ public class RowSet extends ComplexTestCase
{
try
{
- m_rowSet = (XRowSet) UnoRuntime.queryInterface(XRowSet.class,
- getFactory().createInstance("com.sun.star.sdb.RowSet"));
- final XPropertySet rowSetProperties = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, m_rowSet);
+ m_rowSet = UnoRuntime.queryInterface( XRowSet.class, getFactory().createInstance( "com.sun.star.sdb.RowSet" ) );
+ final XPropertySet rowSetProperties = UnoRuntime.queryInterface( XPropertySet.class, m_rowSet );
rowSetProperties.setPropertyValue("Command", command);
rowSetProperties.setPropertyValue("CommandType", Integer.valueOf(commandType));
- rowSetProperties.setPropertyValue("ActiveConnection", m_database.defaultConnection());
+ rowSetProperties.setPropertyValue("ActiveConnection", m_database.defaultConnection().getXConnection());
if (limitFetchSize)
{
rowSetProperties.setPropertyValue("FetchSize", Integer.valueOf(MAX_FETCH_ROWS));
}
- m_resultSet = (XResultSet) UnoRuntime.queryInterface(XResultSet.class, m_rowSet);
- m_resultSetUpdate = (XResultSetUpdate) UnoRuntime.queryInterface(XResultSetUpdate.class, m_rowSet);
- m_row = (XRow) UnoRuntime.queryInterface(XRow.class, m_rowSet);
- m_rowLocate = (XRowLocate) UnoRuntime.queryInterface(XRowLocate.class, m_resultSet);
- m_rowSetProperties = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, m_rowSet);
- m_paramsSupplier = (XParametersSupplier) UnoRuntime.queryInterface(XParametersSupplier.class, m_rowSet);
+ m_resultSet = UnoRuntime.queryInterface( XResultSet.class, m_rowSet );
+ m_resultSetUpdate = UnoRuntime.queryInterface( XResultSetUpdate.class, m_rowSet );
+ m_row = UnoRuntime.queryInterface( XRow.class, m_rowSet );
+ m_rowLocate = UnoRuntime.queryInterface( XRowLocate.class, m_resultSet );
+ m_rowSetProperties = UnoRuntime.queryInterface( XPropertySet.class, m_rowSet );
+ m_paramsSupplier = UnoRuntime.queryInterface( XParametersSupplier.class, m_rowSet );
if (execute)
{
@@ -259,7 +257,7 @@ public class RowSet extends ComplexTestCase
// --------------------------------------------------------------------------------------------------------
XResultSet createClone() throws SQLException
{
- final XResultSetAccess rowAcc = (XResultSetAccess) UnoRuntime.queryInterface(XResultSetAccess.class, m_rowSet);
+ final XResultSetAccess rowAcc = UnoRuntime.queryInterface( XResultSetAccess.class, m_rowSet );
return rowAcc.createResultSet();
}
@@ -269,9 +267,9 @@ public class RowSet extends ComplexTestCase
m_database.executeSQL("DROP TABLE \"TEST1\" IF EXISTS");
m_database.executeSQL("CREATE TABLE \"TEST1\" (\"ID\" integer not null primary key, \"col2\" varchar(50) )");
- final XConnection connection = m_database.defaultConnection();
+ final Connection connection = m_database.defaultConnection();
final XPreparedStatement prep = connection.prepareStatement("INSERT INTO \"TEST1\" values (?,?)");
- final XParameters para = (XParameters) UnoRuntime.queryInterface(XParameters.class, prep);
+ final XParameters para = UnoRuntime.queryInterface( XParameters.class, prep );
for (int i = 1; i <= MAX_TABLE_ROWS; ++i)
{
para.setInt(1, i);
@@ -279,9 +277,7 @@ public class RowSet extends ComplexTestCase
prep.executeUpdate();
}
- final XTablesSupplier suppTables = (XTablesSupplier) UnoRuntime.queryInterface(XTablesSupplier.class, connection);
- final XRefreshable refresh = (XRefreshable) UnoRuntime.queryInterface(XRefreshable.class, suppTables.getTables());
- refresh.refresh();
+ connection.refreshTables();
}
// --------------------------------------------------------------------------------------------------------
@@ -335,8 +331,8 @@ public class RowSet extends ComplexTestCase
{
try
{
- final XRow _row = (XRow) UnoRuntime.queryInterface(XRow.class, _resultSet);
- final XRow cloneRow = (XRow) UnoRuntime.queryInterface(XRow.class, clone);
+ final XRow _row = UnoRuntime.queryInterface( XRow.class, _resultSet );
+ final XRow cloneRow = UnoRuntime.queryInterface( XRow.class, clone );
for (int i = 1; i <= MAX_FETCH_ROWS; ++i)
{
final int calcPos = (MAX_TABLE_ROWS % i) + 1;
@@ -359,14 +355,14 @@ public class RowSet extends ComplexTestCase
{
try
{
- final XRow _row = (XRow) UnoRuntime.queryInterface(XRow.class, _resultSet);
+ final XRow _row = UnoRuntime.queryInterface( XRow.class, _resultSet );
_resultSet.beforeFirst();
for (int i = 1; i <= MAX_TABLE_ROWS; ++i)
{
_resultSet.next();
final XResultSet clone = createClone();
- final XRow cloneRow = (XRow) UnoRuntime.queryInterface(XRow.class, clone);
+ final XRow cloneRow = UnoRuntime.queryInterface( XRow.class, clone );
final int calcPos = MAX_TABLE_ROWS - 1;
if (calcPos != 0 && clone.absolute(calcPos))
{
@@ -420,15 +416,15 @@ public class RowSet extends ComplexTestCase
// first we create our RowSet object
final RowSetEventListener pRow = new RowSetEventListener();
- final XColumnsSupplier colSup = (XColumnsSupplier) UnoRuntime.queryInterface(XColumnsSupplier.class, m_rowSet);
- final XPropertySet col = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, colSup.getColumns().getByName("ID"));
+ final XColumnsSupplier colSup = UnoRuntime.queryInterface( XColumnsSupplier.class, m_rowSet );
+ final XPropertySet col = UnoRuntime.queryInterface( XPropertySet.class, colSup.getColumns().getByName( "ID" ) );
col.addPropertyChangeListener("Value", pRow);
m_rowSetProperties.addPropertyChangeListener("IsModified", pRow);
m_rowSetProperties.addPropertyChangeListener("IsNew", pRow);
m_rowSetProperties.addPropertyChangeListener("IsRowCountFinal", pRow);
m_rowSetProperties.addPropertyChangeListener("RowCount", pRow);
- final XRowSetApproveBroadcaster xApBroad = (XRowSetApproveBroadcaster) UnoRuntime.queryInterface(XRowSetApproveBroadcaster.class, m_resultSet);
+ final XRowSetApproveBroadcaster xApBroad = UnoRuntime.queryInterface( XRowSetApproveBroadcaster.class, m_resultSet );
xApBroad.addRowSetApproveListener(pRow);
m_rowSet.addRowSetListener(pRow);
@@ -458,13 +454,13 @@ public class RowSet extends ComplexTestCase
testCursorMove(m_resultSet, cResSet.getMethod("previous", (Class[]) null), pRow, moves, null);
testCursorMove(m_resultSet, cResSet.getMethod(NEXT, (Class[]) null), pRow, moves, null);
moves[RowSetEventListener.IS_MODIFIED] = true;
- final XRowUpdate updRow = (XRowUpdate) UnoRuntime.queryInterface(XRowUpdate.class, m_resultSet);
+ final XRowUpdate updRow = UnoRuntime.queryInterface( XRowUpdate.class, m_resultSet );
updRow.updateString(2, TEST21);
testCursorMove(m_resultSet, cResSet.getMethod(NEXT, (Class[]) null), pRow, moves, null);
moves[RowSetEventListener.IS_MODIFIED] = false;
final Class cupd = Class.forName("com.sun.star.sdbc.XResultSetUpdate");
- final XResultSetUpdate upd = (XResultSetUpdate) UnoRuntime.queryInterface(XResultSetUpdate.class, m_resultSet);
+ final XResultSetUpdate upd = UnoRuntime.queryInterface( XResultSetUpdate.class, m_resultSet );
testCursorMove(upd, cupd.getMethod("moveToInsertRow", (Class[]) null), pRow, moves, null);
updRow.updateInt(1, MAX_TABLE_ROWS + 2);
@@ -536,7 +532,7 @@ public class RowSet extends ComplexTestCase
moves[RowSetEventListener.ROW_COUNT] = true;
final Class cdelRows = Class.forName("com.sun.star.sdbcx.XDeleteRows");
ctemp[0] = Object[].class;
- final XDeleteRows delRows = (XDeleteRows) UnoRuntime.queryInterface(XDeleteRows.class, m_resultSet);
+ final XDeleteRows delRows = UnoRuntime.queryInterface( XDeleteRows.class, m_resultSet );
final Object bookmarks[] = new Object[5];
m_resultSet.first();
for (int i = 0; i < bookmarks.length; ++i)
@@ -549,7 +545,7 @@ public class RowSet extends ComplexTestCase
testCursorMove(delRows, cdelRows.getMethod("deleteRows", ctemp), pRow, moves, temp);
// now destroy the RowSet
- final XComponent xComp = (XComponent) UnoRuntime.queryInterface(XComponent.class, m_resultSet);
+ final XComponent xComp = UnoRuntime.queryInterface( XComponent.class, m_resultSet );
xComp.dispose();
}
@@ -715,7 +711,7 @@ public class RowSet extends ComplexTestCase
positionRandom();
final Object deleteBookmark = m_rowLocate.getBookmark();
m_resultSetUpdate.deleteRow();
- final XDeleteRows multiDelete = (XDeleteRows) UnoRuntime.queryInterface(XDeleteRows.class, m_resultSet);
+ final XDeleteRows multiDelete = UnoRuntime.queryInterface( XDeleteRows.class, m_resultSet );
final int[] deleteSuccess = multiDelete.deleteRows(new Object[]
{
firstBookmark, deleteBookmark
@@ -745,7 +741,7 @@ public class RowSet extends ComplexTestCase
// .....................................................................................................
// updating values in a deleted row should fail
deleteRandom();
- final XRowUpdate rowUpdated = (XRowUpdate) UnoRuntime.queryInterface(XRowUpdate.class, m_resultSet);
+ final XRowUpdate rowUpdated = UnoRuntime.queryInterface( XRowUpdate.class, m_resultSet );
caughtException = false;
try
{
@@ -762,6 +758,7 @@ public class RowSet extends ComplexTestCase
/** checks whether deletions on the main RowSet properly interfere (or don't interfere) with the movement
* on a clone of the RowSet
*/
+ @SuppressWarnings("empty-statement")
public void testCloneMovesPlusDeletions() throws SQLException, UnknownPropertyException, WrappedTargetException
{
createTestCase(true);
@@ -769,7 +766,7 @@ public class RowSet extends ComplexTestCase
m_resultSet.last();
final XResultSet clone = createClone();
- final XRowLocate cloneRowLocate = (XRowLocate) UnoRuntime.queryInterface(XRowLocate.class, clone);
+ final XRowLocate cloneRowLocate = UnoRuntime.queryInterface( XRowLocate.class, clone );
positionRandom();
@@ -837,7 +834,7 @@ public class RowSet extends ComplexTestCase
m_rowSetProperties.setPropertyValue("FetchSize", Integer.valueOf(10));
final XResultSet clone = createClone();
- final XRow cloneRow = (XRow) UnoRuntime.queryInterface(XRow.class, clone);
+ final XRow cloneRow = UnoRuntime.queryInterface( XRow.class, clone );
// .....................................................................................................
// first check the basic scenario without the |moveToInsertRow| |moveToCurrentRow|, to ensure that
@@ -893,8 +890,7 @@ public class RowSet extends ComplexTestCase
{
createRowSet("SELECT * FROM \"customers\"", CommandType.COMMAND, true);
m_rowSetProperties.setPropertyValue("Command", "SELECT * FROM \"customers\" WHERE \"City\" = :city");
- final XParameters rowsetParams = (XParameters) UnoRuntime.queryInterface(XParameters.class,
- m_rowSet);
+ final XParameters rowsetParams = UnoRuntime.queryInterface( XParameters.class, m_rowSet );
rowsetParams.setString(1, "London");
m_rowSet.execute();
}
@@ -921,8 +917,7 @@ public class RowSet extends ComplexTestCase
for (int i = 0; i < expected; ++i)
{
- final XPropertySet parameter = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class,
- params.getByIndex(i));
+ final XPropertySet parameter = UnoRuntime.queryInterface( XPropertySet.class, params.getByIndex( i ) );
final String expectedName = _paramNames[i];
final String foundName = (String) parameter.getPropertyValue("Name");
@@ -959,12 +954,11 @@ public class RowSet extends ComplexTestCase
createRowSet("products like", CommandType.QUERY, false);
// let's fill in a parameter value via XParameters, and see whether it is respected by the parameters container
- final XParameters rowsetParams = (XParameters) UnoRuntime.queryInterface(XParameters.class,
- m_rowSet);
+ final XParameters rowsetParams = UnoRuntime.queryInterface(XParameters.class, m_rowSet);
rowsetParams.setString(1, "Apples");
XIndexAccess params = m_paramsSupplier.getParameters();
- XPropertySet firstParam = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, params.getByIndex(0));
+ XPropertySet firstParam = UnoRuntime.queryInterface( XPropertySet.class, params.getByIndex( 0 ) );
Object firstParamValue = firstParam.getPropertyValue("Value");
assure("XParameters and the parameters container do not properly interact",
@@ -978,7 +972,7 @@ public class RowSet extends ComplexTestCase
// the execution of the row set. It currently doesn't (though the values it represents do).
// It would be nice, but not strictly necessary, if it would.
params = m_paramsSupplier.getParameters();
- firstParam = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, params.getByIndex(0));
+ firstParam = UnoRuntime.queryInterface( XPropertySet.class, params.getByIndex( 0 ) );
}
firstParamValue = firstParam.getPropertyValue("Value");
assure("XParameters and the parameters container do not properly interact, after the row set has been executed",
diff --git a/dbaccess/qa/complex/dbaccess/TestCase.java b/dbaccess/qa/complex/dbaccess/TestCase.java
index 1051b549c8f0..8a9594a34305 100644
--- a/dbaccess/qa/complex/dbaccess/TestCase.java
+++ b/dbaccess/qa/complex/dbaccess/TestCase.java
@@ -29,8 +29,12 @@
************************************************************************/
package complex.dbaccess;
+import com.sun.star.beans.PropertyValue;
import com.sun.star.beans.XPropertySet;
+import com.sun.star.frame.XComponentLoader;
+import com.sun.star.frame.XModel;
import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.uno.Exception;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.XComponentContext;
import helper.FileTools;
@@ -38,8 +42,6 @@ import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
-import java.net.URI;
-import java.net.URISyntaxException;
public abstract class TestCase extends complexlib.ComplexTestCase
{
@@ -55,8 +57,8 @@ public abstract class TestCase extends complexlib.ComplexTestCase
XComponentContext context = null;
try
{
- final XPropertySet orbProps = (XPropertySet) UnoRuntime.queryInterface( XPropertySet.class, getORB() );
- context = (XComponentContext)UnoRuntime.queryInterface( XComponentContext.class,
+ final XPropertySet orbProps = UnoRuntime.queryInterface( XPropertySet.class, getORB() );
+ context = UnoRuntime.queryInterface( XComponentContext.class,
orbProps.getPropertyValue( "DefaultContext" ) );
}
catch ( Exception ex )
@@ -109,6 +111,15 @@ public abstract class TestCase extends complexlib.ComplexTestCase
}
// --------------------------------------------------------------------------------------------------------
+ protected final XModel loadDocument( final String _docURL ) throws Exception
+ {
+ final XComponentLoader loader = UnoRuntime.queryInterface( XComponentLoader.class,
+ getORB().createInstance( "com.sun.star.frame.Desktop" ) );
+ return UnoRuntime.queryInterface( XModel.class,
+ loader.loadComponentFromURL( _docURL, "_blank", 0, new PropertyValue[] {} ) );
+ }
+
+ // --------------------------------------------------------------------------------------------------------
protected void assureException( Object _object, Class _unoInterfaceClass, String _methodName, Object[] _methodArgs,
Class _expectedExceptionClass )
{
diff --git a/dbaccess/qa/complex/dbaccess/UISettings.java b/dbaccess/qa/complex/dbaccess/UISettings.java
index 23fe10618810..92be58f28dd6 100644
--- a/dbaccess/qa/complex/dbaccess/UISettings.java
+++ b/dbaccess/qa/complex/dbaccess/UISettings.java
@@ -30,15 +30,17 @@
package complex.dbaccess;
import com.sun.star.awt.FontSlant;
-import com.sun.star.beans.PropertyValue;
+import com.sun.star.awt.TextAlign;
import com.sun.star.beans.XPropertySet;
-import com.sun.star.form.XFormController;
-import com.sun.star.frame.XComponentLoader;
+import com.sun.star.container.XNameAccess;
+import com.sun.star.form.runtime.XFormController;
+import com.sun.star.frame.XController;
import com.sun.star.frame.XModel;
-import com.sun.star.lang.XComponent;
+import com.sun.star.sdb.application.DatabaseObject;
import com.sun.star.sdb.application.XDatabaseDocumentUI;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.util.XCloseable;
+import connectivity.tools.CRMDatabase;
public class UISettings extends TestCase
{
@@ -46,7 +48,8 @@ public class UISettings extends TestCase
public String[] getTestMethodNames()
{
return new String[] {
- "checkTableFormattingPersistence"
+ "checkTableFormattingPersistence",
+ "checkTransparentQueryColumnSettings"
};
}
@@ -61,25 +64,13 @@ public class UISettings extends TestCase
*/
public void checkTableFormattingPersistence() throws java.lang.Exception
{
- final CRMDatabase database = new CRMDatabase( getORB() );
-
- // load the document
- String docURL = database.getDatabase().getDocumentURL();
- final XComponentLoader loader = (XComponentLoader)UnoRuntime.queryInterface( XComponentLoader.class,
- getORB().createInstance( "com.sun.star.frame.Desktop" ) );
- XModel doc = (XModel)UnoRuntime.queryInterface( XModel.class,
- loader.loadComponentFromURL( docURL, "_blank", 0, new PropertyValue[] {} ) );
-
- // establish the connection
- XDatabaseDocumentUI docUI = (XDatabaseDocumentUI)UnoRuntime.queryInterface( XDatabaseDocumentUI.class,
- doc.getCurrentController() );
- docUI.connect();
-
- // display the table
- XComponent tableViewComp = docUI.loadComponent( com.sun.star.sdb.application.DatabaseObject.TABLE, "customers", false );
- XFormController tableViewController = (XFormController)UnoRuntime.queryInterface( XFormController.class,
- tableViewComp );
- XPropertySet tableControlModel = (XPropertySet)UnoRuntime.queryInterface( XPropertySet.class,
+ // create, load, and connect a DB doc
+ CRMDatabase database = new CRMDatabase( getORB(), true );
+
+ // display a table
+ XFormController tableViewController = UnoRuntime.queryInterface( XFormController.class,
+ database.loadSubComponent( DatabaseObject.TABLE, "customers" ) );
+ XPropertySet tableControlModel = UnoRuntime.queryInterface( XPropertySet.class,
tableViewController.getCurrentControl().getModel() );
// change the table's formatting
@@ -87,12 +78,10 @@ public class UISettings extends TestCase
tableControlModel.setPropertyValue( "FontHeight", Float.valueOf( 20 ) );
tableControlModel.setPropertyValue( "FontSlant", FontSlant.ITALIC );
- // close the table
- docUI.closeSubComponents();
+ String docURL = database.getDatabase().getModel().getURL();
- // save and close the database document
- database.getDatabase().store();
- database.close();
+ // save close the database document
+ database.saveAndClose();
// load a copy of the document
// normally, it should be sufficient to load the same doc. However, there might be objects in the Java VM
@@ -102,18 +91,13 @@ public class UISettings extends TestCase
// not cleaned up, the "database model impl" - the structure holding all document data - will
// stay alive, and subsequent requests to load the doc will just reuse it, without really loading it.
docURL = copyToTempFile( docURL );
- doc = (XModel)UnoRuntime.queryInterface( XModel.class,
- loader.loadComponentFromURL( docURL, "_blank", 0, new PropertyValue[] {} ) );
-
- docUI = (XDatabaseDocumentUI)UnoRuntime.queryInterface( XDatabaseDocumentUI.class,
- doc.getCurrentController() );
- docUI.connect();
+ loadDocument( docURL );
+ database = new CRMDatabase( getORB(), docURL );
// display the table, again
- tableViewComp = docUI.loadComponent( com.sun.star.sdb.application.DatabaseObject.TABLE, "customers", false );
- tableViewController = (XFormController)UnoRuntime.queryInterface( XFormController.class,
- tableViewComp );
- tableControlModel = (XPropertySet)UnoRuntime.queryInterface( XPropertySet.class,
+ tableViewController = UnoRuntime.queryInterface( XFormController.class,
+ database.loadSubComponent( DatabaseObject.TABLE, "customers" ) );
+ tableControlModel = UnoRuntime.queryInterface( XPropertySet.class,
tableViewController.getCurrentControl().getModel() );
// verify the properties
@@ -122,9 +106,50 @@ public class UISettings extends TestCase
assureEquals( "wrong font slant", FontSlant.ITALIC, (FontSlant)tableControlModel.getPropertyValue( "FontSlant" ) );
// close the doc
- docUI.closeSubComponents();
- final XCloseable closeDoc = (XCloseable)UnoRuntime.queryInterface( XCloseable.class,
- doc );
- closeDoc.close( true );
+ database.saveAndClose();
+ }
+
+ /**
+ * checks whether query columns use the settings of the underlying table column, if they do not (yet) have own
+ * settings
+ * @throws java.lang.Exception
+ */
+ public void checkTransparentQueryColumnSettings() throws java.lang.Exception
+ {
+ // create, load, and connect a DB doc
+ CRMDatabase database = new CRMDatabase( getORB(), true );
+
+ // display a table
+ XController tableView = database.loadSubComponent( DatabaseObject.TABLE, "customers" );
+ XFormController tableViewController = UnoRuntime.queryInterface( XFormController.class,
+ tableView );
+ XNameAccess tableControlModel = UnoRuntime.queryInterface( XNameAccess.class,
+ tableViewController.getCurrentControl().getModel() );
+
+ // change the formatting of a table column
+ XPropertySet idColumn = UnoRuntime.queryInterface( XPropertySet.class, tableControlModel.getByName( "ID" ) );
+ assure( "precondition not met: column already centered",
+ ((Short)idColumn.getPropertyValue( "Align" )).shortValue() != TextAlign.CENTER );
+ idColumn.setPropertyValue( "Align", TextAlign.CENTER );
+
+ // close the table data view
+ XCloseable closeSubComponent = UnoRuntime.queryInterface( XCloseable.class, tableView.getFrame() );
+ closeSubComponent.close( true );
+
+ // create a query based on that column
+ database.getDatabase().getDataSource().createQuery( "q_customers", "SELECT * FROM \"customers\"" );
+
+ // load this query, and verify the table column settings was propagated to the query column
+ XFormController queryViewController = UnoRuntime.queryInterface( XFormController.class,
+ database.loadSubComponent( DatabaseObject.QUERY, "q_customers" ) );
+ tableControlModel = UnoRuntime.queryInterface( XNameAccess.class,
+ queryViewController.getCurrentControl().getModel() );
+ idColumn = UnoRuntime.queryInterface( XPropertySet.class, tableControlModel.getByName( "ID" ) );
+
+ assure( "table column alignment was not propagated to the query column",
+ ((Short)idColumn.getPropertyValue( "Align" )).shortValue() == TextAlign.CENTER );
+
+ // save close the database document
+ database.saveAndClose();
}
}
diff --git a/dbaccess/source/core/api/BookmarkSet.cxx b/dbaccess/source/core/api/BookmarkSet.cxx
index 63d287df08bd..127ee83aaf2c 100644
--- a/dbaccess/source/core/api/BookmarkSet.cxx
+++ b/dbaccess/source/core/api/BookmarkSet.cxx
@@ -270,7 +270,10 @@ void OBookmarkSet::updateColumn(sal_Int32 nPos,Reference< XRowUpdate > _xParamet
case DataType::LONGVARBINARY:
_xParameter->updateBytes(nPos,_rValue);
break;
-
+ case DataType::BLOB:
+ case DataType::CLOB:
+ _xParameter->updateObject(nPos,_rValue.getAny());
+ break;
}
}
}
diff --git a/dbaccess/source/core/api/CacheSet.cxx b/dbaccess/source/core/api/CacheSet.cxx
index bbb080a52238..f7be322caa1a 100644
--- a/dbaccess/source/core/api/CacheSet.cxx
+++ b/dbaccess/source/core/api/CacheSet.cxx
@@ -515,88 +515,7 @@ void OCacheSet::setParameter(sal_Int32 nPos
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::setParameter" );
sal_Int32 nType = ( _nType != DataType::OTHER ) ? _nType : _rValue.getTypeKind();
- if(!_rValue.isNull())
- {
-
- switch(nType)
- {
- case DataType::DECIMAL:
- case DataType::NUMERIC:
- _xParameter->setObjectWithInfo(nPos,_rValue.makeAny(),nType,_nScale);
- break;
- case DataType::CHAR:
- case DataType::VARCHAR:
- case DataType::LONGVARCHAR:
- _xParameter->setString(nPos,_rValue);
- break;
- case DataType::BIGINT:
- if ( _rValue.isSigned() )
- _xParameter->setLong(nPos,_rValue);
- else
- _xParameter->setString(nPos,_rValue);
- break;
- case DataType::BIT:
- case DataType::BOOLEAN:
- _xParameter->setBoolean(nPos,_rValue);
- break;
- case DataType::TINYINT:
- if ( _rValue.isSigned() )
- _xParameter->setByte(nPos,_rValue);
- else
- _xParameter->setShort(nPos,_rValue);
- break;
- case DataType::SMALLINT:
- if ( _rValue.isSigned() )
- _xParameter->setShort(nPos,_rValue);
- else
- _xParameter->setInt(nPos,_rValue);
- break;
- case DataType::INTEGER:
- if ( _rValue.isSigned() )
- _xParameter->setInt(nPos,_rValue);
- else
- _xParameter->setLong(nPos,_rValue);
- break;
- case DataType::FLOAT:
- _xParameter->setFloat(nPos,_rValue);
- break;
- case DataType::DOUBLE:
- case DataType::REAL:
- _xParameter->setDouble(nPos,_rValue);
- break;
- case DataType::DATE:
- _xParameter->setDate(nPos,_rValue);
- break;
- case DataType::TIME:
- _xParameter->setTime(nPos,_rValue);
- break;
- case DataType::TIMESTAMP:
- _xParameter->setTimestamp(nPos,_rValue);
- break;
- case DataType::BINARY:
- case DataType::VARBINARY:
- case DataType::LONGVARBINARY:
- _xParameter->setBytes(nPos,_rValue);
- break;
- case DataType::CLOB:
- {
- Reference<XInputStream> xStream(_rValue.getAny(),UNO_QUERY);
- _xParameter->setCharacterStream(nPos,xStream,xStream.is() ? xStream->available() : sal_Int32(0));
- }
- break;
- case DataType::BLOB:
- {
- Reference<XInputStream> xStream(_rValue.getAny(),UNO_QUERY);
- _xParameter->setBinaryStream(nPos,xStream,xStream.is() ? xStream->available() : sal_Int32(0));
- }
- break;
- case DataType::SQLNULL:
- _xParameter->setNull(nPos,nType);
- break;
- }
- }
- else
- _xParameter->setNull(nPos,nType);
+ ::dbtools::setObjectWithInfo(_xParameter,nPos,_rValue,nType,_nScale);
}
// -------------------------------------------------------------------------
void OCacheSet::fillValueRow(ORowSetRow& _rRow,sal_Int32 _nPosition)
diff --git a/dbaccess/source/core/api/KeySet.cxx b/dbaccess/source/core/api/KeySet.cxx
index 9cc2c6172cf4..845c392bc146 100644
--- a/dbaccess/source/core/api/KeySet.cxx
+++ b/dbaccess/source/core/api/KeySet.cxx
@@ -211,8 +211,33 @@ void OKeySet::construct(const Reference< XResultSet>& _xDriverSet)
Reference<XColumnsSupplier> xSup(m_xComposer,UNO_QUERY);
Reference<XNameAccess> xSourceColumns = m_xTable->getColumns();
- ::dbaccess::getColumnPositions(xSup->getColumns(),xKeyColumns,m_sUpdateTableName,(*m_pKeyColumnNames));
- ::dbaccess::getColumnPositions(xSup->getColumns(),xSourceColumns,m_sUpdateTableName,(*m_pColumnNames));
+ ::rtl::OUString sCatalog,sSchema,sTable;
+
+ Reference<XPropertySet> xTableProp(m_xTable,UNO_QUERY);
+ Any aCatalog = xTableProp->getPropertyValue(PROPERTY_CATALOGNAME);
+ aCatalog >>= sCatalog;
+ xTableProp->getPropertyValue(PROPERTY_SCHEMANAME) >>= sSchema;
+ xTableProp->getPropertyValue(PROPERTY_NAME) >>= sTable;
+
+ ::std::vector< ::rtl::OUString> aBestRowColumnNames;
+ Reference<XResultSet> xBestRes(xMeta->getBestRowIdentifier(aCatalog,sSchema,sTable,0,sal_False));
+ Reference<XRow> xBestRow(xBestRes,uno::UNO_QUERY);
+ while ( xBestRes->next() )
+ {
+ aBestRowColumnNames.push_back(xBestRow->getString(2));
+ }
+
+ Sequence< ::rtl::OUString> aBestColumnNames;
+ if ( aBestRowColumnNames.empty() )
+ {
+ if ( xKeyColumns.is() )
+ aBestColumnNames = xKeyColumns->getElementNames();
+ }
+ else
+ aBestColumnNames = Sequence< ::rtl::OUString>(&aBestRowColumnNames[0],aBestRowColumnNames.size());
+
+ ::dbaccess::getColumnPositions(xSup->getColumns(),aBestColumnNames,m_sUpdateTableName,(*m_pKeyColumnNames));
+ ::dbaccess::getColumnPositions(xSup->getColumns(),xSourceColumns->getElementNames(),m_sUpdateTableName,(*m_pColumnNames));
SelectColumnsMetaData::const_iterator aPosIter = (*m_pKeyColumnNames).begin();
SelectColumnsMetaData::const_iterator aPosEnd = (*m_pKeyColumnNames).end();
@@ -235,16 +260,7 @@ void OKeySet::construct(const Reference< XResultSet>& _xDriverSet)
static ::rtl::OUString aAnd = ::rtl::OUString::createFromAscii(" AND ");
Reference<XDatabaseMetaData> xMetaData = m_xConnection->getMetaData();
- ::rtl::OUString aQuote = getIdentifierQuoteString();
-
- ::rtl::OUStringBuffer aFilter;
- ::rtl::OUString sCatalog,sSchema,sTable;
-
- Reference<XPropertySet> xTableProp(m_xTable,UNO_QUERY);
- xTableProp->getPropertyValue(PROPERTY_CATALOGNAME) >>= sCatalog;
- xTableProp->getPropertyValue(PROPERTY_SCHEMANAME) >>= sSchema;
- xTableProp->getPropertyValue(PROPERTY_NAME) >>= sTable;
-
+ const ::rtl::OUString aQuote = getIdentifierQuoteString();
m_aSelectComposedTableName = getComposedTableName(sCatalog,sSchema,sTable);
::rtl::OUString sComposedName;
@@ -252,6 +268,7 @@ void OKeySet::construct(const Reference< XResultSet>& _xDriverSet)
::dbtools::qualifiedNameComponents(xMetaData,m_sUpdateTableName,sCatalog,sSchema,sTable,::dbtools::eInDataManipulation);
sComposedName = ::dbtools::composeTableName( xMetaData, sCatalog, sSchema, sTable, sal_True, ::dbtools::eInDataManipulation );
+ ::rtl::OUStringBuffer aFilter;
static ::rtl::OUString s_sDot(RTL_CONSTASCII_USTRINGPARAM("."));
static ::rtl::OUString s_sParam(RTL_CONSTASCII_USTRINGPARAM(" = ?"));
// create the where clause
@@ -286,21 +303,20 @@ void OKeySet::construct(const Reference< XResultSet>& _xDriverSet)
::rtl::OUString sSelectTableName = ::dbtools::composeTableName( xMetaData, xProp, ::dbtools::eInDataManipulation, false, false, false );
Reference<XNameAccess > xSelectColumns = xSup->getColumns();
- ::dbaccess::getColumnPositions(xSelectColumns,xSelColSup->getColumns(),sSelectTableName,(*m_pForeignColumnNames));
+ ::dbaccess::getColumnPositions(xSelectColumns,xSelColSup->getColumns()->getElementNames(),sSelectTableName,(*m_pForeignColumnNames));
- uno::Sequence< ::rtl::OUString> aSelectColumnNames = xSelectColumns->getElementNames();
- const ::rtl::OUString* pSelectColumnName = aSelectColumnNames.getConstArray();
- const ::rtl::OUString* pSelectColumnEnd = pSelectColumnName + aSelectColumnNames.getLength();
- for( ; pSelectColumnName != pSelectColumnEnd ; ++pSelectColumnName)
+ aPosEnd = (*m_pForeignColumnNames).end();
+ for(aPosIter = (*m_pForeignColumnNames).begin();aPosIter != aPosEnd;++aPosIter)
{
// look for columns not in the source columns to use them as filter as well
- if ( !xSourceColumns->hasByName(*pSelectColumnName) )
+ // if ( !xSourceColumns->hasByName(aPosIter->first) )
{
+ if ( aFilter.getLength() )
+ aFilter.append(aAnd);
+ aFilter.append(::dbtools::quoteName( aQuote,sSelectTableName));
aFilter.append(s_sDot);
- aFilter.append(::dbtools::quoteName( aQuote,*pSelectColumnName));
+ aFilter.append(::dbtools::quoteName( aQuote,aPosIter->first));
aFilter.append(s_sParam);
- if ( (pSelectColumnName+1) != pSelectColumnEnd )
- aFilter.append(aAnd);
}
}
break;
@@ -499,7 +515,8 @@ void SAL_CALL OKeySet::updateRow(const ORowSetRow& _rInsertRow ,const ORowSetRow
SelectColumnsMetaData::const_iterator aEnd = m_pColumnNames->end();
for(;aIter != aEnd;++aIter,++i)
{
- if(xKeyColumns.is() && xKeyColumns->hasByName(aIter->first))
+ //if(xKeyColumns.is() && xKeyColumns->hasByName(aIter->first))
+ if ( m_pKeyColumnNames->find(aIter->first) != m_pKeyColumnNames->end() )
{
sKeyCondition.append(::dbtools::quoteName( aQuote,aIter->first));
if((_rOrginalRow->get())[aIter->second.nPosition].isNull())
@@ -594,7 +611,8 @@ void SAL_CALL OKeySet::updateRow(const ORowSetRow& _rInsertRow ,const ORowSetRow
::std::vector<sal_Int32>::iterator aIdxColIter = aIndexColumnPositions.begin();
::std::vector<sal_Int32>::iterator aIdxColEnd = aIndexColumnPositions.end();
j = 0;
- for(;aIdxColIter != aIdxColEnd;++aIdxColIter,++i,++j)
+ aIter = m_pColumnNames->begin();
+ for(;aIdxColIter != aIdxColEnd;++aIdxColIter,++i,++j,++aIter)
{
setParameter(i,xParameter,(_rOrginalRow->get())[*aIdxColIter],(_rOrginalRow->get())[*aIdxColIter].getTypeKind(),aIter->second.nScale);
}
@@ -826,7 +844,7 @@ void SAL_CALL OKeySet::deleteRow(const ORowSetRow& _rDeleteRow,const connectivit
sal_Int32 i = 1;
for(i = 1;aIter != aEnd;++aIter,++i)
{
- if(xKeyColumns.is() && xKeyColumns->hasByName(aIter->first))
+ if ( m_pKeyColumnNames->find(aIter->first) != m_pKeyColumnNames->end() )
{
aSql.append(::dbtools::quoteName( aQuote,aIter->first));
if((_rDeleteRow->get())[aIter->second.nPosition].isNull())
@@ -879,7 +897,8 @@ void SAL_CALL OKeySet::deleteRow(const ORowSetRow& _rDeleteRow,const connectivit
// now we have to set the index values
::std::vector<sal_Int32>::iterator aIdxColIter = aIndexColumnPositions.begin();
::std::vector<sal_Int32>::iterator aIdxColEnd = aIndexColumnPositions.end();
- for(;aIdxColIter != aIdxColEnd;++aIdxColIter,++i)
+ aIter = m_pColumnNames->begin();
+ for(;aIdxColIter != aIdxColEnd;++aIdxColIter,++i,++aIter)
{
setParameter(i,xParameter,(_rDeleteRow->get())[*aIdxColIter],(_rDeleteRow->get())[*aIdxColIter].getTypeKind(),aIter->second.nScale);
}
@@ -1394,7 +1413,7 @@ sal_Bool SAL_CALL OKeySet::rowDeleted( ) throw(SQLException, RuntimeException)
namespace dbaccess
{
void getColumnPositions(const Reference<XNameAccess>& _rxQueryColumns,
- const Reference<XNameAccess>& _rxColumns,
+ const Sequence< ::rtl::OUString>& _aColumnNames,
const ::rtl::OUString& _rsUpdateTableName,
SelectColumnsMetaData& _rColumnNames)
{
@@ -1403,9 +1422,8 @@ namespace dbaccess
const ::rtl::OUString* pSelBegin = aSelNames.getConstArray();
const ::rtl::OUString* pSelEnd = pSelBegin + aSelNames.getLength();
- Sequence< ::rtl::OUString> aColumnNames(_rxColumns->getElementNames());
- const ::rtl::OUString* pColumnIter = aColumnNames.getConstArray();
- const ::rtl::OUString* pColumnEnd = pColumnIter + aColumnNames.getLength();
+ const ::rtl::OUString* pColumnIter = _aColumnNames.getConstArray();
+ const ::rtl::OUString* pColumnEnd = pColumnIter + _aColumnNames.getLength();
::comphelper::UStringMixLess aTmp(_rColumnNames.key_comp());
::comphelper::UStringMixEqual bCase(static_cast< ::comphelper::UStringMixLess*>(&aTmp)->isCaseSensitive());
@@ -1439,7 +1457,7 @@ namespace dbaccess
break;
}
}
- pColumnIter = aColumnNames.getConstArray();
+ pColumnIter = _aColumnNames.getConstArray();
}
}
}
diff --git a/dbaccess/source/core/api/KeySet.hxx b/dbaccess/source/core/api/KeySet.hxx
index 4193f60506d1..7a213d05b466 100644
--- a/dbaccess/source/core/api/KeySet.hxx
+++ b/dbaccess/source/core/api/KeySet.hxx
@@ -83,7 +83,7 @@ namespace dbaccess
// the elements of _rxQueryColumns must have the properties PROPERTY_REALNAME and PROPERTY_TABLENAME
void getColumnPositions(const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _rxQueryColumns,
- const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _rxColumns,
+ const ::com::sun::star::uno::Sequence< ::rtl::OUString>& _aColumnNames,
const ::rtl::OUString& _rsUpdateTableName,
SelectColumnsMetaData& _rColumnNames /* out */);
diff --git a/dbaccess/source/core/api/RowSet.cxx b/dbaccess/source/core/api/RowSet.cxx
index 8f84d073f83e..5b71c7d8e56c 100644
--- a/dbaccess/source/core/api/RowSet.cxx
+++ b/dbaccess/source/core/api/RowSet.cxx
@@ -138,6 +138,7 @@
#ifndef _DBHELPER_DBEXCEPTION_HXX_
#include <connectivity/dbexception.hxx>
#endif
+#include <connectivity/BlobHelper.hxx>
#ifndef _DBA_CORE_TABLECONTAINER_HXX_
#include "tablecontainer.hxx"
#endif
@@ -814,7 +815,18 @@ void ORowSet::updateValue(sal_Int32 columnIndex,const ORowSetValue& x)
// XRowUpdate
void SAL_CALL ORowSet::updateNull( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
{
- updateValue(columnIndex,ORowSetValue());
+ ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
+
+ ::osl::MutexGuard aGuard( *m_pMutex );
+ checkUpdateConditions(columnIndex);
+ checkUpdateIterator();
+
+ ::connectivity::ORowSetValue aOldValue(((*m_aCurrentRow)->get())[columnIndex]);
+ m_pCache->updateNull(columnIndex);
+ // we have to notify all listeners
+ ((*m_aCurrentRow)->get())[columnIndex].setNull();
+ firePropertyChange(columnIndex-1 ,aOldValue);
+ fireProperty(PROPERTY_ID_ISMODIFIED,sal_True,sal_False);
}
// -------------------------------------------------------------------------
void SAL_CALL ORowSet::updateBoolean( sal_Int32 columnIndex, sal_Bool x ) throw(SQLException, RuntimeException)
@@ -886,25 +898,23 @@ void SAL_CALL ORowSet::updateBinaryStream( sal_Int32 columnIndex, const Referenc
checkUpdateConditions(columnIndex);
checkUpdateIterator();
- ::connectivity::ORowSetValue aOldValue;
- if(((*m_aCurrentRow)->get())[columnIndex].getTypeKind() == DataType::BLOB)
- {
- m_pCache->updateBinaryStream(columnIndex,x,length);
- aOldValue = ((*m_aCurrentRow)->get())[columnIndex];
- ((*m_aCurrentRow)->get())[columnIndex] = makeAny(x);
- }
- else
+
+ //if(((*m_aCurrentRow)->get())[columnIndex].getTypeKind() == DataType::BLOB)
+ //{
+ // ::connectivity::ORowSetValue aOldValue = ((*m_aCurrentRow)->get())[columnIndex];
+ // m_pCache->updateBinaryStream(columnIndex,x,length);
+ // ((*m_aCurrentRow)->get())[columnIndex] = makeAny(x);
+ // ((*m_aCurrentRow)->get())[columnIndex].setTypeKind(DataType::BLOB);
+ // firePropertyChange(columnIndex-1 ,aOldValue);
+ // fireProperty(PROPERTY_ID_ISMODIFIED,sal_True,sal_False);
+ //}
+ //else
{
Sequence<sal_Int8> aSeq;
if(x.is())
x->readBytes(aSeq,length);
updateValue(columnIndex,aSeq);
- aOldValue = ((*m_aCurrentRow)->get())[columnIndex];
- ((*m_aCurrentRow)->get())[columnIndex] = aSeq;
}
-
- firePropertyChange(columnIndex-1 ,aOldValue);
- fireProperty(PROPERTY_ID_ISMODIFIED,sal_True,sal_False);
}
// -------------------------------------------------------------------------
void SAL_CALL ORowSet::updateCharacterStream( sal_Int32 columnIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(SQLException, RuntimeException)
@@ -1481,14 +1491,19 @@ Reference< XRef > SAL_CALL ORowSet::getRef( sal_Int32 /*columnIndex*/ ) throw(SQ
return Reference< XRef >();
}
// -------------------------------------------------------------------------
-Reference< XBlob > SAL_CALL ORowSet::getBlob( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
+Reference< XBlob > SAL_CALL ORowSet::getBlob( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
{
- return Reference< XBlob >();
+ if ( m_pCache && isInsertRow() )
+ {
+ checkCache();
+ return new ::connectivity::BlobHelper(((*m_pCache->m_aInsertRow)->get())[m_nLastColumnIndex = columnIndex].getSequence());
+ }
+ return ORowSetBase::getBlob(columnIndex);
}
// -------------------------------------------------------------------------
-Reference< XClob > SAL_CALL ORowSet::getClob( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
+Reference< XClob > SAL_CALL ORowSet::getClob( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
{
- return Reference< XClob >();
+ return Reference< XClob >(getInsertValue(columnIndex).makeAny(),UNO_QUERY);
}
// -------------------------------------------------------------------------
Reference< XArray > SAL_CALL ORowSet::getArray( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
@@ -2838,7 +2853,8 @@ ORowSetClone::ORowSetClone( const ::comphelper::ComponentContext& _rContext, ORo
m_aDataColumns.push_back(pColumn);
pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_ALIGN,xColumn->getPropertyValue(PROPERTY_ALIGN));
- sal_Int32 nFormatKey = comphelper::getINT32(xColumn->getPropertyValue(PROPERTY_NUMBERFORMAT));
+ sal_Int32 nFormatKey = 0;
+ xColumn->getPropertyValue(PROPERTY_NUMBERFORMAT) >>= nFormatKey;
if(!nFormatKey && xColumn.is() && m_xNumberFormatTypes.is())
nFormatKey = ::dbtools::getDefaultNumberFormat(xColumn,m_xNumberFormatTypes,aLocale);
pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_NUMBERFORMAT,makeAny(nFormatKey));
diff --git a/dbaccess/source/core/api/RowSetBase.cxx b/dbaccess/source/core/api/RowSetBase.cxx
index a8894bcf5f1b..d8449094fa85 100644
--- a/dbaccess/source/core/api/RowSetBase.cxx
+++ b/dbaccess/source/core/api/RowSetBase.cxx
@@ -469,18 +469,16 @@ Reference< XRef > SAL_CALL ORowSetBase::getRef( sal_Int32 /*columnIndex*/ ) thro
return NULL;
}
// -------------------------------------------------------------------------
-Reference< XBlob > SAL_CALL ORowSetBase::getBlob( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
+Reference< XBlob > SAL_CALL ORowSetBase::getBlob( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::getBlob" );
- ::dbtools::throwFeatureNotImplementedException( "XRow::getBlob", *m_pMySelf );
- return NULL;
+ return Reference< XBlob >(getValue(columnIndex).makeAny(),UNO_QUERY);
}
// -------------------------------------------------------------------------
-Reference< XClob > SAL_CALL ORowSetBase::getClob( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
+Reference< XClob > SAL_CALL ORowSetBase::getClob( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::getClob" );
- ::dbtools::throwFeatureNotImplementedException( "XRow::getClob", *m_pMySelf );
- return NULL;
+ return Reference< XClob >(getValue(columnIndex).makeAny(),UNO_QUERY);
}
// -------------------------------------------------------------------------
Reference< XArray > SAL_CALL ORowSetBase::getArray( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
diff --git a/dbaccess/source/core/api/RowSetCache.cxx b/dbaccess/source/core/api/RowSetCache.cxx
index a96de4b9fbe1..4156c32635a2 100644
--- a/dbaccess/source/core/api/RowSetCache.cxx
+++ b/dbaccess/source/core/api/RowSetCache.cxx
@@ -168,6 +168,16 @@ ORowSetCache::ORowSetCache(const Reference< XResultSet >& _xRs,
Reference< XIndexAccess> xUpdateTableKeys;
::rtl::OUString aUpdateTableName = _rUpdateTableName;
Reference< XConnection> xConnection;
+ // first we need a connection
+ Reference< XStatement> xStmt(_xRs->getStatement(),UNO_QUERY);
+ if(xStmt.is())
+ xConnection = xStmt->getConnection();
+ else
+ {
+ Reference< XPreparedStatement> xPrepStmt(_xRs->getStatement(),UNO_QUERY);
+ xConnection = xPrepStmt->getConnection();
+ }
+ OSL_ENSURE(xConnection.is(),"No connection!");
if(_xAnalyzer.is())
{
try
@@ -215,16 +225,7 @@ ORowSetCache::ORowSetCache(const Reference< XResultSet >& _xRs,
if(xColumnsSupplier.is())
{
- // first we need a connection
- Reference< XStatement> xStmt(_xRs->getStatement(),UNO_QUERY);
- if(xStmt.is())
- xConnection = xStmt->getConnection();
- else
- {
- Reference< XPreparedStatement> xPrepStmt(_xRs->getStatement(),UNO_QUERY);
- xConnection = xPrepStmt->getConnection();
- }
- OSL_ENSURE(xConnection.is(),"No connection!");
+
Reference<XNameAccess> xColumns = xColumnsSupplier->getColumns();
Reference<XColumnsSupplier> xColSup(_xAnalyzer,UNO_QUERY);
@@ -233,7 +234,7 @@ ORowSetCache::ORowSetCache(const Reference< XResultSet >& _xRs,
Reference<XNameAccess> xSelColumns = xColSup->getColumns();
Reference<XDatabaseMetaData> xMeta = xConnection->getMetaData();
SelectColumnsMetaData aColumnNames(xMeta.is() && xMeta->supportsMixedCaseQuotedIdentifiers() ? true : false);
- ::dbaccess::getColumnPositions(xSelColumns,xColumns,aUpdateTableName,aColumnNames);
+ ::dbaccess::getColumnPositions(xSelColumns,xColumns->getElementNames(),aUpdateTableName,aColumnNames);
bAllKeysFound = !aColumnNames.empty() && sal_Int32(aColumnNames.size()) == xColumns->getElementNames().getLength();
}
}
@@ -303,7 +304,7 @@ ORowSetCache::ORowSetCache(const Reference< XResultSet >& _xRs,
Reference<XColumnsSupplier> xColSup(_xAnalyzer,UNO_QUERY);
Reference<XNameAccess> xSelColumns = xColSup->getColumns();
Reference<XNameAccess> xColumns = m_aUpdateTable->getColumns();
- ::dbaccess::getColumnPositions(xSelColumns,xColumns,aUpdateTableName,aColumnNames);
+ ::dbaccess::getColumnPositions(xSelColumns,xColumns->getElementNames(),aUpdateTableName,aColumnNames);
// check privileges
m_nPrivileges = Privilege::SELECT;
@@ -560,10 +561,18 @@ sal_Int32 ORowSetCache::hashBookmark( const Any& bookmark )
// -------------------------------------------------------------------------
// XRowUpdate
// -----------------------------------------------------------------------------
-void ORowSetCache::updateValue(sal_Int32 columnIndex,const ORowSetValue& x)
+void ORowSetCache::updateNull(sal_Int32 columnIndex)
{
checkUpdateConditions(columnIndex);
+ ((*m_aInsertRow)->get())[columnIndex].setBound(sal_True);
+ ((*m_aInsertRow)->get())[columnIndex].setNull();
+ ((*m_aInsertRow)->get())[columnIndex].setModified();
+}
+// -----------------------------------------------------------------------------
+void ORowSetCache::updateValue(sal_Int32 columnIndex,const ORowSetValue& x)
+{
+ checkUpdateConditions(columnIndex);
((*m_aInsertRow)->get())[columnIndex].setBound(sal_True);
((*m_aInsertRow)->get())[columnIndex] = x;
@@ -1342,11 +1351,12 @@ void ORowSetCache::moveToInsertRow( )
// we don't unbound the bookmark column
ORowSetValueVector::Vector::iterator aIter = (*m_aInsertRow)->get().begin()+1;
ORowSetValueVector::Vector::iterator aEnd = (*m_aInsertRow)->get().end();
- for(;aIter != aEnd;++aIter)
+ for(sal_Int32 i = 1;aIter != aEnd;++aIter,++i)
{
aIter->setBound(sal_False);
aIter->setModified(sal_False);
aIter->setNull();
+ aIter->setTypeKind(m_xMetaData->getColumnType(i));
}
}
// -------------------------------------------------------------------------
diff --git a/dbaccess/source/core/api/RowSetCache.hxx b/dbaccess/source/core/api/RowSetCache.hxx
index 0576aa68ac02..1f5be3113f8b 100644
--- a/dbaccess/source/core/api/RowSetCache.hxx
+++ b/dbaccess/source/core/api/RowSetCache.hxx
@@ -225,6 +225,7 @@ namespace dbaccess
void updateCharacterStream( sal_Int32 columnIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length );
void updateObject( sal_Int32 columnIndex, const ::com::sun::star::uno::Any& x );
void updateNumericObject( sal_Int32 columnIndex, const ::com::sun::star::uno::Any& x, sal_Int32 scale );
+ void updateNull(sal_Int32 columnIndex);
// ::com::sun::star::sdbc::XResultSet
sal_Bool next( );
diff --git a/dbaccess/source/core/api/SingleSelectQueryComposer.cxx b/dbaccess/source/core/api/SingleSelectQueryComposer.cxx
index c8a8f9ba01d1..0c2836d5ceec 100644
--- a/dbaccess/source/core/api/SingleSelectQueryComposer.cxx
+++ b/dbaccess/source/core/api/SingleSelectQueryComposer.cxx
@@ -1530,6 +1530,27 @@ void OSingleSelectQueryComposer::setConditionByColumn( const Reference< XPropert
aSQL.append( STR_LIKE );
aSQL.append( DBTypeConversion::toSQLString( nType, aValue, sal_True, m_xTypeConverter ) );
break;
+ case DataType::CLOB:
+ {
+ Reference< XClob > xClob(aValue,UNO_QUERY);
+ if ( xClob.is() )
+ {
+ const ::sal_Int64 nLength = xClob->length();
+ if ( sal_Int64(nLength + aSQL.getLength() + STR_LIKE.getLength() ) < sal_Int64(SAL_MAX_INT32) )
+ {
+ aSQL.append( STR_LIKE );
+ aSQL.appendAscii("'");
+ aSQL.append( xClob->getSubString(1,(sal_Int32)nLength) );
+ aSQL.appendAscii("'");
+ }
+ }
+ else
+ {
+ aSQL.append( STR_LIKE );
+ aSQL.append( DBTypeConversion::toSQLString( nType, aValue, sal_True, m_xTypeConverter ) );
+ }
+ }
+ break;
case DataType::VARBINARY:
case DataType::BINARY:
case DataType::LONGVARBINARY:
diff --git a/dbaccess/source/core/api/column.cxx b/dbaccess/source/core/api/column.cxx
index 05acfa269909..f789394d23f9 100644
--- a/dbaccess/source/core/api/column.cxx
+++ b/dbaccess/source/core/api/column.cxx
@@ -145,31 +145,6 @@ Reference< XPropertySetInfo > OColumn::getPropertySetInfo() throw (RuntimeExcept
return createPropertySetInfo( getInfoHelper() ) ;
}
-//--------------------------------------------------------------------------
-Sequence< sal_Int8 > OColumn::getUnoTunnelImplementationId()
-{
- static ::cppu::OImplementationId * pId = 0;
- if (! pId)
- {
- ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
- if (! pId)
- {
- static ::cppu::OImplementationId aId;
- pId = &aId;
- }
- }
- return pId->getImplementationId();
-}
-
-// com::sun::star::lang::XUnoTunnel
-//------------------------------------------------------------------
-sal_Int64 OColumn::getSomething( const Sequence< sal_Int8 > & rId ) throw (RuntimeException)
-{
- if (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) )
- return reinterpret_cast<sal_Int64>(this);
-
- return 0;
-}
// -----------------------------------------------------------------------------
::rtl::OUString SAL_CALL OColumn::getName( ) throw(::com::sun::star::uno::RuntimeException)
{
diff --git a/dbaccess/source/core/api/columnsettings.cxx b/dbaccess/source/core/api/columnsettings.cxx
index 756c427a7d37..3aba07d88749 100644
--- a/dbaccess/source/core/api/columnsettings.cxx
+++ b/dbaccess/source/core/api/columnsettings.cxx
@@ -36,6 +36,7 @@
#include <cppuhelper/typeprovider.hxx>
#include <comphelper/property.hxx>
#include <tools/debug.hxx>
+#include <tools/diagnose_ex.h>
//........................................................................
namespace dbaccess
@@ -56,6 +57,7 @@ namespace dbaccess
using ::com::sun::star::uno::Type;
using ::com::sun::star::lang::IllegalArgumentException;
using ::com::sun::star::beans::XPropertySet;
+ using ::com::sun::star::beans::XPropertySetInfo;
/** === end UNO using === **/
namespace PropertyAttribute = ::com::sun::star::beans::PropertyAttribute;
@@ -76,34 +78,6 @@ namespace dbaccess
DBG_DTOR( OColumnSettings, NULL );
}
- // XUnoTunnel
- //------------------------------------------------------------------
- sal_Int64 OColumnSettings::getSomething( const Sequence< sal_Int8 > & rId ) throw (RuntimeException)
- {
- if ( ( rId.getLength() == 16 )
- && ( 0 == rtl_compareMemory( getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) )
- )
- return reinterpret_cast< sal_Int64 >( this );
-
- return 0;
- }
-
- //--------------------------------------------------------------------------
- Sequence< sal_Int8 > OColumnSettings::getUnoTunnelImplementationId()
- {
- static ::cppu::OImplementationId * pId = 0;
- if (! pId)
- {
- ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
- if (! pId)
- {
- static ::cppu::OImplementationId aId;
- pId = &aId;
- }
- }
- return pId->getImplementationId();
- }
-
//------------------------------------------------------------------------------
void OColumnSettings::registerProperties( IPropertyContainer& _rPropertyContainer )
{
@@ -124,7 +98,7 @@ namespace dbaccess
}
//------------------------------------------------------------------------------
- bool OColumnSettings::isMine( const sal_Int32 _nPropertyHandle ) const
+ bool OColumnSettings::isColumnSettingProperty( const sal_Int32 _nPropertyHandle )
{
return ( _nPropertyHandle == PROPERTY_ID_ALIGN )
|| ( _nPropertyHandle == PROPERTY_ID_NUMBERFORMAT )
@@ -137,15 +111,69 @@ namespace dbaccess
}
//------------------------------------------------------------------------------
- sal_Bool OColumnSettings::isDefaulted() const
+ bool OColumnSettings::isDefaulted( const sal_Int32 _nPropertyHandle, const Any& _rPropertyValue )
+ {
+ switch ( _nPropertyHandle )
+ {
+ case PROPERTY_ID_ALIGN:
+ case PROPERTY_ID_NUMBERFORMAT:
+ case PROPERTY_ID_RELATIVEPOSITION:
+ case PROPERTY_ID_WIDTH:
+ case PROPERTY_ID_HELPTEXT:
+ case PROPERTY_ID_CONTROLDEFAULT:
+ return !_rPropertyValue.hasValue();
+
+ case PROPERTY_ID_CONTROLMODEL:
+ return !Reference< XPropertySet >( _rPropertyValue, UNO_QUERY ).is();
+
+ case PROPERTY_ID_HIDDEN:
+ {
+ sal_Bool bHidden = sal_False;
+ OSL_VERIFY( _rPropertyValue >>= bHidden );
+ return !bHidden;
+ }
+ }
+ OSL_ENSURE( false, "OColumnSettings::isDefaulted: illegal property handle!" );
+ return sal_False;
+ }
+
+ //------------------------------------------------------------------------------
+ bool OColumnSettings::hasDefaultSettings( const Reference< XPropertySet >& _rxColumn )
{
- return !m_aAlignment.hasValue()
- && !m_aWidth.hasValue()
- && !m_aFormatKey.hasValue()
- && !m_aRelativePosition.hasValue()
- && !m_aHelpText.hasValue()
- && !m_aControlDefault.hasValue()
- && !m_bHidden;
+ ENSURE_OR_THROW( _rxColumn.is(), "illegal column" );
+ try
+ {
+ Reference< XPropertySetInfo > xPSI( _rxColumn->getPropertySetInfo(), UNO_SET_THROW );
+
+ struct PropertyDescriptor
+ {
+ ::rtl::OUString sName;
+ sal_Int32 nHandle;
+ };
+ PropertyDescriptor aProps[] =
+ {
+ { PROPERTY_ALIGN, PROPERTY_ID_ALIGN },
+ { PROPERTY_NUMBERFORMAT, PROPERTY_ID_NUMBERFORMAT },
+ { PROPERTY_RELATIVEPOSITION, PROPERTY_ID_RELATIVEPOSITION },
+ { PROPERTY_WIDTH, PROPERTY_ID_WIDTH },
+ { PROPERTY_HELPTEXT, PROPERTY_ID_HELPTEXT },
+ { PROPERTY_CONTROLDEFAULT, PROPERTY_ID_CONTROLDEFAULT },
+ { PROPERTY_CONTROLMODEL, PROPERTY_ID_CONTROLMODEL },
+ { PROPERTY_HIDDEN, PROPERTY_ID_HIDDEN }
+ };
+
+ for ( size_t i=0; i < sizeof( aProps ) / sizeof( aProps[0] ); ++i )
+ {
+ if ( xPSI->hasPropertyByName( aProps[i].sName ) )
+ if ( !isDefaulted( aProps[i].nHandle, _rxColumn->getPropertyValue( aProps[i].sName ) ) )
+ return false;
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return true;
}
//........................................................................
diff --git a/dbaccess/source/core/api/definitioncolumn.cxx b/dbaccess/source/core/api/definitioncolumn.cxx
index fafdf0a97185..6662b470fcae 100644
--- a/dbaccess/source/core/api/definitioncolumn.cxx
+++ b/dbaccess/source/core/api/definitioncolumn.cxx
@@ -36,18 +36,24 @@
#include "definitioncolumn.hxx"
#include "sdbcoretools.hxx"
+/** === begin UNO includes === **/
#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+/** === end UNO includes === **/
#include <comphelper/property.hxx>
#include <comphelper/types.hxx>
+#include <connectivity/dbtools.hxx>
#include <cppuhelper/typeprovider.hxx>
#include <tools/debug.hxx>
#include <tools/diagnose_ex.h>
using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdbcx;
using namespace ::com::sun::star::beans;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::container;
using namespace ::cppu;
using namespace ::comphelper;
using namespace ::osl;
@@ -64,15 +70,15 @@ using namespace dbaccess;
IMPLEMENT_FORWARD_XINTERFACE2(OTableColumnDescriptor,OColumn,TXChild)
//------------------------------------------------------------------------------
-void OTableColumnDescriptor::impl_registerProperties( const bool _bActAsDescriptor )
+void OTableColumnDescriptor::impl_registerProperties()
{
- sal_Int32 nDefaultAttr = _bActAsDescriptor ? 0 : PropertyAttribute::READONLY;
+ sal_Int32 nDefaultAttr = m_bActAsDescriptor ? 0 : PropertyAttribute::READONLY;
registerProperty( PROPERTY_TYPENAME, PROPERTY_ID_TYPENAME, nDefaultAttr, &m_aTypeName, ::getCppuType( &m_aTypeName ) );
registerProperty( PROPERTY_DESCRIPTION, PROPERTY_ID_DESCRIPTION, nDefaultAttr, &m_aDescription, ::getCppuType( &m_aDescription ) );
registerProperty( PROPERTY_DEFAULTVALUE, PROPERTY_ID_DEFAULTVALUE, nDefaultAttr, &m_aDefaultValue, ::getCppuType( &m_aDefaultValue ) );
- if ( _bActAsDescriptor )
+ if ( m_bActAsDescriptor )
registerProperty( PROPERTY_AUTOINCREMENTCREATION, PROPERTY_ID_AUTOINCREMENTCREATION, nDefaultAttr, &m_aAutoIncrementValue, ::getCppuType( &m_aAutoIncrementValue ) );
registerProperty( PROPERTY_TYPE, PROPERTY_ID_TYPE, nDefaultAttr, &m_nType, ::getCppuType( &m_nType ) );
@@ -87,20 +93,7 @@ void OTableColumnDescriptor::impl_registerProperties( const bool _bActAsDescript
}
//--------------------------------------------------------------------------
-Sequence< sal_Int8 > OTableColumnDescriptor::getImplementationId() throw (RuntimeException)
-{
- static OImplementationId * pId = 0;
- if (! pId)
- {
- MutexGuard aGuard( Mutex::getGlobalMutex() );
- if (! pId)
- {
- static OImplementationId aId;
- pId = &aId;
- }
- }
- return pId->getImplementationId();
-}
+IMPLEMENT_GET_IMPLEMENTATION_ID( OTableColumnDescriptor )
// ::com::sun::star::lang::XServiceInfo
//------------------------------------------------------------------------------
@@ -113,7 +106,7 @@ rtl::OUString OTableColumnDescriptor::getImplementationName( ) throw (RuntimeEx
Sequence< ::rtl::OUString > OTableColumnDescriptor::getSupportedServiceNames( ) throw (RuntimeException)
{
Sequence< ::rtl::OUString > aSNS( 2 );
- aSNS[0] = SERVICE_SDBCX_COLUMNDESCRIPTOR;
+ aSNS[0] = m_bActAsDescriptor ? SERVICE_SDBCX_COLUMNDESCRIPTOR : SERVICE_SDBCX_COLUMN;
aSNS[1] = SERVICE_SDB_COLUMNSETTINGS;
return aSNS;
}
@@ -142,15 +135,6 @@ void OTableColumnDescriptor::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle
}
// -----------------------------------------------------------------------------
-sal_Int64 SAL_CALL OTableColumnDescriptor::getSomething( const Sequence< sal_Int8 >& aIdentifier ) throw(RuntimeException)
-{
- sal_Int64 nReturn = OColumn::getSomething( aIdentifier );
- if ( !nReturn )
- nReturn = OColumnSettings::getSomething( aIdentifier );
- return nReturn;
-}
-
-// -----------------------------------------------------------------------------
Reference< XInterface > SAL_CALL OTableColumnDescriptor::getParent( ) throw (RuntimeException)
{
::osl::MutexGuard aGuard(m_aMutex);
@@ -169,110 +153,205 @@ DBG_NAME(OTableColumn);
// -------------------------------------------------------------------------
OTableColumn::OTableColumn( const ::rtl::OUString& _rName )
- :OTableColumnDescriptor( false )
+ :OTableColumnDescriptor( false /* do not act as descriptor */ )
{
DBG_CTOR(OTableColumn,NULL);
m_sName = _rName;
}
-// -------------------------------------------------------------------------
-OTableColumn::OTableColumn(const Reference<XPropertySet>& _xColumn)
- :OTableColumnDescriptor( false )
+// -----------------------------------------------------------------------------
+OTableColumn::~OTableColumn()
{
- DBG_CTOR(OTableColumn,NULL);
+ DBG_DTOR(OTableColumn,NULL);
+}
- OSL_VERIFY( _xColumn->getPropertyValue( PROPERTY_TYPENAME ) >>= m_aTypeName );
- OSL_VERIFY( _xColumn->getPropertyValue( PROPERTY_ISNULLABLE ) >>= m_nIsNullable );
- OSL_VERIFY( _xColumn->getPropertyValue( PROPERTY_PRECISION ) >>= m_nPrecision );
- OSL_VERIFY( _xColumn->getPropertyValue( PROPERTY_SCALE ) >>= m_nScale );
- OSL_VERIFY( _xColumn->getPropertyValue( PROPERTY_TYPE ) >>= m_nType );
- OSL_VERIFY( _xColumn->getPropertyValue( PROPERTY_ISAUTOINCREMENT ) >>= m_bAutoIncrement );
- OSL_VERIFY( _xColumn->getPropertyValue( PROPERTY_ISCURRENCY ) >>= m_bCurrency );
- OSL_VERIFY( _xColumn->getPropertyValue( PROPERTY_NAME ) >>= m_sName );
+//--------------------------------------------------------------------------
+IMPLEMENT_GET_IMPLEMENTATION_ID( OTableColumn )
+
+//------------------------------------------------------------------------------
+rtl::OUString OTableColumn::getImplementationName( ) throw (RuntimeException)
+{
+ return rtl::OUString::createFromAscii("com.sun.star.sdb.OTableColumn");
+}
+
+//------------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper& SAL_CALL OTableColumn::getInfoHelper()
+{
+ return *OTableColumn_PBase::getArrayHelper();
+}
+
+//------------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper* OTableColumn::createArrayHelper( ) const
+{
+ return OTableColumnDescriptor::createArrayHelper();
+}
+
+// =========================================================================
+//= OQueryColumn
+// =========================================================================
+DBG_NAME( OQueryColumn );
+
+// -------------------------------------------------------------------------
+OQueryColumn::OQueryColumn( const Reference< XPropertySet >& _rxParserColumn, const Reference< XConnection >& _rxConnection )
+ :OTableColumnDescriptor( false /* do not act as descriptor */ )
+{
+ const sal_Int32 nPropAttr = PropertyAttribute::READONLY;
+ registerProperty( PROPERTY_CATALOGNAME, PROPERTY_ID_CATALOGNAME, nPropAttr, &m_sCatalogName, ::getCppuType( &m_sCatalogName ) );
+ registerProperty( PROPERTY_SCHEMANAME, PROPERTY_ID_SCHEMANAME, nPropAttr, &m_sSchemaName, ::getCppuType( &m_sSchemaName ) );
+ registerProperty( PROPERTY_TABLENAME, PROPERTY_ID_TABLENAME, nPropAttr, &m_sTableName, ::getCppuType( &m_sTableName ) );
+ registerProperty( PROPERTY_REALNAME, PROPERTY_ID_REALNAME, nPropAttr, &m_sRealName, ::getCppuType( &m_sRealName ) );
+
+ DBG_CTOR( OQueryColumn, NULL );
+
+ OSL_VERIFY( _rxParserColumn->getPropertyValue( PROPERTY_TYPENAME ) >>= m_aTypeName );
+ OSL_VERIFY( _rxParserColumn->getPropertyValue( PROPERTY_ISNULLABLE ) >>= m_nIsNullable );
+ OSL_VERIFY( _rxParserColumn->getPropertyValue( PROPERTY_PRECISION ) >>= m_nPrecision );
+ OSL_VERIFY( _rxParserColumn->getPropertyValue( PROPERTY_SCALE ) >>= m_nScale );
+ OSL_VERIFY( _rxParserColumn->getPropertyValue( PROPERTY_TYPE ) >>= m_nType );
+ OSL_VERIFY( _rxParserColumn->getPropertyValue( PROPERTY_ISAUTOINCREMENT ) >>= m_bAutoIncrement );
+ OSL_VERIFY( _rxParserColumn->getPropertyValue( PROPERTY_ISCURRENCY ) >>= m_bCurrency );
+ OSL_VERIFY( _rxParserColumn->getPropertyValue( PROPERTY_NAME ) >>= m_sName );
m_bRowVersion = sal_False;
- Reference< XPropertySetInfo > xPSI( _xColumn->getPropertySetInfo(), UNO_SET_THROW );
+ Reference< XPropertySetInfo > xPSI( _rxParserColumn->getPropertySetInfo(), UNO_SET_THROW );
if ( xPSI->hasPropertyByName( PROPERTY_DEFAULTVALUE ) )
- OSL_VERIFY( _xColumn->getPropertyValue( PROPERTY_DEFAULTVALUE ) >>= m_aDefaultValue );
+ OSL_VERIFY( _rxParserColumn->getPropertyValue( PROPERTY_DEFAULTVALUE ) >>= m_aDefaultValue );
- // if the source column also has column settings, copy those
- struct ColumnSettingDescriptor
+ // copy some optional properties from the parser column
+ struct PropertyDescriptor
{
::rtl::OUString sName;
sal_Int32 nHandle;
};
- ColumnSettingDescriptor aProps[] =
+ PropertyDescriptor aProps[] =
{
- { PROPERTY_WIDTH, PROPERTY_ID_WIDTH },
- { PROPERTY_NUMBERFORMAT, PROPERTY_ID_NUMBERFORMAT },
- { PROPERTY_RELATIVEPOSITION, PROPERTY_ID_RELATIVEPOSITION },
- { PROPERTY_ALIGN, PROPERTY_ID_ALIGN },
- { PROPERTY_HELPTEXT, PROPERTY_ID_HELPTEXT },
- { PROPERTY_CONTROLDEFAULT, PROPERTY_ID_CONTROLDEFAULT },
- { PROPERTY_HIDDEN, PROPERTY_ID_HIDDEN }
+ { PROPERTY_CATALOGNAME, PROPERTY_ID_CATALOGNAME },
+ { PROPERTY_SCHEMANAME, PROPERTY_ID_SCHEMANAME },
+ { PROPERTY_TABLENAME, PROPERTY_ID_TABLENAME },
+ { PROPERTY_REALNAME, PROPERTY_ID_REALNAME }
};
for ( size_t i=0; i < sizeof( aProps ) / sizeof( aProps[0] ); ++i )
{
if ( xPSI->hasPropertyByName( aProps[i].sName ) )
- OTableColumnDescriptor::setFastPropertyValue_NoBroadcast( aProps[i].nHandle, _xColumn->getPropertyValue( aProps[i].sName ) );
+ setFastPropertyValue_NoBroadcast( aProps[i].nHandle, _rxParserColumn->getPropertyValue( aProps[i].sName ) );
}
+
+ // determine the table column we're based on
+ osl_incrementInterlockedCount( &m_refCount );
+ {
+ m_xOriginalTableColumn = impl_determineOriginalTableColumn( _rxConnection );
+ }
+ osl_decrementInterlockedCount( &m_refCount );
}
-// -----------------------------------------------------------------------------
-OTableColumn::~OTableColumn()
+//--------------------------------------------------------------------------
+OQueryColumn::~OQueryColumn()
{
- DBG_DTOR(OTableColumn,NULL);
+ DBG_DTOR( OQueryColumn, NULL );
}
-// com::sun::star::lang::XTypeProvider
//--------------------------------------------------------------------------
-Sequence< sal_Int8 > OTableColumn::getImplementationId() throw (RuntimeException)
+Reference< XPropertySet > OQueryColumn::impl_determineOriginalTableColumn( const Reference< XConnection >& _rxConnection )
{
- static OImplementationId * pId = 0;
- if (! pId)
+ OSL_PRECOND( _rxConnection.is(), "OQueryColumn::impl_determineOriginalTableColumn: illegal connection!" );
+ if ( !_rxConnection.is() )
+ return NULL;
+
+ Reference< XPropertySet > xOriginalTableColumn;
+ try
{
- MutexGuard aGuard( Mutex::getGlobalMutex() );
- if (! pId)
- {
- static OImplementationId aId;
- pId = &aId;
- }
+ // determine the composed table name, plus the column name, as indicated by the
+ // respective properties
+ ::rtl::OUString sCatalog, sSchema, sTable;
+ OSL_VERIFY( getPropertyValue( PROPERTY_CATALOGNAME ) >>= sCatalog );
+ OSL_VERIFY( getPropertyValue( PROPERTY_SCHEMANAME ) >>= sSchema );
+ OSL_VERIFY( getPropertyValue( PROPERTY_TABLENAME ) >>= sTable );
+ if ( !sCatalog.getLength() && !sSchema.getLength() && !sTable.getLength() )
+ return NULL;
+
+ ::rtl::OUString sComposedTableName = ::dbtools::composeTableName(
+ _rxConnection->getMetaData(), sCatalog, sSchema, sTable, sal_False, ::dbtools::eComplete );
+
+ // retrieve the table in question
+ Reference< XTablesSupplier > xSuppTables( _rxConnection, UNO_QUERY_THROW );
+ Reference< XNameAccess > xTables( xSuppTables->getTables(), UNO_QUERY_THROW );
+ if ( !xTables->hasByName( sComposedTableName ) )
+ return NULL;
+
+ Reference< XColumnsSupplier > xSuppCols( xTables->getByName( sComposedTableName ), UNO_QUERY_THROW );
+ Reference< XNameAccess > xColumns( xSuppCols->getColumns(), UNO_QUERY_THROW );
+
+ ::rtl::OUString sColumn;
+ OSL_VERIFY( getPropertyValue( PROPERTY_REALNAME ) >>= sColumn );
+ if ( !xColumns->hasByName( sColumn ) )
+ return NULL;
+
+ xOriginalTableColumn.set( xColumns->getByName( sColumn ), UNO_QUERY );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
}
- return pId->getImplementationId();
+ return xOriginalTableColumn;
}
-// ::com::sun::star::lang::XServiceInfo
-//------------------------------------------------------------------------------
-rtl::OUString OTableColumn::getImplementationName( ) throw (RuntimeException)
+//--------------------------------------------------------------------------
+IMPLEMENT_GET_IMPLEMENTATION_ID( OQueryColumn )
+
+//--------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OQueryColumn::getImplementationName( ) throw(RuntimeException)
{
- return rtl::OUString::createFromAscii("com.sun.star.sdb.OTableColumn");
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.comp.dbaccess.OQueryColumn" ) );
}
//------------------------------------------------------------------------------
-Sequence< ::rtl::OUString > OTableColumn::getSupportedServiceNames( ) throw (RuntimeException)
+::cppu::IPropertyArrayHelper& SAL_CALL OQueryColumn::getInfoHelper()
{
- Sequence< ::rtl::OUString > aSNS( 2 );
- aSNS[0] = SERVICE_SDBCX_COLUMN;
- aSNS[1] = SERVICE_SDB_COLUMNSETTINGS;
- return aSNS;
+ return *OQueryColumn_PBase::getArrayHelper();
}
-//------------------------------------------------------------------------------
-::cppu::IPropertyArrayHelper& OTableColumn::getInfoHelper()
+//--------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper* OQueryColumn::createArrayHelper() const
{
- return *static_cast< ::comphelper::OPropertyArrayUsageHelper< OTableColumn >* >(this)->getArrayHelper();
+ return OTableColumnDescriptor::createArrayHelper();
}
-// comphelper::OPropertyArrayUsageHelper
-//------------------------------------------------------------------------------
-::cppu::IPropertyArrayHelper* OTableColumn::createArrayHelper( ) const
+//--------------------------------------------------------------------------
+void SAL_CALL OQueryColumn::getFastPropertyValue( Any& _rValue, sal_Int32 _nHandle ) const
{
- return OTableColumnDescriptor::createArrayHelper();
+ OTableColumnDescriptor::getFastPropertyValue( _rValue, _nHandle );
+
+ // special treatment for column settings:
+ if ( !OColumnSettings::isColumnSettingProperty( _nHandle ) )
+ return;
+
+ // If the setting has its default value, then try to obtain the value from the table column which
+ // this query column is based on
+ if ( !OColumnSettings::isDefaulted( _nHandle, _rValue ) )
+ return;
+
+ if ( !m_xOriginalTableColumn.is() )
+ return;
+
+ try
+ {
+ // determine original property name
+ ::rtl::OUString sPropName;
+ sal_Int16 nAttributes( 0 );
+ const_cast< OQueryColumn* >( this )->getInfoHelper().fillPropertyMembersByHandle( &sPropName, &nAttributes, _nHandle );
+ OSL_ENSURE( sPropName.getLength(), "OColumnWrapper::impl_getPropertyNameFromHandle: property not found!" );
+
+ _rValue = m_xOriginalTableColumn->getPropertyValue( sPropName );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
}
-//============================================================
+//==========================================================================
//= OColumnWrapper
-//============================================================
+//==========================================================================
DBG_NAME(OColumnWrapper);
//--------------------------------------------------------------------------
OColumnWrapper::OColumnWrapper( const Reference< XPropertySet > & rCol, const bool _bNameIsReadOnly )
@@ -364,14 +443,10 @@ void OColumnWrapper::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const
// -----------------------------------------------------------------------------
sal_Int64 SAL_CALL OColumnWrapper::getSomething( const Sequence< sal_Int8 >& aIdentifier ) throw(RuntimeException)
{
- sal_Int64 nRet = OColumn::getSomething(aIdentifier);
- if(!nRet)
- {
- Reference<XUnoTunnel> xTunnel(m_xAggregate,UNO_QUERY);
- if(xTunnel.is())
- nRet = xTunnel->getSomething(aIdentifier);
- }
- return nRet;
+ Reference< XUnoTunnel > xTunnel( m_xAggregate, UNO_QUERY);
+ if ( xTunnel.is() )
+ return xTunnel->getSomething( aIdentifier );
+ return 0;
}
//============================================================
@@ -389,20 +464,7 @@ OTableColumnDescriptorWrapper::OTableColumnDescriptorWrapper( const Reference< X
// com::sun::star::lang::XTypeProvider
//--------------------------------------------------------------------------
-Sequence< sal_Int8 > OTableColumnDescriptorWrapper::getImplementationId() throw (RuntimeException)
-{
- static OImplementationId * pId = 0;
- if (! pId)
- {
- MutexGuard aGuard( Mutex::getGlobalMutex() );
- if (! pId)
- {
- static OImplementationId aId;
- pId = &aId;
- }
- }
- return pId->getImplementationId();
-}
+IMPLEMENT_GET_IMPLEMENTATION_ID( OTableColumnDescriptorWrapper )
// ::com::sun::star::lang::XServiceInfo
//------------------------------------------------------------------------------
@@ -420,15 +482,6 @@ Sequence< ::rtl::OUString > OTableColumnDescriptorWrapper::getSupportedServiceNa
return aSNS;
}
-// -----------------------------------------------------------------------------
-sal_Int64 SAL_CALL OTableColumnDescriptorWrapper::getSomething( const Sequence< sal_Int8 >& aIdentifier ) throw(RuntimeException)
-{
- sal_Int64 nReturn = OColumnWrapper::getSomething( aIdentifier );
- if ( !nReturn )
- nReturn = OColumnSettings::getSomething( aIdentifier );
- return nReturn;
-}
-
// comphelper::OPropertyArrayUsageHelper
//------------------------------------------------------------------------------
::cppu::IPropertyArrayHelper* OTableColumnDescriptorWrapper::createArrayHelper( sal_Int32 nId ) const
@@ -587,24 +640,9 @@ OTableColumnWrapper::~OTableColumnWrapper()
{
}
-// com::sun::star::lang::XTypeProvider
//--------------------------------------------------------------------------
-Sequence< sal_Int8 > OTableColumnWrapper::getImplementationId() throw (RuntimeException)
-{
- static OImplementationId * pId = 0;
- if (! pId)
- {
- MutexGuard aGuard( Mutex::getGlobalMutex() );
- if (! pId)
- {
- static OImplementationId aId;
- pId = &aId;
- }
- }
- return pId->getImplementationId();
-}
+IMPLEMENT_GET_IMPLEMENTATION_ID( OTableColumnWrapper )
-// ::com::sun::star::lang::XServiceInfo
//------------------------------------------------------------------------------
rtl::OUString OTableColumnWrapper::getImplementationName( ) throw (RuntimeException)
{
diff --git a/dbaccess/source/core/api/query.cxx b/dbaccess/source/core/api/query.cxx
index 489ca625c5d7..7468e88f4fff 100644
--- a/dbaccess/source/core/api/query.cxx
+++ b/dbaccess/source/core/api/query.cxx
@@ -241,13 +241,12 @@ void OQuery::rebuildColumns()
for ( ;pBegin != pEnd; ++pBegin)
{
Reference<XPropertySet> xSource(xColumns->getByName( *pBegin ),UNO_QUERY);
- OTableColumn* pColumn = new OTableColumn( xSource );
- Reference<XChild> xChild(*pColumn,UNO_QUERY);
- if ( xChild.is() )
- xChild->setParent(*this);
+ OQueryColumn* pColumn = new OQueryColumn( xSource, m_xConnection );
+ Reference< XChild > xChild( *pColumn, UNO_QUERY_THROW );
+ xChild->setParent( *this );
implAppendColumn( *pBegin, pColumn );
- Reference<XPropertySet> xDest(*pColumn,UNO_QUERY);
+ Reference< XPropertySet > xDest( *pColumn, UNO_QUERY_THROW );
if ( m_pColumnMediator.is() )
m_pColumnMediator->notifyElementCreated( *pBegin, xDest );
}
diff --git a/dbaccess/source/core/api/querycontainer.cxx b/dbaccess/source/core/api/querycontainer.cxx
index f86a1a8bf6e5..2d75ce3bf8bd 100644
--- a/dbaccess/source/core/api/querycontainer.cxx
+++ b/dbaccess/source/core/api/querycontainer.cxx
@@ -163,6 +163,10 @@ OQueryContainer::~OQueryContainer()
}
// -----------------------------------------------------------------------------
IMPLEMENT_FORWARD_XINTERFACE2( OQueryContainer,ODefinitionContainer,OQueryContainer_Base)
+
+//------------------------------------------------------------------------------
+IMPLEMENT_FORWARD_XTYPEPROVIDER2( OQueryContainer,ODefinitionContainer,OQueryContainer_Base)
+
//------------------------------------------------------------------------------
void OQueryContainer::disposing()
{
diff --git a/dbaccess/source/core/api/querydescriptor.cxx b/dbaccess/source/core/api/querydescriptor.cxx
index a666d250f07c..00b3a247aed5 100644
--- a/dbaccess/source/core/api/querydescriptor.cxx
+++ b/dbaccess/source/core/api/querydescriptor.cxx
@@ -265,7 +265,7 @@ Reference< XNameAccess > SAL_CALL OQueryDescriptor_Base::getColumns( ) throw (Ru
{
rebuildColumns();
}
- catch(...)
+ catch ( const Exception& )
{
setColumnsOutOfDate( sal_True );
throw;
@@ -336,9 +336,10 @@ void OQueryDescriptor_Base::refreshColumns()
}
//------------------------------------------------------------------------------
-OColumn* OQueryDescriptor_Base::createColumn(const ::rtl::OUString& _rName) const
+OColumn* OQueryDescriptor_Base::createColumn( const ::rtl::OUString& /*_rName*/ ) const
{
- return new OTableColumn(_rName);
+ // creating a column/descriptor for a query/descriptor does not make sense at all
+ return NULL;
}
// -----------------------------------------------------------------------------
//........................................................................
diff --git a/dbaccess/source/core/api/tablecontainer.cxx b/dbaccess/source/core/api/tablecontainer.cxx
index 2d8ce453fb2c..8c1abc1f0048 100644
--- a/dbaccess/source/core/api/tablecontainer.cxx
+++ b/dbaccess/source/core/api/tablecontainer.cxx
@@ -364,15 +364,11 @@ ObjectType OTableContainer::appendObject( const ::rtl::OUString& _rForName, cons
if ( !xColumnDefinitions->hasByName(*pIter) )
{
Reference<XPropertySet> xColumn(xNames->getByName(*pIter),UNO_QUERY);
- OColumnSettings* pColumnSettings = NULL;
- if ( ::comphelper::getImplementation( pColumnSettings, xColumn ) )
+ if ( !OColumnSettings::hasDefaultSettings( xColumn ) )
{
- if ( ( pColumnSettings && !pColumnSettings->isDefaulted() ) )
- {
- ::comphelper::copyProperties(xColumn,xProp);
- xAppend->appendByDescriptor(xProp);
- bModified = sal_True;
- }
+ ::comphelper::copyProperties( xColumn, xProp );
+ xAppend->appendByDescriptor( xProp );
+ bModified = sal_True;
}
}
}
diff --git a/dbaccess/source/core/dataaccess/ComponentDefinition.cxx b/dbaccess/source/core/dataaccess/ComponentDefinition.cxx
index 81ad98dfc97b..678ed2ce612e 100644
--- a/dbaccess/source/core/dataaccess/ComponentDefinition.cxx
+++ b/dbaccess/source/core/dataaccess/ComponentDefinition.cxx
@@ -282,6 +282,8 @@ OColumn* OComponentDefinition::createColumn(const ::rtl::OUString& _rName) const
aFind->second->addPropertyChangeListener(::rtl::OUString(),m_xColumnPropertyListener.getRef());
return new OTableColumnWrapper( aFind->second, aFind->second, true );
}
+ OSL_ENSURE( false, "OComponentDefinition::createColumn: is this a valid case?" );
+ // This here is the last place creating a OTableColumn, and somehow /me thinks it is not needed ...
return new OTableColumn( _rName );
}
// -----------------------------------------------------------------------------
diff --git a/dbaccess/source/core/dataaccess/databasecontext.cxx b/dbaccess/source/core/dataaccess/databasecontext.cxx
index 22f3aa7c5bd7..cae64615b1de 100644
--- a/dbaccess/source/core/dataaccess/databasecontext.cxx
+++ b/dbaccess/source/core/dataaccess/databasecontext.cxx
@@ -36,6 +36,7 @@
#include "core_resource.hxx"
#include "databasecontext.hxx"
#include "databasedocument.hxx"
+#include "databaseregistrations.hxx"
#include "datasource.hxx"
#include "dbastrings.hrc"
#include "module_dba.hxx"
@@ -70,7 +71,6 @@
#include <cppuhelper/typeprovider.hxx>
#include <cppuhelper/exc_hlp.hxx>
#include <svtools/filenotation.hxx>
-#include <svtools/pathoptions.hxx>
#include <tools/debug.hxx>
#include <tools/diagnose_ex.h>
#include <tools/fsys.hxx>
@@ -114,30 +114,6 @@ namespace dbaccess
{
//........................................................................
- namespace
- {
- //--------------------------------------------------------------------
- const ::rtl::OUString& getDbRegisteredNamesNodeName()
- {
- static ::rtl::OUString s_sNodeName = ::rtl::OUString::createFromAscii("org.openoffice.Office.DataAccess/RegisteredNames");
- return s_sNodeName;
- }
-
- //--------------------------------------------------------------------
- const ::rtl::OUString& getDbNameNodeName()
- {
- static ::rtl::OUString s_sNodeName = ::rtl::OUString::createFromAscii("Name");
- return s_sNodeName;
- }
-
- //--------------------------------------------------------------------
- const ::rtl::OUString& getDbLocationNodeName()
- {
- static ::rtl::OUString s_sNodeName = ::rtl::OUString::createFromAscii("Location");
- return s_sNodeName;
- }
- // -----------------------------------------------------------------------------
- }
// .............................................................................
typedef ::cppu::WeakImplHelper1 < XTerminateListener
> DatabaseDocumentLoader_Base;
@@ -224,6 +200,15 @@ ODatabaseContext::ODatabaseContext( const Reference< XComponentContext >& _rxCon
{
m_pDatabaseDocumentLoader = new DatabaseDocumentLoader( m_aContext );
::basic::BasicManagerRepository::registerCreationListener( *this );
+
+ osl_incrementInterlockedCount( &m_refCount );
+ {
+ m_xDBRegistrationAggregate.set( createDataSourceRegistrations( m_aContext ), UNO_SET_THROW );
+ m_xDatabaseRegistrations.set( m_xDBRegistrationAggregate, UNO_QUERY_THROW );
+
+ m_xDBRegistrationAggregate->setDelegator( *this );
+ }
+ osl_decrementInterlockedCount( &m_refCount );
}
//--------------------------------------------------------------------------
@@ -232,6 +217,10 @@ ODatabaseContext::~ODatabaseContext()
::basic::BasicManagerRepository::revokeCreationListener( *this );
if ( m_pDatabaseDocumentLoader )
m_pDatabaseDocumentLoader->release();
+
+ m_xDBRegistrationAggregate->setDelegator( NULL );
+ m_xDBRegistrationAggregate.clear();
+ m_xDatabaseRegistrations.clear();
}
// Helper
@@ -327,25 +316,6 @@ void ODatabaseContext::disposing()
m_aDatabaseObjects.clear();
}
-//------------------------------------------------------------------------------
-bool ODatabaseContext::getURLForRegisteredObject( const ::rtl::OUString& _rRegisteredName, ::rtl::OUString& _rURL )
-{
- if ( !_rRegisteredName.getLength() )
- throw IllegalArgumentException();
-
- // the config node where all pooling relevant info are stored under
- OConfigurationTreeRoot aDbRegisteredNamesRoot = OConfigurationTreeRoot::createWithServiceFactory(
- m_aContext.getLegacyServiceFactory(), getDbRegisteredNamesNodeName(), -1, OConfigurationTreeRoot::CM_READONLY);
- if ( aDbRegisteredNamesRoot.isValid() && aDbRegisteredNamesRoot.hasByName( _rRegisteredName ) )
- {
- OConfigurationNode aRegisterObj = aDbRegisteredNamesRoot.openNode( _rRegisteredName );
- aRegisterObj.getNodeValue(getDbLocationNodeName()) >>= _rURL;
- _rURL = SvtPathOptions().SubstituteVariable( _rURL );
- return true;
- }
- return false;
-}
-
// XNamingService
//------------------------------------------------------------------------------
Reference< XInterface > ODatabaseContext::getRegisteredObject(const rtl::OUString& _rName) throw( Exception, RuntimeException )
@@ -353,9 +323,7 @@ Reference< XInterface > ODatabaseContext::getRegisteredObject(const rtl::OUStri
MutexGuard aGuard(m_aMutex);
::connectivity::checkDisposed(DatabaseAccessContext_Base::rBHelper.bDisposed);
- ::rtl::OUString sURL;
- if ( !getURLForRegisteredObject( _rName, sURL ) )
- throw NoSuchElementException(_rName, *this);
+ ::rtl::OUString sURL( getDatabaseLocation( _rName ) );
if ( !sURL.getLength() )
// there is a registration for this name, but no URL
@@ -500,23 +468,7 @@ void ODatabaseContext::registerObject(const rtl::OUString& _rName, const Referen
if ( !sURL.getLength() )
throw IllegalArgumentException( DBACORE_RESSTRING( RID_STR_DATASOURCE_NOT_STORED ), *this, 2 );
- OConfigurationTreeRoot aDbRegisteredNamesRoot = OConfigurationTreeRoot::createWithServiceFactory(
- ::comphelper::getProcessServiceFactory(), getDbRegisteredNamesNodeName(), -1, OConfigurationTreeRoot::CM_UPDATABLE);
-
- if ( aDbRegisteredNamesRoot.isValid() )
- {
- OConfigurationNode oDataSourceRegistration;
- // the sub-node for the concrete registration
- if (aDbRegisteredNamesRoot.hasByName(_rName))
- oDataSourceRegistration = aDbRegisteredNamesRoot.openNode(_rName);
- else
- oDataSourceRegistration = aDbRegisteredNamesRoot.createNode(_rName);
-
- // set the values
- oDataSourceRegistration.setNodeValue(getDbNameNodeName(), makeAny(_rName));
- oDataSourceRegistration.setNodeValue(getDbLocationNodeName(), makeAny(sURL));
- aDbRegisteredNamesRoot.commit();
- }
+ registerDatabaseLocation( _rName, sURL );
ODatabaseSource::setName( xDocDataSource, _rName, ODatabaseSource::DBContextAccess() );
@@ -601,30 +553,20 @@ void ODatabaseContext::revokeObject(const rtl::OUString& _rName) throw( Exceptio
Reference< XInterface > xExistent;
- OConfigurationTreeRoot aDbRegisteredNamesRoot = OConfigurationTreeRoot::createWithServiceFactory(
- m_aContext.getLegacyServiceFactory(), getDbRegisteredNamesNodeName(), -1, OConfigurationTreeRoot::CM_UPDATABLE);
- if ( aDbRegisteredNamesRoot.isValid() && aDbRegisteredNamesRoot.hasByName(_rName) )
- {
- OConfigurationNode aThisDriverSettings = aDbRegisteredNamesRoot.openNode(_rName);
- ::rtl::OUString sURL;
- aThisDriverSettings.getNodeValue(getDbLocationNodeName()) >>= sURL;
- sURL = SvtPathOptions().SubstituteVariable(sURL);
+ ::rtl::OUString sURL = getDatabaseLocation( _rName );
- if ( m_aDatabaseObjects.find( _rName ) != m_aDatabaseObjects.end() )
- {
- m_aDatasourceProperties[ sURL ] = m_aDatasourceProperties[ _rName ];
- }
+ revokeDatabaseLocation( _rName );
+ // will throw if something goes wrong
- // check if URL is already loaded
- ObjectCacheIterator aExistent = m_aDatabaseObjects.find(sURL);
- if ( aExistent != m_aDatabaseObjects.end() )
- m_aDatabaseObjects.erase(aExistent);
- if (!aDbRegisteredNamesRoot.removeNode(_rName))
- throw Exception(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("An unexpected und unknown error occured.")), static_cast<XNamingService*>(this));
- aDbRegisteredNamesRoot.commit();
+ if ( m_aDatabaseObjects.find( _rName ) != m_aDatabaseObjects.end() )
+ {
+ m_aDatasourceProperties[ sURL ] = m_aDatasourceProperties[ _rName ];
}
- else
- throw NoSuchElementException(_rName,*this);
+
+ // check if URL is already loaded
+ ObjectCacheIterator aExistent = m_aDatabaseObjects.find(sURL);
+ if ( aExistent != m_aDatabaseObjects.end() )
+ m_aDatabaseObjects.erase(aExistent);
// notify our container listeners
ContainerEvent aEvent(static_cast<XContainer*>(this), makeAny(_rName), Any(), makeAny(xExistent));
@@ -634,6 +576,60 @@ void ODatabaseContext::revokeObject(const rtl::OUString& _rName) throw( Exceptio
static_cast<XContainerListener*>(aListenerLoop.next())->elementRemoved(aEvent);
}
+//------------------------------------------------------------------------------
+::sal_Bool SAL_CALL ODatabaseContext::hasRegisteredDatabase( const ::rtl::OUString& _Name ) throw (IllegalArgumentException, RuntimeException)
+{
+ return m_xDatabaseRegistrations->hasRegisteredDatabase( _Name );
+}
+
+//------------------------------------------------------------------------------
+Sequence< ::rtl::OUString > SAL_CALL ODatabaseContext::getRegistrationNames() throw (RuntimeException)
+{
+ return m_xDatabaseRegistrations->getRegistrationNames();
+}
+
+//------------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseContext::getDatabaseLocation( const ::rtl::OUString& _Name ) throw (IllegalArgumentException, NoSuchElementException, RuntimeException)
+{
+ return m_xDatabaseRegistrations->getDatabaseLocation( _Name );
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL ODatabaseContext::registerDatabaseLocation( const ::rtl::OUString& _Name, const ::rtl::OUString& _Location ) throw (IllegalArgumentException, ElementExistException, RuntimeException)
+{
+ m_xDatabaseRegistrations->registerDatabaseLocation( _Name, _Location );
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL ODatabaseContext::revokeDatabaseLocation( const ::rtl::OUString& _Name ) throw (IllegalArgumentException, NoSuchElementException, IllegalAccessException, RuntimeException)
+{
+ m_xDatabaseRegistrations->revokeDatabaseLocation( _Name );
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL ODatabaseContext::changeDatabaseLocation( const ::rtl::OUString& _Name, const ::rtl::OUString& _NewLocation ) throw (IllegalArgumentException, NoSuchElementException, IllegalAccessException, RuntimeException)
+{
+ m_xDatabaseRegistrations->changeDatabaseLocation( _Name, _NewLocation );
+}
+
+//------------------------------------------------------------------------------
+::sal_Bool SAL_CALL ODatabaseContext::isDatabaseRegistrationReadOnly( const ::rtl::OUString& _Name ) throw (IllegalArgumentException, NoSuchElementException, RuntimeException)
+{
+ return m_xDatabaseRegistrations->isDatabaseRegistrationReadOnly( _Name );
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL ODatabaseContext::addDatabaseRegistrationsListener( const Reference< XDatabaseRegistrationsListener >& _Listener ) throw (RuntimeException)
+{
+ m_xDatabaseRegistrations->addDatabaseRegistrationsListener( _Listener );
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL ODatabaseContext::removeDatabaseRegistrationsListener( const Reference< XDatabaseRegistrationsListener >& _Listener ) throw (RuntimeException)
+{
+ m_xDatabaseRegistrations->removeDatabaseRegistrationsListener( _Listener );
+}
+
// ::com::sun::star::container::XElementAccess
//------------------------------------------------------------------------------
Type ODatabaseContext::getElementType( ) throw(RuntimeException)
@@ -676,8 +672,9 @@ Any ODatabaseContext::getByName(const rtl::OUString& _rName) throw( NoSuchElemen
// see whether this is an registered name
::rtl::OUString sURL;
- if ( getURLForRegisteredObject( _rName, sURL ) )
+ if ( hasRegisteredDatabase( _rName ) )
{
+ sURL = getDatabaseLocation( _rName );
// is the object cached under its URL?
xExistent = getObject( sURL );
}
@@ -704,7 +701,8 @@ Any ODatabaseContext::getByName(const rtl::OUString& _rName) throw( NoSuchElemen
}
catch (Exception& e)
{ // exceptions other than the speciafied ones -> wrap
- throw WrappedTargetException(_rName, *this, makeAny( e ) );
+ Any aError = ::cppu::getCaughtException();
+ throw WrappedTargetException(_rName, *this, aError );
}
}
@@ -714,19 +712,7 @@ Sequence< rtl::OUString > ODatabaseContext::getElementNames(void) throw( Runtime
MutexGuard aGuard(m_aMutex);
::connectivity::checkDisposed(DatabaseAccessContext_Base::rBHelper.bDisposed);
- DECLARE_STL_USTRINGACCESS_MAP( bool , TNameMap);
- TNameMap aRet;
-
- OConfigurationTreeRoot aDbRegisteredNamesRoot = OConfigurationTreeRoot::createWithServiceFactory(
- m_aContext.getLegacyServiceFactory(), getDbRegisteredNamesNodeName(), -1, OConfigurationTreeRoot::CM_READONLY);
-
- Sequence< ::rtl::OUString> aSeq;
- if ( aDbRegisteredNamesRoot.isValid() )
- {
- aSeq = aDbRegisteredNamesRoot.getNodeNames();
- } // if ( aDbRegisteredNamesRoot.isValid() )
-
- return aSeq;
+ return getRegistrationNames();
}
//------------------------------------------------------------------------------
@@ -735,11 +721,9 @@ sal_Bool ODatabaseContext::hasByName(const rtl::OUString& _rName) throw( Runtime
MutexGuard aGuard(m_aMutex);
::connectivity::checkDisposed(DatabaseAccessContext_Base::rBHelper.bDisposed);
- OConfigurationTreeRoot aDbRegisteredNamesRoot = OConfigurationTreeRoot::createWithServiceFactory(
- m_aContext.getLegacyServiceFactory(), getDbRegisteredNamesNodeName(), -1, OConfigurationTreeRoot::CM_READONLY);
-
- return aDbRegisteredNamesRoot.isValid() && aDbRegisteredNamesRoot.hasByName(_rName);
+ return hasRegisteredDatabase( _rName );
}
+
// -----------------------------------------------------------------------------
Reference< XInterface > ODatabaseContext::getObject(const ::rtl::OUString& _rName)
{
diff --git a/dbaccess/source/core/dataaccess/databasecontext.hxx b/dbaccess/source/core/dataaccess/databasecontext.hxx
index f09d54daf3f3..2eaf663e9796 100644
--- a/dbaccess/source/core/dataaccess/databasecontext.hxx
+++ b/dbaccess/source/core/dataaccess/databasecontext.hxx
@@ -31,57 +31,29 @@
#ifndef _DBA_COREDATAACCESS_DATABASECONTEXT_HXX_
#define _DBA_COREDATAACCESS_DATABASECONTEXT_HXX_
-#ifndef _COM_SUN_STAR_CONTAINER_XENUMERATIONACCESS_HPP_
+#include "ModelImpl.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/container/ElementExistException.hpp>
+#include <com/sun/star/container/XContainer.hpp>
#include <com/sun/star/container/XEnumerationAccess.hpp>
-#endif
-#ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
+#include <com/sun/star/container/XHierarchicalNameAccess.hpp>
#include <com/sun/star/container/XNameAccess.hpp>
-#endif
-#ifndef _COM_SUN_STAR_UNO_XNAMINGSERVICE_HPP_
-#include <com/sun/star/uno/XNamingService.hpp>
-#endif
-#ifndef _COM_SUN_STAR_LANG_XUNOTUNNEL_HPP_
-#include <com/sun/star/lang/XUnoTunnel.hpp>
-#endif
-#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
+#include <com/sun/star/lang/XEventListener.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
-#endif
-#ifndef _COM_SUN_STAR_SDB_XDATABASEENVIRONMENT_HPP_
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#include <com/sun/star/lang/XUnoTunnel.hpp>
#include <com/sun/star/sdb/XDatabaseEnvironment.hpp>
-#endif
-#ifndef _COM_SUN_STAR_CONTAINER_XHIERARCHICALNAMEACCESS_HPP_
-#include <com/sun/star/container/XHierarchicalNameAccess.hpp>
-#endif
-#ifndef _COM_SUN_STAR_CONTAINER_XCONTAINER_HPP_
-#include <com/sun/star/container/XContainer.hpp>
-#endif
-#ifndef _CPPUHELPER_COMPBASE7_HXX_
-#include <cppuhelper/compbase7.hxx>
-#endif
-#ifndef _COMPHELPER_STLTYPES_HXX_
-#include <comphelper/stl_types.hxx>
-#endif
-#ifndef COMPHELPER_COMPONENTCONTEXT_HXX
+#include <com/sun/star/sdb/XDatabaseRegistrations.hpp>
+#include <com/sun/star/uno/XNamingService.hpp>
+#include <com/sun/star/uno/XAggregation.hpp>
+/** === end UNO includes === **/
+
+#include <basic/basicmanagerrepository.hxx>
#include <comphelper/componentcontext.hxx>
-#endif
-#ifndef _CPPUHELPER_INTERFACECONTAINER_HXX_
+#include <comphelper/stl_types.hxx>
+#include <cppuhelper/compbase8.hxx>
#include <cppuhelper/interfacecontainer.hxx>
-#endif
-#ifndef _COM_SUN_STAR_CONTAINER_ELEMENTEXISTEXCEPTION_HPP_
-#include <com/sun/star/container/ElementExistException.hpp>
-#endif
-#ifndef _COM_SUN_STAR_LANG_XEVENTLISTENER_HPP_
-#include <com/sun/star/lang/XEventListener.hpp>
-#endif
-#ifndef _COM_SUN_STAR_LANG_XSINGLESERVICEFACTORY_HPP_
-#include <com/sun/star/lang/XSingleServiceFactory.hpp>
-#endif
-#ifndef _DBA_COREDATAACCESS_MODELIMPL_HXX_
-#include "ModelImpl.hxx"
-#endif
-#ifndef BASICMANAGERREPOSITORY_HXX
-#include <basic/basicmanagerrepository.hxx>
-#endif
#include <boost/shared_ptr.hpp>
@@ -105,13 +77,14 @@ class DatabaseDocumentLoader;
::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
ODatabaseContext_CreateInstance(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >&);
-typedef ::cppu::WeakComponentImplHelper7 < ::com::sun::star::lang::XServiceInfo
+typedef ::cppu::WeakComponentImplHelper8 < ::com::sun::star::lang::XServiceInfo
, ::com::sun::star::container::XEnumerationAccess
, ::com::sun::star::container::XNameAccess
, ::com::sun::star::uno::XNamingService
, ::com::sun::star::container::XContainer
, ::com::sun::star::lang::XSingleServiceFactory
, ::com::sun::star::lang::XUnoTunnel
+ , ::com::sun::star::sdb::XDatabaseRegistrations
> DatabaseAccessContext_Base;
class ODatabaseContext :public DatabaseAccessContext_Base
@@ -126,12 +99,6 @@ private:
::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > loadObjectFromURL(const ::rtl::OUString& _rName,const ::rtl::OUString& _sURL);
::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > getObject(const ::rtl::OUString& _rName);
- /** retrieves the URL for a given registration name, if any
- @returns <FALSE/> if and only if there exists a registration for the given name
- @throws IllegalArgumentException if the name is empty
- */
- bool getURLForRegisteredObject( const ::rtl::OUString& _rRegisteredName, ::rtl::OUString& _rURL );
-
/** sets all properties which were transient at the data source. e.g. password
@param _sURL The file URL of the data source
@param _xObject The data source itself.
@@ -147,6 +114,11 @@ protected:
::osl::Mutex m_aMutex;
::comphelper::ComponentContext m_aContext;
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XAggregation >
+ m_xDBRegistrationAggregate;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XDatabaseRegistrations >
+ m_xDatabaseRegistrations;
+
DECLARE_STL_USTRINGACCESS_MAP( ODatabaseModelImpl*, ObjectCache );
ObjectCache m_aDatabaseObjects;
@@ -166,42 +138,53 @@ public:
virtual ~ODatabaseContext();
-// OComponentHelper
+ // OComponentHelper
virtual void SAL_CALL disposing(void);
-// ::com::sun::star::lang::XSingleServiceFactory
+ // XSingleServiceFactory
virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL createInstance( ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL createInstanceWithArguments( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& _rArguments ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
-// ::com::sun::star::lang::XServiceInfo
+ // XServiceInfo
virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException);
virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException);
-// ::com::sun::star::lang::XServiceInfo - static methods
+ // XServiceInfo - static methods
static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_static(void) throw( ::com::sun::star::uno::RuntimeException );
static ::rtl::OUString getImplementationName_static(void) throw( ::com::sun::star::uno::RuntimeException );
static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
SAL_CALL Create(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >&);
-// ::com::sun::star::container::XElementAccess
+ // XElementAccess
virtual ::com::sun::star::uno::Type SAL_CALL getElementType( ) throw(::com::sun::star::uno::RuntimeException);
virtual sal_Bool SAL_CALL hasElements( ) throw(::com::sun::star::uno::RuntimeException);
-// ::com::sun::star::container::XEnumerationAccess
+ // XEnumerationAccess
virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL createEnumeration( ) throw(::com::sun::star::uno::RuntimeException);
-// ::com::sun::star::container::XNameAccess
+ // XNameAccess
virtual ::com::sun::star::uno::Any SAL_CALL getByName( const ::rtl::OUString& aName ) throw(::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames( ) throw(::com::sun::star::uno::RuntimeException);
virtual sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName ) throw(::com::sun::star::uno::RuntimeException);
-// ::com::sun::star::uno::XNamingService
+ // XNamingService
virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getRegisteredObject( const ::rtl::OUString& Name ) throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL registerObject( const ::rtl::OUString& Name, const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& Object ) throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL revokeObject( const ::rtl::OUString& Name ) throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
-// ::com::sun::star::container::XContainer
+ // XDatabaseRegistrations
+ virtual ::sal_Bool SAL_CALL hasRegisteredDatabase( const ::rtl::OUString& Name ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getRegistrationNames() throw (::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getDatabaseLocation( const ::rtl::OUString& Name ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL registerDatabaseLocation( const ::rtl::OUString& Name, const ::rtl::OUString& Location ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::container::ElementExistException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL revokeDatabaseLocation( const ::rtl::OUString& Name ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::IllegalAccessException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL changeDatabaseLocation( const ::rtl::OUString& Name, const ::rtl::OUString& NewLocation ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::IllegalAccessException, ::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL isDatabaseRegistrationReadOnly( const ::rtl::OUString& Name ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addDatabaseRegistrationsListener( const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XDatabaseRegistrationsListener >& Listener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeDatabaseRegistrationsListener( const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XDatabaseRegistrationsListener >& Listener ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XContainer
virtual void SAL_CALL addContainerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener >& xListener ) throw(::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL removeContainerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener >& xListener ) throw(::com::sun::star::uno::RuntimeException);
diff --git a/dbaccess/source/core/dataaccess/databaseregistrations.cxx b/dbaccess/source/core/dataaccess/databaseregistrations.cxx
new file mode 100644
index 000000000000..5b4f42586a4b
--- /dev/null
+++ b/dbaccess/source/core/dataaccess/databaseregistrations.cxx
@@ -0,0 +1,402 @@
+/*************************************************************************
+* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+*
+* Copyright 2009 by Sun Microsystems, Inc.
+*
+* OpenOffice.org - a multi-platform office productivity suite
+*
+* 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_dbaccess.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/sdb/XDatabaseRegistrations.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/componentcontext.hxx>
+#include <cppuhelper/basemutex.hxx>
+#include <cppuhelper/interfacecontainer.hxx>
+#include <cppuhelper/implbase1.hxx>
+#include <rtl/ustrbuf.hxx>
+#include <svtools/pathoptions.hxx>
+#include <tools/urlobj.hxx>
+#include <unotools/confignode.hxx>
+
+//........................................................................
+namespace dbaccess
+{
+//........................................................................
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::uno::XInterface;
+ using ::com::sun::star::uno::UNO_QUERY;
+ using ::com::sun::star::uno::UNO_QUERY_THROW;
+ using ::com::sun::star::uno::UNO_SET_THROW;
+ using ::com::sun::star::uno::Exception;
+ using ::com::sun::star::uno::RuntimeException;
+ using ::com::sun::star::uno::Any;
+ using ::com::sun::star::uno::makeAny;
+ using ::com::sun::star::uno::Sequence;
+ using ::com::sun::star::uno::Type;
+ using ::com::sun::star::container::NoSuchElementException;
+ using ::com::sun::star::lang::IllegalArgumentException;
+ using ::com::sun::star::lang::IllegalAccessException;
+ using ::com::sun::star::container::ElementExistException;
+ using ::com::sun::star::sdb::XDatabaseRegistrations;
+ using ::com::sun::star::sdb::XDatabaseRegistrationsListener;
+ using ::com::sun::star::sdb::DatabaseRegistrationEvent;
+ using ::com::sun::star::uno::XAggregation;
+ /** === end UNO using === **/
+
+ //--------------------------------------------------------------------
+ static const ::rtl::OUString& getConfigurationRootPath()
+ {
+ static ::rtl::OUString s_sNodeName = ::rtl::OUString::createFromAscii("org.openoffice.Office.DataAccess/RegisteredNames");
+ return s_sNodeName;
+ }
+
+ //--------------------------------------------------------------------
+ const ::rtl::OUString& getLocationNodeName()
+ {
+ static ::rtl::OUString s_sNodeName = ::rtl::OUString::createFromAscii( "Location" );
+ return s_sNodeName;
+ }
+
+ //--------------------------------------------------------------------
+ const ::rtl::OUString& getNameNodeName()
+ {
+ static ::rtl::OUString s_sNodeName = ::rtl::OUString::createFromAscii( "Name" );
+ return s_sNodeName;
+ }
+
+ //====================================================================
+ //= DatabaseRegistrations - declaration
+ //====================================================================
+ typedef ::cppu::WeakAggImplHelper1 < XDatabaseRegistrations
+ > DatabaseRegistrations_Base;
+ class DatabaseRegistrations :public ::cppu::BaseMutex
+ ,public DatabaseRegistrations_Base
+ {
+ public:
+ DatabaseRegistrations( const ::comphelper::ComponentContext& _rxContext );
+
+ protected:
+ ~DatabaseRegistrations();
+
+ public:
+ virtual ::sal_Bool SAL_CALL hasRegisteredDatabase( const ::rtl::OUString& _Name ) throw (IllegalArgumentException, RuntimeException);
+ virtual Sequence< ::rtl::OUString > SAL_CALL getRegistrationNames() throw (RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getDatabaseLocation( const ::rtl::OUString& _Name ) throw (IllegalArgumentException, NoSuchElementException, RuntimeException);
+ virtual void SAL_CALL registerDatabaseLocation( const ::rtl::OUString& _Name, const ::rtl::OUString& _Location ) throw (IllegalArgumentException, ElementExistException, RuntimeException);
+ virtual void SAL_CALL revokeDatabaseLocation( const ::rtl::OUString& _Name ) throw (IllegalArgumentException, NoSuchElementException, IllegalAccessException, RuntimeException);
+ virtual void SAL_CALL changeDatabaseLocation( const ::rtl::OUString& Name, const ::rtl::OUString& NewLocation ) throw (IllegalArgumentException, NoSuchElementException, IllegalAccessException, RuntimeException);
+ virtual ::sal_Bool SAL_CALL isDatabaseRegistrationReadOnly( const ::rtl::OUString& _Name ) throw (IllegalArgumentException, NoSuchElementException, RuntimeException);
+ virtual void SAL_CALL addDatabaseRegistrationsListener( const Reference< XDatabaseRegistrationsListener >& Listener ) throw (RuntimeException);
+ virtual void SAL_CALL removeDatabaseRegistrationsListener( const Reference< XDatabaseRegistrationsListener >& Listener ) throw (RuntimeException);
+
+ private:
+ ::utl::OConfigurationNode
+ impl_checkValidName_throw( const ::rtl::OUString& _rName, const bool _bMustExist );
+
+ void impl_checkValidLocation_throw( const ::rtl::OUString& _rLocation );
+
+ /** retrieves the configuration node whose "Name" sub node has the given value
+
+ Since we separated the name of the registration node from the "Name" value of the registration, we cannot
+ simply do a "getByName" (equivalent) when we want to retrieve the node for a given registration name.
+ Instead, we must search all nodes.
+
+ If _bMustExist is <TRUE/>, and a node with the given display name does not exist, then a NoSuchElementException
+ is thrown.
+
+ If _bMustExist is <FALSE/>, and a node with the given name already exists, then a ElementExistException is
+ thrown.
+
+ In either case, if no exception is thrown, then a valid node is returned: If the node existed and was allowed
+ to exist, it is returned, if the node did not yet exist, and was required to not exist, a new node is created.
+ However, in this case the root node is not yet committed.
+ */
+ ::utl::OConfigurationNode
+ impl_getNodeForName_throw( const ::rtl::OUString& _rName, const bool _bMustExist );
+
+ ::utl::OConfigurationNode
+ impl_getNodeForName_nothrow( const ::rtl::OUString& _rName );
+
+ private:
+ ::comphelper::ComponentContext m_aContext;
+ ::utl::OConfigurationTreeRoot m_aConfigurationRoot;
+ ::cppu::OInterfaceContainerHelper m_aRegistrationListeners;
+ };
+
+ //====================================================================
+ //= DatabaseRegistrations - implementation
+ //====================================================================
+ //--------------------------------------------------------------------
+ DatabaseRegistrations::DatabaseRegistrations( const ::comphelper::ComponentContext& _rxContext )
+ :m_aContext( _rxContext )
+ ,m_aConfigurationRoot()
+ ,m_aRegistrationListeners( m_aMutex )
+ {
+ m_aConfigurationRoot = ::utl::OConfigurationTreeRoot::createWithServiceFactory(
+ m_aContext.getLegacyServiceFactory(), getConfigurationRootPath(), -1, ::utl::OConfigurationTreeRoot::CM_UPDATABLE );
+ }
+
+ //--------------------------------------------------------------------
+ DatabaseRegistrations::~DatabaseRegistrations()
+ {
+ }
+
+ //--------------------------------------------------------------------
+ ::utl::OConfigurationNode DatabaseRegistrations::impl_getNodeForName_nothrow( const ::rtl::OUString& _rName )
+ {
+ Sequence< ::rtl::OUString > aNames( m_aConfigurationRoot.getNodeNames() );
+ for ( const ::rtl::OUString* pName = aNames.getConstArray();
+ pName != aNames.getConstArray() + aNames.getLength();
+ ++pName
+ )
+ {
+ ::utl::OConfigurationNode aNodeForName = m_aConfigurationRoot.openNode( *pName );
+
+ ::rtl::OUString sTestName;
+ OSL_VERIFY( aNodeForName.getNodeValue( getNameNodeName() ) >>= sTestName );
+ if ( sTestName == _rName )
+ return aNodeForName;
+ }
+ return ::utl::OConfigurationNode();
+ }
+
+ //--------------------------------------------------------------------
+ ::utl::OConfigurationNode DatabaseRegistrations::impl_getNodeForName_throw( const ::rtl::OUString& _rName, const bool _bMustExist )
+ {
+ ::utl::OConfigurationNode aNodeForName( impl_getNodeForName_nothrow( _rName ) );
+
+ if ( aNodeForName.isValid() )
+ {
+ if ( !_bMustExist )
+ throw ElementExistException( _rName, *this );
+
+ return aNodeForName;
+ }
+
+ if ( _bMustExist )
+ throw NoSuchElementException( _rName, *this );
+
+ ::rtl::OUString sNewNodeName;
+ {
+ ::rtl::OUStringBuffer aNewNodeName;
+ aNewNodeName.appendAscii( "org.openoffice." );
+ aNewNodeName.append( _rName );
+
+ // make unique
+ ::rtl::OUStringBuffer aReset( aNewNodeName );
+ sNewNodeName = aNewNodeName.makeStringAndClear();
+ sal_Int32 i=2;
+ while ( m_aConfigurationRoot.hasByName( sNewNodeName ) )
+ {
+ aNewNodeName = aReset;
+ aNewNodeName.appendAscii( " " );
+ aNewNodeName.append( i );
+ sNewNodeName = aNewNodeName.makeStringAndClear();
+ }
+ }
+
+ ::utl::OConfigurationNode aNewNode( m_aConfigurationRoot.createNode( sNewNodeName ) );
+ aNewNode.setNodeValue( getNameNodeName(), makeAny( _rName ) );
+ return aNewNode;
+ }
+
+ //--------------------------------------------------------------------
+ ::utl::OConfigurationNode DatabaseRegistrations::impl_checkValidName_throw( const ::rtl::OUString& _rName, const bool _bMustExist )
+ {
+ if ( !m_aConfigurationRoot.isValid() )
+ throw RuntimeException( ::rtl::OUString(), *this );
+
+ if ( !_rName.getLength() )
+ throw IllegalArgumentException( ::rtl::OUString(), *this, 1 );
+
+ return impl_getNodeForName_throw( _rName, _bMustExist );
+ }
+
+ //--------------------------------------------------------------------
+ void DatabaseRegistrations::impl_checkValidLocation_throw( const ::rtl::OUString& _rLocation )
+ {
+ if ( !_rLocation.getLength() )
+ throw IllegalArgumentException( ::rtl::OUString(), *this, 2 );
+
+ INetURLObject aURL( _rLocation );
+ if ( aURL.GetProtocol() == INET_PROT_NOT_VALID )
+ throw IllegalArgumentException( ::rtl::OUString(), *this, 2 );
+ }
+
+ //--------------------------------------------------------------------
+ ::sal_Bool SAL_CALL DatabaseRegistrations::hasRegisteredDatabase( const ::rtl::OUString& _Name ) throw (IllegalArgumentException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ ::utl::OConfigurationNode aNodeForName = impl_getNodeForName_nothrow( _Name );
+ return aNodeForName.isValid();
+ }
+
+ //------------------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL DatabaseRegistrations::getRegistrationNames() throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if ( !m_aConfigurationRoot.isValid() )
+ throw RuntimeException( ::rtl::OUString(), *this );
+
+ Sequence< ::rtl::OUString > aProgrammaticNames( m_aConfigurationRoot.getNodeNames() );
+ Sequence< ::rtl::OUString > aDisplayNames( aProgrammaticNames.getLength() );
+ ::rtl::OUString* pDisplayName = aDisplayNames.getArray();
+
+ for ( const ::rtl::OUString* pName = aProgrammaticNames.getConstArray();
+ pName != aProgrammaticNames.getConstArray() + aProgrammaticNames.getLength();
+ ++pName, ++pDisplayName
+ )
+ {
+ ::rtl::OUStringBuffer aNodePath;
+ aNodePath.append( *pName );
+ aNodePath.append( sal_Unicode( '/' ) );
+ aNodePath.append( getNameNodeName() );
+
+ OSL_VERIFY( m_aConfigurationRoot.getNodeValue( aNodePath.makeStringAndClear() ) >>= *pDisplayName );
+
+ }
+
+ return aDisplayNames;
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL DatabaseRegistrations::getDatabaseLocation( const ::rtl::OUString& _Name ) throw (IllegalArgumentException, NoSuchElementException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ ::utl::OConfigurationNode aNodeForName = impl_checkValidName_throw( _Name, true );
+
+ ::rtl::OUString sLocation;
+ OSL_VERIFY( aNodeForName.getNodeValue( getLocationNodeName() ) >>= sLocation );
+ sLocation = SvtPathOptions().SubstituteVariable( sLocation );
+
+ return sLocation;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL DatabaseRegistrations::registerDatabaseLocation( const ::rtl::OUString& _Name, const ::rtl::OUString& _Location ) throw (IllegalArgumentException, ElementExistException, RuntimeException)
+ {
+ ::osl::ClearableMutexGuard aGuard( m_aMutex );
+
+ // check
+ impl_checkValidLocation_throw( _Location );
+ ::utl::OConfigurationNode aDataSourceRegistration = impl_checkValidName_throw( _Name, false );
+
+ // register
+ aDataSourceRegistration.setNodeValue( getLocationNodeName(), makeAny( _Location ) );
+ m_aConfigurationRoot.commit();
+
+ // notify
+ DatabaseRegistrationEvent aEvent( *this, _Name, ::rtl::OUString(), _Location );
+ aGuard.clear();
+ m_aRegistrationListeners.notifyEach( &XDatabaseRegistrationsListener::registeredDatabaseLocation, aEvent );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL DatabaseRegistrations::revokeDatabaseLocation( const ::rtl::OUString& _Name ) throw (IllegalArgumentException, NoSuchElementException, IllegalAccessException, RuntimeException)
+ {
+ ::osl::ClearableMutexGuard aGuard( m_aMutex );
+
+ // check
+ ::utl::OConfigurationNode aNodeForName = impl_checkValidName_throw( _Name, true );
+
+ // obtain properties for notification
+ ::rtl::OUString sLocation;
+ OSL_VERIFY( aNodeForName.getNodeValue( getLocationNodeName() ) >>= sLocation );
+
+ // revoke
+ if ( aNodeForName.isReadonly()
+ || !m_aConfigurationRoot.removeNode( aNodeForName.getLocalName() )
+ )
+ throw IllegalAccessException( ::rtl::OUString(), *this );
+
+ m_aConfigurationRoot.commit();
+
+ // notify
+ DatabaseRegistrationEvent aEvent( *this, _Name, sLocation, ::rtl::OUString() );
+ aGuard.clear();
+ m_aRegistrationListeners.notifyEach( &XDatabaseRegistrationsListener::revokedDatabaseLocation, aEvent );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL DatabaseRegistrations::changeDatabaseLocation( const ::rtl::OUString& _Name, const ::rtl::OUString& _NewLocation ) throw (IllegalArgumentException, NoSuchElementException, IllegalAccessException, RuntimeException)
+ {
+ ::osl::ClearableMutexGuard aGuard( m_aMutex );
+
+ // check
+ impl_checkValidLocation_throw( _NewLocation );
+ ::utl::OConfigurationNode aDataSourceRegistration = impl_checkValidName_throw( _Name, true );
+
+ if ( aDataSourceRegistration.isReadonly() )
+ throw IllegalAccessException( ::rtl::OUString(), *this );
+
+ // obtain properties for notification
+ ::rtl::OUString sOldLocation;
+ OSL_VERIFY( aDataSourceRegistration.getNodeValue( getLocationNodeName() ) >>= sOldLocation );
+
+ // change
+ aDataSourceRegistration.setNodeValue( getLocationNodeName(), makeAny( _NewLocation ) );
+ m_aConfigurationRoot.commit();
+
+ // notify
+ DatabaseRegistrationEvent aEvent( *this, _Name, sOldLocation, _NewLocation );
+ aGuard.clear();
+ m_aRegistrationListeners.notifyEach( &XDatabaseRegistrationsListener::changedDatabaseLocation, aEvent );
+ }
+
+ //--------------------------------------------------------------------
+ ::sal_Bool SAL_CALL DatabaseRegistrations::isDatabaseRegistrationReadOnly( const ::rtl::OUString& _Name ) throw (IllegalArgumentException, NoSuchElementException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ ::utl::OConfigurationNode aDataSourceRegistration = impl_checkValidName_throw( _Name, true );
+ return aDataSourceRegistration.isReadonly();
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL DatabaseRegistrations::addDatabaseRegistrationsListener( const Reference< XDatabaseRegistrationsListener >& _Listener ) throw (RuntimeException)
+ {
+ if ( _Listener.is() )
+ m_aRegistrationListeners.addInterface( _Listener );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL DatabaseRegistrations::removeDatabaseRegistrationsListener( const Reference< XDatabaseRegistrationsListener >& _Listener ) throw (RuntimeException)
+ {
+ if ( _Listener.is() )
+ m_aRegistrationListeners.removeInterface( _Listener );
+ }
+
+ //====================================================================
+ //= DatabaseRegistrations - factory
+ //====================================================================
+ Reference< XAggregation > createDataSourceRegistrations( const ::comphelper::ComponentContext& _rxContext )
+ {
+ return new DatabaseRegistrations( _rxContext );
+ }
+
+//........................................................................
+} // namespace dbaccess
+//........................................................................
diff --git a/dbaccess/source/core/dataaccess/databaseregistrations.hxx b/dbaccess/source/core/dataaccess/databaseregistrations.hxx
new file mode 100644
index 000000000000..068f6ea975c9
--- /dev/null
+++ b/dbaccess/source/core/dataaccess/databaseregistrations.hxx
@@ -0,0 +1,50 @@
+/*************************************************************************
+* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+*
+* Copyright 2009 by Sun Microsystems, Inc.
+*
+* OpenOffice.org - a multi-platform office productivity suite
+*
+* 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 OOO_DATASOURCEREGISTRATIONS_HXX
+#define OOO_DATASOURCEREGISTRATIONS_HXX
+
+/** === begin UNO includes === **/
+#include <com/sun/star/uno/XAggregation.hpp>
+/** === end UNO includes === **/
+
+namespace comphelper
+{
+ class ComponentContext;
+}
+
+//........................................................................
+namespace dbaccess
+{
+//........................................................................
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XAggregation >
+ createDataSourceRegistrations( const ::comphelper::ComponentContext& _rxContext );
+
+//........................................................................
+} // namespace dbaccess
+//........................................................................
+
+#endif // OOO_DATASOURCEREGISTRATIONS_HXX
diff --git a/dbaccess/source/core/dataaccess/datasource.cxx b/dbaccess/source/core/dataaccess/datasource.cxx
index 9d50a0d06623..3f33bc226aa2 100644
--- a/dbaccess/source/core/dataaccess/datasource.cxx
+++ b/dbaccess/source/core/dataaccess/datasource.cxx
@@ -799,8 +799,6 @@ Reference< XConnection > ODatabaseSource::buildLowLevelConnection(const ::rtl::O
m_pImpl->getDefaultDataSourceSettings()
);
- impl_insertJavaDriverClassPath_nothrow(aDriverInfo);
-
if ( m_pImpl->isEmbeddedDatabase() )
{
sal_Int32 nCount = aDriverInfo.getLength();
@@ -1502,29 +1500,6 @@ Reference< XInterface > ODatabaseSource::getThis() const
return *const_cast< ODatabaseSource* >( this );
}
// -----------------------------------------------------------------------------
-void ODatabaseSource::impl_insertJavaDriverClassPath_nothrow(Sequence< PropertyValue >& _rDriverInfo)
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "ODatabaseSource::impl_insertJavaDriverClassPath_nothrow" );
- Reference< XPropertySet > xPropertySet( m_pImpl->m_xSettings, UNO_QUERY_THROW );
- ::rtl::OUString sJavaDriverClass;
- xPropertySet->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JavaDriverClass"))) >>= sJavaDriverClass;
- if ( sJavaDriverClass.getLength() )
- {
- static const ::rtl::OUString s_sNodeName(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.Office.DataAccess/JDBC/DriverClassPaths"));
- ::utl::OConfigurationTreeRoot aNamesRoot = ::utl::OConfigurationTreeRoot::createWithServiceFactory(
- m_pImpl->m_aContext.getLegacyServiceFactory(), s_sNodeName, -1, ::utl::OConfigurationTreeRoot::CM_READONLY);
- if ( aNamesRoot.isValid() && aNamesRoot.hasByName( sJavaDriverClass ) )
- {
- ::utl::OConfigurationNode aRegisterObj = aNamesRoot.openNode( sJavaDriverClass );
- ::rtl::OUString sURL;
- OSL_VERIFY( aRegisterObj.getNodeValue( "Path" ) >>= sURL );
-
- ::comphelper::NamedValueCollection aDriverSettings( _rDriverInfo );
- aDriverSettings.put( "JavaDriverClassPath", sURL );
- aDriverSettings >>= _rDriverInfo;
- }
- }
-}
//........................................................................
} // namespace dbaccess
//........................................................................
diff --git a/dbaccess/source/core/dataaccess/datasource.hxx b/dbaccess/source/core/dataaccess/datasource.hxx
index 863dc252328a..4fa86beccfef 100644
--- a/dbaccess/source/core/dataaccess/datasource.hxx
+++ b/dbaccess/source/core/dataaccess/datasource.hxx
@@ -299,8 +299,6 @@ private:
void clearConnections();
- void impl_insertJavaDriverClassPath_nothrow(::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& _rDriverInfo);
-
protected:
using ::cppu::OPropertySetHelper::getFastPropertyValue;
};
diff --git a/dbaccess/source/core/dataaccess/documentcontainer.cxx b/dbaccess/source/core/dataaccess/documentcontainer.cxx
index c5b176478ecd..96cae44e6a3e 100644
--- a/dbaccess/source/core/dataaccess/documentcontainer.cxx
+++ b/dbaccess/source/core/dataaccess/documentcontainer.cxx
@@ -88,6 +88,7 @@
#include <vcl/svapp.hxx>
#include <vos/mutex.hxx>
+#include <comphelper/namedvaluecollection.hxx>
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::lang;
@@ -212,60 +213,32 @@ Reference< XInterface > SAL_CALL ODocumentContainer::createInstanceWithArguments
if ( ServiceSpecifier == SERVICE_SDB_DOCUMENTDEFINITION )
{
MutexGuard aGuard(m_aMutex);
- ::rtl::OUString sName,sPersistentName,sURL;
+
+ ::rtl::OUString sName, sPersistentName, sURL, sMediaType;
Reference< XCommandProcessor > xCopyFrom;
- Reference<XConnection> xConnection;
- Sequence<sal_Int8> aClassID;
+ Reference< XConnection > xConnection;
+ Sequence< sal_Int8 > aClassID;
sal_Bool bAsTemplate = sal_False;
- const Any* pBegin = _aArguments.getConstArray();
- const Any* pEnd = pBegin + _aArguments.getLength();
- PropertyValue aValue;
- for(;pBegin != pEnd;++pBegin)
- {
- *pBegin >>= aValue;
- if ( aValue.Name.equalsAscii(PROPERTY_NAME) )
- {
- aValue.Value >>= sName;
- }
- else if ( aValue.Name.equalsAscii(PROPERTY_PERSISTENT_NAME) )
- {
- aValue.Value >>= sPersistentName;
- }
- else if ( aValue.Name.equalsAscii(PROPERTY_EMBEDDEDOBJECT) )
- {
- xCopyFrom.set(aValue.Value,UNO_QUERY);
- }
- else if ( aValue.Name.equalsAscii(PROPERTY_URL) )
- {
- aValue.Value >>= sURL;
- }
- else if ( aValue.Name.equalsAscii(PROPERTY_ACTIVE_CONNECTION) )
- {
- xConnection.set(aValue.Value,UNO_QUERY);
- }
- else if ( aValue.Name.equalsAscii("ClassID") )
- {
- if (! ( aValue.Value >>= aClassID ) )
- {
- // Extended for usage also with a string
- ::rtl::OUString suValue;
- aValue.Value >>= suValue;
- aClassID = ::comphelper::MimeConfigurationHelper::GetSequenceClassIDRepresentation( suValue );
+ ::comphelper::NamedValueCollection aArgs( _aArguments );
+ sName = aArgs.getOrDefault( (::rtl::OUString)PROPERTY_NAME, sName );
+ sPersistentName = aArgs.getOrDefault( (::rtl::OUString)PROPERTY_PERSISTENT_NAME, sPersistentName );
+ xCopyFrom = aArgs.getOrDefault( (::rtl::OUString)PROPERTY_EMBEDDEDOBJECT, xCopyFrom );
+ sURL = aArgs.getOrDefault( (::rtl::OUString)PROPERTY_URL, sURL );
+ xConnection = aArgs.getOrDefault( (::rtl::OUString)PROPERTY_ACTIVE_CONNECTION, xConnection );
+ bAsTemplate = aArgs.getOrDefault( (::rtl::OUString)PROPERTY_AS_TEMPLATE, bAsTemplate );
+ sMediaType = aArgs.getOrDefault( (::rtl::OUString)INFO_MEDIATYPE, sMediaType );
- }
- rtl::OUString suClassID = ::comphelper::MimeConfigurationHelper::GetStringClassIDRepresentation(aClassID);
- volatile int dummy = 0;
- (void)dummy;
- (void)suClassID;
- }
- else if ( aValue.Name.equalsAscii(PROPERTY_AS_TEMPLATE) )
- {
- aValue.Value >>= bAsTemplate;
- }
- else
+ if ( aArgs.has( "ClassID" ) )
+ {
+ Any aClassIDValue = aArgs.get( "ClassID" );
+ // class IDs might be passed as byte sequence ...
+ if ( !( aClassIDValue >>= aClassID ) )
{
- // DBG_ASSERT("unknown property exception");
+ // ... or as string
+ ::rtl::OUString sClassID;
+ aClassIDValue >>= sClassID;
+ aClassID = ::comphelper::MimeConfigurationHelper::GetSequenceClassIDRepresentation( sClassID );
}
}
@@ -282,6 +255,7 @@ Reference< XInterface > SAL_CALL ODocumentContainer::createInstanceWithArguments
if ( xElements.is() )
sPersistentName = ::dbtools::createUniqueName(xElements,sPersistentName);
+ const bool bNeedClassID = ( aClassID.getLength() == 0 ) && ( 0 == sURL.getLength() );
if ( xCopyFrom.is() )
{
Sequence<Any> aIni(2);
@@ -295,10 +269,16 @@ Reference< XInterface > SAL_CALL ODocumentContainer::createInstanceWithArguments
Reference<XPropertySet> xProp(xCopyFrom,UNO_QUERY);
if ( xProp.is() && xProp->getPropertySetInfo().is() && xProp->getPropertySetInfo()->hasPropertyByName(PROPERTY_AS_TEMPLATE) )
xProp->getPropertyValue(PROPERTY_AS_TEMPLATE) >>= bAsTemplate;
- }
- if ( ( aClassID.getLength() == 0 ) && ( 0 == sURL.getLength() ) )
- ODocumentDefinition::GetDocumentServiceFromMediaType( getContainerStorage(), sPersistentName, m_aContext, aClassID );
+ // if we do not have an own class ID, see if we can determine one from the copy we just created
+ if ( bNeedClassID )
+ ODocumentDefinition::GetDocumentServiceFromMediaType( getContainerStorage(), sPersistentName, m_aContext, aClassID );
+ }
+ else
+ {
+ if ( bNeedClassID && sMediaType.getLength() )
+ ODocumentDefinition::GetDocumentServiceFromMediaType( sMediaType, m_aContext, aClassID );
+ }
}
ODefinitionContainer_Impl::const_iterator aFind = rDefinitions.find( sName );
diff --git a/dbaccess/source/core/dataaccess/documentdefinition.cxx b/dbaccess/source/core/dataaccess/documentdefinition.cxx
index 8a4cff9624ae..992fc156d386 100644
--- a/dbaccess/source/core/dataaccess/documentdefinition.cxx
+++ b/dbaccess/source/core/dataaccess/documentdefinition.cxx
@@ -422,7 +422,7 @@ namespace dbaccess
//==================================================================
typedef ::cppu::WeakImplHelper1 < css::lang::XEventListener
> LifetimeCoupler_Base;
- /** helper class which couples the lifetime of a component to the lifetim
+ /** helper class which couples the lifetime of a component to the lifetime
of another component
Instances of this class are constructed with two components. The first is
@@ -617,13 +617,12 @@ void SAL_CALL ODocumentDefinition::disposing()
::osl::MutexGuard aGuard(m_aMutex);
closeObject();
::comphelper::disposeComponent(m_xListener);
- if ( m_bRemoveListener && m_xDesktop.is() )
+ if ( m_bRemoveListener )
{
Reference<util::XCloseable> xCloseable(m_pImpl->m_pDataSource->getModel_noCreate(),UNO_QUERY);
if ( xCloseable.is() )
xCloseable->removeCloseListener(this);
}
- m_xDesktop = NULL;
}
// -----------------------------------------------------------------------------
IMPLEMENT_TYPEPROVIDER3(ODocumentDefinition,OContentHelper,OPropertyStateContainer,ODocumentDefinition_Base);
@@ -690,17 +689,15 @@ namespace
}
// -----------------------------------------------------------------------------
-void ODocumentDefinition::impl_removeFrameFromDesktop_throw( const Reference< XFrame >& _rxFrame )
+void ODocumentDefinition::impl_removeFrameFromDesktop_throw( const ::comphelper::ComponentContext& _rContxt, const Reference< XFrame >& _rxFrame )
{
- if ( !m_xDesktop.is() )
- m_xDesktop.set( m_aContext.createComponent( (::rtl::OUString)SERVICE_FRAME_DESKTOP ), UNO_QUERY_THROW );
-
- Reference< XFrames > xFrames( m_xDesktop->getFrames(), UNO_QUERY_THROW );
+ Reference< XFramesSupplier > xDesktop( _rContxt.createComponent( (::rtl::OUString)SERVICE_FRAME_DESKTOP ), UNO_QUERY_THROW );
+ Reference< XFrames > xFrames( xDesktop->getFrames(), UNO_QUERY_THROW );
xFrames->remove( _rxFrame );
}
// -----------------------------------------------------------------------------
-void ODocumentDefinition::impl_onActivateEmbeddedObject()
+void ODocumentDefinition::impl_onActivateEmbeddedObject_nothrow()
{
try
{
@@ -712,26 +709,23 @@ void ODocumentDefinition::impl_onActivateEmbeddedObject()
if ( !m_xListener.is() )
// it's the first time the embedded object has been activated
// create an OEmbedObjectHolder
- m_xListener = new OEmbedObjectHolder(m_xEmbeddedObject,this);
+ m_xListener = new OEmbedObjectHolder( m_xEmbeddedObject, this );
- Reference< XFrame > xFrame( xController->getFrame() );
- if ( xFrame.is() )
- {
- // raise the window to top (especially necessary if this is not the first activation)
- Reference< XTopWindow > xTopWindow( xFrame->getContainerWindow(), UNO_QUERY_THROW );
- xTopWindow->toFront();
+ // raise the window to top (especially necessary if this is not the first activation)
+ Reference< XFrame > xFrame( xController->getFrame(), UNO_SET_THROW );
+ Reference< XTopWindow > xTopWindow( xFrame->getContainerWindow(), UNO_QUERY_THROW );
+ xTopWindow->toFront();
- // remove the frame from the desktop's frame collection because we need full control of it.
- impl_removeFrameFromDesktop_throw( xFrame );
- }
+ // remove the frame from the desktop's frame collection because we need full control of it.
+ impl_removeFrameFromDesktop_throw( m_aContext, xFrame );
// ensure that we ourself are kept alive as long as the embedded object's frame is
// opened
LifetimeCoupler::couple( *this, Reference< XComponent >( xFrame, UNO_QUERY_THROW ) );
// init the edit view
- if ( m_bOpenInDesign )
- impl_initObjectEditView( xController );
+ if ( m_bForm && m_bOpenInDesign )
+ impl_initFormEditView( xController );
}
catch( const RuntimeException& )
{
@@ -833,12 +827,8 @@ namespace
}
// -----------------------------------------------------------------------------
-void ODocumentDefinition::impl_initObjectEditView( const Reference< XController >& _rxController )
+void ODocumentDefinition::impl_initFormEditView( const Reference< XController >& _rxController )
{
- if ( !m_bForm )
- // currently, only forms need to be initialized
- return;
-
try
{
Reference< XViewSettingsSupplier > xSettingsSupplier( _rxController, UNO_QUERY_THROW );
@@ -872,10 +862,10 @@ void ODocumentDefinition::impl_initObjectEditView( const Reference< XController
}
// -----------------------------------------------------------------------------
-void ODocumentDefinition::onCommandOpenSomething( const Any& _rOpenArgument, const bool _bActivate,
- const Reference< XCommandEnvironment >& _rxEnvironment, Any& _out_rComponent, ::osl::ClearableMutexGuard & _aGuard )
+Any ODocumentDefinition::onCommandOpenSomething( const Any& _rOpenArgument, const bool _bActivate,
+ const Reference< XCommandEnvironment >& _rxEnvironment )
{
- OExecuteImpl aExecuteGuard(m_bInExecute);
+ OExecuteImpl aExecuteGuard( m_bInExecute );
Reference< XConnection > xConnection;
sal_Int32 nOpenMode = OpenMode::DOCUMENT;
@@ -885,7 +875,9 @@ void ODocumentDefinition::onCommandOpenSomething( const Any& _rOpenArgument, con
// for the document, default to the interaction handler as used for loading the DB doc
// This might be overwritten below, when examining _rOpenArgument.
::comphelper::NamedValueCollection aDBDocArgs( m_pImpl->m_pDataSource->getResource() );
- aDocumentArgs.put( "InteractionHandler", aDBDocArgs.getOrDefault( "InteractionHandler", Reference< XInteractionHandler >() ) );
+ Reference< XInteractionHandler > xHandler( aDBDocArgs.getOrDefault( "InteractionHandler", Reference< XInteractionHandler >() ) );
+ if ( xHandler.is() )
+ aDocumentArgs.put( "InteractionHandler", xHandler );
::boost::optional< sal_Int16 > aDocumentMacroMode;
@@ -999,7 +991,7 @@ void ODocumentDefinition::onCommandOpenSomething( const Any& _rOpenArgument, con
OSL_ENSURE( m_pImpl->m_aProps.sPersistentName.getLength(),
"ODocumentDefinition::onCommandOpenSomething: no persistent name - cannot load!" );
if ( !m_pImpl->m_aProps.sPersistentName.getLength() )
- return;
+ return Any();
// embedded objects themself do not support the hidden flag. We implement support for
// it by changing the STATE to RUNNING only, instead of ACTIVE.
@@ -1009,7 +1001,7 @@ void ODocumentDefinition::onCommandOpenSomething( const Any& _rOpenArgument, con
loadEmbeddedObject( xConnection, Sequence< sal_Int8 >(), aDocumentArgs.getPropertyValues(), false, !m_bOpenInDesign );
OSL_ENSURE( m_xEmbeddedObject.is(), "ODocumentDefinition::onCommandOpenSomething: what's this?" );
if ( !m_xEmbeddedObject.is() )
- return;
+ return Any();
Reference< XModel > xModel( getComponent(), UNO_QUERY );
Reference< report::XReportDefinition > xReportDefinition(xModel,UNO_QUERY);
@@ -1035,158 +1027,169 @@ void ODocumentDefinition::onCommandOpenSomething( const Any& _rOpenArgument, con
xReportEngine->setReportDefinition(xReportDefinition);
xReportEngine->setActiveConnection(m_xLastKnownConnection);
if ( bOpenHidden )
- _out_rComponent <<= xReportEngine->createDocumentModel( );
- else
- _out_rComponent <<= xReportEngine->createDocumentAlive(NULL);
- return;
+ return makeAny( xReportEngine->createDocumentModel() );
+ return makeAny( xReportEngine->createDocumentAlive( NULL ) );
}
if ( _bActivate && !bOpenHidden )
{
m_xEmbeddedObject->changeState( EmbedStates::ACTIVE );
- impl_onActivateEmbeddedObject();
+ ODocumentDefinition::impl_onActivateEmbeddedObject_nothrow();
}
- // LLA: Alle fillReportData() calls prfen, sollte es welche geben, die danach noch viel machen
- // LLA: sollten wir einen _aGuard Pointer bergeben, sonst erstmal als Referenz
- fillReportData(_aGuard);
- _out_rComponent <<= xModel;
+ if ( !m_bForm && m_pImpl->m_aProps.bAsTemplate && !m_bOpenInDesign )
+ ODocumentDefinition::fillReportData( m_aContext, getComponent(), xConnection );
+
+ return makeAny( xModel );
}
// -----------------------------------------------------------------------------
Any SAL_CALL ODocumentDefinition::execute( const Command& aCommand, sal_Int32 CommandId, const Reference< XCommandEnvironment >& Environment ) throw (Exception, CommandAbortedException, RuntimeException)
{
Any aRet;
- ::osl::ClearableMutexGuard aGuard(m_aMutex);
- if ( !m_bInExecute )
- {
- sal_Bool bOpen = aCommand.Name.equalsAscii( "open" );
- sal_Bool bOpenInDesign = aCommand.Name.equalsAscii( "openDesign" );
- sal_Bool bOpenForMail = aCommand.Name.equalsAscii( "openForMail" );
- if ( bOpen || bOpenInDesign || bOpenForMail )
- {
- bool bActivateObject = true;
- if ( bOpenForMail )
- {
- OSL_ENSURE( false, "ODocumentDefinition::execute: 'openForMail' should not be used anymore - use the 'Hidden' parameter instead!" );
- bActivateObject = false;
- }
-
- // if the object is already opened, do nothing
- // #i89509# / 2008-05-22 / frank.schoenheit@sun.com
- if ( m_xEmbeddedObject.is() )
- {
- sal_Int32 nCurrentState = m_xEmbeddedObject->getCurrentState();
- bool bIsActive = ( nCurrentState == EmbedStates::ACTIVE );
-
- // exception: new-style reports always create a new document when "open" is executed
- Reference< report::XReportDefinition > xReportDefinition( getComponent(), UNO_QUERY );
- bool bIsAliveNewStyleReport = ( xReportDefinition.is() && ( bOpen || bOpenForMail ) );
-
- if ( bIsActive && !bIsAliveNewStyleReport )
- {
- impl_onActivateEmbeddedObject();
- return makeAny( getComponent() );
- }
- }
-
- // m_bOpenInDesign = bOpenInDesign;
- // onCommandOpenSomething( aCommand.Argument, !bOpenForMail, Environment, aRet, aGuard );
- m_bOpenInDesign = bOpenInDesign || bOpenForMail;
- onCommandOpenSomething( aCommand.Argument, bActivateObject, Environment, aRet, aGuard );
- }
- else if ( aCommand.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "copyTo" ) ) )
+ sal_Bool bOpen = aCommand.Name.equalsAscii( "open" );
+ sal_Bool bOpenInDesign = aCommand.Name.equalsAscii( "openDesign" );
+ sal_Bool bOpenForMail = aCommand.Name.equalsAscii( "openForMail" );
+ if ( bOpen || bOpenInDesign || bOpenForMail )
+ {
+ // opening the document involves a lot of VCL code, which is not thread-safe, but needs the SolarMutex locked.
+ // Unfortunately, the DocumentDefinition, as well as the EmbeddedObject implementation, calls into VCL-dependent
+ // components *without* releasing the own mutex, which is a guaranteed recipe for deadlocks.
+ // We have control over this implementation here, and in modifying it to release the own mutex before calling into
+ // the VCL-dependent components is not too difficult (was there, seen it).
+ // However, we do /not/ have control over the EmbeddedObject implementation, and from a first look, it seems as
+ // making it release the own mutex before calling SolarMutex-code is ... difficult, at least.
+ // So, to be on the same side, we lock the SolarMutex here. Yes, it sucks.
+ ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+ ::osl::ClearableMutexGuard aGuard(m_aMutex);
+ if ( m_bInExecute )
+ return aRet;
+
+ bool bActivateObject = true;
+ if ( bOpenForMail )
{
- Sequence<Any> aIni;
- aCommand.Argument >>= aIni;
- if ( aIni.getLength() != 2 )
- {
- OSL_ENSURE( sal_False, "Wrong argument type!" );
- ucbhelper::cancelCommandExecution(
- makeAny( IllegalArgumentException(
- rtl::OUString(),
- static_cast< cppu::OWeakObject * >( this ),
- -1 ) ),
- Environment );
- // Unreachable
- }
- Reference< XStorage> xDest(aIni[0],UNO_QUERY);
- ::rtl::OUString sPersistentName;
- aIni[1] >>= sPersistentName;
- Reference< XStorage> xStorage = getContainerStorage();
- // -----------------------------------------------------------------------------
- xStorage->copyElementTo(m_pImpl->m_aProps.sPersistentName,xDest,sPersistentName);
- /*loadEmbeddedObject( true );
- Reference<XEmbedPersist> xPersist(m_xEmbeddedObject,UNO_QUERY);
- if ( xPersist.is() )
- {
- xPersist->storeToEntry(xStorage,sPersistentName,Sequence<PropertyValue>(),Sequence<PropertyValue>());
- xPersist->storeOwn();
- m_xEmbeddedObject->changeState(EmbedStates::LOADED);
- }
- else
- throw CommandAbortedException();*/
- }
- else if ( aCommand.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "preview" ) ) )
- {
- onCommandPreview(aRet);
+ OSL_ENSURE( false, "ODocumentDefinition::execute: 'openForMail' should not be used anymore - use the 'Hidden' parameter instead!" );
+ bActivateObject = false;
}
- else if ( aCommand.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "insert" ) ) )
+
+ // if the object is already opened, do nothing
+ // #i89509# / 2008-05-22 / frank.schoenheit@sun.com
+ if ( m_xEmbeddedObject.is() )
{
- Sequence<Any> aIni;
- aCommand.Argument >>= aIni;
- if ( aIni.getLength() > 0 && aIni.getLength() < 2 )
+ sal_Int32 nCurrentState = m_xEmbeddedObject->getCurrentState();
+ bool bIsActive = ( nCurrentState == EmbedStates::ACTIVE );
+
+ // exception: new-style reports always create a new document when "open" is executed
+ Reference< report::XReportDefinition > xReportDefinition( getComponent(), UNO_QUERY );
+ bool bIsAliveNewStyleReport = ( xReportDefinition.is() && ( bOpen || bOpenForMail ) );
+
+ if ( bIsActive && !bIsAliveNewStyleReport )
{
- OSL_ENSURE( sal_False, "Wrong argument type!" );
- ucbhelper::cancelCommandExecution(
- makeAny( IllegalArgumentException(
- rtl::OUString(),
- static_cast< cppu::OWeakObject * >( this ),
- -1 ) ),
- Environment );
- // Unreachable
+ ODocumentDefinition::impl_onActivateEmbeddedObject_nothrow();
+ return makeAny( getComponent() );
}
- ::rtl::OUString sURL;
- aIni[0] >>= sURL;
- onCommandInsert( sURL, Environment );
}
- else if ( aCommand.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "getdocumentinfo" ) ) // compatibility
- || aCommand.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "getDocumentInfo" ) )
- )
- {
- onCommandGetDocumentProperties( aRet );
- }
- else if ( aCommand.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "delete" ) ) )
- {
- //////////////////////////////////////////////////////////////////
- // delete
- //////////////////////////////////////////////////////////////////
- closeObject();
- Reference< XStorage> xStorage = getContainerStorage();
- if ( xStorage.is() )
- xStorage->removeElement(m_pImpl->m_aProps.sPersistentName);
- dispose();
+ m_bOpenInDesign = bOpenInDesign || bOpenForMail;
+ return onCommandOpenSomething( aCommand.Argument, bActivateObject, Environment );
+ }
- }
- else if ( ( aCommand.Name.compareToAscii( "storeOwn" ) == 0 ) // compatibility
- || ( aCommand.Name.compareToAscii( "store" ) == 0 )
- )
+ ::osl::ClearableMutexGuard aGuard(m_aMutex);
+ if ( m_bInExecute )
+ return aRet;
+
+ if ( aCommand.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "copyTo" ) ) )
+ {
+ Sequence<Any> aIni;
+ aCommand.Argument >>= aIni;
+ if ( aIni.getLength() != 2 )
{
- impl_store_throw();
+ OSL_ENSURE( sal_False, "Wrong argument type!" );
+ ucbhelper::cancelCommandExecution(
+ makeAny( IllegalArgumentException(
+ rtl::OUString(),
+ static_cast< cppu::OWeakObject * >( this ),
+ -1 ) ),
+ Environment );
+ // Unreachable
}
- else if ( ( aCommand.Name.compareToAscii( "shutdown" ) == 0 ) // compatibility
- || ( aCommand.Name.compareToAscii( "close" ) == 0 )
- )
+ Reference< XStorage> xDest(aIni[0],UNO_QUERY);
+ ::rtl::OUString sPersistentName;
+ aIni[1] >>= sPersistentName;
+ Reference< XStorage> xStorage = getContainerStorage();
+ // -----------------------------------------------------------------------------
+ xStorage->copyElementTo(m_pImpl->m_aProps.sPersistentName,xDest,sPersistentName);
+ /*loadEmbeddedObject( true );
+ Reference<XEmbedPersist> xPersist(m_xEmbeddedObject,UNO_QUERY);
+ if ( xPersist.is() )
{
- aRet <<= impl_close_throw();
+ xPersist->storeToEntry(xStorage,sPersistentName,Sequence<PropertyValue>(),Sequence<PropertyValue>());
+ xPersist->storeOwn();
+ m_xEmbeddedObject->changeState(EmbedStates::LOADED);
}
else
+ throw CommandAbortedException();*/
+ }
+ else if ( aCommand.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "preview" ) ) )
+ {
+ onCommandPreview(aRet);
+ }
+ else if ( aCommand.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "insert" ) ) )
+ {
+ Sequence<Any> aIni;
+ aCommand.Argument >>= aIni;
+ if ( !aIni.getLength() )
{
- aRet = OContentHelper::execute(aCommand,CommandId,Environment);
+ OSL_ENSURE( sal_False, "Wrong argument count!" );
+ ucbhelper::cancelCommandExecution(
+ makeAny( IllegalArgumentException(
+ rtl::OUString(),
+ static_cast< cppu::OWeakObject * >( this ),
+ -1 ) ),
+ Environment );
+ // Unreachable
}
+ ::rtl::OUString sURL;
+ aIni[0] >>= sURL;
+ onCommandInsert( sURL, Environment );
+ }
+ else if ( aCommand.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "getdocumentinfo" ) ) // compatibility
+ || aCommand.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "getDocumentInfo" ) )
+ )
+ {
+ onCommandGetDocumentProperties( aRet );
+ }
+ else if ( aCommand.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "delete" ) ) )
+ {
+ //////////////////////////////////////////////////////////////////
+ // delete
+ //////////////////////////////////////////////////////////////////
+ closeObject();
+ Reference< XStorage> xStorage = getContainerStorage();
+ if ( xStorage.is() )
+ xStorage->removeElement(m_pImpl->m_aProps.sPersistentName);
+
+ dispose();
+
}
+ else if ( ( aCommand.Name.compareToAscii( "storeOwn" ) == 0 ) // compatibility
+ || ( aCommand.Name.compareToAscii( "store" ) == 0 )
+ )
+ {
+ impl_store_throw();
+ }
+ else if ( ( aCommand.Name.compareToAscii( "shutdown" ) == 0 ) // compatibility
+ || ( aCommand.Name.compareToAscii( "close" ) == 0 )
+ )
+ {
+ aRet <<= impl_close_throw();
+ }
+ else
+ {
+ aRet = OContentHelper::execute(aCommand,CommandId,Environment);
+ }
+
return aRet;
}
// -----------------------------------------------------------------------------
@@ -1607,9 +1610,8 @@ Sequence< PropertyValue > ODocumentDefinition::fillLoadArgs( const Reference< XC
xParentFrame = lcl_getDatabaseDocumentFrame( *m_pImpl->m_pDataSource );
if ( !xParentFrame.is() )
{ // i87957 we need a parent frame
- if ( !m_xDesktop.is() )
- m_xDesktop.set( m_aContext.createComponent( (::rtl::OUString)SERVICE_FRAME_DESKTOP ), UNO_QUERY_THROW );
- xParentFrame.set(m_xDesktop,uno::UNO_QUERY);
+ Reference< XComponentLoader > xDesktop( m_aContext.createComponent( (::rtl::OUString)SERVICE_FRAME_DESKTOP ), UNO_QUERY_THROW );
+ xParentFrame.set( xDesktop, UNO_QUERY );
if ( xParentFrame.is() )
{
Reference<util::XCloseable> xCloseable(m_pImpl->m_pDataSource->getModel_noCreate(),UNO_QUERY);
@@ -1918,10 +1920,8 @@ Reference< XComponent > ODocumentDefinition::impl_openUI_nolck_throw( bool _bFor
{
// no XDatabaseDocumentUI -> just execute the respective command
m_bOpenInDesign = _bForEditing;
- Any aComponent;
- onCommandOpenSomething( Any(), true, NULL, aComponent, aGuard );
- Reference< XComponent > xComponent;
- OSL_VERIFY( aComponent >>= xComponent );
+ Reference< XComponent > xComponent( onCommandOpenSomething( Any(), true, NULL ), UNO_QUERY );
+ OSL_ENSURE( xComponent.is(), "ODocumentDefinition::impl_openUI_nolck_throw: opening the thingie failed." );
return xComponent;
}
@@ -2122,26 +2122,29 @@ bool ODocumentDefinition::prepareClose()
return true;
}
// -----------------------------------------------------------------------------
-void ODocumentDefinition::fillReportData(::osl::ClearableMutexGuard & _aGuard)
+void ODocumentDefinition::fillReportData( const ::comphelper::ComponentContext& _rContext,
+ const Reference< util::XCloseable >& _rxComponent,
+ const Reference< XConnection >& _rxActiveConnection )
{
- if ( !m_bForm && m_pImpl->m_aProps.bAsTemplate && !m_bOpenInDesign ) // open a report in alive mode, so we need to fill it
- {
- Sequence<Any> aArgs(2);
- PropertyValue aValue;
- aValue.Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("TextDocument"));
- aValue.Value <<= getComponent();
- aArgs[0] <<= aValue;
- aValue.Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ActiveConnection"));
- aValue.Value <<= m_xLastKnownConnection;
- aArgs[1] <<= aValue;
-
- Reference< XJobExecutor > xExecuteable( m_aContext.createComponentWithArguments( "com.sun.star.wizards.report.CallReportWizard", aArgs ), UNO_QUERY );
- if ( xExecuteable.is() )
- {
- _aGuard.clear();
- xExecuteable->trigger(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("fill")));
+ Sequence< Any > aArgs(2);
+ PropertyValue aValue;
+ aValue.Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "TextDocument" ) );
+ aValue.Value <<= _rxComponent;
+ aArgs[0] <<= aValue;
+ aValue.Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ActiveConnection" ) );
+ aValue.Value <<= _rxActiveConnection;
+ aArgs[1] <<= aValue;
+
+ try
+ {
+ Reference< XJobExecutor > xExecuteable(
+ _rContext.createComponentWithArguments( "com.sun.star.wizards.report.CallReportWizard", aArgs ), UNO_QUERY_THROW );
+ xExecuteable->trigger( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "fill" ) ) );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
}
-}
}
// -----------------------------------------------------------------------------
void ODocumentDefinition::updateDocumentTitle()
diff --git a/dbaccess/source/core/dataaccess/documentdefinition.hxx b/dbaccess/source/core/dataaccess/documentdefinition.hxx
index 2d8d5f6df343..c48d20ad58a3 100644
--- a/dbaccess/source/core/dataaccess/documentdefinition.hxx
+++ b/dbaccess/source/core/dataaccess/documentdefinition.hxx
@@ -92,7 +92,6 @@ class ODocumentDefinition
{
::com::sun::star::uno::Reference< ::com::sun::star::embed::XEmbeddedObject> m_xEmbeddedObject;
::com::sun::star::uno::Reference< ::com::sun::star::embed::XStateChangeListener > m_xListener;
- ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFramesSupplier > m_xDesktop;
::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > m_xLastKnownConnection;
OInterceptor* m_pInterceptor;
@@ -163,9 +162,17 @@ public:
sal_Bool saveAs();
void closeObject();
sal_Bool isModified();
- void fillReportData(::osl::ClearableMutexGuard & _aGuard);
inline sal_Bool isNewReport() const { return !m_bForm && !m_pImpl->m_aProps.bAsTemplate; }
+ static void fillReportData(
+ const ::comphelper::ComponentContext& _rContext,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloseable >& _rxComponent,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxActiveConnection
+ );
+
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >&
+ getConnection() const { return m_xLastKnownConnection; }
+
/** prepares closing the document component
The method suspends the controller associated with the document, and saves the document
@@ -192,12 +199,10 @@ public:
private:
/** does necessary initializations after our embedded object has been switched to ACTIVE
- @param _bOpenedInDesignMode
- determines whether the embedded object has been opened for designing it or for data display
*/
- void impl_onActivateEmbeddedObject();
+ void impl_onActivateEmbeddedObject_nothrow();
- /** initializes a newly created view/controller which is displaying our embedded object
+ /** initializes a newly created view/controller of a form which is displaying our embedded object
Has only to be called if the respective embedded object has been loaded for design (and
not for data entry)
@@ -205,12 +210,15 @@ private:
@param _rxController
the controller which belongs to the XModel of our (active) embedded object
*/
- void impl_initObjectEditView( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController >& _rxController );
+ static void impl_initFormEditView( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController >& _rxController );
/** removes the given frame from the desktop's frame collection
@raises ::com::sun::star::uno::RuntimeException
*/
- void impl_removeFrameFromDesktop_throw( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& _rxFrame );
+ static void impl_removeFrameFromDesktop_throw(
+ const ::comphelper::ComponentContext& _rContxt,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& _rxFrame
+ );
/** opens the UI for this sub document
*/
@@ -310,10 +318,12 @@ private:
void onCommandGetDocumentProperties( ::com::sun::star::uno::Any& _rProps );
void onCommandInsert( const ::rtl::OUString& _sURL, const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XCommandEnvironment >& Environment ) throw( ::com::sun::star::uno::Exception );
void onCommandPreview( ::com::sun::star::uno::Any& _rImage );
- void onCommandOpenSomething( const ::com::sun::star::uno::Any& _rArgument, const bool _bActivate,
- const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XCommandEnvironment >& _rxEnvironment,
- ::com::sun::star::uno::Any& _out_rComponent,
- ::osl::ClearableMutexGuard & _aClearableGuard);
+ ::com::sun::star::uno::Any
+ onCommandOpenSomething(
+ const ::com::sun::star::uno::Any& _rArgument,
+ const bool _bActivate,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XCommandEnvironment >& _rxEnvironment
+ );
};
//........................................................................
diff --git a/dbaccess/source/core/dataaccess/intercept.cxx b/dbaccess/source/core/dataaccess/intercept.cxx
index 733f155dae5d..9211302f0d9b 100644
--- a/dbaccess/source/core/dataaccess/intercept.cxx
+++ b/dbaccess/source/core/dataaccess/intercept.cxx
@@ -31,28 +31,17 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_dbaccess.hxx"
-#ifndef _COM_SUN_STAR_EMBED_EMBEDSTATES_HPP_
+#include "intercept.hxx"
+#include "dbastrings.hrc"
+
#include <com/sun/star/embed/EmbedStates.hpp>
-#endif
-#ifndef _COM_SUN_STAR_DOCUMENT_XEVENTBROADCASTER_HPP_
#include <com/sun/star/document/XEventBroadcaster.hpp>
-#endif
-#ifndef _COM_SUN_STAR_UTIL_XMODIFIABLE_HPP_
#include <com/sun/star/util/XModifiable.hpp>
-#endif
-#ifndef _CPPUHELPER_WEAK_HXX_
#include <cppuhelper/weak.hxx>
-#endif
-#ifndef _COMPHELPER_TYPES_HXX_
+
#include <comphelper/types.hxx>
-#endif
-#ifndef DBA_INTERCEPT_HXX
-#include "intercept.hxx"
-#endif
-#include "dbastrings.hrc"
-#ifndef _TOOLS_DEBUG_HXX
#include <tools/debug.hxx>
-#endif
+#include <tools/diagnose_ex.h>
namespace dbaccess
@@ -140,66 +129,78 @@ struct DispatchHelper
//XDispatch
void SAL_CALL OInterceptor::dispatch( const URL& _URL,const Sequence<PropertyValue >& Arguments ) throw (RuntimeException)
{
- osl::ClearableMutexGuard aClearableGuard(m_aMutex);
- if( m_pContentHolder )
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if ( !m_pContentHolder )
+ return;
+
+ if ( _URL.Complete == m_aInterceptedURL[ DISPATCH_SAVE ] )
{
- if( _URL.Complete == m_aInterceptedURL[DISPATCH_SAVE] )
- {
- m_pContentHolder->save(sal_False);
- }
- else if( _URL.Complete == m_aInterceptedURL[DISPATCH_RELOAD] )
+ m_pContentHolder->save( sal_False );
+ return;
+ }
+
+ if ( _URL.Complete == m_aInterceptedURL[ DISPATCH_RELOAD ] )
+ {
+ ODocumentDefinition::fillReportData(
+ m_pContentHolder->getContext(),
+ m_pContentHolder->getComponent(),
+ m_pContentHolder->getConnection()
+ );
+ return;
+ }
+
+ if( _URL.Complete == m_aInterceptedURL[ DISPATCH_SAVEAS ] )
+ {
+ if ( m_pContentHolder->isNewReport() )
{
- m_pContentHolder->fillReportData(aClearableGuard);
- // IMPORTANT: m_aMutex is cleared!
+ m_pContentHolder->saveAs();
}
- else if( _URL.Complete == m_aInterceptedURL[DISPATCH_SAVEAS] )
+ else if ( m_xSlaveDispatchProvider.is() )
{
- if ( m_pContentHolder->isNewReport() )
- {
- m_pContentHolder->saveAs();
- }
- else if ( m_xSlaveDispatchProvider.is() )
- {
- Sequence< PropertyValue > aNewArgs = Arguments;
- sal_Int32 nInd = 0;
+ Sequence< PropertyValue > aNewArgs = Arguments;
+ sal_Int32 nInd = 0;
- while( nInd < aNewArgs.getLength() )
- {
- if ( aNewArgs[nInd].Name.equalsAscii( "SaveTo" ) )
- {
- aNewArgs[nInd].Value <<= sal_True;
- break;
- }
- nInd++;
- }
-
- if ( nInd == aNewArgs.getLength() )
+ while( nInd < aNewArgs.getLength() )
+ {
+ if ( aNewArgs[nInd].Name.equalsAscii( "SaveTo" ) )
{
- aNewArgs.realloc( nInd + 1 );
- aNewArgs[nInd].Name = ::rtl::OUString::createFromAscii( "SaveTo" );
aNewArgs[nInd].Value <<= sal_True;
+ break;
}
+ nInd++;
+ }
- Reference< XDispatch > xDispatch = m_xSlaveDispatchProvider->queryDispatch(
- _URL, ::rtl::OUString::createFromAscii( "_self" ), 0 );
- if ( xDispatch.is() )
- xDispatch->dispatch( _URL, aNewArgs );
+ if ( nInd == aNewArgs.getLength() )
+ {
+ aNewArgs.realloc( nInd + 1 );
+ aNewArgs[nInd].Name = ::rtl::OUString::createFromAscii( "SaveTo" );
+ aNewArgs[nInd].Value <<= sal_True;
}
+
+ Reference< XDispatch > xDispatch = m_xSlaveDispatchProvider->queryDispatch(
+ _URL, ::rtl::OUString::createFromAscii( "_self" ), 0 );
+ if ( xDispatch.is() )
+ xDispatch->dispatch( _URL, aNewArgs );
}
- else if ( _URL.Complete == m_aInterceptedURL[DISPATCH_CLOSEDOC]
- || _URL.Complete == m_aInterceptedURL[DISPATCH_CLOSEWIN]
- || _URL.Complete == m_aInterceptedURL[DISPATCH_CLOSEFRAME])
- {
- DispatchHelper* pHelper = new DispatchHelper;
- pHelper->aArguments = Arguments;
- pHelper->aURL = _URL;
- Application::PostUserEvent(LINK(this, OInterceptor, OnDispatch),reinterpret_cast<void*>(pHelper) );
- }
+ return;
+ }
+
+ if ( _URL.Complete == m_aInterceptedURL[ DISPATCH_CLOSEDOC ]
+ || _URL.Complete == m_aInterceptedURL[ DISPATCH_CLOSEWIN ]
+ || _URL.Complete == m_aInterceptedURL[ DISPATCH_CLOSEFRAME ]
+ )
+ {
+ DispatchHelper* pHelper = new DispatchHelper;
+ pHelper->aArguments = Arguments;
+ pHelper->aURL = _URL;
+ Application::PostUserEvent( LINK( this, OInterceptor, OnDispatch ), reinterpret_cast< void* >( pHelper ) );
+ return;
}
}
-IMPL_LINK( OInterceptor, OnDispatch, void*, _nId)
+
+IMPL_LINK( OInterceptor, OnDispatch, void*, _pDispatcher )
{
- ::std::auto_ptr<DispatchHelper> pHelper(reinterpret_cast<DispatchHelper*>(_nId));
+ ::std::auto_ptr<DispatchHelper> pHelper( reinterpret_cast< DispatchHelper* >( _pDispatcher ) );
try
{
if ( m_pContentHolder && m_pContentHolder->prepareClose() && m_xSlaveDispatchProvider.is() )
@@ -217,10 +218,11 @@ IMPL_LINK( OInterceptor, OnDispatch, void*, _nId)
}
}
}
- catch(const Exception&)
+ catch ( const Exception& )
{
- OSL_ENSURE(sal_False, "caught an exception while starting the table wizard!");
+ DBG_UNHANDLED_EXCEPTION();
}
+
return 0L;
}
diff --git a/dbaccess/source/core/dataaccess/makefile.mk b/dbaccess/source/core/dataaccess/makefile.mk
index 580d62c08e55..aff531b3a388 100644
--- a/dbaccess/source/core/dataaccess/makefile.mk
+++ b/dbaccess/source/core/dataaccess/makefile.mk
@@ -56,6 +56,7 @@ SLOFILES= \
$(SLO)$/databasecontext.obj \
$(SLO)$/connection.obj \
$(SLO)$/datasource.obj \
+ $(SLO)$/databaseregistrations.obj \
$(SLO)$/intercept.obj \
$(SLO)$/myucp_datasupplier.obj \
$(SLO)$/myucp_resultset.obj \
diff --git a/dbaccess/source/core/inc/ContainerMediator.hxx b/dbaccess/source/core/inc/ContainerMediator.hxx
index af2076f3e0f9..0b129d5465f0 100644
--- a/dbaccess/source/core/inc/ContainerMediator.hxx
+++ b/dbaccess/source/core/inc/ContainerMediator.hxx
@@ -112,23 +112,12 @@ namespace dbaccess
*/
void impl_cleanup_nothrow();
- /** retrieves the settings object to initialize a container element
-
- Normally, this object will simply retrieve the object with the given name from our settings
- container. Hiowever, for columns, there's a fallback in case this settings object does
- not yet exist: Then, we check if the given destination object refers to a table column, via its
- TableName and RealName property. If so, this table column is used as initialization object.
-
- @param _rName
- the name of the destination object in its container
- @param _rxDestination
- the destination object to initialize
+ /** initializes the properties of the given object from its counterpart in our settings container
*/
- ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
- impl_getSettingsForInitialization_nothrow(
+ void impl_initSettings_nothrow(
const ::rtl::OUString& _rName,
const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxDestination
- ) const;
+ );
};
//........................................................................
} // namespace dbaccess
diff --git a/dbaccess/source/core/inc/ContentHelper.hxx b/dbaccess/source/core/inc/ContentHelper.hxx
index 227110bd324d..d9d000435ec4 100644
--- a/dbaccess/source/core/inc/ContentHelper.hxx
+++ b/dbaccess/source/core/inc/ContentHelper.hxx
@@ -236,6 +236,8 @@ namespace dbaccess
getPropertyValues( const ::com::sun::star::uno::Sequence<
::com::sun::star::beans::Property >& rProperties );
+ const ::comphelper::ComponentContext& getContext() const { return m_aContext; }
+
inline TContentPtr getImpl() const { return m_pImpl; }
protected:
diff --git a/dbaccess/source/core/inc/PropertyForward.hxx b/dbaccess/source/core/inc/PropertyForward.hxx
index a4adbb59ef47..1e5cd6f0d4d0 100644
--- a/dbaccess/source/core/inc/PropertyForward.hxx
+++ b/dbaccess/source/core/inc/PropertyForward.hxx
@@ -55,24 +55,31 @@
namespace dbaccess
{
//........................................................................
+
+ // ===================================================================
+ // = OPropertyForward
+ // ===================================================================
typedef ::cppu::WeakImplHelper1 < ::com::sun::star::beans::XPropertyChangeListener
> OPropertyForward_Base;
- class OPropertyForward : public ::comphelper::OBaseMutex
+ class OPropertyForward :public ::comphelper::OBaseMutex
,public OPropertyForward_Base
{
- ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> m_xSource;
- ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> m_xDest;
- ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo> m_xDestInfo;
- ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess> m_xDestContainer;
- ::rtl::OUString m_sName;
- sal_Bool m_bInInsert;
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xSource;
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xDest;
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > m_xDestInfo;
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > m_xDestContainer;
+ ::rtl::OUString m_sName;
+ sal_Bool m_bInInsert;
+
protected:
virtual ~OPropertyForward();
+
public:
- OPropertyForward(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _xSource
- ,const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess>& _xDestContainer
- ,const ::rtl::OUString& _sName
- ,const ::std::vector< ::rtl::OUString>& _aPropertyList = ::std::vector< ::rtl::OUString>());
+ OPropertyForward( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _xSource,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess>& _xDestContainer,
+ const ::rtl::OUString& _sName,
+ const ::std::vector< ::rtl::OUString >& _aPropertyList
+ );
// ::com::sun::star::beans::XPropertyChangeListener
virtual void SAL_CALL propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& evt ) throw(::com::sun::star::uno::RuntimeException);
@@ -80,10 +87,11 @@ namespace dbaccess
// ::com::sun::star::lang::XEventListener
virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& _rSource ) throw (::com::sun::star::uno::RuntimeException);
- inline void setName(const ::rtl::OUString& _sName) { m_sName = _sName; }
- void setDefinition(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _xDest);
- inline ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> getDefinition() const { return m_xDest;}
+ inline void setName( const ::rtl::OUString& _sName ) { m_sName = _sName; }
+ void setDefinition( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _xDest);
+ inline ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > getDefinition() const { return m_xDest; }
};
+
//........................................................................
} // namespace dbaccess
//........................................................................
diff --git a/dbaccess/source/core/inc/column.hxx b/dbaccess/source/core/inc/column.hxx
index b35ecebb3066..ab4fcb211e6a 100644
--- a/dbaccess/source/core/inc/column.hxx
+++ b/dbaccess/source/core/inc/column.hxx
@@ -58,7 +58,7 @@
#include <connectivity/FValue.hxx>
#include <connectivity/TColumnsHelper.hxx>
#include <connectivity/sdbcx/IRefreshable.hxx>
-#include <cppuhelper/compbase3.hxx>
+#include <cppuhelper/compbase2.hxx>
#include <cppuhelper/compbase4.hxx>
#include <cppuhelper/implbase1.hxx>
#include <cppuhelper/propshlp.hxx>
@@ -72,9 +72,9 @@ namespace dbaccess
//************************************************************
// OColumn
//************************************************************
- typedef ::cppu::WeakComponentImplHelper3< ::com::sun::star::lang::XServiceInfo,
- ::com::sun::star::container::XNamed,
- ::com::sun::star::lang::XUnoTunnel > OColumnBase;
+ typedef ::cppu::WeakComponentImplHelper2< ::com::sun::star::lang::XServiceInfo,
+ ::com::sun::star::container::XNamed
+ > OColumnBase;
//------------------------------------------------------------
class OColumn :public comphelper::OBaseMutex
@@ -107,10 +107,6 @@ namespace dbaccess
// com::sun::star::beans::XPropertySet
virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException);
- // com::sun::star::lang::XUnoTunnel
- virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException);
- static ::com::sun::star::uno::Sequence< sal_Int8 > getUnoTunnelImplementationId();
-
// cppu::OComponentHelper
virtual void SAL_CALL disposing(void);
diff --git a/dbaccess/source/core/inc/columnsettings.hxx b/dbaccess/source/core/inc/columnsettings.hxx
index a6abc3642f2a..22d119d6c429 100644
--- a/dbaccess/source/core/inc/columnsettings.hxx
+++ b/dbaccess/source/core/inc/columnsettings.hxx
@@ -87,20 +87,18 @@ namespace dbaccess
public:
OColumnSettings();
- virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException);
- static ::com::sun::star::uno::Sequence< sal_Int8 > getUnoTunnelImplementationId();
-
protected:
void registerProperties( IPropertyContainer& _rPropertyContainer );
/** determines whether the property with the given handle is handled by the class
*/
- bool isMine( const sal_Int32 _nPropertyHandle ) const;
+ static bool isColumnSettingProperty( const sal_Int32 _nPropertyHandle );
+ static bool isDefaulted( const sal_Int32 _nPropertyHandle, const ::com::sun::star::uno::Any& _rPropertyValue );
public:
/** check if the persistent settings have their default value
*/
- sal_Bool isDefaulted() const;
+ static bool hasDefaultSettings( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxColumn );
};
//........................................................................
diff --git a/dbaccess/source/core/inc/definitioncolumn.hxx b/dbaccess/source/core/inc/definitioncolumn.hxx
index 85800355ddfa..96f20be014cb 100644
--- a/dbaccess/source/core/inc/definitioncolumn.hxx
+++ b/dbaccess/source/core/inc/definitioncolumn.hxx
@@ -47,6 +47,9 @@ namespace dbaccess
{
typedef ::cppu::ImplHelper1< ::com::sun::star::container::XChild > TXChild;
+ // =========================================================================
+ //= OTableColumnDescriptor
+ // =========================================================================
/**
* provides the properties for description. A descriptor could be used to create a new table column.
*/
@@ -55,7 +58,9 @@ namespace dbaccess
,public ::comphelper::OPropertyArrayUsageHelper < OTableColumnDescriptor >
,public TXChild
{
- ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > m_xParent;
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > m_xParent;
+ const bool m_bActAsDescriptor;
+
protected:
// <properties>
rtl::OUString m_aTypeName;
@@ -74,6 +79,7 @@ namespace dbaccess
public:
OTableColumnDescriptor( const bool _bActAsDescriptor )
:OColumn( !_bActAsDescriptor )
+ ,m_bActAsDescriptor( _bActAsDescriptor )
,m_nType( ::com::sun::star::sdbc::DataType::SQLNULL )
,m_nPrecision( 0 )
,m_nScale( 0 )
@@ -82,7 +88,7 @@ namespace dbaccess
,m_bRowVersion( sal_False )
,m_bCurrency( sal_False )
{
- impl_registerProperties( _bActAsDescriptor );
+ impl_registerProperties();
}
DECLARE_XINTERFACE( )
@@ -105,42 +111,86 @@ namespace dbaccess
virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue ) throw (::com::sun::star::uno::Exception);
- protected:
- // XUnoTunnel
- virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException);
-
private:
- void impl_registerProperties( const bool _bActAsDescriptor );
-
- protected:
- using OColumn::getFastPropertyValue;
+ void impl_registerProperties();
};
- /** describes a column of a table or query
+ // =========================================================================
+ // = OTableColumn
+ // =========================================================================
+ class OTableColumn;
+ typedef ::comphelper::OPropertyArrayUsageHelper < OTableColumn > OTableColumn_PBase;
+ /** describes a column of a table
*/
class OTableColumn :public OTableColumnDescriptor
- ,public ::comphelper::OPropertyArrayUsageHelper < OTableColumn >
+ ,public OTableColumn_PBase
{
- friend class ODBTable;
-
protected:
virtual ~OTableColumn();
+
public:
OTableColumn(const ::rtl::OUString& _rName);
- OTableColumn(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _xColumn);
- // com::sun::star::lang::XTypeProvider
+ // XTypeProvider
virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException);
- // ::com::sun::star::lang::XServiceInfo
+ // XServiceInfo
virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException);
- virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException);
- // ::comphelper::OPropertyArrayUsageHelper
+ // OPropertyArrayUsageHelper
+ virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
virtual ::cppu::IPropertyArrayHelper* createArrayHelper() const;
+ };
+
+ // =========================================================================
+ // = OQueryColumn
+ // =========================================================================
+ class OQueryColumn;
+ typedef ::comphelper::OPropertyArrayUsageHelper< OQueryColumn > OQueryColumn_PBase;
+ /** a column of a Query, with additional information obtained from parsing the query statement
+ */
+ class OQueryColumn :public OTableColumnDescriptor
+ ,public OQueryColumn_PBase
+ {
+ // <properties>
+ ::rtl::OUString m_sCatalogName;
+ ::rtl::OUString m_sSchemaName;
+ ::rtl::OUString m_sTableName;
+ ::rtl::OUString m_sRealName;
+ // </properties>
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xOriginalTableColumn;
+
+ protected:
+ ~OQueryColumn();
+
+ public:
+ OQueryColumn(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _rxParserColumn,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection
+ );
+
+ // XTypeProvider
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException);
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException);
+
+ // *Property*
virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
+ virtual ::cppu::IPropertyArrayHelper* createArrayHelper() const;
+ virtual void SAL_CALL getFastPropertyValue( ::com::sun::star::uno::Any& rValue, sal_Int32 nHandle ) const;
+
+ private:
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
+ impl_determineOriginalTableColumn(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection
+ );
};
+ // =========================================================================
+ // = OColumnWrapper
+ // =========================================================================
/**
* describes all properties for a columns of a table. Only the view parts are provided
* directly, all the other parts are derived from a driver implementation
@@ -184,6 +234,9 @@ namespace dbaccess
using OColumn::getFastPropertyValue;
};
+ // =========================================================================
+ // = OTableColumnDescriptorWrapper
+ // =========================================================================
/**
* provides the properties for description. A descriptor could be used to create a new table column.
*/
@@ -227,13 +280,12 @@ namespace dbaccess
throw (::com::sun::star::uno::Exception);
protected:
- // XUnoTunnel
- virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException);
-
- protected:
using OColumnWrapper::getFastPropertyValue;
};
+ // =========================================================================
+ // = OTableColumnWrapper
+ // =========================================================================
/**
* describes all properties for a columns of a table. Only the view parts are provided
* directly, all the other parts are derived from a driver implementation
diff --git a/dbaccess/source/core/inc/querycontainer.hxx b/dbaccess/source/core/inc/querycontainer.hxx
index ac3d61bac8d1..6d8b523ec84c 100644
--- a/dbaccess/source/core/inc/querycontainer.hxx
+++ b/dbaccess/source/core/inc/querycontainer.hxx
@@ -180,7 +180,7 @@ namespace dbaccess
);
DECLARE_XINTERFACE( )
- // ::com::sun::star::lang::XServiceInfo
+ DECLARE_XTYPEPROVIDER( )
DECLARE_SERVICE_INFO();
// ::com::sun::star::container::XContainerListener
diff --git a/dbaccess/source/core/misc/ContainerMediator.cxx b/dbaccess/source/core/misc/ContainerMediator.cxx
index c116928ce267..fdae237aad4c 100644
--- a/dbaccess/source/core/misc/ContainerMediator.cxx
+++ b/dbaccess/source/core/misc/ContainerMediator.cxx
@@ -128,7 +128,7 @@ void OContainerMediator::impl_cleanup_nothrow()
xContainer = m_xContainer;
if ( xContainer.is() )
xContainer->removeContainerListener( this );
- m_xContainer.clear();//WeakReference< XContainer >();
+ m_xContainer.clear();
m_aForwardList.clear();
}
@@ -214,115 +214,69 @@ void SAL_CALL OContainerMediator::disposing( const EventObject& /*Source*/ ) thr
{
::osl::MutexGuard aGuard(m_aMutex);
-// Reference< XContainer > xContainer = m_xContainer;
-// if ( Source.Source == xContainer || Source.Source == m_xSettings )
- // this can only be one of them :-) So no check needed here
impl_cleanup_nothrow();
}
// -----------------------------------------------------------------------------
-Reference< XPropertySet > OContainerMediator::impl_getSettingsForInitialization_nothrow( const ::rtl::OUString& _rName,
- const Reference< XPropertySet >& _rxDestination ) const
+void OContainerMediator::impl_initSettings_nothrow( const ::rtl::OUString& _rName, const Reference< XPropertySet >& _rxDestination )
{
- Reference< XPropertySet > xSettings;
try
{
if ( m_xSettings.is() && m_xSettings->hasByName( _rName ) )
- OSL_VERIFY( m_xSettings->getByName( _rName ) >>= xSettings );
- else if ( m_eType == eColumns )
{
- do // artifial loop for easier flow control
- {
-
- Reference< XConnection > xConnection( m_aConnection );
- if ( !xConnection.is() )
- break;
-
- Reference< XPropertySetInfo > xPSI( _rxDestination->getPropertySetInfo(), UNO_QUERY_THROW );
- if ( !xPSI->hasPropertyByName( PROPERTY_TABLENAME )
- || !xPSI->hasPropertyByName( PROPERTY_REALNAME )
- )
- break;
-
- // determine the composed table name, plus the column name, as indicated by the
- // respective properties at the destination object
- ::rtl::OUString sCatalog, sSchema, sTable, sColumn;
- if ( xPSI->hasPropertyByName( PROPERTY_CATALOGNAME ) )
- {
- OSL_VERIFY( _rxDestination->getPropertyValue( PROPERTY_CATALOGNAME ) >>= sCatalog );
- }
- if ( xPSI->hasPropertyByName( PROPERTY_SCHEMANAME ) )
- {
- OSL_VERIFY( _rxDestination->getPropertyValue( PROPERTY_SCHEMANAME ) >>= sSchema );
- }
- OSL_VERIFY( _rxDestination->getPropertyValue( PROPERTY_TABLENAME ) >>= sTable );
- OSL_VERIFY( _rxDestination->getPropertyValue( PROPERTY_REALNAME ) >>= sColumn );
-
- ::rtl::OUString sComposedTableName = ::dbtools::composeTableName(
- xConnection->getMetaData(), sCatalog, sSchema, sTable, sal_False, ::dbtools::eComplete );
-
- // retrieve the table in question
- Reference< XTablesSupplier > xSuppTables( xConnection, UNO_QUERY_THROW );
- Reference< XNameAccess > xTables( xSuppTables->getTables(), UNO_QUERY_THROW );
- if ( !xTables->hasByName( sComposedTableName ) )
- break;
-
- Reference< XColumnsSupplier > xSuppCols( xTables->getByName( sComposedTableName ), UNO_QUERY_THROW );
- Reference< XNameAccess > xColumns( xSuppCols->getColumns(), UNO_QUERY_THROW );
- if ( !xColumns->hasByName( sColumn ) )
- break;
-
- xSettings.set( xColumns->getByName( sColumn ), UNO_QUERY );
-
- }
- while ( false );
+ Reference< XPropertySet > xSettings( m_xSettings->getByName( _rName ), UNO_QUERY_THROW );
+ ::comphelper::copyProperties( xSettings, _rxDestination );
}
}
catch( const Exception& )
{
DBG_UNHANDLED_EXCEPTION();
}
- return xSettings;
}
// -----------------------------------------------------------------------------
-void OContainerMediator::notifyElementCreated(const ::rtl::OUString& _sName,const Reference<XPropertySet>& _xDest)
+void OContainerMediator::notifyElementCreated( const ::rtl::OUString& _sName, const Reference< XPropertySet >& _xDest )
{
- PropertyForwardList::iterator aFind = m_aForwardList.find(_sName);
- if ( (aFind == m_aForwardList.end() || !aFind->second->getDefinition().is() )&& m_xSettings.is() )
- {
- ::std::vector< ::rtl::OUString> aPropertyList;
+ if ( !m_xSettings.is() )
+ return;
- try
- {
- // initially copy from the settings object (if existent) to the newly created object
- Reference< XPropertySet > xSetting( impl_getSettingsForInitialization_nothrow( _sName, _xDest ) );
- if ( xSetting.is() )
- ::comphelper::copyProperties( xSetting, _xDest );
+ PropertyForwardList::iterator aFind = m_aForwardList.find( _sName );
+ if ( aFind != m_aForwardList.end()
+ && aFind->second->getDefinition().is()
+ )
+ {
+ OSL_ENSURE( false, "OContainerMediator::notifyElementCreated: is this really a valid case?" );
+ return;
+ }
- // collect the to-be-monitored properties
- Reference< XPropertySetInfo > xPSI( _xDest->getPropertySetInfo(), UNO_QUERY_THROW );
- Sequence< Property > aProperties( xPSI->getProperties() );
- const Property* property = aProperties.getConstArray();
- const Property* propertyEnd = aProperties.getConstArray() + aProperties.getLength();
- for ( ; property != propertyEnd; ++property )
- {
- if ( ( property->Attributes & PropertyAttribute::READONLY ) != 0 )
- continue;
- if ( ( property->Attributes & PropertyAttribute::BOUND ) == 0 )
- continue;
+ ::std::vector< ::rtl::OUString > aPropertyList;
+ try
+ {
+ // initially copy from the settings object (if existent) to the newly created object
+ impl_initSettings_nothrow( _sName, _xDest );
- aPropertyList.push_back( property->Name );
- }
- }
- catch( const Exception& )
+ // collect the to-be-monitored properties
+ Reference< XPropertySetInfo > xPSI( _xDest->getPropertySetInfo(), UNO_QUERY_THROW );
+ Sequence< Property > aProperties( xPSI->getProperties() );
+ const Property* property = aProperties.getConstArray();
+ const Property* propertyEnd = aProperties.getConstArray() + aProperties.getLength();
+ for ( ; property != propertyEnd; ++property )
{
- DBG_UNHANDLED_EXCEPTION();
+ if ( ( property->Attributes & PropertyAttribute::READONLY ) != 0 )
+ continue;
+ if ( ( property->Attributes & PropertyAttribute::BOUND ) == 0 )
+ continue;
+
+ aPropertyList.push_back( property->Name );
}
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
- ::rtl::Reference< OPropertyForward > pForward( new OPropertyForward( _xDest, m_xSettings, _sName, aPropertyList ) );
- m_aForwardList[_sName] = pForward;
- } // if ( aFind == m_aForwardList.end() && m_xSettings.is() )
+ ::rtl::Reference< OPropertyForward > pForward( new OPropertyForward( _xDest, m_xSettings, _sName, aPropertyList ) );
+ m_aForwardList[ _sName ] = pForward;
}
// -----------------------------------------------------------------------------
//........................................................................
diff --git a/dbaccess/source/core/misc/PropertyForward.cxx b/dbaccess/source/core/misc/PropertyForward.cxx
index f5bc30825291..4db6ef964448 100644
--- a/dbaccess/source/core/misc/PropertyForward.cxx
+++ b/dbaccess/source/core/misc/PropertyForward.cxx
@@ -30,140 +30,146 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_dbaccess.hxx"
-#ifndef DBA_PROPERTYSETFORWARD_HXX
+
#include "PropertyForward.hxx"
-#endif
-#ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_
-#include <com/sun/star/beans/PropertyValue.hpp>
-#endif
-#ifndef DBACCESS_SHARED_DBASTRINGS_HRC
#include "dbastrings.hrc"
-#endif
-#ifndef _COMPHELPER_PROPERTY_HXX_
-#include <comphelper/property.hxx>
-#endif
-#ifndef _COM_SUN_STAR_SDBCX_XDATADESCRIPTORFACTORY_HPP_
+
+#include <com/sun/star/beans/PropertyValue.hpp>
#include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
-#endif
-#ifndef _COM_SUN_STAR_SDBCX_XAPPEND_HPP_
#include <com/sun/star/sdbcx/XAppend.hpp>
-#endif
-#ifndef _TOOLS_DEBUG_HXX
+
+#include <comphelper/property.hxx>
#include <tools/debug.hxx>
-#endif
+#include <tools/diagnose_ex.h>
//........................................................................
namespace dbaccess
{
//........................................................................
+
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::beans;
using namespace ::com::sun::star::container;
using namespace ::com::sun::star::sdbcx;
+ using namespace ::com::sun::star::lang;
-DBG_NAME(OPropertyForward)
-OPropertyForward::OPropertyForward(const Reference< XPropertySet>& _xSource
- ,const Reference< XNameAccess>& _xDestContainer
- ,const ::rtl::OUString& _sName
- ,const ::std::vector< ::rtl::OUString>& _aPropertyList)
- : m_xSource(_xSource)
- , m_xDestContainer(_xDestContainer)
- , m_sName(_sName)
- , m_bInInsert(sal_False)
-{
- DBG_CTOR(OPropertyForward,NULL);
- OSL_ENSURE(_xDestContainer.is(),"OPropertyForward::OPropertyForward: destination should be valid!");
- OSL_ENSURE(m_xSource.is(),"OPropertyForward::OPropertyForward: source must be valid!");
- osl_incrementInterlockedCount(&m_refCount);
- try
+ DBG_NAME(OPropertyForward)
+
+ //------------------------------------------------------------------------
+ OPropertyForward::OPropertyForward( const Reference< XPropertySet>& _xSource, const Reference< XNameAccess>& _xDestContainer,
+ const ::rtl::OUString& _sName, const ::std::vector< ::rtl::OUString>& _aPropertyList )
+ :m_xSource( _xSource, UNO_SET_THROW )
+ ,m_xDestContainer( _xDestContainer, UNO_SET_THROW )
+ ,m_sName( _sName )
+ ,m_bInInsert( sal_False )
{
- if ( _aPropertyList.empty() )
- _xSource->addPropertyChangeListener(::rtl::OUString(), this);
- else
+ DBG_CTOR(OPropertyForward,NULL);
+
+ osl_incrementInterlockedCount(&m_refCount);
+ try
{
- ::std::vector< ::rtl::OUString>::const_iterator aIter = _aPropertyList.begin();
- ::std::vector< ::rtl::OUString>::const_iterator aEnd = _aPropertyList.end();
- for (; aIter != aEnd ; ++aIter )
- _xSource->addPropertyChangeListener(*aIter, this);
+ if ( _aPropertyList.empty() )
+ _xSource->addPropertyChangeListener( ::rtl::OUString(), this );
+ else
+ {
+ ::std::vector< ::rtl::OUString >::const_iterator aIter = _aPropertyList.begin();
+ ::std::vector< ::rtl::OUString >::const_iterator aEnd = _aPropertyList.end();
+ for (; aIter != aEnd ; ++aIter )
+ _xSource->addPropertyChangeListener( *aIter, this );
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
}
+ osl_decrementInterlockedCount( &m_refCount );
}
- catch(Exception&)
+
+ // -----------------------------------------------------------------------------
+ OPropertyForward::~OPropertyForward()
{
- OSL_ENSURE(sal_False, "OPropertyForward::OPropertyForward: caught an exception!");
+ DBG_DTOR(OPropertyForward,NULL);
}
- osl_decrementInterlockedCount(&m_refCount);
-}
-// -----------------------------------------------------------------------------
-OPropertyForward::~OPropertyForward()
-{
- DBG_DTOR(OPropertyForward,NULL);
-}
-// -----------------------------------------------------------------------------
-void SAL_CALL OPropertyForward::propertyChange( const PropertyChangeEvent& evt ) throw(RuntimeException)
-{
- ::osl::MutexGuard aGuard(m_aMutex);
- if ( m_xDestContainer.is() )
+
+ // -----------------------------------------------------------------------------
+ void SAL_CALL OPropertyForward::propertyChange( const PropertyChangeEvent& evt ) throw(RuntimeException)
{
- if ( m_xDestContainer->hasByName(m_sName) )
- {
- m_xDest.set(m_xDestContainer->getByName(m_sName),UNO_QUERY);
- }
- else
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( !m_xDestContainer.is() )
+ throw DisposedException( ::rtl::OUString(), *this );
+
+ try
{
- Reference<XDataDescriptorFactory> xFactory(m_xDestContainer,UNO_QUERY);
- if ( xFactory.is() )
+ if ( !m_xDest.is() )
{
- m_xDest = xFactory->createDataDescriptor();
- if ( m_xDest.is() )
+ if ( m_xDestContainer->hasByName( m_sName ) )
+ {
+ m_xDest.set( m_xDestContainer->getByName( m_sName ), UNO_QUERY_THROW );
+ }
+ else
{
- ::comphelper::copyProperties(m_xSource,m_xDest);
+ Reference< XDataDescriptorFactory > xFactory( m_xDestContainer, UNO_QUERY_THROW );
+ m_xDest.set( xFactory->createDataDescriptor(), UNO_SET_THROW );
+
+ ::comphelper::copyProperties( m_xSource, m_xDest );
+
m_bInInsert = sal_True;
- Reference<XAppend> xAppend(m_xDestContainer,UNO_QUERY);
- if ( xAppend.is() )
- xAppend->appendByDescriptor(m_xDest);
+ Reference< XAppend > xAppend( m_xDestContainer, UNO_QUERY_THROW );
+ xAppend->appendByDescriptor( m_xDest );
m_bInInsert = sal_False;
}
+
+ m_xDestInfo.set( m_xDest->getPropertySetInfo(), UNO_SET_THROW );
}
+
+ if ( m_xDestInfo->hasPropertyByName( evt.PropertyName ) )
+ {
+ m_xDest->setPropertyValue( evt.PropertyName, evt.NewValue );
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
}
- if ( m_xDest.is() )
- m_xDestInfo = m_xDest->getPropertySetInfo();
}
- if ( m_xDestInfo.is() && m_xDestInfo->hasPropertyByName(evt.PropertyName) )
+ // -----------------------------------------------------------------------------
+ void SAL_CALL OPropertyForward::disposing( const ::com::sun::star::lang::EventObject& /*_rSource*/ ) throw (RuntimeException)
{
- m_xDest->setPropertyValue(evt.PropertyName,evt.NewValue);
- }
-}
-// -----------------------------------------------------------------------------
-void SAL_CALL OPropertyForward::disposing( const ::com::sun::star::lang::EventObject& /*_rSource*/ ) throw (RuntimeException)
-{
- ::osl::MutexGuard aGuard(m_aMutex);
- if ( m_xSource.is() )
- {
- m_xSource->removePropertyChangeListener(::rtl::OUString(), this);
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+ if ( !m_xSource.is() )
+ throw DisposedException( ::rtl::OUString(), *this );
+
+ m_xSource->removePropertyChangeListener( ::rtl::OUString(), this );
m_xSource = NULL;
+ m_xDestContainer = NULL;
+ m_xDestInfo = NULL;
+ m_xDest = NULL;
}
- m_xDestContainer = NULL;
- m_xDestInfo = NULL;
- m_xDest = NULL;
-}
-// -----------------------------------------------------------------------------
-void OPropertyForward::setDefinition(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _xDest)
-{
- ::osl::MutexGuard aGuard(m_aMutex);
- if ( !m_bInInsert )
+
+ // -----------------------------------------------------------------------------
+ void OPropertyForward::setDefinition( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _xDest )
{
- OSL_ENSURE( !m_xDest.is(),"Definition object is already set!");
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if ( m_bInInsert )
+ return;
- m_xDest = _xDest;
- if ( m_xDest.is() )
+ OSL_ENSURE( !m_xDest.is(), "OPropertyForward::setDefinition: definition object is already set!" );
+ try
{
- m_xDestInfo = m_xDest->getPropertySetInfo();
- ::comphelper::copyProperties(m_xDest,m_xSource);
+ m_xDest.set( _xDest, UNO_SET_THROW );
+ m_xDestInfo.set( m_xDest->getPropertySetInfo(), UNO_SET_THROW );
+ ::comphelper::copyProperties( m_xDest, m_xSource );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
}
}
-}
+
//........................................................................
} // namespace dbaccess
//........................................................................
diff --git a/dbaccess/source/ui/browser/sbagrid.cxx b/dbaccess/source/ui/browser/sbagrid.cxx
index 1ca1a737dfd2..d75411cb7997 100644
--- a/dbaccess/source/ui/browser/sbagrid.cxx
+++ b/dbaccess/source/ui/browser/sbagrid.cxx
@@ -985,13 +985,13 @@ void SbaGridControl::PreExecuteRowContextMenu(sal_uInt16 nRow, PopupMenu& rMenu)
rMenu.SetHelpId(ID_BROWSER_ROWHEIGHT, aNewItems.GetHelpId(ID_BROWSER_ROWHEIGHT));
rMenu.InsertSeparator(nPos++);
} // if (!IsReadOnlyDB())
-
- if ( GetSelectRowCount() > 0 )
- {
- rMenu.InsertItem(ID_BROWSER_COPY, aNewItems.GetItemText(SID_COPY), 0, nPos++);
- rMenu.SetHelpId(ID_BROWSER_COPY, aNewItems.GetHelpId(SID_COPY));
-
- rMenu.InsertSeparator(nPos++);
+
+ if ( GetSelectRowCount() > 0 )
+ {
+ rMenu.InsertItem(ID_BROWSER_COPY, aNewItems.GetItemText(SID_COPY), 0, nPos++);
+ rMenu.SetHelpId(ID_BROWSER_COPY, aNewItems.GetHelpId(SID_COPY));
+
+ rMenu.InsertSeparator(nPos++);
}
}
@@ -1428,20 +1428,20 @@ void SbaGridControl::DoColumnDrag(sal_uInt16 nColumnPos)
}
// -----------------------------------------------------------------------
-void SbaGridControl::CopySelectedRowsToClipboard()
-{
- DBG_ASSERT( GetSelectRowCount() > 0, "SbaGridControl::CopySelectedRowsToClipboard: invalid call!" );
- implTransferSelectedRows( (sal_Int16)FirstSelectedRow(), true );
-}
-
-// -----------------------------------------------------------------------
-void SbaGridControl::DoRowDrag( sal_Int16 nRowPos )
-{
- implTransferSelectedRows( nRowPos, false );
-}
-
-// -----------------------------------------------------------------------
-void SbaGridControl::implTransferSelectedRows( sal_Int16 nRowPos, bool _bTrueIfClipboardFalseIfDrag )
+void SbaGridControl::CopySelectedRowsToClipboard()
+{
+ DBG_ASSERT( GetSelectRowCount() > 0, "SbaGridControl::CopySelectedRowsToClipboard: invalid call!" );
+ implTransferSelectedRows( (sal_Int16)FirstSelectedRow(), true );
+}
+
+// -----------------------------------------------------------------------
+void SbaGridControl::DoRowDrag( sal_Int16 nRowPos )
+{
+ implTransferSelectedRows( nRowPos, false );
+}
+
+// -----------------------------------------------------------------------
+void SbaGridControl::implTransferSelectedRows( sal_Int16 nRowPos, bool _bTrueIfClipboardFalseIfDrag )
{
Reference< XPropertySet > xDataSource(getDataSource(), UNO_QUERY);
DBG_ASSERT(xDataSource.is(), "SbaGridControl::implTransferSelectedRows : invalid data source !");
@@ -1478,8 +1478,8 @@ void SbaGridControl::implTransferSelectedRows( sal_Int16 nRowPos, bool _bTrueIfC
ODataClipboard* pTransfer = new ODataClipboard(xDataSource, aSelectedRows,xRowSetClone, getServiceManager());
Reference< XTransferable > xEnsureDelete = pTransfer;
- if ( _bTrueIfClipboardFalseIfDrag )
- pTransfer->CopyToClipboard( this );
+ if ( _bTrueIfClipboardFalseIfDrag )
+ pTransfer->CopyToClipboard( this );
else
pTransfer->StartDrag(this, DND_ACTION_COPY | DND_ACTION_LINK);
}
diff --git a/dbaccess/source/ui/browser/unodatbr.cxx b/dbaccess/source/ui/browser/unodatbr.cxx
index 8f2528e1f96a..9f3403b690c5 100644
--- a/dbaccess/source/ui/browser/unodatbr.cxx
+++ b/dbaccess/source/ui/browser/unodatbr.cxx
@@ -77,6 +77,7 @@
#include <com/sun/star/sdb/SQLContext.hpp>
#include <com/sun/star/sdb/XBookmarksSupplier.hpp>
#include <com/sun/star/sdb/XCompletedConnection.hpp>
+#include <com/sun/star/sdb/XDatabaseRegistrations.hpp>
#include <com/sun/star/sdb/XDocumentDataSource.hpp>
#include <com/sun/star/sdb/XParametersSupplier.hpp>
#include <com/sun/star/sdb/XQueriesSupplier.hpp>
@@ -109,6 +110,7 @@
#include <comphelper/sequence.hxx>
#include <comphelper/types.hxx>
#include <connectivity/dbexception.hxx>
+#include <cppuhelper/exc_hlp.hxx>
#include <cppuhelper/implbase2.hxx>
#include <cppuhelper/typeprovider.hxx>
#include <sfx2/app.hxx>
@@ -197,25 +199,21 @@ void SafeRemovePropertyListener(const Reference< XPropertySet > & xSet, const ::
//-------------------------------------------------------------------------
::rtl::OUString SAL_CALL SbaTableQueryBrowser::getImplementationName() throw(RuntimeException)
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::getImplementationName" );
return getImplementationName_Static();
}
//-------------------------------------------------------------------------
::comphelper::StringSequence SAL_CALL SbaTableQueryBrowser::getSupportedServiceNames() throw(RuntimeException)
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::getSupportedServiceNames" );
return getSupportedServiceNames_Static();
}
// -------------------------------------------------------------------------
::rtl::OUString SbaTableQueryBrowser::getImplementationName_Static() throw(RuntimeException)
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::getImplementationName_Static" );
return ::rtl::OUString::createFromAscii("org.openoffice.comp.dbu.ODatasourceBrowser");
}
//-------------------------------------------------------------------------
::comphelper::StringSequence SbaTableQueryBrowser::getSupportedServiceNames_Static() throw(RuntimeException)
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::getSupportedServiceNames_Static" );
::comphelper::StringSequence aSupported(1);
aSupported.getArray()[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdb.DataSourceBrowser");
return aSupported;
@@ -223,7 +221,6 @@ void SafeRemovePropertyListener(const Reference< XPropertySet > & xSet, const ::
//-------------------------------------------------------------------------
Reference< XInterface > SAL_CALL SbaTableQueryBrowser::Create(const Reference<XMultiServiceFactory >& _rxFactory)
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::Create" );
::vos::OGuard aGuard(Application::GetSolarMutex());
return *(new SbaTableQueryBrowser(_rxFactory));
}
@@ -246,7 +243,6 @@ SbaTableQueryBrowser::SbaTableQueryBrowser(const Reference< XMultiServiceFactory
,m_bInSuspend(sal_False)
,m_bEnableBrowser(sal_True)
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::SbaTableQueryBrowser" );
DBG_CTOR(SbaTableQueryBrowser,NULL);
}
@@ -266,7 +262,6 @@ SbaTableQueryBrowser::~SbaTableQueryBrowser()
//------------------------------------------------------------------------------
Any SAL_CALL SbaTableQueryBrowser::queryInterface(const Type& _rType) throw (RuntimeException)
{
- //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::queryInterface" );
if ( _rType.equals( XScriptInvocationContext::static_type() ) )
{
OSL_PRECOND( !!m_aDocScriptSupport, "SbaTableQueryBrowser::queryInterface: did not initialize this, yet!" );
@@ -284,7 +279,6 @@ Any SAL_CALL SbaTableQueryBrowser::queryInterface(const Type& _rType) throw (Run
//------------------------------------------------------------------------------
Sequence< Type > SAL_CALL SbaTableQueryBrowser::getTypes( ) throw (RuntimeException)
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::getTypes" );
Sequence< Type > aTypes( ::comphelper::concatSequences(
SbaXDataBrowserController::getTypes(),
SbaTableQueryBrowser_Base::getTypes()
@@ -308,7 +302,6 @@ Sequence< Type > SAL_CALL SbaTableQueryBrowser::getTypes( ) throw (RuntimeExcep
//------------------------------------------------------------------------------
Sequence< sal_Int8 > SAL_CALL SbaTableQueryBrowser::getImplementationId( ) throw (RuntimeException)
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::getImplementationId" );
static ::cppu::OImplementationId * pId = 0;
if (! pId)
{
@@ -325,7 +318,6 @@ Sequence< sal_Int8 > SAL_CALL SbaTableQueryBrowser::getImplementationId( ) thro
//------------------------------------------------------------------------------
void SAL_CALL SbaTableQueryBrowser::disposing()
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::disposing" );
::vos::OGuard aGuard(Application::GetSolarMutex());
// doin' a lot of VCL stuff here -> lock the SolarMutex
@@ -350,9 +342,15 @@ void SAL_CALL SbaTableQueryBrowser::disposing()
implRemoveStatusListeners();
// remove the container listener from the database context
- Reference< XContainer > xDatasourceContainer(m_xDatabaseContext, UNO_QUERY);
- if (xDatasourceContainer.is())
- xDatasourceContainer->removeContainerListener(this);
+ try
+ {
+ Reference< XDatabaseRegistrations > xDatabaseRegistrations( m_xDatabaseContext, UNO_QUERY_THROW );
+ xDatabaseRegistrations->removeDatabaseRegistrationsListener( this );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
// check out from all the objects we are listening
// the frame
@@ -364,23 +362,17 @@ void SAL_CALL SbaTableQueryBrowser::disposing()
//------------------------------------------------------------------------------
sal_Bool SbaTableQueryBrowser::Construct(Window* pParent)
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::Construct" );
- if (!SbaXDataBrowserController::Construct(pParent))
+ if ( !SbaXDataBrowserController::Construct( pParent ) )
return sal_False;
try
{
- Reference< XContainer > xDatasourceContainer(m_xDatabaseContext, UNO_QUERY);
- if (xDatasourceContainer.is())
- xDatasourceContainer->addContainerListener(this);
- else {
- DBG_ERROR("SbaTableQueryBrowser::Construct: the DatabaseContext should allow us to be a listener!");
- }
+ Reference< XDatabaseRegistrations > xDatabaseRegistrations( m_xDatabaseContext, UNO_QUERY_THROW );
+ xDatabaseRegistrations->addDatabaseRegistrationsListener( this );
// the collator for the string compares
- m_xCollator = Reference< XCollator >(getORB()->createInstance(::rtl::OUString::createFromAscii("com.sun.star.i18n.Collator")), UNO_QUERY);
- if (m_xCollator.is())
- m_xCollator->loadDefaultCollator(Application::GetSettings().GetLocale(), 0);
+ m_xCollator = Reference< XCollator >( getORB()->createInstance(::rtl::OUString::createFromAscii( "com.sun.star.i18n.Collator" ) ), UNO_QUERY_THROW );
+ m_xCollator->loadDefaultCollator( Application::GetSettings().GetLocale(), 0 );
}
catch(Exception&)
{
@@ -433,7 +425,6 @@ sal_Bool SbaTableQueryBrowser::Construct(Window* pParent)
// -------------------------------------------------------------------------
sal_Bool SbaTableQueryBrowser::InitializeForm(const Reference< ::com::sun::star::sdbc::XRowSet > & _rxForm)
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::InitializeForm" );
if(!m_pCurrentlyDisplayed)
return sal_True;
@@ -490,7 +481,6 @@ sal_Bool SbaTableQueryBrowser::InitializeForm(const Reference< ::com::sun::star:
//------------------------------------------------------------------------------
void SbaTableQueryBrowser::initializePreviewMode()
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::initializePreviewMode" );
if ( getBrowserView() && getBrowserView()->getVclControl() )
{
getBrowserView()->getVclControl()->AlwaysEnableInput( FALSE );
@@ -509,7 +499,6 @@ void SbaTableQueryBrowser::initializePreviewMode()
//------------------------------------------------------------------------------
sal_Bool SbaTableQueryBrowser::InitializeGridModel(const Reference< ::com::sun::star::form::XFormComponent > & xGrid)
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::InitializeGridModel" );
try
{
Reference< ::com::sun::star::form::XGridColumnFactory > xColFactory(xGrid, UNO_QUERY);
@@ -633,6 +622,7 @@ sal_Bool SbaTableQueryBrowser::InitializeGridModel(const Reference< ::com::sun::
break;
case DataType::LONGVARCHAR:
+ case DataType::CLOB:
aInitialValues.push_back( NamedValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MultiLine" ) ), makeAny( (sal_Bool)sal_True ) ) );
// NO break!
case DataType::BINARY:
@@ -750,7 +740,6 @@ Reference<XPropertySet> getColumnHelper(SvLBoxEntry* _pCurrentlyDisplayed,const
// -----------------------------------------------------------------------
void SbaTableQueryBrowser::transferChangedControlProperty(const ::rtl::OUString& _rProperty, const Any& _rNewValue)
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::transferChangedControlProperty" );
if(m_pCurrentlyDisplayed)
{
DBTreeListUserData* pData = static_cast<DBTreeListUserData*>(m_pCurrentlyDisplayed->GetUserData());
@@ -764,7 +753,6 @@ void SbaTableQueryBrowser::transferChangedControlProperty(const ::rtl::OUString&
// -----------------------------------------------------------------------
void SbaTableQueryBrowser::propertyChange(const PropertyChangeEvent& evt) throw(::com::sun::star::uno::RuntimeException)
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::propertyChange" );
SbaXDataBrowserController::propertyChange(evt);
try
@@ -873,7 +861,6 @@ void SbaTableQueryBrowser::propertyChange(const PropertyChangeEvent& evt) throw(
// -----------------------------------------------------------------------
sal_Bool SbaTableQueryBrowser::suspend(sal_Bool bSuspend) throw( RuntimeException )
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::suspend" );
vos::OGuard aSolarGuard( Application::GetSolarMutex() );
::osl::MutexGuard aGuard( getMutex() );
if ( getView() && getView()->IsInModalMode() )
@@ -898,7 +885,6 @@ sal_Bool SbaTableQueryBrowser::suspend(sal_Bool bSuspend) throw( RuntimeExceptio
// -------------------------------------------------------------------------
void SAL_CALL SbaTableQueryBrowser::statusChanged( const FeatureStateEvent& _rEvent ) throw(RuntimeException)
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::statusChanged" );
// search the external dispatcher causing this call
Reference< XDispatch > xSource(_rEvent.Source, UNO_QUERY);
ExternalFeaturesMap::iterator aLoop;
@@ -953,7 +939,6 @@ void SAL_CALL SbaTableQueryBrowser::statusChanged( const FeatureStateEvent& _rEv
// -------------------------------------------------------------------------
void SbaTableQueryBrowser::checkDocumentDataSource()
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::checkDocumentDataSource" );
SvLBoxEntry* pDataSourceEntry = NULL;
SvLBoxEntry* pContainerEntry = NULL;
SvLBoxEntry* pObjectEntry = getObjectEntry( m_aDocumentDataSource, &pDataSourceEntry, &pContainerEntry, sal_False );
@@ -991,7 +976,6 @@ void SbaTableQueryBrowser::checkDocumentDataSource()
// -------------------------------------------------------------------------
void SbaTableQueryBrowser::extractDescriptorProps(const ::svx::ODataAccessDescriptor& _rDescriptor, ::rtl::OUString& _rDataSource, ::rtl::OUString& _rCommand, sal_Int32& _rCommandType, sal_Bool& _rEscapeProcessing)
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::extractDescriptorProps" );
_rDataSource = _rDescriptor.getDataSource();
if ( _rDescriptor.has(daCommand) )
_rDescriptor[daCommand] >>= _rCommand;
@@ -1043,7 +1027,6 @@ namespace
// -------------------------------------------------------------------------
String SbaTableQueryBrowser::getDataSourceAcessor( SvLBoxEntry* _pDataSourceEntry ) const
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::getDataSourceAcessor" );
DBG_ASSERT( _pDataSourceEntry, "SbaTableQueryBrowser::getDataSourceAcessor: invalid entry!" );
DBTreeListUserData* pData = static_cast< DBTreeListUserData* >( _pDataSourceEntry->GetUserData() );
@@ -1057,7 +1040,6 @@ SvLBoxEntry* SbaTableQueryBrowser::getObjectEntry(const ::rtl::OUString& _rDataS
SvLBoxEntry** _ppDataSourceEntry, SvLBoxEntry** _ppContainerEntry, sal_Bool _bExpandAncestors,
const SharedConnection& _rxConnection )
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::getObjectEntry" );
if (_ppDataSourceEntry)
*_ppDataSourceEntry = NULL;
if (_ppContainerEntry)
@@ -1080,9 +1062,7 @@ SvLBoxEntry* SbaTableQueryBrowser::getObjectEntry(const ::rtl::OUString& _rDataS
{
// special case, the data source is a URL
// add new entries to the list box model
- Image a, b, c; // not interested in reusing them
- String e, f;
- implAddDatasource( _rDataSource, a, e, b, f, c, _rxConnection );
+ implAddDatasource( _rDataSource, _rxConnection );
pDataSource = m_pTreeView->getListBox().GetEntryPosByName( sDisplayName, NULL, &aFilter );
DBG_ASSERT( pDataSource, "SbaTableQueryBrowser::getObjectEntry: hmm - did not find it again!" );
}
@@ -1132,7 +1112,6 @@ SvLBoxEntry* SbaTableQueryBrowser::getObjectEntry(const ::svx::ODataAccessDescri
SvLBoxEntry** _ppDataSourceEntry, SvLBoxEntry** _ppContainerEntry,
sal_Bool _bExpandAncestors)
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::getObjectEntry" );
// extract the props from the descriptor
::rtl::OUString sDataSource;
::rtl::OUString sCommand;
@@ -1146,7 +1125,6 @@ SvLBoxEntry* SbaTableQueryBrowser::getObjectEntry(const ::svx::ODataAccessDescri
// -------------------------------------------------------------------------
void SbaTableQueryBrowser::connectExternalDispatches()
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::connectExternalDispatches" );
Reference< XDispatchProvider > xProvider( getFrame(), UNO_QUERY );
DBG_ASSERT(xProvider.is(), "SbaTableQueryBrowser::connectExternalDispatches: no DispatchProvider !");
if (xProvider.is())
@@ -1213,7 +1191,6 @@ void SbaTableQueryBrowser::connectExternalDispatches()
// -------------------------------------------------------------------------
void SbaTableQueryBrowser::implCheckExternalSlot( sal_uInt16 _nId )
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::implCheckExternalSlot" );
if ( !m_xMainToolbar.is() )
return;
@@ -1236,7 +1213,6 @@ void SbaTableQueryBrowser::implCheckExternalSlot( sal_uInt16 _nId )
// -------------------------------------------------------------------------
void SAL_CALL SbaTableQueryBrowser::disposing( const EventObject& _rSource ) throw(RuntimeException)
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::disposing" );
// our frame ?
Reference< ::com::sun::star::frame::XFrame > xSourceFrame(_rSource.Source, UNO_QUERY);
if (m_xCurrentFrameParent.is() && (xSourceFrame == m_xCurrentFrameParent))
@@ -1299,7 +1275,6 @@ void SAL_CALL SbaTableQueryBrowser::disposing( const EventObject& _rSource ) thr
// -------------------------------------------------------------------------
void SbaTableQueryBrowser::implRemoveStatusListeners()
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::implRemoveStatusListeners" );
// clear all old dispatches
for ( ExternalFeaturesMap::const_iterator aLoop = m_aExternalFeatures.begin();
aLoop != m_aExternalFeatures.end();
@@ -1324,7 +1299,6 @@ void SbaTableQueryBrowser::implRemoveStatusListeners()
// -------------------------------------------------------------------------
sal_Bool SAL_CALL SbaTableQueryBrowser::select( const Any& _rSelection ) throw (IllegalArgumentException, RuntimeException)
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::select" );
::vos::OGuard aGuard(Application::GetSolarMutex());
// doin' a lot of VCL stuff here -> lock the SolarMutex
@@ -1354,7 +1328,6 @@ sal_Bool SAL_CALL SbaTableQueryBrowser::select( const Any& _rSelection ) throw (
// -------------------------------------------------------------------------
Any SAL_CALL SbaTableQueryBrowser::getSelection( ) throw (RuntimeException)
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::getSelection" );
Any aReturn;
try
@@ -1382,21 +1355,18 @@ Any SAL_CALL SbaTableQueryBrowser::getSelection( ) throw (RuntimeException)
// -------------------------------------------------------------------------
void SAL_CALL SbaTableQueryBrowser::addSelectionChangeListener( const Reference< XSelectionChangeListener >& _rxListener ) throw (RuntimeException)
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::addSelectionChangeListener" );
m_aSelectionListeners.addInterface(_rxListener);
}
// -------------------------------------------------------------------------
void SAL_CALL SbaTableQueryBrowser::removeSelectionChangeListener( const Reference< XSelectionChangeListener >& _rxListener ) throw (RuntimeException)
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::removeSelectionChangeListener" );
m_aSelectionListeners.removeInterface(_rxListener);
}
// -------------------------------------------------------------------------
void SbaTableQueryBrowser::attachFrame(const Reference< ::com::sun::star::frame::XFrame > & _xFrame) throw( RuntimeException )
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::attachFrame" );
implRemoveStatusListeners();
if (m_xCurrentFrameParent.is())
@@ -1441,7 +1411,6 @@ void SbaTableQueryBrowser::attachFrame(const Reference< ::com::sun::star::frame:
// -------------------------------------------------------------------------
void SbaTableQueryBrowser::addModelListeners(const Reference< ::com::sun::star::awt::XControlModel > & _xGridControlModel)
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::addModelListeners" );
SbaXDataBrowserController::addModelListeners(_xGridControlModel);
Reference< XPropertySet > xSourceSet(_xGridControlModel, UNO_QUERY);
if (xSourceSet.is())
@@ -1459,7 +1428,6 @@ void SbaTableQueryBrowser::addModelListeners(const Reference< ::com::sun::star::
// -------------------------------------------------------------------------
void SbaTableQueryBrowser::removeModelListeners(const Reference< ::com::sun::star::awt::XControlModel > & _xGridControlModel)
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::removeModelListeners" );
SbaXDataBrowserController::removeModelListeners(_xGridControlModel);
Reference< XPropertySet > xSourceSet(_xGridControlModel, UNO_QUERY);
if (xSourceSet.is())
@@ -1475,7 +1443,6 @@ void SbaTableQueryBrowser::removeModelListeners(const Reference< ::com::sun::sta
// -------------------------------------------------------------------------
void SbaTableQueryBrowser::RowChanged()
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::RowChanged" );
if(getBrowserView())
{
SbaGridControl* pControl = getBrowserView()->getVclControl();
@@ -1488,7 +1455,6 @@ void SbaTableQueryBrowser::RowChanged()
// -------------------------------------------------------------------------
void SbaTableQueryBrowser::ColumnChanged()
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::ColumnChanged" );
if(getBrowserView())
{
SbaGridControl* pControl = getBrowserView()->getVclControl();
@@ -1500,7 +1466,6 @@ void SbaTableQueryBrowser::ColumnChanged()
//------------------------------------------------------------------------------
void SbaTableQueryBrowser::AddColumnListener(const Reference< XPropertySet > & xCol)
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::AddColumnListener" );
SbaXDataBrowserController::AddColumnListener(xCol);
SafeAddPropertyListener(xCol, PROPERTY_WIDTH, static_cast<XPropertyChangeListener*>(this));
SafeAddPropertyListener(xCol, PROPERTY_HIDDEN, static_cast<XPropertyChangeListener*>(this));
@@ -1511,7 +1476,6 @@ void SbaTableQueryBrowser::AddColumnListener(const Reference< XPropertySet > & x
//------------------------------------------------------------------------------
void SbaTableQueryBrowser::RemoveColumnListener(const Reference< XPropertySet > & xCol)
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::RemoveColumnListener" );
SbaXDataBrowserController::RemoveColumnListener(xCol);
SafeRemovePropertyListener(xCol, PROPERTY_WIDTH, static_cast<XPropertyChangeListener*>(this));
SafeRemovePropertyListener(xCol, PROPERTY_HIDDEN, static_cast<XPropertyChangeListener*>(this));
@@ -1522,7 +1486,6 @@ void SbaTableQueryBrowser::RemoveColumnListener(const Reference< XPropertySet >
//------------------------------------------------------------------------------
void SbaTableQueryBrowser::criticalFail()
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::criticalFail" );
SbaXDataBrowserController::criticalFail();
unloadAndCleanup( sal_False );
}
@@ -1530,7 +1493,6 @@ void SbaTableQueryBrowser::criticalFail()
//------------------------------------------------------------------------------
void SbaTableQueryBrowser::LoadFinished(sal_Bool _bWasSynch)
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::LoadFinished" );
SbaXDataBrowserController::LoadFinished(_bWasSynch);
m_sQueryCommand = ::rtl::OUString();
@@ -1552,7 +1514,6 @@ void SbaTableQueryBrowser::LoadFinished(sal_Bool _bWasSynch)
//------------------------------------------------------------------------------
sal_Bool SbaTableQueryBrowser::getExternalSlotState( sal_uInt16 _nId ) const
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::getExternalSlotState" );
sal_Bool bEnabled = sal_False;
ExternalFeaturesMap::const_iterator aPos = m_aExternalFeatures.find( _nId );
if ( ( m_aExternalFeatures.end() != aPos ) && aPos->second.xDispatcher.is() )
@@ -1563,7 +1524,6 @@ sal_Bool SbaTableQueryBrowser::getExternalSlotState( sal_uInt16 _nId ) const
//------------------------------------------------------------------------------
FeatureState SbaTableQueryBrowser::GetState(sal_uInt16 nId) const
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::GetState" );
FeatureState aReturn;
// (disabled automatically)
@@ -1765,7 +1725,6 @@ FeatureState SbaTableQueryBrowser::GetState(sal_uInt16 nId) const
//------------------------------------------------------------------------------
void SbaTableQueryBrowser::Execute(sal_uInt16 nId, const Sequence< PropertyValue >& aArgs)
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::Execute" );
switch (nId)
{
default:
@@ -1951,12 +1910,20 @@ void SbaTableQueryBrowser::Execute(sal_uInt16 nId, const Sequence< PropertyValue
break;
}
}
+
+// -------------------------------------------------------------------------
+void SbaTableQueryBrowser::implAddDatasource( const String& _rDataSourceName, const SharedConnection& _rxConnection )
+{
+ Image a, b, c;
+ String d, e;
+ implAddDatasource( _rDataSourceName, a, d, b, e, c, _rxConnection );
+}
+
// -------------------------------------------------------------------------
void SbaTableQueryBrowser::implAddDatasource(const String& _rDbName, Image& _rDbImage,
String& _rQueryName, Image& _rQueryImage, String& _rTableName, Image& _rTableImage,
const SharedConnection& _rxConnection)
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::implAddDatasource" );
vos::OGuard aGuard( Application::GetSolarMutex() );
// initialize the names/images if necessary
if (!_rQueryName.Len())
@@ -2010,7 +1977,6 @@ void SbaTableQueryBrowser::implAddDatasource(const String& _rDbName, Image& _rDb
// -------------------------------------------------------------------------
void SbaTableQueryBrowser::initializeTreeModel()
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::initializeTreeModel" );
if (m_xDatabaseContext.is())
{
Image aDBImage, aQueriesImage, aTablesImage;
@@ -2029,7 +1995,6 @@ sal_Bool SbaTableQueryBrowser::populateTree(const Reference<XNameAccess>& _xName
SvLBoxEntry* _pParent,
EntryType _eEntryType)
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::populateTree" );
DBTreeListUserData* pData = static_cast<DBTreeListUserData*>(_pParent->GetUserData());
if(pData) // don't ask if the nameaccess is already set see OnExpandEntry views and tables
pData->xContainer = _xNameAccess;
@@ -2060,7 +2025,6 @@ sal_Bool SbaTableQueryBrowser::populateTree(const Reference<XNameAccess>& _xName
//------------------------------------------------------------------------------
void SbaTableQueryBrowser::implAppendEntry( SvLBoxEntry* _pParent, const String& _rName, void* _pUserData, EntryType _eEntryType )
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::implAppendEntry" );
::std::auto_ptr< ImageProvider > pImageProvider( getImageProviderFor( _pParent ) );
Image aImage, aImageHC;
@@ -2077,7 +2041,6 @@ void SbaTableQueryBrowser::implAppendEntry( SvLBoxEntry* _pParent, const String&
//------------------------------------------------------------------------------
IMPL_LINK(SbaTableQueryBrowser, OnExpandEntry, SvLBoxEntry*, _pParent)
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::OnExpandEntry" );
if (_pParent->HasChilds())
// nothing to to ...
return 1L;
@@ -2180,7 +2143,6 @@ IMPL_LINK(SbaTableQueryBrowser, OnExpandEntry, SvLBoxEntry*, _pParent)
//------------------------------------------------------------------------------
sal_Bool SbaTableQueryBrowser::ensureEntryObject( SvLBoxEntry* _pEntry )
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::ensureEntryObject" );
DBG_ASSERT(_pEntry, "SbaTableQueryBrowser::ensureEntryObject: invalid argument!");
if (!_pEntry)
return sal_False;
@@ -2240,7 +2202,6 @@ sal_Bool SbaTableQueryBrowser::ensureEntryObject( SvLBoxEntry* _pEntry )
//------------------------------------------------------------------------------
sal_Bool SbaTableQueryBrowser::implSelect(const ::svx::ODataAccessDescriptor& _rDescriptor,sal_Bool _bSelectDirect)
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::implSelect(_rDescriptor,_bSelectDirect)" );
// extract the props
::rtl::OUString sDataSource;
::rtl::OUString sCommand;
@@ -2256,7 +2217,6 @@ sal_Bool SbaTableQueryBrowser::implSelect(const ::svx::ODataAccessDescriptor& _r
sal_Bool SbaTableQueryBrowser::implLoadAnything(const ::rtl::OUString& _rDataSourceName, const ::rtl::OUString& _rCommand,
const sal_Int32 _nCommandType, const sal_Bool _bEscapeProcessing, const SharedConnection& _rxConnection)
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::implLoadAnything" );
Reference<XPropertySet> xProp(getRowSet(),UNO_QUERY);
if(xProp.is())
{
@@ -2274,8 +2234,6 @@ sal_Bool SbaTableQueryBrowser::implLoadAnything(const ::rtl::OUString& _rDataSou
xProp->setPropertyValue(PROPERTY_ESCAPE_PROCESSING, ::cppu::bool2any(_bEscapeProcessing));
if ( m_bPreview )
{
- // this be undone by the grid control in DbGridControl::RecalcRows
- // xProp->setPropertyValue(PROPERTY_FETCHSIZE, makeAny(sal_Int32(20)));
xProp->setPropertyValue(PROPERTY_FETCHDIRECTION, makeAny(FetchDirection::FORWARD));
}
@@ -2310,21 +2268,24 @@ sal_Bool SbaTableQueryBrowser::implLoadAnything(const ::rtl::OUString& _rDataSou
InvalidateAll();
return bSuccess;
}
- catch(SQLException& e)
+ catch( const SQLException& e )
{
- showError(SQLExceptionInfo(e));
+ Any aException( ::cppu::getCaughtException() );
+ showError( SQLExceptionInfo( aException ) );
}
- catch(WrappedTargetException& e)
+ catch( const WrappedTargetException& e )
{
SQLException aSql;
- if(e.TargetException >>= aSql)
- showError(SQLExceptionInfo(aSql));
+ if ( e.TargetException.isExtractableTo( ::cppu::UnoType< SQLException >::get() ) )
+ showError( SQLExceptionInfo( e.TargetException ) );
else
- OSL_ENSURE(sal_False, "SbaTableQueryBrowser::implLoadAnything: something strange happended!");
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
}
catch(Exception&)
{
- OSL_ENSURE(sal_False, "SbaTableQueryBrowser::implLoadAnything: something strange happended!");
+ DBG_UNHANDLED_EXCEPTION();
}
}
@@ -2338,7 +2299,6 @@ sal_Bool SbaTableQueryBrowser::implSelect(const ::rtl::OUString& _rDataSourceNam
const SharedConnection& _rxConnection
,sal_Bool _bSelectDirect)
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::implSelect(_rDataSourceName,_rCommand,...)" );
if (_rDataSourceName.getLength() && _rCommand.getLength() && (-1 != _nCommandType))
{
SvLBoxEntry* pDataSource = NULL;
@@ -2387,7 +2347,6 @@ IMPL_LINK(SbaTableQueryBrowser, OnSelectionChange, void*, /*NOINTERESTEDIN*/)
//------------------------------------------------------------------------------
bool SbaTableQueryBrowser::implSelect( SvLBoxEntry* _pEntry )
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::implSelect(_pEntry)" );
if ( !_pEntry )
return false;
@@ -2581,7 +2540,6 @@ bool SbaTableQueryBrowser::implSelect( SvLBoxEntry* _pEntry )
// -----------------------------------------------------------------------------
SvLBoxEntry* SbaTableQueryBrowser::getEntryFromContainer(const Reference<XNameAccess>& _rxNameAccess)
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::getEntryFromContainer" );
DBTreeListBox& rListBox = m_pTreeView->getListBox();
SvLBoxEntry* pContainer = NULL;
SvLBoxEntry* pDSLoop = rListBox.FirstChild(NULL);
@@ -2606,7 +2564,6 @@ SvLBoxEntry* SbaTableQueryBrowser::getEntryFromContainer(const Reference<XNameAc
// -------------------------------------------------------------------------
void SAL_CALL SbaTableQueryBrowser::elementInserted( const ContainerEvent& _rEvent ) throw(RuntimeException)
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::elementInserted" );
vos::OGuard aSolarGuard( Application::GetSolarMutex() );
Reference< XNameAccess > xNames(_rEvent.Source, UNO_QUERY);
@@ -2638,24 +2595,12 @@ void SAL_CALL SbaTableQueryBrowser::elementInserted( const ContainerEvent& _rEve
}
implAppendEntry( pEntry, ::comphelper::getString( _rEvent.Accessor ), pNewData, pNewData->eType );
}
- else if (xNames.get() == m_xDatabaseContext.get())
- { // a new datasource has been added to the context
- // the name of the new ds
- ::rtl::OUString sNewDS;
- _rEvent.Accessor >>= sNewDS;
-
- // add new entries to the list box model
- Image a, b, c; // not interested in reusing them
- String e, f;
- implAddDatasource( sNewDS, a, e, b, f, c, SharedConnection() );
- }
else
SbaXDataBrowserController::elementInserted(_rEvent);
}
// -------------------------------------------------------------------------
sal_Bool SbaTableQueryBrowser::isCurrentlyDisplayedChanged(const String& _sName,SvLBoxEntry* _pContainer)
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::isCurrentlyDisplayedChanged" );
return m_pCurrentlyDisplayed
&& getEntryType(m_pCurrentlyDisplayed) == getChildType(_pContainer)
&& m_pTreeView->getListBox().GetParent(m_pCurrentlyDisplayed) == _pContainer
@@ -2664,7 +2609,6 @@ sal_Bool SbaTableQueryBrowser::isCurrentlyDisplayedChanged(const String& _sName,
// -------------------------------------------------------------------------
void SAL_CALL SbaTableQueryBrowser::elementRemoved( const ContainerEvent& _rEvent ) throw(RuntimeException)
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::elementRemoved" );
::vos::OGuard aSolarGuard(Application::GetSolarMutex());
Reference< XNameAccess > xNames(_rEvent.Source, UNO_QUERY);
@@ -2711,62 +2655,6 @@ void SAL_CALL SbaTableQueryBrowser::elementRemoved( const ContainerEvent& _rEven
// maybe the object which is part of the document data source has been removed
checkDocumentDataSource();
}
- else if (xNames.get() == m_xDatabaseContext.get())
- { // a datasource has been removed from the context
-
- // the name
- ::rtl::OUString sNewDS;
- _rEvent.Accessor >>= sNewDS;
- String sNewDatasource = sNewDS;
-
- // get the top-level representing the removed data source
- SvLBoxEntry* pDSLoop = m_pTreeView->getListBox().FirstChild(NULL);
- while (pDSLoop)
- {
- if (m_pTreeView->getListBox().GetEntryText(pDSLoop) == sNewDatasource)
- break;
-
- pDSLoop = m_pTreeView->getListBox().NextSibling(pDSLoop);
- }
-
- if (pDSLoop)
- {
- if (isSelected(pDSLoop))
- { // a table or query belonging to the deleted data source is currently beeing displayed.
- OSL_ENSURE(m_pTreeView->getListBox().GetRootLevelParent(m_pCurrentlyDisplayed) == pDSLoop, "SbaTableQueryBrowser::elementRemoved: inconsistence (1)!");
- unloadAndCleanup( sal_True );
- }
- else
- OSL_ENSURE(
- (NULL == m_pCurrentlyDisplayed)
- || (m_pTreeView->getListBox().GetRootLevelParent(m_pCurrentlyDisplayed) != pDSLoop), "SbaTableQueryBrowser::elementRemoved: inconsistence (2)!");
-
- // look for user data to delete
- SvTreeEntryList* pList = m_pTreeModel->GetChildList(pDSLoop);
- if(pList)
- {
- SvLBoxEntry* pEntryLoop = static_cast<SvLBoxEntry*>(pList->First());
- while (pEntryLoop)
- {
- DBTreeListUserData* pData = static_cast<DBTreeListUserData*>(pEntryLoop->GetUserData());
- pEntryLoop->SetUserData(NULL);
- delete pData;
- pEntryLoop = static_cast<SvLBoxEntry*>(pList->Next());
- }
- }
- // remove the entry. This should remove all children, too.
- DBTreeListUserData* pData = static_cast<DBTreeListUserData*>(pDSLoop->GetUserData());
- pDSLoop->SetUserData(NULL);
- delete pData;
- m_pTreeModel->Remove(pDSLoop);
- }
- else {
- DBG_ERROR("SbaTableQueryBrowser::elementRemoved: unknown datasource name!");
- }
-
- // maybe the object which is part of the document data source has been removed
- checkDocumentDataSource();
- }
else
SbaXDataBrowserController::elementRemoved(_rEvent);
}
@@ -2774,7 +2662,6 @@ void SAL_CALL SbaTableQueryBrowser::elementRemoved( const ContainerEvent& _rEven
// -------------------------------------------------------------------------
void SAL_CALL SbaTableQueryBrowser::elementReplaced( const ContainerEvent& _rEvent ) throw(RuntimeException)
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::elementReplaced" );
::vos::OGuard aSolarGuard(Application::GetSolarMutex());
Reference< XNameAccess > xNames(_rEvent.Source, UNO_QUERY);
@@ -2847,7 +2734,6 @@ void SAL_CALL SbaTableQueryBrowser::elementReplaced( const ContainerEvent& _rEve
// -------------------------------------------------------------------------
void SbaTableQueryBrowser::impl_releaseConnection( SharedConnection& _rxConnection )
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::impl_releaseConnection" );
// remove as event listener
Reference< XComponent > xComponent( _rxConnection, UNO_QUERY );
if ( xComponent.is() )
@@ -2876,7 +2762,6 @@ void SbaTableQueryBrowser::impl_releaseConnection( SharedConnection& _rxConnecti
// -------------------------------------------------------------------------
void SbaTableQueryBrowser::disposeConnection( SvLBoxEntry* _pDSEntry )
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::disposeConnection" );
DBG_ASSERT( _pDSEntry, "SbaTableQueryBrowser::disposeConnection: invalid entry (NULL)!" );
DBG_ASSERT( impl_isDataSourceEntry( _pDSEntry ), "SbaTableQueryBrowser::disposeConnection: invalid entry (not top-level)!" );
@@ -2891,7 +2776,6 @@ void SbaTableQueryBrowser::disposeConnection( SvLBoxEntry* _pDSEntry )
// -------------------------------------------------------------------------
void SbaTableQueryBrowser::closeConnection(SvLBoxEntry* _pDSEntry,sal_Bool _bDisposeConnection)
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::closeConnection" );
DBG_ASSERT(_pDSEntry, "SbaTableQueryBrowser::closeConnection: invalid entry (NULL)!");
DBG_ASSERT( impl_isDataSourceEntry( _pDSEntry ), "SbaTableQueryBrowser::closeConnection: invalid entry (not top-level)!");
@@ -2928,7 +2812,6 @@ void SbaTableQueryBrowser::closeConnection(SvLBoxEntry* _pDSEntry,sal_Bool _bDis
// -------------------------------------------------------------------------
void SbaTableQueryBrowser::unloadAndCleanup( sal_Bool _bDisposeConnection )
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::unloadAndCleanup" );
if (!m_pCurrentlyDisplayed)
// nothing to do
return;
@@ -3016,7 +2899,6 @@ namespace
// -------------------------------------------------------------------------
void SbaTableQueryBrowser::impl_initialize()
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::impl_initialize" );
::vos::OGuard aGuard(Application::GetSolarMutex());
// doin' a lot of VCL stuff here -> lock the SolarMutex
@@ -3150,12 +3032,7 @@ void SbaTableQueryBrowser::impl_initialize()
}
}
- Image aDBImage, aQueriesImage, aTablesImage;
- String sQueriesName, sTablesName;
-
- implAddDatasource( sInitialDataSourceName,
- aDBImage, sQueriesName, aQueriesImage, sTablesName, aTablesImage, xConnection
- );
+ implAddDatasource( sInitialDataSourceName, xConnection );
m_pTreeView->getListBox().Expand( m_pTreeView->getListBox().First() );
}
else
@@ -3196,14 +3073,12 @@ void SbaTableQueryBrowser::impl_initialize()
// -------------------------------------------------------------------------
sal_Bool SbaTableQueryBrowser::haveExplorer() const
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::haveExplorer" );
return m_pTreeView && m_pTreeView->IsVisible();
}
// -------------------------------------------------------------------------
void SbaTableQueryBrowser::hideExplorer()
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::hideExplorer" );
if (!haveExplorer())
return;
if (!getBrowserView())
@@ -3219,7 +3094,6 @@ void SbaTableQueryBrowser::hideExplorer()
// -------------------------------------------------------------------------
void SbaTableQueryBrowser::showExplorer()
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::showExplorer" );
if (haveExplorer())
return;
@@ -3236,7 +3110,6 @@ void SbaTableQueryBrowser::showExplorer()
// -----------------------------------------------------------------------------
sal_Bool SbaTableQueryBrowser::ensureConnection(SvLBoxEntry* _pAnyEntry, SharedConnection& _rConnection)
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::ensureConnection" );
SvLBoxEntry* pDSEntry = m_pTreeView->getListBox().GetRootLevelParent(_pAnyEntry);
DBTreeListUserData* pDSData =
pDSEntry
@@ -3249,7 +3122,6 @@ sal_Bool SbaTableQueryBrowser::ensureConnection(SvLBoxEntry* _pAnyEntry, SharedC
// -----------------------------------------------------------------------------
::std::auto_ptr< ImageProvider > SbaTableQueryBrowser::getImageProviderFor( SvLBoxEntry* _pAnyEntry )
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::getImageProviderFor" );
::std::auto_ptr< ImageProvider > pImageProvider( new ImageProvider );
SharedConnection xConnection;
if ( getExistentConnectionFor( _pAnyEntry, xConnection ) )
@@ -3260,7 +3132,6 @@ sal_Bool SbaTableQueryBrowser::ensureConnection(SvLBoxEntry* _pAnyEntry, SharedC
// -----------------------------------------------------------------------------
sal_Bool SbaTableQueryBrowser::getExistentConnectionFor( SvLBoxEntry* _pAnyEntry, SharedConnection& _rConnection )
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::getExistentConnectionFor" );
SvLBoxEntry* pDSEntry = m_pTreeView->getListBox().GetRootLevelParent( _pAnyEntry );
DBTreeListUserData* pDSData =
pDSEntry
@@ -3275,7 +3146,6 @@ sal_Bool SbaTableQueryBrowser::getExistentConnectionFor( SvLBoxEntry* _pAnyEntry
// -----------------------------------------------------------------------------
bool SbaTableQueryBrowser::impl_isDataSourceEntry( SvLBoxEntry* _pEntry ) const
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::impl_isDataSourceEntry" );
return m_pTreeModel->GetRootLevelParent( _pEntry ) == _pEntry;
}
#endif
@@ -3283,7 +3153,6 @@ bool SbaTableQueryBrowser::impl_isDataSourceEntry( SvLBoxEntry* _pEntry ) const
// -----------------------------------------------------------------------------
sal_Bool SbaTableQueryBrowser::ensureConnection( SvLBoxEntry* _pDSEntry, void* pDSData, SharedConnection& _rConnection )
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::ensureConnection" );
DBG_ASSERT( impl_isDataSourceEntry( _pDSEntry ), "SbaTableQueryBrowser::ensureConnection: this entry does not denote a data source!" );
if(_pDSEntry)
{
@@ -3386,7 +3255,6 @@ IMPL_LINK( SbaTableQueryBrowser, OnTreeEntryCompare, const SvSortData*, _pSortDa
// -----------------------------------------------------------------------------
void SbaTableQueryBrowser::implAdministrate( SvLBoxEntry* _pApplyTo )
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::implAdministrate" );
OSL_PRECOND( _pApplyTo, "SbaTableQueryBrowser::implAdministrate: illegal entry!" );
if ( !_pApplyTo )
return;
@@ -3444,7 +3312,6 @@ void SbaTableQueryBrowser::implAdministrate( SvLBoxEntry* _pApplyTo )
// -----------------------------------------------------------------------------
sal_Bool SbaTableQueryBrowser::requestQuickHelp( const SvLBoxEntry* _pEntry, String& _rText ) const
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::requestQuickHelp" );
const DBTreeListUserData* pData = static_cast< const DBTreeListUserData* >( _pEntry->GetUserData() );
if ( ( pData->eType == etDatasource ) && pData->sAccessor.Len() )
{
@@ -3457,7 +3324,6 @@ sal_Bool SbaTableQueryBrowser::requestQuickHelp( const SvLBoxEntry* _pEntry, Str
// -----------------------------------------------------------------------------
PopupMenu* SbaTableQueryBrowser::getContextMenu( Control& _rControl ) const
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::getContextMenu" );
OSL_PRECOND( &m_pTreeView->getListBox() == &_rControl,
"SbaTableQueryBrowser::getContextMenu: where does this come from?" );
if ( &m_pTreeView->getListBox() != &_rControl )
@@ -3469,21 +3335,18 @@ PopupMenu* SbaTableQueryBrowser::getContextMenu( Control& _rControl ) const
// -----------------------------------------------------------------------------
IController& SbaTableQueryBrowser::getCommandController()
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::getCommandController" );
return *this;
}
// -----------------------------------------------------------------------------
::cppu::OInterfaceContainerHelper* SbaTableQueryBrowser::getContextMenuInterceptors()
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::getContextMenuInterceptors" );
return &m_aContextMenuInterceptors;
}
// -----------------------------------------------------------------------------
Any SbaTableQueryBrowser::getCurrentSelection( Control& _rControl ) const
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::getCurrentSelection" );
OSL_PRECOND( &m_pTreeView->getListBox() == &_rControl,
"SbaTableQueryBrowser::getCurrentSelection: where does this come from?" );
@@ -3525,7 +3388,6 @@ Any SbaTableQueryBrowser::getCurrentSelection( Control& _rControl ) const
// -----------------------------------------------------------------------------
sal_Bool SbaTableQueryBrowser::implGetQuerySignature( ::rtl::OUString& _rCommand, sal_Bool& _bEscapeProcessing )
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::implGetQuerySignature" );
_rCommand = ::rtl::OUString();
_bEscapeProcessing = sal_False;
@@ -3574,7 +3436,6 @@ sal_Bool SbaTableQueryBrowser::implGetQuerySignature( ::rtl::OUString& _rCommand
//------------------------------------------------------------------------------
void SbaTableQueryBrowser::frameAction(const ::com::sun::star::frame::FrameActionEvent& aEvent) throw( RuntimeException )
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::frameAction" );
if (aEvent.Frame == m_xCurrentFrameParent)
{
if(aEvent.Action == FrameAction_COMPONENT_DETACHING)
@@ -3589,7 +3450,6 @@ void SbaTableQueryBrowser::frameAction(const ::com::sun::star::frame::FrameActio
// -----------------------------------------------------------------------------
void SbaTableQueryBrowser::clearGridColumns(const Reference< XNameContainer >& _xColContainer)
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::clearGridColumns" );
// first we have to clear the grid
Sequence< ::rtl::OUString > aNames = _xColContainer->getElementNames();
const ::rtl::OUString* pIter = aNames.getConstArray();
@@ -3605,7 +3465,6 @@ void SbaTableQueryBrowser::clearGridColumns(const Reference< XNameContainer >& _
// -----------------------------------------------------------------------------
sal_Bool SbaTableQueryBrowser::isHiContrast() const
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::isHiContrast" );
sal_Bool bRet = sal_False;
if ( m_pTreeView )
bRet = m_pTreeView->getListBox().GetBackground().GetColor().IsDark();
@@ -3614,7 +3473,6 @@ sal_Bool SbaTableQueryBrowser::isHiContrast() const
// -----------------------------------------------------------------------------
void SbaTableQueryBrowser::loadMenu(const Reference< XFrame >& _xFrame)
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::loadMenu" );
if ( m_bShowMenu )
{
OGenericUnoController::loadMenu(_xFrame);
@@ -3636,7 +3494,6 @@ void SbaTableQueryBrowser::loadMenu(const Reference< XFrame >& _xFrame)
// -----------------------------------------------------------------------------
::rtl::OUString SbaTableQueryBrowser::getPrivateTitle() const
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::getPrivateTitle" );
::rtl::OUString sTitle;
if ( m_pCurrentlyDisplayed )
{
@@ -3661,7 +3518,6 @@ void SbaTableQueryBrowser::loadMenu(const Reference< XFrame >& _xFrame)
// -----------------------------------------------------------------------------
sal_Bool SbaTableQueryBrowser::preReloadForm()
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::preReloadForm" );
sal_Bool bIni = sal_False;
if ( !m_pCurrentlyDisplayed )
{
@@ -3690,7 +3546,6 @@ sal_Bool SbaTableQueryBrowser::preReloadForm()
// -----------------------------------------------------------------------------
void SbaTableQueryBrowser::postReloadForm()
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::postReloadForm" );
InitializeGridModel(getFormComponent());
LoadFinished(sal_True);
//updateTitle();
@@ -3699,7 +3554,6 @@ void SbaTableQueryBrowser::postReloadForm()
//------------------------------------------------------------------------------
Reference< XEmbeddedScripts > SAL_CALL SbaTableQueryBrowser::getScriptContainer() throw (RuntimeException)
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::getScriptContainer" );
// update our database document
Reference< XModel > xDocument;
try
@@ -3726,7 +3580,6 @@ Reference< XEmbeddedScripts > SAL_CALL SbaTableQueryBrowser::getScriptContainer(
//------------------------------------------------------------------------------
void SAL_CALL SbaTableQueryBrowser::registerContextMenuInterceptor( const Reference< XContextMenuInterceptor >& _Interceptor ) throw (RuntimeException)
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::registerContextMenuInterceptor" );
if ( _Interceptor.is() )
m_aContextMenuInterceptors.addInterface( _Interceptor );
}
@@ -3734,10 +3587,90 @@ void SAL_CALL SbaTableQueryBrowser::registerContextMenuInterceptor( const Refere
//------------------------------------------------------------------------------
void SAL_CALL SbaTableQueryBrowser::releaseContextMenuInterceptor( const Reference< XContextMenuInterceptor >& _Interceptor ) throw (RuntimeException)
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::releaseContextMenuInterceptor" );
- m_aContextMenuInterceptors.removeInterface( _Interceptor );
+ if ( _Interceptor.is() )
+ m_aContextMenuInterceptors.removeInterface( _Interceptor );
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL SbaTableQueryBrowser::registeredDatabaseLocation( const DatabaseRegistrationEvent& _Event ) throw (RuntimeException)
+{
+ ::vos::OGuard aGuard( Application::GetSolarMutex() );
+ implAddDatasource( _Event.Name, SharedConnection() );
}
+//------------------------------------------------------------------------------
+void SbaTableQueryBrowser::impl_cleanupDataSourceEntry( const String& _rDataSourceName )
+{
+ // get the top-level representing the removed data source
+ SvLBoxEntry* pDataSourceEntry = m_pTreeView->getListBox().FirstChild( NULL );
+ while ( pDataSourceEntry )
+ {
+ if ( m_pTreeView->getListBox().GetEntryText( pDataSourceEntry ) == _rDataSourceName )
+ break;
+
+ pDataSourceEntry = m_pTreeView->getListBox().NextSibling( pDataSourceEntry );
+ }
+
+ OSL_ENSURE( pDataSourceEntry, "SbaTableQueryBrowser::impl_cleanupDataSourceEntry: do not know this data source!" );
+ if ( !pDataSourceEntry )
+ return;
+
+ if ( isSelected( pDataSourceEntry ) )
+ { // a table or query belonging to the deleted data source is currently beeing displayed.
+ OSL_ENSURE( m_pTreeView->getListBox().GetRootLevelParent( m_pCurrentlyDisplayed ) == pDataSourceEntry,
+ "SbaTableQueryBrowser::impl_cleanupDataSourceEntry: inconsistence (1)!" );
+ unloadAndCleanup( sal_True );
+ }
+ else
+ OSL_ENSURE(
+ ( NULL == m_pCurrentlyDisplayed )
+ || ( m_pTreeView->getListBox().GetRootLevelParent( m_pCurrentlyDisplayed ) != pDataSourceEntry ),
+ "SbaTableQueryBrowser::impl_cleanupDataSourceEntry: inconsistence (2)!");
+
+ // delete any user data of the child entries of the to-be-removed entry
+ SvTreeEntryList* pList = m_pTreeModel->GetChildList( pDataSourceEntry );
+ if ( pList )
+ {
+ SvLBoxEntry* pEntryLoop = static_cast<SvLBoxEntry*>( pList->First() );
+ while ( pEntryLoop )
+ {
+ DBTreeListUserData* pData = static_cast< DBTreeListUserData* >( pEntryLoop->GetUserData() );
+ pEntryLoop->SetUserData( NULL );
+ delete pData;
+ pEntryLoop = static_cast< SvLBoxEntry* >( pList->Next() );
+ }
+ }
+
+ // remove the entry
+ DBTreeListUserData* pData = static_cast< DBTreeListUserData* >( pDataSourceEntry->GetUserData() );
+ pDataSourceEntry->SetUserData( NULL );
+ delete pData;
+ m_pTreeModel->Remove( pDataSourceEntry );
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL SbaTableQueryBrowser::revokedDatabaseLocation( const DatabaseRegistrationEvent& _Event ) throw (RuntimeException)
+{
+ ::vos::OGuard aGuard( Application::GetSolarMutex() );
+
+ impl_cleanupDataSourceEntry( _Event.Name );
+
+ // maybe the object which is part of the document data source has been removed
+ checkDocumentDataSource();
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL SbaTableQueryBrowser::changedDatabaseLocation( const DatabaseRegistrationEvent& _Event ) throw (RuntimeException)
+{
+ ::vos::OGuard aGuard( Application::GetSolarMutex() );
+
+ // in case the data source was expanded, and connected, we need to clean it up
+ // for simplicity, just do as if the data source were completely removed and re-added
+ impl_cleanupDataSourceEntry( _Event.Name );
+ implAddDatasource( _Event.Name, SharedConnection() );
+}
+
+
// .........................................................................
} // namespace dbaui
// .........................................................................
diff --git a/dbaccess/source/ui/control/FieldDescControl.cxx b/dbaccess/source/ui/control/FieldDescControl.cxx
index 8c7f94a2ac39..e0f4e0de7666 100644
--- a/dbaccess/source/ui/control/FieldDescControl.cxx
+++ b/dbaccess/source/ui/control/FieldDescControl.cxx
@@ -1375,6 +1375,14 @@ void OFieldDescControl::DisplayData(OFieldDescription* pFieldDescr )
ActivateAggregate( tpFormat );
break;
case DataType::BIT:
+ if ( pFieldType->aCreateParams.getLength() )
+ {
+ DeactivateAggregate( tpFormat );
+ DeactivateAggregate( tpTextLen );
+ DeactivateAggregate( tpBoolDefault );
+ break;
+ }
+ // run through
case DataType::BOOLEAN:
DeactivateAggregate( tpTextLen );
DeactivateAggregate( tpFormat );
@@ -1473,7 +1481,9 @@ void OFieldDescControl::DisplayData(OFieldDescription* pFieldDescr )
if( pBoolDefault )
{
// wenn pRequired auf sal_True gesetzt ist, dann darf das sal_Bool Feld nicht den Eintrag <<keiner>> besitzen
- String sDef = BoolStringUI(::comphelper::getString(pFieldDescr->GetControlDefault()));
+ ::rtl::OUString sValue;
+ pFieldDescr->GetControlDefault() >>= sValue;
+ String sDef = BoolStringUI(sValue);
// sicher stellen das <<keiner>> nur vorhanden ist, wenn das Feld NULL sein darf
if ( ( pFieldType.get() && !pFieldType->bNullable ) || !pFieldDescr->IsNullable() )
diff --git a/dbaccess/source/ui/inc/TypeInfo.hxx b/dbaccess/source/ui/inc/TypeInfo.hxx
index b44daeba3beb..ee5a5235da68 100644
--- a/dbaccess/source/ui/inc/TypeInfo.hxx
+++ b/dbaccess/source/ui/inc/TypeInfo.hxx
@@ -83,6 +83,7 @@ const sal_uInt16 TYPE_BLOB = 27;
const sal_uInt16 TYPE_CLOB = 28;
const sal_uInt16 TYPE_REF = 29;
const sal_uInt16 TYPE_OTHER = 30;
+const sal_uInt16 TYPE_BIT = 31;
class OTypeInfo
{
diff --git a/dbaccess/source/ui/inc/unodatbr.hxx b/dbaccess/source/ui/inc/unodatbr.hxx
index c6315cc1db22..23d9cfd5b542 100644
--- a/dbaccess/source/ui/inc/unodatbr.hxx
+++ b/dbaccess/source/ui/inc/unodatbr.hxx
@@ -70,8 +70,11 @@
#ifndef _COM_SUN_STAR_SDB_APPLICATION_DATABASEOBJECTCONTAINER_HPP_
#include <com/sun/star/sdb/application/DatabaseObjectContainer.hpp>
#endif
-#ifndef _CPPUHELPER_IMPLBASE4_HXX_
-#include <cppuhelper/implbase4.hxx>
+#ifndef _COM_SUN_STAR_SDB_DATABASEOBJECTCONTAINER_HPP_
+#include <com/sun/star/sdb/XDatabaseRegistrationsListener.hpp>
+#endif
+#ifndef _CPPUHELPER_IMPLBASE5_HXX_
+#include <cppuhelper/implbase5.hxx>
#endif
#ifndef _DBACCESS_UI_CALLBACKS_HXX_
#include "callbacks.hxx"
@@ -113,10 +116,11 @@ namespace dbaui
class ImageProvider;
// =====================================================================
- typedef ::cppu::ImplHelper4 < ::com::sun::star::frame::XStatusListener
+ typedef ::cppu::ImplHelper5 < ::com::sun::star::frame::XStatusListener
, ::com::sun::star::view::XSelectionSupplier
, ::com::sun::star::document::XScriptInvocationContext
, ::com::sun::star::ui::XContextMenuInterception
+ , ::com::sun::star::sdb::XDatabaseRegistrationsListener
> SbaTableQueryBrowser_Base;
class SbaTableQueryBrowser
:public SbaXDataBrowserController
@@ -256,6 +260,11 @@ namespace dbaui
virtual void SAL_CALL registerContextMenuInterceptor( const ::com::sun::star::uno::Reference< ::com::sun::star::ui::XContextMenuInterceptor >& Interceptor ) throw (::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL releaseContextMenuInterceptor( const ::com::sun::star::uno::Reference< ::com::sun::star::ui::XContextMenuInterceptor >& Interceptor ) throw (::com::sun::star::uno::RuntimeException);
+ // XDatabaseRegistrationsListener
+ virtual void SAL_CALL registeredDatabaseLocation( const ::com::sun::star::sdb::DatabaseRegistrationEvent& Event ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL revokedDatabaseLocation( const ::com::sun::star::sdb::DatabaseRegistrationEvent& Event ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL changedDatabaseLocation( const ::com::sun::star::sdb::DatabaseRegistrationEvent& Event ) throw (::com::sun::star::uno::RuntimeException);
+
protected:
// SbaXDataBrowserController overridables
virtual sal_Bool InitializeForm(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet > & xForm);
@@ -339,6 +348,11 @@ namespace dbaui
const SharedConnection& _rxConnection
);
+ void implAddDatasource( const String& _rDataSourceName, const SharedConnection& _rxConnection );
+
+ /// removes (and cleans up) the entry for the given data source
+ void impl_cleanupDataSourceEntry( const String& _rDataSourceName );
+
/// clears the tree list box
void clearTreeModel();
diff --git a/dbaccess/source/ui/misc/RowSetDrop.cxx b/dbaccess/source/ui/misc/RowSetDrop.cxx
index 53b1105c6aba..2c679ba22da8 100644
--- a/dbaccess/source/ui/misc/RowSetDrop.cxx
+++ b/dbaccess/source/ui/misc/RowSetDrop.cxx
@@ -237,6 +237,12 @@ sal_Bool ORowSetImportExport::insertNewRow()
case DataType::VARBINARY:
aValue <<= m_xRow->getBytes(*aIter);
break;
+ case DataType::BLOB:
+ aValue <<= m_xRow->getBlob(*aIter);
+ break;
+ case DataType::CLOB:
+ aValue <<= m_xRow->getClob(*aIter);
+ break;
default:
OSL_ENSURE(0,"Unknown type");
}
diff --git a/dbaccess/source/ui/misc/UITools.cxx b/dbaccess/source/ui/misc/UITools.cxx
index 25a6299bae12..8d97d4829173 100644
--- a/dbaccess/source/ui/misc/UITools.cxx
+++ b/dbaccess/source/ui/misc/UITools.cxx
@@ -803,6 +803,12 @@ void fillTypeInfo( const Reference< ::com::sun::star::sdbc::XConnection>& _rxCo
aName = _rsTypeNames.GetToken(TYPE_DATETIME);
break;
case DataType::BIT:
+ if ( pInfo->aCreateParams.getLength() )
+ {
+ aName = _rsTypeNames.GetToken(TYPE_BIT);
+ break;
+ }
+ // run through
case DataType::BOOLEAN:
aName = _rsTypeNames.GetToken(TYPE_BOOL);
break;
@@ -1155,7 +1161,7 @@ sal_Bool callColumnFormatDialog(Window* _pParent,
if (_bHasFormat)
{
// if the col is bound to a text field we have to disallow all non-text formats
- if ((DataType::CHAR == _nDataType) || (DataType::VARCHAR == _nDataType) || (DataType::LONGVARCHAR == _nDataType))
+ if ((DataType::CHAR == _nDataType) || (DataType::VARCHAR == _nDataType) || (DataType::LONGVARCHAR == _nDataType) || (DataType::CLOB == _nDataType))
{
bText = sal_True;
pFormatDescriptor->Put(SfxBoolItem(SID_ATTR_NUMBERFORMAT_ONE_AREA, sal_True));
@@ -1622,6 +1628,10 @@ TOTypeInfoSP queryTypeInfoByType(sal_Int32 _nDataType,const OTypeInfoMap& _rType
if ( pTypeInfo = queryTypeInfoByType(DataType::LONGVARCHAR,_rTypeInfo) )
break;
break;
+ case DataType::LONGVARCHAR:
+ if ( pTypeInfo = queryTypeInfoByType(DataType::CLOB,_rTypeInfo) )
+ break;
+ break;
default:
;
} // switch(_nDataType)
diff --git a/dbaccess/source/ui/misc/WCopyTable.cxx b/dbaccess/source/ui/misc/WCopyTable.cxx
index 82fa7b7ec2bf..2b664c02f7e2 100644
--- a/dbaccess/source/ui/misc/WCopyTable.cxx
+++ b/dbaccess/source/ui/misc/WCopyTable.cxx
@@ -633,6 +633,22 @@ OCopyTableWizard::OCopyTableWizard( Window * pParent, const ::rtl::OUString& _rD
if ( !lcl_sameConnection_throw( _xSourceConnection, m_xDestConnection ) )
bAllowViews = false;
+ if ( m_bInterConnectionCopy )
+ {
+ Reference< XDatabaseMetaData > xSrcMeta = _xSourceConnection->getMetaData();
+ ::rtl::OUString sCatalog;
+ ::rtl::OUString sSchema;
+ ::rtl::OUString sTable;
+ ::dbtools::qualifiedNameComponents( xSrcMeta,
+ m_sName,
+ sCatalog,
+ sSchema,
+ sTable,
+ ::dbtools::eInDataManipulation);
+
+ m_sName = ::dbtools::composeTableName(m_xDestConnection->getMetaData(),sCatalog,sSchema,sTable,sal_False,::dbtools::eInTableDefinitions);
+ }
+
OCopyTable* pPage1( new OCopyTable( this ) );
pPage1->disallowUseHeaderLine();
if ( !bAllowViews )
@@ -1581,6 +1597,10 @@ TOTypeInfoSP OCopyTableWizard::convertType(const TOTypeInfoSP& _pType,sal_Bool&
if ( supportsType(DataType::LONGVARCHAR,nDefaultType) )
break;
break;
+ case DataType::LONGVARCHAR:
+ if ( supportsType(DataType::CLOB,nDefaultType) )
+ break;
+ break;
default:
nDefaultType = DataType::VARCHAR;
}
diff --git a/dbaccess/source/ui/misc/controllerframe.cxx b/dbaccess/source/ui/misc/controllerframe.cxx
index e20f5e04b35b..491e27fc49de 100644
--- a/dbaccess/source/ui/misc/controllerframe.cxx
+++ b/dbaccess/source/ui/misc/controllerframe.cxx
@@ -44,6 +44,8 @@
#include <rtl/ref.hxx>
#include <sfx2/objsh.hxx>
#include <tools/diagnose_ex.h>
+#include <toolkit/helper/vclunohelper.hxx>
+#include <vcl/window.hxx>
//........................................................................
namespace dbaui
@@ -77,6 +79,7 @@ namespace dbaui
using ::com::sun::star::lang::DisposedException;
using ::com::sun::star::lang::EventObject;
using ::com::sun::star::document::XDocumentEventBroadcaster;
+ using ::com::sun::star::awt::XWindow;
/** === end UNO using === **/
//====================================================================
@@ -125,7 +128,7 @@ namespace dbaui
,m_xDocEventBroadcaster()
,m_pListener()
,m_bActive( false )
- ,m_bLivesInTopWindow( false )
+ ,m_bIsTopLevelDocumentWindow( false )
{
}
@@ -134,7 +137,7 @@ namespace dbaui
Reference< XDocumentEventBroadcaster > m_xDocEventBroadcaster;
::rtl::Reference< FrameWindowActivationListener > m_pListener;
bool m_bActive;
- bool m_bLivesInTopWindow;
+ bool m_bIsTopLevelDocumentWindow;
};
//====================================================================
@@ -208,7 +211,7 @@ namespace dbaui
if ( !xCompController.is() )
return;
- if ( _rData.m_bActive && _rData.m_bLivesInTopWindow )
+ if ( _rData.m_bActive && _rData.m_bIsTopLevelDocumentWindow )
{
// set the "current component" at the SfxObjectShell
Reference< XModel > xModel( xCompController->getModel() );
@@ -288,9 +291,21 @@ namespace dbaui
void ( SAL_CALL XTopWindow::*pListenerAction )( const Reference< XTopWindowListener >& ) =
_bRegister ? &XTopWindow::addTopWindowListener : &XTopWindow::removeTopWindowListener;
- Reference< XTopWindow > xFrameContainer( m_pData->m_xFrame->getContainerWindow(), UNO_QUERY );
+ const Reference< XWindow > xContainerWindow( m_pData->m_xFrame->getContainerWindow(), UNO_SET_THROW );
if ( _bRegister )
- m_pData->m_bLivesInTopWindow = xFrameContainer.is();
+ {
+ const Window* pContainerWindow = VCLUnoHelper::GetWindow( xContainerWindow );
+ ENSURE_OR_THROW( pContainerWindow, "no Window implementation for the frame's container window!" );
+
+ /*const Window* pContainerParentWindow = pContainerWindow->GetParent();
+ if ( pContainerParentWindow && ( pContainerParentWindow->GetType() == WINDOW_BORDERWINDOW ) )
+ pContainerParentWindow = pContainerParentWindow->GetParent();
+ m_pData->m_bIsTopLevelDocumentWindow = ( pContainerParentWindow == NULL );*/
+
+ m_pData->m_bIsTopLevelDocumentWindow = ( pContainerWindow->GetExtendedStyle() & WB_EXT_DOCUMENT ) != 0;
+ }
+
+ const Reference< XTopWindow > xFrameContainer( xContainerWindow, UNO_QUERY );
if ( xFrameContainer.is() )
(xFrameContainer.get()->*pListenerAction)( this );
}
diff --git a/dbaccess/source/ui/misc/databaseobjectview.cxx b/dbaccess/source/ui/misc/databaseobjectview.cxx
index 259834be1724..26e5b5bafd98 100644
--- a/dbaccess/source/ui/misc/databaseobjectview.cxx
+++ b/dbaccess/source/ui/misc/databaseobjectview.cxx
@@ -31,66 +31,30 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_dbaccess.hxx"
-#ifndef DBACCESS_DATABASE_OBJECT_VIEW_HXX
#include "databaseobjectview.hxx"
-#endif
-#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC
#include "dbustrings.hrc"
-#endif
-#ifndef DBACCESS_ASYNCMODALDIALOG_HXX
#include "asyncmodaldialog.hxx"
-#endif
/** === begin UNO includes === **/
-#ifndef _COM_SUN_STAR_LANG_XSINGLESERVICEFACTORY_HPP_
#include <com/sun/star/lang/XSingleServiceFactory.hpp>
-#endif
-#ifndef _COM_SUN_STAR_FRAME_XDISPATCHPROVIDER_HPP_
#include <com/sun/star/frame/XDispatchProvider.hpp>
-#endif
-#ifndef _COM_SUN_STAR_FRAME_XFRAME_HPP_
#include <com/sun/star/frame/XFrame.hpp>
-#endif
-#ifndef _COM_SUN_STAR_FRAME_XFRAMES_HPP_
#include <com/sun/star/frame/XFrames.hpp>
-#endif
-#ifndef _COM_SUN_STAR_FRAME_FRAMESEARCHFLAG_HPP_
#include <com/sun/star/frame/FrameSearchFlag.hpp>
-#endif
-#ifndef _COM_SUN_STAR_SDB_COMMANDTYPE_HPP_
#include <com/sun/star/sdb/CommandType.hpp>
-#endif
-#ifndef _COM_SUN_STAR_SDB_APPLICATION_XTABLEUIPROVIDER_HPP_
#include <com/sun/star/sdb/application/XTableUIProvider.hpp>
-#endif
-#ifndef _COM_SUN_STAR_BEANS_NAMEDVALUE_HPP_
#include <com/sun/star/beans/NamedValue.hpp>
-#endif
-#ifndef _COM_SUN_STAR_AWT_RECTANGLE_HPP_
#include <com/sun/star/awt/Rectangle.hpp>
-#endif
/** === end UNO includes === **/
-#ifndef _COMPHELPER_EXTRACT_HXX_
#include <comphelper/extract.hxx>
-#endif
-#ifndef _COMPHELPER_SEQUENCE_HXX_
#include <comphelper/sequence.hxx>
-#endif
-#ifndef COMPHELPER_NAMEDVALUECOLLECTION_HXX
#include <comphelper/namedvaluecollection.hxx>
-#endif
-
-#ifndef _CONNECTIVITY_DBTOOLS_HXX_
#include <connectivity/dbtools.hxx>
-#endif
-
-#ifndef _OSL_DIAGNOSE_H_
#include <osl/diagnose.h>
-#endif
-#ifndef TOOLS_DIAGNOSE_EX_H
+#include <toolkit/helper/vclunohelper.hxx>
#include <tools/diagnose_ex.h>
-#endif
+#include <vcl/window.hxx>
// .........................................................................
namespace dbaui
@@ -183,6 +147,15 @@ namespace dbaui
lArgs[nArg++] <<= aProp;
m_xFrameLoader.set(xFact->createInstanceWithArguments(lArgs), UNO_QUERY_THROW);
+
+ // everything we load can be considered a "top level document", so set the respective bit at the window.
+ // This, amongst other things, triggers that the component in this task participates in the
+ // "ThisComponent"-game for the global application Basic.
+ const Reference< XFrame > xFrame( m_xFrameLoader, UNO_QUERY_THROW );
+ const Reference< XWindow > xFrameWindow( xFrame->getContainerWindow(), UNO_SET_THROW );
+ Window* pContainerWindow = VCLUnoHelper::GetWindow( xFrameWindow );
+ ENSURE_OR_THROW( pContainerWindow, "no implementation access to the frame's container window!" );
+ pContainerWindow->SetExtendedStyle( pContainerWindow->GetExtendedStyle() | WB_EXT_DOCUMENT );
}
Reference< XComponentLoader > xFrameLoader( m_xFrameLoader, UNO_QUERY_THROW );
diff --git a/dbaccess/source/ui/misc/linkeddocuments.cxx b/dbaccess/source/ui/misc/linkeddocuments.cxx
index 69ec1dcf4975..9d32d70e2c31 100644
--- a/dbaccess/source/ui/misc/linkeddocuments.cxx
+++ b/dbaccess/source/ui/misc/linkeddocuments.cxx
@@ -349,7 +349,7 @@ namespace dbaui
//------------------------------------------------------------------
Reference< XComponent > OLinkedDocumentsAccess::newDocument( sal_Int32 _nNewFormId, Reference< XComponent >& _xDefinition, const sal_Int32 _nCommandType, const ::rtl::OUString& _sObjectName )
{
- OSL_ENSURE(m_xDocumentContainer.is(), "OLinkedDocumentsAccess::OLinkedDocumentsAccess: invalid document container!");
+ OSL_ENSURE(m_xDocumentContainer.is(), "OLinkedDocumentsAccess::newDocument: invalid document container!");
// determine the URL to use for the new document
Sequence<sal_Int8> aClassId;
switch (_nNewFormId)
@@ -372,7 +372,7 @@ namespace dbaui
case SID_DB_FORM_NEW_PILOT:
default:
- OSL_ENSURE(sal_False, "OLinkedDocumentsAccess::newForm: pleas use newFormWithPilot!");
+ OSL_ENSURE(sal_False, "OLinkedDocumentsAccess::newDocument: please use newFormWithPilot!");
return Reference< XComponent >();
}
diff --git a/dbaccess/source/ui/querydesign/QueryDesignView.cxx b/dbaccess/source/ui/querydesign/QueryDesignView.cxx
index e489a0c2a585..f7f08cd63df5 100644
--- a/dbaccess/source/ui/querydesign/QueryDesignView.cxx
+++ b/dbaccess/source/ui/querydesign/QueryDesignView.cxx
@@ -369,6 +369,7 @@ namespace
case DataType::CHAR:
case DataType::VARCHAR:
case DataType::LONGVARCHAR:
+ case DataType::CLOB:
rNewValue = ::dbtools::quoteName(aQuote,rValue);
break;
case DataType::DECIMAL:
@@ -382,6 +383,7 @@ namespace
case DataType::BINARY:
case DataType::VARBINARY:
case DataType::LONGVARBINARY:
+ case DataType::BLOB:
rNewValue = rValue;
break;
case DataType::BIT:
@@ -1385,6 +1387,9 @@ namespace
// first extract the inner joins conditions
GetInnerJoinCriteria(_pView,pNodeTmp);
+ // now simplify again, join are checked in ComparisonPredicate
+ ::connectivity::OSQLParseNode::absorptions(pNodeTmp);
+ pNodeTmp = pNode->getChild(1);
// it could happen that pCondition is not more valid
eErrorCode = GetORCriteria(_pView,_pSelectionBrw,pNodeTmp, rLevel);
@@ -1395,7 +1400,7 @@ namespace
SqlParseError GetANDCriteria( OQueryDesignView* _pView,
OSelectionBrowseBox* _pSelectionBrw,
const ::connectivity::OSQLParseNode * pCondition,
- const sal_uInt16 nLevel,
+ sal_uInt16& nLevel,
sal_Bool bHaving,
bool bAddOrOnOneLine);
//------------------------------------------------------------------------------
@@ -1432,7 +1437,11 @@ namespace
if ( SQL_ISRULE(pChild,search_condition) )
eErrorCode = GetORCriteria(_pView,_pSelectionBrw,pChild,nLevel,bHaving,bAddOrOnOneLine);
else
- eErrorCode = GetANDCriteria(_pView,_pSelectionBrw,pChild, bAddOrOnOneLine ? nLevel : nLevel++,bHaving, i == 0 ? false : bAddOrOnOneLine);
+ {
+ eErrorCode = GetANDCriteria(_pView,_pSelectionBrw,pChild, nLevel,bHaving, i == 0 ? false : bAddOrOnOneLine);
+ if ( !bAddOrOnOneLine)
+ nLevel++;
+ }
}
}
else
@@ -1466,7 +1475,7 @@ namespace
SqlParseError GetANDCriteria( OQueryDesignView* _pView,
OSelectionBrowseBox* _pSelectionBrw,
const ::connectivity::OSQLParseNode * pCondition,
- const sal_uInt16 nLevel,
+ sal_uInt16& nLevel,
sal_Bool bHaving,
bool bAddOrOnOneLine)
{
@@ -1480,10 +1489,18 @@ namespace
// Runde Klammern
if (SQL_ISRULE(pCondition,boolean_primary))
{
- sal_uInt16 nLevel2 = nLevel;
// check if we have to put the or criteria on one line.
- bool bMustAddOrOnOneLine = CheckOrCriteria(pCondition->getChild(1),NULL);
- eErrorCode = GetORCriteria(_pView,_pSelectionBrw,pCondition->getChild(1), nLevel2,bHaving,bMustAddOrOnOneLine );
+ const ::connectivity::OSQLParseNode* pSearchCondition = pCondition->getChild(1);
+ bool bMustAddOrOnOneLine = CheckOrCriteria(pSearchCondition,NULL);
+ if ( SQL_ISRULE( pSearchCondition, search_condition) ) // we have a or
+ {
+ _pSelectionBrw->DuplicateConditionLevel( nLevel);
+ eErrorCode = GetORCriteria(_pView,_pSelectionBrw,pSearchCondition->getChild(0), nLevel,bHaving,bMustAddOrOnOneLine );
+ ++nLevel;
+ eErrorCode = GetORCriteria(_pView,_pSelectionBrw,pSearchCondition->getChild(2), nLevel,bHaving,bMustAddOrOnOneLine );
+ }
+ else
+ eErrorCode = GetORCriteria(_pView,_pSelectionBrw,pSearchCondition, nLevel,bHaving,bMustAddOrOnOneLine );
}
// Das erste Element ist (wieder) eine AND-Verknuepfung
else if ( SQL_ISRULE(pCondition,boolean_term) )
@@ -1579,10 +1596,32 @@ namespace
_pSelectionBrw->AddCondition(aDragLeft, sCondition, nLevel,bAddOrOnOneLine);
}
}
+ else
+ {
+ // Funktions-Bedingung parsen
+ ::rtl::OUString sCondition = ParseCondition(rController,pCondition,sDecimal,aLocale,1);
+ Reference< XConnection> xConnection = rController.getConnection();
+ Reference< XDatabaseMetaData > xMetaData = xConnection->getMetaData();
+ // the international doesn't matter I have a string
+ ::rtl::OUString sName;
+ pCondition->getChild(0)->parseNodeToPredicateStr(sName,
+ xConnection,
+ rController.getNumberFormatter(),
+ aLocale,
+ static_cast<sal_Char>(sDecimal.toChar()),
+ &rController.getParser().getContext());
+
+ OTableFieldDescRef aDragLeft = new OTableFieldDesc();
+ aDragLeft->SetField(sName);
+ aDragLeft->SetFunctionType(FKT_OTHER);
+
+ if ( bHaving )
+ aDragLeft->SetGroupBy(sal_True);
+ _pSelectionBrw->AddCondition(aDragLeft, sCondition, nLevel,bAddOrOnOneLine);
+ }
}
else if( SQL_ISRULEOR2(pCondition,existence_test,unique_test) )
{
-
// Funktions-Bedingung parsen
::rtl::OUString aCondition = ParseCondition(rController,pCondition,sDecimal,aLocale,0);
diff --git a/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx b/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx
index 6b48bc528776..27ad175c071c 100644
--- a/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx
+++ b/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx
@@ -1207,6 +1207,7 @@ sal_Bool OSelectionBrowseBox::SaveModified()
case DataType::CHAR:
case DataType::VARCHAR:
case DataType::LONGVARCHAR:
+ case DataType::CLOB:
if(aText.GetChar(0) != '\'' || aText.GetChar(aText.Len() -1) != '\'')
{
aText.SearchAndReplaceAll(String::CreateFromAscii("'"),String::CreateFromAscii("''"));
@@ -1836,6 +1837,32 @@ void OSelectionBrowseBox::AddGroupBy( const OTableFieldDescRef& rInfo , sal_uInt
}
}
//------------------------------------------------------------------------------
+void OSelectionBrowseBox::DuplicateConditionLevel( const sal_uInt16 nLevel)
+{
+ DBG_CHKTHIS(OSelectionBrowseBox,NULL);
+ const sal_uInt16 nNewLevel = nLevel +1;
+ OTableFields& rFields = getFields();
+ OTableFields::iterator aIter = rFields.begin();
+ OTableFields::iterator aEnd = rFields.end();
+ for(;aIter != aEnd;++aIter)
+ {
+ OTableFieldDescRef pEntry = *aIter;
+
+ ::rtl::OUString sValue = pEntry->GetCriteria(nLevel);
+ if ( sValue.getLength() )
+ {
+ pEntry->SetCriteria( nNewLevel, sValue);
+ if ( nNewLevel == (m_nVisibleCount-BROW_CRIT1_ROW-1) )
+ {
+ RowInserted( GetRowCount()-1, 1, TRUE );
+ m_bVisibleRow.push_back(sal_True);
+ ++m_nVisibleCount;
+ }
+ m_bVisibleRow[BROW_CRIT1_ROW + nNewLevel] = sal_True;
+ } // if (!pEntry->GetCriteria(nLevel).getLength() )
+ } // for(;aIter != getFields().end();++aIter)
+}
+//------------------------------------------------------------------------------
void OSelectionBrowseBox::AddCondition( const OTableFieldDescRef& rInfo, const String& rValue, const sal_uInt16 nLevel,bool _bAddOrOnOneLine )
{
Reference< XConnection> xConnection = static_cast<OQueryController&>(getDesignView()->getController()).getConnection();
diff --git a/dbaccess/source/ui/querydesign/SelectionBrowseBox.hxx b/dbaccess/source/ui/querydesign/SelectionBrowseBox.hxx
index 1d4a188dab9d..c92ce7caf7f0 100644
--- a/dbaccess/source/ui/querydesign/SelectionBrowseBox.hxx
+++ b/dbaccess/source/ui/querydesign/SelectionBrowseBox.hxx
@@ -132,6 +132,7 @@ namespace dbaui
const String& rValue,
const sal_uInt16 nLevel,
bool _bAddOrOnOneLine );
+ void DuplicateConditionLevel( const sal_uInt16 nLevel);
void AddOrder(const OTableFieldDescRef& rInfo, const EOrderDir eDir, sal_uInt32 _nCurrentPos);
void ClearAll();
OTableFieldDescRef AppendNewCol( sal_uInt16 nCnt=1 );
diff --git a/dbaccess/source/ui/querydesign/querycontainerwindow.cxx b/dbaccess/source/ui/querydesign/querycontainerwindow.cxx
index 2f3a70890e92..785e29bb9a0c 100644
--- a/dbaccess/source/ui/querydesign/querycontainerwindow.cxx
+++ b/dbaccess/source/ui/querydesign/querycontainerwindow.cxx
@@ -229,16 +229,17 @@ namespace dbaui
Reference < XFrame > xBeamerFrame( m_pViewSwitch->getORB()->createInstance(::rtl::OUString::createFromAscii("com.sun.star.frame.Frame")),UNO_QUERY );
m_xBeamer.set( xBeamerFrame );
+ OSL_ENSURE(m_xBeamer.is(),"No frame created!");
+ m_xBeamer->initialize( VCLUnoHelper::GetInterface ( m_pBeamer ) );
// notify layout manager to not create internal toolbars
Reference < XPropertySet > xPropSet( xBeamerFrame, UNO_QUERY );
try
{
const ::rtl::OUString aLayoutManager( RTL_CONSTASCII_USTRINGPARAM( "LayoutManager" ));
- Reference < XPropertySet > xLMPropSet;
+ Reference < XPropertySet > xLMPropSet(xPropSet->getPropertyValue( aLayoutManager ),UNO_QUERY);
- Any a = xPropSet->getPropertyValue( aLayoutManager );
- if ( a >>= xLMPropSet )
+ if ( xLMPropSet.is() )
{
const ::rtl::OUString aAutomaticToolbars( RTL_CONSTASCII_USTRINGPARAM( "AutomaticToolbars" ));
xLMPropSet->setPropertyValue( aAutomaticToolbars, Any( sal_False ));
@@ -248,8 +249,6 @@ namespace dbaui
{
}
- OSL_ENSURE(m_xBeamer.is(),"No frame created!");
- m_xBeamer->initialize( VCLUnoHelper::GetInterface ( m_pBeamer ) );
m_xBeamer->setName(FRAME_NAME_QUERY_PREVIEW);
// append our frame
diff --git a/dbaccess/source/ui/tabledesign/FieldDescriptions.cxx b/dbaccess/source/ui/tabledesign/FieldDescriptions.cxx
index 699a2db8404b..6e90ebed7e88 100644
--- a/dbaccess/source/ui/tabledesign/FieldDescriptions.cxx
+++ b/dbaccess/source/ui/tabledesign/FieldDescriptions.cxx
@@ -239,8 +239,19 @@ void OFieldDescription::FillFromTypeInfo(const TOTypeInfoSP& _pType,sal_Bool _bF
if ( bForce )
{
sal_Int32 nPrec = DEFAULT_OTHER_PRECSION;
- if ( GetPrecision() )
- nPrec = GetPrecision();
+ switch ( _pType->nType )
+ {
+ case DataType::BIT:
+ case DataType::BLOB:
+ case DataType::CLOB:
+ nPrec = _pType->nPrecision;
+ break;
+ default:
+ if ( GetPrecision() )
+ nPrec = GetPrecision();
+ break;
+ }
+
if ( _pType->nPrecision )
SetPrecision(::std::min<sal_Int32>(nPrec ? nPrec : DEFAULT_NUMERIC_PRECSION,_pType->nPrecision));
if ( _pType->nMaximumScale )
diff --git a/dbaccess/source/ui/tabledesign/TableController.cxx b/dbaccess/source/ui/tabledesign/TableController.cxx
index 98f57b61fbdc..1eed02543cda 100644
--- a/dbaccess/source/ui/tabledesign/TableController.cxx
+++ b/dbaccess/source/ui/tabledesign/TableController.cxx
@@ -1390,7 +1390,7 @@ void OTableController::alterColumns()
bNeedAppendKey = sal_True;
}
- if ( bNeedDropKey )
+ if ( bNeedDropKey && xKeyColumns.is() && xKeyColumns->getElementNames().getLength() )
dropPrimaryKey();
if ( bNeedAppendKey )
diff --git a/dbaccess/source/ui/tabledesign/table.src b/dbaccess/source/ui/tabledesign/table.src
index af911ec85c07..9fa0b0743ef4 100644
--- a/dbaccess/source/ui/tabledesign/table.src
+++ b/dbaccess/source/ui/tabledesign/table.src
@@ -56,7 +56,7 @@
String STR_TABLEDESIGN_DBFIELDTYPES
{
- Text [ en-US ] = "Unknown;Text;Number;Date/Time;Date;Time;Yes/No;Currency;Memo;Counter;Image;Text (fix);Decimal;Binary (fix);Binary;BigInt;Double;Float;Real;Integer;Small Integer;Tiny Integer;SQL Null;Object;Distinct;Structure;Field;BLOB;CLOB;REF;OTHER";
+ Text [ en-US ] = "Unknown;Text;Number;Date/Time;Date;Time;Yes/No;Currency;Memo;Counter;Image;Text (fix);Decimal;Binary (fix);Binary;BigInt;Double;Float;Real;Integer;Small Integer;Tiny Integer;SQL Null;Object;Distinct;Structure;Field;BLOB;CLOB;REF;OTHER;Bit (fix)";
};
String STR_TABLEDESIGN_UNDO_PRIMKEY
diff --git a/dbaccess/source/ui/uno/copytablewizard.cxx b/dbaccess/source/ui/uno/copytablewizard.cxx
index 26f859cf2045..ce79281f0cac 100644
--- a/dbaccess/source/ui/uno/copytablewizard.cxx
+++ b/dbaccess/source/ui/uno/copytablewizard.cxx
@@ -58,6 +58,8 @@
#include <com/sun/star/sdb/XSingleSelectQueryComposer.hpp>
#include <com/sun/star/sdbc/XParameters.hpp>
#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XBlob.hpp>
+#include <com/sun/star/sdbc/XClob.hpp>
#include <com/sun/star/sdbcx/XRowLocate.hpp>
#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
#include <com/sun/star/sdb/SQLContext.hpp>
@@ -127,6 +129,8 @@ namespace dbaui
using ::com::sun::star::sdbc::XParameters;
using ::com::sun::star::sdbc::XResultSet;
using ::com::sun::star::sdbc::XRow;
+ using ::com::sun::star::sdbc::XBlob;
+ using ::com::sun::star::sdbc::XClob;
using ::com::sun::star::sdbcx::XRowLocate;
using ::com::sun::star::sdbc::XResultSetMetaDataSupplier;
using ::com::sun::star::sdbc::XResultSetMetaData;
@@ -1281,6 +1285,7 @@ void CopyTableWizard::impl_copyRows_throw( const Reference< XResultSet >& _rxSou
case DataType::LONGVARBINARY:
case DataType::BINARY:
case DataType::VARBINARY:
+ case DataType::BIT:
aTransfer.transferComplexValue( &XRow::getBytes, &XParameters::setBytes );
break;
@@ -1296,7 +1301,6 @@ void CopyTableWizard::impl_copyRows_throw( const Reference< XResultSet >& _rxSou
aTransfer.transferComplexValue( &XRow::getTimestamp, &XParameters::setTimestamp );
break;
- case DataType::BIT:
case DataType::BOOLEAN:
aTransfer.transferValue( &XRow::getBoolean, &XParameters::setBoolean );
break;
@@ -1313,6 +1317,14 @@ void CopyTableWizard::impl_copyRows_throw( const Reference< XResultSet >& _rxSou
aTransfer.transferValue( &XRow::getInt, &XParameters::setInt );
break;
+ case DataType::BLOB:
+ aTransfer.transferComplexValue( &XRow::getBlob, &XParameters::setBlob );
+ break;
+
+ case DataType::CLOB:
+ aTransfer.transferComplexValue( &XRow::getClob, &XParameters::setClob );
+ break;
+
default:
{
::rtl::OUString aMessage( String( ModuleRes( STR_CTW_UNSUPPORTED_COLUMN_TYPE ) ) );