summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dbaccess/qa/complex/dbaccess/ApplicationController.java129
-rw-r--r--dbaccess/qa/complex/dbaccess/Beamer.java194
-rw-r--r--dbaccess/qa/complex/dbaccess/CRMBasedTestCase.java4
-rw-r--r--dbaccess/qa/complex/dbaccess/CRMDatabase.java59
-rwxr-xr-xdbaccess/qa/complex/dbaccess/CopyTableInterActionHandler.java53
-rwxr-xr-xdbaccess/qa/complex/dbaccess/CopyTableWizard.java239
-rw-r--r--dbaccess/qa/complex/dbaccess/DataSource.java55
-rwxr-xr-xdbaccess/qa/complex/dbaccess/DatabaseApplication.java104
-rw-r--r--dbaccess/qa/complex/dbaccess/DatabaseDocument.java697
-rw-r--r--dbaccess/qa/complex/dbaccess/FileHelper.java1
-rw-r--r--dbaccess/qa/complex/dbaccess/Parser.java71
-rw-r--r--dbaccess/qa/complex/dbaccess/PropertyBag.java45
-rw-r--r--dbaccess/qa/complex/dbaccess/Query.java24
-rw-r--r--dbaccess/qa/complex/dbaccess/QueryInQuery.java21
-rw-r--r--dbaccess/qa/complex/dbaccess/RowSet.java846
-rw-r--r--dbaccess/qa/complex/dbaccess/RowSetEventListener.java14
-rwxr-xr-xdbaccess/qa/complex/dbaccess/SingleSelectQueryComposer.java373
-rw-r--r--dbaccess/qa/complex/dbaccess/TestCase.java8
-rw-r--r--dbaccess/qa/complex/dbaccess/UISettings.java11
-rw-r--r--dbaccess/qa/complex/dbaccess/dbaccess.sce2
-rw-r--r--dbaccess/source/core/api/RowSet.cxx2
-rw-r--r--dbaccess/source/core/api/RowSetBase.cxx3
-rw-r--r--dbaccess/source/core/api/RowSetCache.cxx15
-rw-r--r--dbaccess/source/core/api/RowSetCache.hxx1
-rw-r--r--dbaccess/source/core/api/SingleSelectQueryComposer.cxx3
-rw-r--r--dbaccess/source/core/dataaccess/databasecontext.cxx5
-rw-r--r--dbaccess/source/core/misc/dsntypes.cxx13
-rw-r--r--dbaccess/source/sdbtools/resource/sdbt_strings.src2
-rw-r--r--dbaccess/source/ui/app/AppController.cxx2
-rw-r--r--dbaccess/source/ui/app/AppControllerDnD.cxx72
-rw-r--r--dbaccess/source/ui/browser/brwctrlr.cxx27
-rw-r--r--dbaccess/source/ui/browser/dbexchange.cxx18
-rw-r--r--dbaccess/source/ui/browser/dsEntriesNoExp.cxx4
-rw-r--r--dbaccess/source/ui/browser/sbagrid.cxx38
-rw-r--r--dbaccess/source/ui/browser/sbagrid.src4
-rw-r--r--dbaccess/source/ui/browser/unodatbr.cxx50
-rw-r--r--dbaccess/source/ui/dlg/generalpage.cxx5
-rw-r--r--dbaccess/source/ui/dlg/makefile.mk2
-rw-r--r--dbaccess/source/ui/dlg/queryfilter.cxx13
-rw-r--r--dbaccess/source/ui/dlg/sqlmessage.cxx9
-rw-r--r--dbaccess/source/ui/inc/IUpdateHelper.hxx7
-rw-r--r--dbaccess/source/ui/inc/TokenWriter.hxx2
-rw-r--r--dbaccess/source/ui/inc/dbexchange.hxx5
-rw-r--r--dbaccess/source/ui/inc/sbagrid.hxx7
-rw-r--r--dbaccess/source/ui/inc/unodatbr.hxx1
-rw-r--r--dbaccess/source/ui/misc/DExport.cxx14
-rw-r--r--dbaccess/source/ui/misc/TokenWriter.cxx148
-rw-r--r--dbaccess/source/ui/misc/UpdateHelperImpl.hxx27
-rw-r--r--dbaccess/source/ui/misc/dbumiscres.src6
-rw-r--r--dbaccess/source/ui/misc/linkeddocuments.cxx3
-rw-r--r--dbaccess/source/ui/relationdesign/relation.src2
-rw-r--r--dbaccess/source/ui/tabledesign/FieldDescriptions.cxx12
-rw-r--r--reportdesign/inc/rptui_slotid.hrc3
-rw-r--r--reportdesign/source/ui/dlg/AddField.cxx2
-rw-r--r--reportdesign/source/ui/dlg/Navigator.cxx10
-rw-r--r--reportdesign/source/ui/inc/Navigator.hxx1
-rw-r--r--reportdesign/source/ui/inc/ReportController.hxx6
-rw-r--r--reportdesign/source/ui/inc/SectionWindow.hxx3
-rw-r--r--reportdesign/source/ui/inc/StartMarker.hxx1
-rw-r--r--reportdesign/source/ui/report/DesignView.cxx4
-rw-r--r--reportdesign/source/ui/report/ReportController.cxx19
-rw-r--r--reportdesign/source/ui/report/SectionWindow.cxx16
-rw-r--r--reportdesign/source/ui/report/StartMarker.cxx18
-rw-r--r--reportdesign/uiconfig/dbreport/accelerator/de-DE/default.xml2
-rw-r--r--reportdesign/uiconfig/dbreport/accelerator/en-GB/default.xml2
-rw-r--r--reportdesign/uiconfig/dbreport/accelerator/en-US/default.xml2
66 files changed, 2332 insertions, 1229 deletions
diff --git a/dbaccess/qa/complex/dbaccess/ApplicationController.java b/dbaccess/qa/complex/dbaccess/ApplicationController.java
index 41bf379f7a91..c3661ef7ffee 100644
--- a/dbaccess/qa/complex/dbaccess/ApplicationController.java
+++ b/dbaccess/qa/complex/dbaccess/ApplicationController.java
@@ -27,7 +27,6 @@
* for a copy of the LGPLv3 License.
*
************************************************************************/
-
package complex.dbaccess;
import com.sun.star.beans.PropertyValue;
@@ -56,9 +55,10 @@ import java.io.IOException;
*/
public class ApplicationController extends complexlib.ComplexTestCase
{
- private HsqlDatabase m_database;
+
+ private HsqlDatabase m_database;
private XOfficeDatabaseDocument m_databaseDocument;
- private XDatabaseDocumentUI m_documentUI;
+ private XDatabaseDocumentUI m_documentUI;
public ApplicationController()
{
@@ -66,11 +66,29 @@ public class ApplicationController extends complexlib.ComplexTestCase
}
// --------------------------------------------------------------------------------------------------------
+ protected final XComponentContext getComponentContext()
+ {
+ XComponentContext context = null;
+ try
+ {
+ final XPropertySet orbProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, getORB());
+ context = (XComponentContext) UnoRuntime.queryInterface(XComponentContext.class,
+ orbProps.getPropertyValue("DefaultContext"));
+ }
+ catch (Exception ex)
+ {
+ failed("could not retrieve the ComponentContext");
+ }
+ return context;
+ }
+ // --------------------------------------------------------------------------------------------------------
+
public String[] getTestMethodNames()
{
- return new String[] {
- "checkSaveAs"
- };
+ return new String[]
+ {
+ "checkSaveAs"
+ };
}
// --------------------------------------------------------------------------------------------------------
@@ -82,30 +100,13 @@ public class ApplicationController extends complexlib.ComplexTestCase
// --------------------------------------------------------------------------------------------------------
protected final XMultiServiceFactory getORB()
{
- return (XMultiServiceFactory)param.getMSF();
- }
-
- // --------------------------------------------------------------------------------------------------------
- protected final XComponentContext getComponentContext()
- {
- XComponentContext context = null;
- try
- {
- XPropertySet orbProps = (XPropertySet) UnoRuntime.queryInterface( XPropertySet.class, getORB() );
- context = (XComponentContext)UnoRuntime.queryInterface( XComponentContext.class,
- orbProps.getPropertyValue( "DefaultContext" ) );
- }
- catch ( Exception ex )
- {
- failed( "could not retrieve the ComponentContext" );
- }
- return context;
+ return (XMultiServiceFactory) param.getMSF();
}
// --------------------------------------------------------------------------------------------------------
private void impl_closeDocument()
{
- if ( m_database != null )
+ if (m_database != null)
{
m_database.close();
m_database = null;
@@ -115,36 +116,36 @@ public class ApplicationController extends complexlib.ComplexTestCase
}
// --------------------------------------------------------------------------------------------------------
- private void impl_switchToDocument( String _documentURL ) throws java.lang.Exception
+ private void impl_switchToDocument(String _documentURL) throws java.lang.Exception
{
// close previous database document
impl_closeDocument();
// create/load the new database document
- m_database = ( _documentURL == null )
- ? new HsqlDatabase( getORB() )
- : new HsqlDatabase( getORB(), _documentURL );
+ m_database = (_documentURL == null)
+ ? new HsqlDatabase(getORB())
+ : new HsqlDatabase(getORB(), _documentURL);
m_databaseDocument = m_database.getDatabaseDocument();
// load it into a frame
- Object object = getORB().createInstance( "com.sun.star.frame.Desktop" );
- XComponentLoader xComponentLoader = (XComponentLoader)UnoRuntime.queryInterface( XComponentLoader.class, object );
- XComponent loadedComponent = xComponentLoader.loadComponentFromURL( m_database.getDocumentURL(), "_blank", FrameSearchFlag.ALL, new PropertyValue[0] );
+ final Object object = getORB().createInstance("com.sun.star.frame.Desktop");
+ final XComponentLoader 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 ) );
+ assure("too many document instances!",
+ UnoRuntime.areSame(loadedComponent, m_databaseDocument));
// get the controller, which provides access to various UI operations
- XModel docModel = (XModel)UnoRuntime.queryInterface( XModel.class,
- loadedComponent );
- m_documentUI = (XDatabaseDocumentUI)UnoRuntime.queryInterface( XDatabaseDocumentUI.class,
- docModel.getCurrentController() );
+ final XModel docModel = (XModel) UnoRuntime.queryInterface(XModel.class,
+ loadedComponent);
+ m_documentUI = (XDatabaseDocumentUI) UnoRuntime.queryInterface(XDatabaseDocumentUI.class,
+ docModel.getCurrentController());
}
// --------------------------------------------------------------------------------------------------------
public void before() throws Exception, java.lang.Exception
{
- impl_switchToDocument( null );
+ impl_switchToDocument(null);
}
// --------------------------------------------------------------------------------------------------------
@@ -152,52 +153,54 @@ public class ApplicationController extends complexlib.ComplexTestCase
{
impl_closeDocument();
}
-
// --------------------------------------------------------------------------------------------------------
+
public void checkSaveAs() throws Exception, IOException, java.lang.Exception
{
// issue 93737 describes the problem that when you save-as a database document, and do changes to it,
// then those changes are saved in the old document, actually
- String oldDocumentURL = m_database.getDocumentURL();
+ final String oldDocumentURL = m_database.getDocumentURL();
- File documentFile = java.io.File.createTempFile( getTestObjectName(), ".odb" );
+ final File documentFile = java.io.File.createTempFile(getTestObjectName(), ".odb");
documentFile.deleteOnExit();
- String newDocumentURL = URLHelper.getFileURLFromSystemPath( documentFile.getAbsoluteFile() );
+ final String newDocumentURL = URLHelper.getFileURLFromSystemPath(documentFile.getAbsoluteFile());
// store the doc in a new location
- XStorable storeDoc = (XStorable)UnoRuntime.queryInterface( XStorable.class,
- m_databaseDocument );
- storeDoc.storeAsURL( newDocumentURL, new PropertyValue[] {} );
+ final XStorable storeDoc = (XStorable) UnoRuntime.queryInterface(XStorable.class,
+ m_databaseDocument);
+ storeDoc.storeAsURL(newDocumentURL, new PropertyValue[]
+ {
+ });
// connect
m_documentUI.connect();
- assure( "could not connect to " + m_database.getDocumentURL(), m_documentUI.isConnected() );
+ assure("could not connect to " + m_database.getDocumentURL(), m_documentUI.isConnected());
// create a table in the database
- m_database.createTable( new HsqlTableDescriptor( "abc", new HsqlColumnDescriptor[] {
- new HsqlColumnDescriptor( "a", "VARCHAR(50)" ),
- new HsqlColumnDescriptor( "b", "VARCHAR(50)" ),
- new HsqlColumnDescriptor( "c", "VARCHAR(50)" )
- }
- ) );
+ m_database.createTable(new HsqlTableDescriptor("abc", new HsqlColumnDescriptor[]
+ {
+ new HsqlColumnDescriptor("a", "VARCHAR(50)"),
+ new HsqlColumnDescriptor("b", "VARCHAR(50)"),
+ new HsqlColumnDescriptor("c", "VARCHAR(50)")
+ }));
// load the old document, and verify there is *no* table therein
- impl_switchToDocument( oldDocumentURL );
+ 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() );
+ assure("could not connect to " + m_database.getDocumentURL(), m_documentUI.isConnected());
+ XTablesSupplier suppTables = (XTablesSupplier) UnoRuntime.queryInterface(XTablesSupplier.class,
+ m_documentUI.getActiveConnection());
XNameAccess tables = suppTables.getTables();
- assure( "the table was created in the wrong database", !tables.hasByName( "abc" ) );
+ assure("the table was created in the wrong database", !tables.hasByName("abc"));
// load the new document, and verify there *is* a table therein
- impl_switchToDocument( newDocumentURL );
+ impl_switchToDocument(newDocumentURL);
m_documentUI.connect();
- assure( "could not connect to " + m_database.getDocumentURL(), m_documentUI.isConnected() );
+ assure("could not connect to " + m_database.getDocumentURL(), m_documentUI.isConnected());
- suppTables = (XTablesSupplier)UnoRuntime.queryInterface( XTablesSupplier.class,
- m_documentUI.getActiveConnection() );
+ suppTables = (XTablesSupplier) UnoRuntime.queryInterface(XTablesSupplier.class,
+ m_documentUI.getActiveConnection());
tables = suppTables.getTables();
- assure( "the newly created table has not been written", tables.hasByName( "abc" ) );
+ assure("the newly created table has not been written", tables.hasByName("abc"));
}
}
diff --git a/dbaccess/qa/complex/dbaccess/Beamer.java b/dbaccess/qa/complex/dbaccess/Beamer.java
new file mode 100644
index 000000000000..e24d6211cb1f
--- /dev/null
+++ b/dbaccess/qa/complex/dbaccess/Beamer.java
@@ -0,0 +1,194 @@
+/*************************************************************************
+ *
+ * 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: Beamer.java,v $
+ * $Revision: 1.1.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.beans.PropertyState;
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.container.XEnumeration;
+import com.sun.star.container.XEnumerationAccess;
+import com.sun.star.container.XNameAccess;
+import com.sun.star.frame.FrameSearchFlag;
+import com.sun.star.frame.XComponentLoader;
+import com.sun.star.frame.XController;
+import com.sun.star.frame.XDispatch;
+import com.sun.star.frame.XDispatchProvider;
+import com.sun.star.frame.XFrame;
+import com.sun.star.frame.XModel;
+import com.sun.star.frame.XStorable;
+import com.sun.star.lang.XComponent;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.sdb.CommandType;
+import com.sun.star.sdb.XDocumentDataSource;
+import com.sun.star.sdb.XOfficeDatabaseDocument;
+import com.sun.star.sdb.application.XDatabaseDocumentUI;
+import com.sun.star.sdbcx.XTablesSupplier;
+import com.sun.star.uno.Exception;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XComponentContext;
+import com.sun.star.uno.XNamingService;
+import com.sun.star.util.URL;
+import com.sun.star.util.XCloseable;
+import com.sun.star.util.XURLTransformer;
+import com.sun.star.view.XSelectionSupplier;
+import connectivity.tools.DataSource;
+import connectivity.tools.HsqlColumnDescriptor;
+import connectivity.tools.HsqlDatabase;
+import connectivity.tools.HsqlTableDescriptor;
+import helper.URLHelper;
+import java.io.File;
+import java.io.IOException;
+import util.UITools;
+
+/** complex test case for Base's application UI
+ */
+public class Beamer extends complexlib.ComplexTestCase
+{
+
+ private XModel docModel;
+
+ public Beamer()
+ {
+ super();
+ }
+
+ // --------------------------------------------------------------------------------------------------------
+ protected final XComponentContext getComponentContext()
+ {
+ XComponentContext context = null;
+ try
+ {
+ final XPropertySet orbProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, getORB());
+ context = (XComponentContext) UnoRuntime.queryInterface(XComponentContext.class,
+ orbProps.getPropertyValue("DefaultContext"));
+ }
+ catch (Exception ex)
+ {
+ failed("could not retrieve the ComponentContext");
+ }
+ return context;
+ }
+ // --------------------------------------------------------------------------------------------------------
+
+ public String[] getTestMethodNames()
+ {
+ return new String[]
+ {
+ "testBeamer"
+ };
+ }
+
+ // --------------------------------------------------------------------------------------------------------
+ public String getTestObjectName()
+ {
+ return getClass().getName();
+ }
+
+ // --------------------------------------------------------------------------------------------------------
+ protected final XMultiServiceFactory getORB()
+ {
+ return (XMultiServiceFactory) param.getMSF();
+ }
+
+ // --------------------------------------------------------------------------------------------------------
+ private void impl_closeDocument()
+ {
+ }
+
+ // --------------------------------------------------------------------------------------------------------
+ public void before() throws Exception, java.lang.Exception
+ {
+ // 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 XComponent loadedComponent = xComponentLoader.loadComponentFromURL("private:factory/swriter", "_blank", 0, new PropertyValue[0]);
+ // get the controller, which provides access to various UI operations
+ docModel = (XModel) UnoRuntime.queryInterface(XModel.class, loadedComponent);
+ }
+
+ // --------------------------------------------------------------------------------------------------------
+ public void after()
+ {
+ }
+ // --------------------------------------------------------------------------------------------------------
+
+ public void testBeamer() throws Exception, IOException, java.lang.Exception
+ {
+ final XController controller = docModel.getCurrentController();
+ final XFrame frame = controller.getFrame();
+ final XDispatchProvider dispatchP = (XDispatchProvider) UnoRuntime.queryInterface(XDispatchProvider.class, frame);
+ URL command = new URL();
+ // command.Complete = ".component:DB/DataSourceBrowser";
+ command.Complete = ".uno:ViewDataSourceBrowser";
+
+ Object instance = getORB().createInstance("com.sun.star.util.URLTransformer");
+ XURLTransformer atrans = (XURLTransformer) UnoRuntime.queryInterface(XURLTransformer.class, instance);
+ com.sun.star.util.URL[] aURLA = new com.sun.star.util.URL[1];
+ aURLA[0] = command;
+ atrans.parseStrict(aURLA);
+ command = aURLA[0];
+
+ final XDispatch dispatch = dispatchP.queryDispatch(command, "_self", FrameSearchFlag.AUTO);
+ assure(dispatch != null);
+ dispatch.dispatch(command, new PropertyValue[0]);
+
+ final PropertyValue[] props = new PropertyValue[]
+ {
+ new PropertyValue("DataSourceName", 0, "Bibliography", PropertyState.DIRECT_VALUE),
+ new PropertyValue("CommandType", 0, Integer.valueOf(CommandType.TABLE), PropertyState.DIRECT_VALUE),
+ new PropertyValue("Command", 0, "biblio", PropertyState.DIRECT_VALUE)
+ };
+
+ final XFrame beamer = frame.findFrame("_beamer", 0);
+ assure(beamer != null);
+ final XEnumerationAccess evtBc = (XEnumerationAccess) UnoRuntime.queryInterface(XEnumerationAccess.class, getORB().createInstance("com.sun.star.frame.GlobalEventBroadcaster"));
+ XEnumeration enumeration = evtBc.createEnumeration();
+ int count = -1;
+ while (enumeration.hasMoreElements())
+ {
+ enumeration.nextElement();
+ ++count;
+ }
+ final XSelectionSupplier selSup = (XSelectionSupplier)UnoRuntime.queryInterface(XSelectionSupplier.class, beamer.getController());
+ selSup.select(props);
+ final com.sun.star.util.XCloseable close = (com.sun.star.util.XCloseable)UnoRuntime.queryInterface(com.sun.star.util.XCloseable.class, frame);
+ close.close(false);
+
+ enumeration = evtBc.createEnumeration();
+ int count2 = 0;
+ while (enumeration.hasMoreElements())
+ {
+ enumeration.nextElement();
+ ++count2;
+ }
+
+ assure("count1 = " + count + " count2 = " + count2, count == count2);
+ }
+}
diff --git a/dbaccess/qa/complex/dbaccess/CRMBasedTestCase.java b/dbaccess/qa/complex/dbaccess/CRMBasedTestCase.java
index edcb62579aac..eccb48647bae 100644
--- a/dbaccess/qa/complex/dbaccess/CRMBasedTestCase.java
+++ b/dbaccess/qa/complex/dbaccess/CRMBasedTestCase.java
@@ -54,12 +54,14 @@ public abstract class CRMBasedTestCase extends TestCase
}
// --------------------------------------------------------------------------------------------------------
+ @Override
public void before()
{
createTestCase();
}
// --------------------------------------------------------------------------------------------------------
+ @Override
public void after()
{
try
@@ -78,7 +80,7 @@ public abstract class CRMBasedTestCase extends TestCase
*/
protected final XSingleSelectQueryComposer createQueryComposer() throws com.sun.star.uno.Exception
{
- XMultiServiceFactory connectionFactory = (XMultiServiceFactory)UnoRuntime.queryInterface(
+ final XMultiServiceFactory connectionFactory = (XMultiServiceFactory)UnoRuntime.queryInterface(
XMultiServiceFactory.class, m_database.getConnection() );
return (XSingleSelectQueryComposer)UnoRuntime.queryInterface(
XSingleSelectQueryComposer.class, connectionFactory.createInstance( "com.sun.star.sdb.SingleSelectQueryComposer" ) );
diff --git a/dbaccess/qa/complex/dbaccess/CRMDatabase.java b/dbaccess/qa/complex/dbaccess/CRMDatabase.java
index ca28c1c769e7..77e2dcf6b2e2 100644
--- a/dbaccess/qa/complex/dbaccess/CRMDatabase.java
+++ b/dbaccess/qa/complex/dbaccess/CRMDatabase.java
@@ -51,10 +51,12 @@ import connectivity.tools.QueryDefinition;
*/
public class CRMDatabase
{
- private XMultiServiceFactory m_orb;
- private HsqlDatabase m_database;
- private DataSource m_dataSource;
- private XConnection m_connection;
+ 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
*/
@@ -97,8 +99,8 @@ public class CRMDatabase
{
HsqlTableDescriptor table = new HsqlTableDescriptor( "categories",
new HsqlColumnDescriptor[] {
- new HsqlColumnDescriptor( "ID", "INTEGER", HsqlColumnDescriptor.PRIMARY ),
- new HsqlColumnDescriptor( "Name", "VARCHAR(50)" ),
+ new HsqlColumnDescriptor( "ID",INTEGER, HsqlColumnDescriptor.PRIMARY ),
+ new HsqlColumnDescriptor( "Name",VARCHAR50),
new HsqlColumnDescriptor( "Description", "VARCHAR(1024)" ),
new HsqlColumnDescriptor( "Image", "LONGVARBINARY" ) } );
m_database.createTable( table, true );
@@ -108,9 +110,9 @@ public class CRMDatabase
table = new HsqlTableDescriptor( "products",
new HsqlColumnDescriptor[] {
- new HsqlColumnDescriptor( "ID", "INTEGER", HsqlColumnDescriptor.PRIMARY ),
- new HsqlColumnDescriptor( "Name", "VARCHAR(50)" ),
- new HsqlColumnDescriptor( "CategoryID", "INTEGER", HsqlColumnDescriptor.REQUIRED, "categories", "ID" ) } );
+ 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 )" );
@@ -120,22 +122,23 @@ public class CRMDatabase
table = new HsqlTableDescriptor( "customers",
new HsqlColumnDescriptor[] {
- new HsqlColumnDescriptor( "ID", "INTEGER", HsqlColumnDescriptor.PRIMARY ),
- new HsqlColumnDescriptor( "Name", "VARCHAR(50)" ),
- new HsqlColumnDescriptor( "Address", "VARCHAR(50)" ),
- new HsqlColumnDescriptor( "City", "VARCHAR(50)" ),
- new HsqlColumnDescriptor( "Postal", "VARCHAR(50)" ) } );
+ 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') " );
- m_database.executeSQL( "INSERT INTO \"customers\" VALUES(2,'Simply Delicious','Down Under','Melbourne','518') " );
- m_database.executeSQL( "INSERT INTO \"customers\" VALUES(3,'Pure Health','10 Fish St.','San Francisco','94107') " );
- m_database.executeSQL( "INSERT INTO \"customers\" VALUES(4,'Milk And More','Arlington Road 21','Dublin','31021') " );
+ 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( "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 );
@@ -145,9 +148,9 @@ public class CRMDatabase
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" ) } );
+ 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)" );
@@ -158,9 +161,9 @@ public class CRMDatabase
// since we created the tables by directly executing the SQL statements, we need to refresh
// the tables container
- XTablesSupplier suppTables = (XTablesSupplier)UnoRuntime.queryInterface(
+ final XTablesSupplier suppTables = (XTablesSupplier)UnoRuntime.queryInterface(
XTablesSupplier.class, m_connection );
- XRefreshable refreshTables = (XRefreshable)UnoRuntime.queryInterface(
+ final XRefreshable refreshTables = (XRefreshable)UnoRuntime.queryInterface(
XRefreshable.class, suppTables.getTables() );
refreshTables.refresh();
}
@@ -169,11 +172,11 @@ public class CRMDatabase
private void validateUnparseable()
{
// The "unparseable" query should be indeed be unparseable by OOo (though a valid HSQL query)
- XSingleSelectQueryComposer composer = null;
- QueryDefinition unparseableQuery = null;
+ XSingleSelectQueryComposer composer;
+ QueryDefinition unparseableQuery;
try
{
- XMultiServiceFactory factory = (XMultiServiceFactory)UnoRuntime.queryInterface(
+ final XMultiServiceFactory factory = (XMultiServiceFactory)UnoRuntime.queryInterface(
XMultiServiceFactory.class, m_database.defaultConnection() );
composer = (XSingleSelectQueryComposer)UnoRuntime.queryInterface(
XSingleSelectQueryComposer.class, factory.createInstance( "com.sun.star.sdb.SingleSelectQueryComposer" ) );
diff --git a/dbaccess/qa/complex/dbaccess/CopyTableInterActionHandler.java b/dbaccess/qa/complex/dbaccess/CopyTableInterActionHandler.java
new file mode 100755
index 000000000000..977ddd059eb5
--- /dev/null
+++ b/dbaccess/qa/complex/dbaccess/CopyTableInterActionHandler.java
@@ -0,0 +1,53 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: RowSetEventListener.java,v $
+ * $Revision: 1.4 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package complex.dbaccess;
+
+import com.sun.star.lib.uno.helper.WeakBase;
+import com.sun.star.task.XInteractionHandler;
+import com.sun.star.task.XInteractionRequest;
+
+/**
+ *
+ * @author oj93728
+ */
+class CopyTableInterActionHandler extends WeakBase
+ implements XInteractionHandler
+{
+ private final CopyTableWizard test;
+ public CopyTableInterActionHandler(CopyTableWizard testCase)
+ {
+ test = testCase;
+ }
+
+ public void handle(XInteractionRequest xRequest)
+ {
+ test.assure(xRequest.toString());
+ }
+}
diff --git a/dbaccess/qa/complex/dbaccess/CopyTableWizard.java b/dbaccess/qa/complex/dbaccess/CopyTableWizard.java
new file mode 100755
index 000000000000..9a9f8bd3731e
--- /dev/null
+++ b/dbaccess/qa/complex/dbaccess/CopyTableWizard.java
@@ -0,0 +1,239 @@
+/*************************************************************************
+ *
+ * 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: CopyTableWizard.java,v $
+ * $Revision: 1.1.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.accessibility.XAccessible;
+import com.sun.star.accessibility.XAccessibleContext;
+import com.sun.star.awt.XExtendedToolkit;
+import com.sun.star.awt.XWindow;
+import com.sun.star.beans.Optional;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.container.XNameAccess;
+import com.sun.star.sdb.CommandType;
+import com.sun.star.sdb.application.XCopyTableWizard;
+import com.sun.star.sdb.DataAccessDescriptorFactory;
+import com.sun.star.sdbc.XConnection;
+import com.sun.star.sdbcx.XTablesSupplier;
+import com.sun.star.task.XInteractionHandler;
+import com.sun.star.uno.Exception;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XComponentContext;
+import connectivity.tools.DbaseDatabase;
+import java.io.IOException;
+import util.UITools;
+
+/** complex test case for Base's application UI
+ */
+public class CopyTableWizard extends CRMBasedTestCase
+{
+
+ private DatabaseApplication source;
+ private DatabaseApplication dest;
+
+ public CopyTableWizard()
+ {
+ super();
+ }
+
+ // --------------------------------------------------------------------------------------------------------
+ public String[] getTestMethodNames()
+ {
+ return new String[]
+ {
+ "copyTable", "copyTableDbase"
+ };
+ }
+
+ // --------------------------------------------------------------------------------------------------------
+ @Override
+ public String getTestObjectName()
+ {
+ return getClass().getName();
+ }
+// --------------------------------------------------------------------------------------------------------
+ // --------------------------------------------------------------------------------------------------------
+
+ @Override
+ public void after()
+ {
+ dest.store();
+ super.after();
+ }
+
+ @Override
+ public void before()
+ {
+ try
+ {
+ createTestCase();
+ source = new DatabaseApplication(this.m_database.getDatabase());
+ dest = new DatabaseApplication(new DbaseDatabase(getORB()));
+ }
+ catch (java.lang.Exception ex)
+ {
+ assure(false);
+ }
+ }
+ // --------------------------------------------------------------------------------------------------------
+
+
+
+ class CopyThread implements Runnable
+ {
+
+ final XCopyTableWizard copyWizard;
+
+ public CopyThread(final XCopyTableWizard copyWizard)
+ {
+ this.copyWizard = copyWizard;
+ }
+
+ public void run()
+ {
+ copyWizard.execute();
+ }
+ }
+
+ private XWindow getActiveWindow()
+ {
+ Object toolKit = null;
+ try
+ {
+ toolKit = getORB().createInstance("com.sun.star.awt.Toolkit");
+ }
+ catch (com.sun.star.uno.Exception e)
+ {
+ return null;
+ }
+
+ XExtendedToolkit tk = (XExtendedToolkit) UnoRuntime.queryInterface(XExtendedToolkit.class, toolKit);
+ Object atw = tk.getActiveTopWindow();
+ return (XWindow) UnoRuntime.queryInterface(XWindow.class, atw);
+ }
+
+ public void copyTable() throws Exception, IOException, java.lang.Exception
+ {
+ copyTable(source,source);
+ }
+
+ public void copyTableDbase() throws Exception, IOException, java.lang.Exception
+ {
+ copyTable(source,dest);
+ }
+ public void copyTable(final DatabaseApplication sourceDb,final DatabaseApplication destDb) throws Exception, IOException, java.lang.Exception
+ {
+ final XConnection destConnection = destDb.getDocumentUI().getActiveConnection();
+
+ final XConnection sourceConnection = sourceDb.getDocumentUI().getActiveConnection();
+ final XTablesSupplier suppTables = (XTablesSupplier) UnoRuntime.queryInterface(XTablesSupplier.class, sourceConnection);
+ final XNameAccess tables = suppTables.getTables();
+
+ final String[] names = tables.getElementNames();
+ for (int i = 0; i < names.length; i++)
+ {
+ copyTable(names[i], sourceConnection, destConnection);
+ }
+ }
+
+ public void assure(final String message)
+ {
+ assure(message, false);
+ }
+
+ private void copyTable(final String tableName, final XConnection sourceConnection, final XConnection destConnection) throws Exception, IOException, java.lang.Exception
+ {
+
+ final XInteractionHandler interAction = new CopyTableInterActionHandler(this);
+ final XComponentContext context = getComponentContext();
+ final XPropertySet sourceDescriptor = DataAccessDescriptorFactory.get(context).createDataAccessDescriptor();
+ sourceDescriptor.setPropertyValue("CommandType", CommandType.TABLE);
+ sourceDescriptor.setPropertyValue("Command", tableName);
+ sourceDescriptor.setPropertyValue("ActiveConnection", sourceConnection);
+
+ final XPropertySet destDescriptor = DataAccessDescriptorFactory.get(context).createDataAccessDescriptor();
+ destDescriptor.setPropertyValue("ActiveConnection", destConnection);
+
+ final XCopyTableWizard copyWizard = com.sun.star.sdb.application.CopyTableWizard.createWithInteractionHandler(context, sourceDescriptor, destDescriptor, interAction);
+ copyWizard.setOperation((short) 0); // com.sun.star.sdb.application.CopyDefinitionAndData
+ Optional<String> auto = new Optional<String>();
+
+ auto.IsPresent = destConnection.getMetaData().supportsCoreSQLGrammar();
+ if (auto.IsPresent)
+ {
+ auto.Value = "ID_test";
+ }
+ copyWizard.setCreatePrimaryKey(auto);
+ Thread thread = new Thread(new CopyThread(copyWizard));
+ thread.start();
+ sleep();
+
+ try
+ {
+ final XWindow dialog = getActiveWindow();
+ final UITools uiTools = new UITools(getORB(), dialog);
+ final XAccessible root = uiTools.getRoot();
+ final XAccessibleContext accContext = root.getAccessibleContext();
+ final int count = accContext.getAccessibleChildCount();
+ String buttonName = "Create";
+ final XAccessibleContext childContext = accContext.getAccessibleChild(count - 3).getAccessibleContext();
+ final String name = childContext.getAccessibleName();
+ if (name != null && !"".equals(name))
+ {
+ buttonName = name;
+ }
+ try
+ {
+ uiTools.clickButton(buttonName);
+ }
+ catch (java.lang.Exception exception)
+ {
+ exception.printStackTrace();
+ }
+ }
+ catch (com.sun.star.lang.IndexOutOfBoundsException indexOutOfBoundsException)
+ {
+ }
+ sleep();
+
+ thread.join();
+ }
+
+ private void sleep()
+ {
+ try
+ {
+ Thread.sleep(500);
+ }
+ catch (java.lang.InterruptedException e)
+ {
+ }
+ }
+ // --------------------------------------------------------------------------------------------------------
+}
diff --git a/dbaccess/qa/complex/dbaccess/DataSource.java b/dbaccess/qa/complex/dbaccess/DataSource.java
index cb19a1f85d53..29c9d2f2cdd7 100644
--- a/dbaccess/qa/complex/dbaccess/DataSource.java
+++ b/dbaccess/qa/complex/dbaccess/DataSource.java
@@ -30,21 +30,27 @@
package complex.dbaccess;
import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.uno.Exception;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.XNamingService;
+import complexlib.ComplexTestCase;
+import connectivity.tools.HsqlDatabase;
+import java.util.logging.Level;
+import java.util.logging.Logger;
-public class DataSource extends complexlib.ComplexTestCase {
+public class DataSource extends ComplexTestCase
+{
- connectivity.tools.HsqlDatabase m_database;
- connectivity.tools.DataSource m_dataSource;
+ HsqlDatabase m_database;
+ connectivity.tools.DataSource m_dataSource;
// --------------------------------------------------------------------------------------------------------
public String[] getTestMethodNames()
{
return new String[]
- {
- "testRegistrationName"
- };
+ {
+ "testRegistrationName"
+ };
}
// --------------------------------------------------------------------------------------------------------
@@ -58,52 +64,49 @@ public class DataSource extends complexlib.ComplexTestCase {
{
try
{
- if ( m_database == null )
+ if (m_database == null)
{
- CRMDatabase database = new CRMDatabase( getFactory() );
+ final CRMDatabase database = new CRMDatabase(getFactory());
m_database = database.getDatabase();
m_dataSource = m_database.getDataSource();
}
}
- catch( Exception e )
+ catch (Exception e)
+ {
+ failed("could not create the test case, error message:\n" + e.getMessage());
+ }
+ catch (java.lang.Exception e)
{
- failed( "could not create the test case, error message:\n" + e.getMessage() );
+ failed("could not create the test case, error message:\n" + e.getMessage());
}
}
// --------------------------------------------------------------------------------------------------------
private XMultiServiceFactory getFactory()
{
- return (XMultiServiceFactory)param.getMSF();
+ return (XMultiServiceFactory) param.getMSF();
}
// --------------------------------------------------------------------------------------------------------
public void testRegistrationName()
{
- createTestCase();
-
try
{
+ createTestCase();
// 1. check the existing "Bibliography" data source whether it has the proper name
String dataSourceName = "Bibliography";
- connectivity.tools.DataSource bibliography = new connectivity.tools.DataSource( getFactory(), dataSourceName );
- assureEquals( "pre-registered database has a wrong name!",
- dataSourceName, bibliography.getName() );
-
+ final connectivity.tools.DataSource bibliography = new connectivity.tools.DataSource(getFactory(), dataSourceName);
+ assureEquals("pre-registered database has a wrong name!", dataSourceName, bibliography.getName());
// 2. register a newly created data source, and verify it has the proper name
dataSourceName = "someDataSource";
-
- XNamingService dataSourceRegistrations = (XNamingService)UnoRuntime.queryInterface(
- XNamingService.class, getFactory().createInstance("com.sun.star.sdb.DatabaseContext"));
+ final XNamingService dataSourceRegistrations = (XNamingService) UnoRuntime.queryInterface(
+ XNamingService.class, getFactory().createInstance("com.sun.star.sdb.DatabaseContext"));
dataSourceRegistrations.registerObject("someDataSource", m_dataSource.getXDataSource());
-
- assureEquals( "registration name of a newly registered data source is wrong",
- dataSourceName, m_dataSource.getName() );
+ assureEquals("registration name of a newly registered data source is wrong", dataSourceName, m_dataSource.getName());
}
- catch ( AssureException e ) { throw e; }
- catch ( Exception e )
+ catch (Exception ex)
{
- failed( "caught an unexpected exception: " + e.getMessage() );
+ Logger.getLogger(DataSource.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
diff --git a/dbaccess/qa/complex/dbaccess/DatabaseApplication.java b/dbaccess/qa/complex/dbaccess/DatabaseApplication.java
new file mode 100755
index 000000000000..139582bc1953
--- /dev/null
+++ b/dbaccess/qa/complex/dbaccess/DatabaseApplication.java
@@ -0,0 +1,104 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: RowSetEventListener.java,v $
+ * $Revision: 1.4 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package complex.dbaccess;
+
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.frame.FrameSearchFlag;
+import com.sun.star.frame.XComponentLoader;
+import com.sun.star.frame.XModel;
+import com.sun.star.frame.XStorable;
+import com.sun.star.lang.XComponent;
+import com.sun.star.sdb.XOfficeDatabaseDocument;
+import com.sun.star.sdb.application.XDatabaseDocumentUI;
+import com.sun.star.uno.Exception;
+import com.sun.star.uno.UnoRuntime;
+import connectivity.tools.DatabaseAccess;
+
+/**
+ *
+ * @author oj93728
+ */
+public class DatabaseApplication
+{
+
+ private final XOfficeDatabaseDocument databaseDocument;
+ private final XDatabaseDocumentUI documentUI;
+ private final DatabaseAccess db;
+
+ public DatabaseApplication(final DatabaseAccess _db) throws Exception
+ {
+ db = _db;
+ databaseDocument = db.getDatabaseDocument();
+
+ // load it into a frame
+ final Object object = db.getORB().createInstance("com.sun.star.frame.Desktop");
+ final XComponentLoader xComponentLoader = (XComponentLoader) UnoRuntime.queryInterface(XComponentLoader.class, object);
+ final XComponent loadedComponent = xComponentLoader.loadComponentFromURL(db.getDocumentURL(), "_blank", FrameSearchFlag.ALL, new PropertyValue[0]);
+
+ // get the controller, which provides access to various UI operations
+ final XModel docModel = (XModel) UnoRuntime.queryInterface(XModel.class,
+ loadedComponent);
+ documentUI = (XDatabaseDocumentUI) UnoRuntime.queryInterface(XDatabaseDocumentUI.class,
+ docModel.getCurrentController());
+ documentUI.connect();
+ }
+
+ public XOfficeDatabaseDocument getDatabaseDocument()
+ {
+ return databaseDocument;
+ }
+
+ public XDatabaseDocumentUI getDocumentUI()
+ {
+ return documentUI;
+ }
+
+ public DatabaseAccess getDb()
+ {
+ return db;
+ }
+
+ public void store()
+ {
+ // store the doc in a new location
+ try
+ {
+ final XStorable storeDoc = (XStorable) UnoRuntime.queryInterface(XStorable.class,
+ databaseDocument);
+ if (storeDoc != null)
+ {
+ storeDoc.store();
+ }
+ }
+ catch (com.sun.star.io.IOException iOException)
+ {
+ }
+ }
+}
diff --git a/dbaccess/qa/complex/dbaccess/DatabaseDocument.java b/dbaccess/qa/complex/dbaccess/DatabaseDocument.java
index ceca1e431715..3b00de883319 100644
--- a/dbaccess/qa/complex/dbaccess/DatabaseDocument.java
+++ b/dbaccess/qa/complex/dbaccess/DatabaseDocument.java
@@ -78,24 +78,25 @@ import com.sun.star.util.XChangesBatch;
import com.sun.star.util.XCloseable;
import com.sun.star.util.XModifiable;
import com.sun.star.util.XURLTransformer;
-import connectivity.tools.*;
import java.io.IOException;
import java.util.Iterator;
-import java.util.Vector;
+import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
public class DatabaseDocument extends TestCase implements com.sun.star.document.XDocumentEventListener
{
- private XComponent m_callbackFactory = null;
- private Vector m_documentEvents = new Vector();
- private Vector m_globalEvents = new Vector();
+ private static final String ONLOAD = "OnLoad";
+ private static final String _BLANK = "_blank";
+ private XComponent m_callbackFactory = null;
+ private final ArrayList m_documentEvents = new ArrayList();
+ private final ArrayList m_globalEvents = new ArrayList();
// for those states, see testDocumentEvents
- private static short STATE_NOT_STARTED = 0;
- private static short STATE_LOADING_DOC = 1;
- private static short STATE_MACRO_EXEC_APPROVED = 2;
- private static short STATE_ON_LOAD_RECEIVED = 3;
+ private static short STATE_NOT_STARTED = 0;
+ private static short STATE_LOADING_DOC = 1;
+ private static short STATE_MACRO_EXEC_APPROVED = 2;
+ private static short STATE_ON_LOAD_RECEIVED = 3;
private short m_loadDocState = STATE_NOT_STARTED;
// ========================================================================================================
@@ -104,21 +105,22 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document.
*/
private class CallbackComponent implements XDocumentEventListener, XTypeProvider
{
- public void documentEventOccured( DocumentEvent _event )
+
+ public void documentEventOccured(DocumentEvent _event)
{
- onDocumentEvent( _event );
+ onDocumentEvent(_event);
}
- public void disposing( com.sun.star.lang.EventObject _Event )
+ public void disposing(com.sun.star.lang.EventObject _Event)
{
// not interested in
}
public Type[] getTypes()
{
- Class interfaces[] = getClass().getInterfaces();
+ final Class interfaces[] = getClass().getInterfaces();
Type types[] = new Type[interfaces.length];
- for(int i = 0; i < interfaces.length; ++ i)
+ for (int i = 0; i < interfaces.length; ++i)
{
types[i] = new Type(interfaces[i]);
}
@@ -142,16 +144,17 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document.
*/
private class CallbackComponentFactory implements XSingleComponentFactory, XServiceInfo, XComponent
{
- private Vector m_eventListeners = new Vector();
- public Object createInstanceWithContext( XComponentContext _context ) throws Exception
+ private final ArrayList m_eventListeners = new ArrayList();
+
+ public Object createInstanceWithContext(XComponentContext _context) throws Exception
{
return new CallbackComponent();
}
- public Object createInstanceWithArgumentsAndContext( Object[] arg0, XComponentContext _context ) throws Exception
+ public Object createInstanceWithArgumentsAndContext(Object[] arg0, XComponentContext _context) throws Exception
{
- return createInstanceWithContext( _context );
+ return createInstanceWithContext(_context);
}
public String getImplementationName()
@@ -159,76 +162,82 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document.
return "org.openoffice.complex.dbaccess.CallbackComponent";
}
- public boolean supportsService( String _service )
+ public boolean supportsService(String _service)
{
- return _service.equals( getCallbackComponentServiceName() );
+ return _service.equals(getCallbackComponentServiceName());
}
public String[] getSupportedServiceNames()
{
- return new String[] { getCallbackComponentServiceName() };
+ return new String[]
+ {
+ getCallbackComponentServiceName()
+ };
}
public void dispose()
{
- EventObject event = new EventObject( this );
+ final EventObject event = new EventObject(this);
- Vector eventListenersCopy = (Vector)m_eventListeners.clone();
- Iterator iter = eventListenersCopy.iterator();
- while ( iter.hasNext() )
+ final ArrayList eventListenersCopy = (ArrayList) m_eventListeners.clone();
+ final Iterator iter = eventListenersCopy.iterator();
+ while (iter.hasNext())
{
- ((XEventListener)iter.next()).disposing( event );
+ ((XEventListener) iter.next()).disposing(event);
}
}
- public void addEventListener( XEventListener _listener )
+ public void addEventListener(XEventListener _listener)
{
- if ( _listener != null )
- m_eventListeners.add( _listener );
+ if (_listener != null)
+ {
+ m_eventListeners.add(_listener);
+ }
}
- public void removeEventListener( XEventListener _listener )
+ public void removeEventListener(XEventListener _listener)
{
- m_eventListeners.remove( _listener );
+ m_eventListeners.remove(_listener);
}
};
// ========================================================================================================
private class MacroExecutionApprove implements XInteractionHandler
{
+
private XInteractionHandler m_defaultHandler = null;
- MacroExecutionApprove( XMultiServiceFactory _factory )
+ MacroExecutionApprove(XMultiServiceFactory _factory)
{
try
{
- m_defaultHandler = (XInteractionHandler)UnoRuntime.queryInterface( XInteractionHandler.class,
- _factory.createInstance( "com.sun.star.sdb.InteractionHandler" ) );
+ m_defaultHandler = (XInteractionHandler) UnoRuntime.queryInterface(XInteractionHandler.class,
+ _factory.createInstance("com.sun.star.sdb.InteractionHandler"));
}
- catch ( Exception ex )
+ catch (Exception ex)
{
- Logger.getLogger( DatabaseDocument.class.getName() ).log( Level.SEVERE, null, ex );
+ Logger.getLogger(DatabaseDocument.class.getName()).log(Level.SEVERE, null, ex);
}
}
- public void handle( XInteractionRequest _request )
+ public void handle(XInteractionRequest _request)
{
- Object request = _request.getRequest();
- if ( !( request instanceof DocumentMacroConfirmationRequest ) && ( m_defaultHandler != null ) )
+ final Object request = _request.getRequest();
+ if (!(request instanceof DocumentMacroConfirmationRequest) && (m_defaultHandler != null))
{
- m_defaultHandler.handle( _request );
+ m_defaultHandler.handle(_request);
return;
}
- assureEquals( "interaction handleer called in wrong state", STATE_LOADING_DOC, m_loadDocState );
+ assureEquals("interaction handleer called in wrong state", STATE_LOADING_DOC, m_loadDocState);
// auto-approve
- XInteractionContinuation continuations[] = _request.getContinuations();
- for ( int i=0; i<continuations.length; ++i )
+ final XInteractionContinuation continuations[] = _request.getContinuations();
+ for (int i = 0; i < continuations.length; ++i)
{
- XInteractionApprove approve = (XInteractionApprove)UnoRuntime.queryInterface( XInteractionApprove.class,
- continuations[i] );
- if ( approve != null )
+ final XInteractionApprove approve = (XInteractionApprove) UnoRuntime.queryInterface(XInteractionApprove.class,
+ continuations[i]);
+ if (approve != null)
{
approve.select();
m_loadDocState = STATE_MACRO_EXEC_APPROVED;
@@ -243,11 +252,11 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document.
public String[] getTestMethodNames()
{
return new String[]
- {
- "testLoadable",
- "testDocumentEvents",
- "testGlobalEvents"
- };
+ {
+ "testLoadable",
+ "testDocumentEvents",
+ "testGlobalEvents"
+ };
}
// --------------------------------------------------------------------------------------------------------
@@ -265,21 +274,21 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document.
// at our service factory, insert a new factory for our CallbackComponent
// this will allow the Basic code in our test documents to call back into this test case
// here, by just instantiating this service
- XSet globalFactory = (XSet)UnoRuntime.queryInterface(
- XSet.class, getORB() );
+ final XSet globalFactory = (XSet) UnoRuntime.queryInterface(
+ XSet.class, getORB());
m_callbackFactory = new CallbackComponentFactory();
- globalFactory.insert( m_callbackFactory );
+ globalFactory.insert(m_callbackFactory);
// register ourself as listener at the global event broadcaster
- XDocumentEventBroadcaster broadcaster = (XDocumentEventBroadcaster)UnoRuntime.queryInterface(
- XDocumentEventBroadcaster.class, getORB().createInstance( "com.sun.star.frame.GlobalEventBroadcaster" ) );
- broadcaster.addDocumentEventListener( this );
+ final XDocumentEventBroadcaster broadcaster = (XDocumentEventBroadcaster) UnoRuntime.queryInterface(
+ XDocumentEventBroadcaster.class, getORB().createInstance("com.sun.star.frame.GlobalEventBroadcaster"));
+ broadcaster.addDocumentEventListener(this);
}
- catch( Exception e )
+ catch (Exception e)
{
- System.err.println( "could not create the test case, error message:\n" + e.getMessage() );
- e.printStackTrace( System.err );
- failed( "failed to create the test case" );
+ log.println("could not create the test case, error message:\n" + e.getMessage());
+ e.printStackTrace(System.err);
+ failed("failed to create the test case");
}
}
@@ -295,25 +304,26 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document.
m_callbackFactory.dispose();
// revoke ourself as listener at the global event broadcaster
- XDocumentEventBroadcaster broadcaster = (XDocumentEventBroadcaster) UnoRuntime.queryInterface(
- XDocumentEventBroadcaster.class, getORB().createInstance( "com.sun.star.frame.GlobalEventBroadcaster" ) );
- broadcaster.removeDocumentEventListener( this );
+ final XDocumentEventBroadcaster broadcaster = (XDocumentEventBroadcaster) UnoRuntime.queryInterface(
+ XDocumentEventBroadcaster.class, getORB().createInstance("com.sun.star.frame.GlobalEventBroadcaster"));
+ broadcaster.removeDocumentEventListener(this);
}
- catch ( Exception e )
+ catch (Exception e)
{
- System.err.println( "could not close the test case, error message:\n" + e.getMessage() );
- e.printStackTrace( System.err );
- failed( "failed to close the test case" );
+ log.println("could not create the test case, error message:\n" + e.getMessage());
+ e.printStackTrace(System.err);
+ failed("failed to close the test case");
}
}
// --------------------------------------------------------------------------------------------------------
- private class UnoMethodDescriptor
+ private static class UnoMethodDescriptor
{
- public Class unoInterfaceClass = null;
- public String methodName = null;
- public UnoMethodDescriptor( Class _class, String _method )
+ public Class unoInterfaceClass = null;
+ public String methodName = null;
+
+ public UnoMethodDescriptor(Class _class, String _method)
{
unoInterfaceClass = _class;
methodName = _method;
@@ -321,21 +331,22 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document.
}
// --------------------------------------------------------------------------------------------------------
- private void impl_checkDocumentInitState( Object _document, boolean _isInitialized )
+ private void impl_checkDocumentInitState(Object _document, boolean _isInitialized)
{
// things you cannot do with an uninitialized document:
- UnoMethodDescriptor[] unsupportedMethods = new UnoMethodDescriptor[] {
- new UnoMethodDescriptor( XStorable.class, "store" ),
- new UnoMethodDescriptor( XFormDocumentsSupplier.class, "getFormDocuments" ),
- new UnoMethodDescriptor( XReportDocumentsSupplier.class, "getReportDocuments" ),
- new UnoMethodDescriptor( XScriptProviderSupplier.class, "getScriptProvider" ),
- new UnoMethodDescriptor( XEventsSupplier.class, "getEvents" ),
- new UnoMethodDescriptor( XTitle.class, "getTitle" ),
- new UnoMethodDescriptor( XModel2.class, "getControllers" )
- // (there's much more than this, but we cannot list all methods here, can we ...)
+ final UnoMethodDescriptor[] unsupportedMethods = new UnoMethodDescriptor[]
+ {
+ new UnoMethodDescriptor(XStorable.class, "store"),
+ new UnoMethodDescriptor(XFormDocumentsSupplier.class, "getFormDocuments"),
+ new UnoMethodDescriptor(XReportDocumentsSupplier.class, "getReportDocuments"),
+ new UnoMethodDescriptor(XScriptProviderSupplier.class, "getScriptProvider"),
+ new UnoMethodDescriptor(XEventsSupplier.class, "getEvents"),
+ new UnoMethodDescriptor(XTitle.class, "getTitle"),
+ new UnoMethodDescriptor(XModel2.class, "getControllers")
+ // (there's much more than this, but we cannot list all methods here, can we ...)
};
- for ( int i=0; i<unsupportedMethods.length; ++i)
+ for (int i = 0; i < unsupportedMethods.length; ++i)
{
assureException( _document, unsupportedMethods[i].unoInterfaceClass,
unsupportedMethods[i].methodName, new Object[]{}, _isInitialized ? null : NotInitializedException.class );
@@ -343,59 +354,59 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document.
}
// --------------------------------------------------------------------------------------------------------
- private XModel impl_createDocument( ) throws Exception
+ private XModel impl_createDocument() throws Exception
{
- XModel databaseDoc = (XModel)UnoRuntime.queryInterface( XModel.class,
- getORB().createInstance( "com.sun.star.sdb.OfficeDatabaseDocument" ) );
+ final XModel databaseDoc = (XModel) UnoRuntime.queryInterface(XModel.class,
+ getORB().createInstance("com.sun.star.sdb.OfficeDatabaseDocument"));
// should not be initialized here - we did neither initNew nor load nor storeAsURL it
- impl_checkDocumentInitState( databaseDoc, false );
+ impl_checkDocumentInitState(databaseDoc, false);
return databaseDoc;
}
// --------------------------------------------------------------------------------------------------------
- private void impl_closeDocument( XModel _databaseDoc ) throws CloseVetoException, IOException, Exception
+ private void impl_closeDocument(XModel _databaseDoc) throws CloseVetoException, IOException, Exception
{
- XCloseable closeDoc = (XCloseable)UnoRuntime.queryInterface( XCloseable.class,
- _databaseDoc );
- closeDoc.close( true );
+ final XCloseable closeDoc = (XCloseable) UnoRuntime.queryInterface(XCloseable.class,
+ _databaseDoc);
+ closeDoc.close(true);
}
// --------------------------------------------------------------------------------------------------------
private XModel impl_createEmptyEmbeddedHSQLDocument() throws Exception, IOException
{
- XModel databaseDoc = (XModel)UnoRuntime.queryInterface( XModel.class,
- getORB().createInstance( "com.sun.star.sdb.OfficeDatabaseDocument" ) );
- XStorable storeDoc = (XStorable)UnoRuntime.queryInterface( XStorable.class, databaseDoc );
+ final XModel databaseDoc = (XModel) UnoRuntime.queryInterface(XModel.class,
+ getORB().createInstance("com.sun.star.sdb.OfficeDatabaseDocument"));
+ final XStorable storeDoc = (XStorable) UnoRuntime.queryInterface(XStorable.class, databaseDoc);
// verify the document rejects API calls which require it to be initialized
- impl_checkDocumentInitState( databaseDoc, false );
+ impl_checkDocumentInitState(databaseDoc, false);
// though the document is not initialized, you can ask for the location, the URL, and the args
- String location = storeDoc.getLocation();
- String url = databaseDoc.getURL();
- PropertyValue[] args = databaseDoc.getArgs();
+ final String location = storeDoc.getLocation();
+ final String url = databaseDoc.getURL();
+ final PropertyValue[] args = databaseDoc.getArgs();
// they should be all empty at this time
- assureEquals( "location is expected to be empty here", "", location );
- assureEquals( "URL is expected to be empty here", "", url );
- assureEquals( "Args are expected to be empty here", 0, args.length );
+ assureEquals("location is expected to be empty here", "", location);
+ assureEquals("URL is expected to be empty here", "", url);
+ assureEquals("Args are expected to be empty here", 0, args.length);
// and, you should be able to set properties at the data source
- XOfficeDatabaseDocument dataSourceAccess = (XOfficeDatabaseDocument)UnoRuntime.queryInterface(
- XOfficeDatabaseDocument.class, databaseDoc );
- XPropertySet dsProperties = (XPropertySet)UnoRuntime.queryInterface(
- XPropertySet.class, dataSourceAccess.getDataSource() );
- dsProperties.setPropertyValue( "URL", "sdbc:embedded:hsqldb" );
+ final XOfficeDatabaseDocument dataSourceAccess = (XOfficeDatabaseDocument) UnoRuntime.queryInterface(
+ XOfficeDatabaseDocument.class, databaseDoc);
+ final XPropertySet dsProperties = (XPropertySet) UnoRuntime.queryInterface(
+ XPropertySet.class, dataSourceAccess.getDataSource());
+ dsProperties.setPropertyValue("URL", "sdbc:embedded:hsqldb");
- String documentURL = createTempFileURL();
- storeDoc.storeAsURL( documentURL, new PropertyValue[0] );
+ final String documentURL = createTempFileURL();
+ storeDoc.storeAsURL(documentURL, new PropertyValue[0]);
// now that the document is stored, ...
// ... its URL should be correct
- assureEquals( "wrong URL after storing the document", documentURL, databaseDoc.getURL() );
+ assureEquals("wrong URL after storing the document", documentURL, databaseDoc.getURL());
// ... it should be initialized
- impl_checkDocumentInitState( databaseDoc, true );
+ impl_checkDocumentInitState(databaseDoc, true);
return databaseDoc;
}
@@ -415,16 +426,19 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document.
// ....................................................................
// 2. XLoadable::load
- databaseDoc = (XModel)UnoRuntime.queryInterface( XModel.class,
- getORB().createInstance( "com.sun.star.sdb.OfficeDatabaseDocument" ) );
- documentURL = copyToTempFile( documentURL );
+ databaseDoc = (XModel) UnoRuntime.queryInterface(XModel.class,
+ getORB().createInstance("com.sun.star.sdb.OfficeDatabaseDocument"));
+ documentURL = copyToTempFile(documentURL);
// load the doc, and verify it's initialized then, and has the proper URL
- XLoadable loadDoc = (XLoadable)UnoRuntime.queryInterface( XLoadable.class, databaseDoc );
- loadDoc.load( new PropertyValue[] { new PropertyValue( "URL", 0, documentURL, PropertyState.DIRECT_VALUE ) } );
- databaseDoc.attachResource( documentURL, new PropertyValue[0] );
+ XLoadable loadDoc = (XLoadable) UnoRuntime.queryInterface(XLoadable.class, databaseDoc);
+ loadDoc.load(new PropertyValue[]
+ {
+ new PropertyValue("URL", 0, documentURL, PropertyState.DIRECT_VALUE)
+ });
+ databaseDoc.attachResource(documentURL, new PropertyValue[0]);
- assureEquals( "wrong URL after loading the document", documentURL, databaseDoc.getURL() );
- impl_checkDocumentInitState( databaseDoc, true );
+ assureEquals("wrong URL after loading the document", documentURL, databaseDoc.getURL());
+ impl_checkDocumentInitState(databaseDoc, true);
// and while we are here ... initilizing the same document again should not be possible
assureException( databaseDoc, XLoadable.class, "initNew", new Object[0],
@@ -434,12 +448,12 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document.
// ....................................................................
// 3. XLoadable::initNew
- impl_closeDocument( databaseDoc );
+ impl_closeDocument(databaseDoc);
databaseDoc = impl_createDocument();
- loadDoc = (XLoadable)UnoRuntime.queryInterface( XLoadable.class, databaseDoc );
+ loadDoc = (XLoadable) UnoRuntime.queryInterface(XLoadable.class, databaseDoc);
loadDoc.initNew();
- assureEquals( "wrong URL after initializing the document", "", databaseDoc.getURL() );
- impl_checkDocumentInitState( databaseDoc, true );
+ assureEquals("wrong URL after initializing the document", "", databaseDoc.getURL());
+ impl_checkDocumentInitState(databaseDoc, true);
// same as above - initializing the document a second time must fail
assureException( databaseDoc, XLoadable.class, "initNew", new Object[0],
@@ -451,38 +465,41 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document.
// --------------------------------------------------------------------------------------------------------
private PropertyValue[] impl_getDefaultLoadArgs()
{
- return new PropertyValue[] {
- new PropertyValue( "PickListEntry", 0, false, PropertyState.DIRECT_VALUE )
- };
+ return new PropertyValue[]
+ {
+ new PropertyValue("PickListEntry", 0, false, PropertyState.DIRECT_VALUE)
+ };
}
// --------------------------------------------------------------------------------------------------------
private PropertyValue[] impl_getMacroExecLoadArgs()
{
- return new PropertyValue[] {
- new PropertyValue( "PickListEntry", 0, false, PropertyState.DIRECT_VALUE ),
- new PropertyValue( "MacroExecutionMode", 0, com.sun.star.document.MacroExecMode.USE_CONFIG, PropertyState.DIRECT_VALUE ),
- new PropertyValue( "InteractionHandler", 0, new MacroExecutionApprove(( getORB() )), PropertyState.DIRECT_VALUE )
- };
+ return new PropertyValue[]
+ {
+ new PropertyValue("PickListEntry", 0, false, PropertyState.DIRECT_VALUE),
+ new PropertyValue("MacroExecutionMode", 0, com.sun.star.document.MacroExecMode.USE_CONFIG, PropertyState.DIRECT_VALUE),
+ new PropertyValue("InteractionHandler", 0, new MacroExecutionApprove(getORB()), PropertyState.DIRECT_VALUE)
+ };
}
// --------------------------------------------------------------------------------------------------------
- private int impl_setMacroSecurityLevel( int _level ) throws Exception
+ private int impl_setMacroSecurityLevel(int _level) throws Exception
{
- XMultiServiceFactory configProvider = (XMultiServiceFactory)UnoRuntime.queryInterface( XMultiServiceFactory.class,
- getORB().createInstance( "com.sun.star.configuration.ConfigurationProvider" ) );
+ final XMultiServiceFactory configProvider = (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class,
+ getORB().createInstance("com.sun.star.configuration.ConfigurationProvider"));
- PropertyValue[] args = new PropertyValue[] {
- new PropertyValue( "nodepath", 0, "/org.openoffice.Office.Common/Security/Scripting", PropertyState.DIRECT_VALUE )
+ final PropertyValue[] args = new PropertyValue[]
+ {
+ new PropertyValue("nodepath", 0, "/org.openoffice.Office.Common/Security/Scripting", PropertyState.DIRECT_VALUE)
};
- XPropertySet securitySettings = (XPropertySet)UnoRuntime.queryInterface( XPropertySet.class,
- configProvider.createInstanceWithArguments( "com.sun.star.configuration.ConfigurationUpdateAccess", args ) );
- int oldValue = ((Integer)securitySettings.getPropertyValue( "MacroSecurityLevel" )).intValue();
- securitySettings.setPropertyValue( "MacroSecurityLevel", new Integer( _level ) );
+ final XPropertySet securitySettings = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class,
+ configProvider.createInstanceWithArguments("com.sun.star.configuration.ConfigurationUpdateAccess", args));
+ final int oldValue = ((Integer) securitySettings.getPropertyValue("MacroSecurityLevel")).intValue();
+ securitySettings.setPropertyValue("MacroSecurityLevel", Integer.valueOf(_level));
- XChangesBatch committer = (XChangesBatch)UnoRuntime.queryInterface( XChangesBatch.class,
- securitySettings );
+ final XChangesBatch committer = (XChangesBatch) UnoRuntime.queryInterface(XChangesBatch.class,
+ securitySettings);
committer.commitChanges();
return oldValue;
@@ -495,50 +512,50 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document.
XModel databaseDoc = impl_createEmptyEmbeddedHSQLDocument();
// create Basic library/module therein
- XEmbeddedScripts embeddedScripts = (XEmbeddedScripts) UnoRuntime.queryInterface( XEmbeddedScripts.class,
- databaseDoc );
- XStorageBasedLibraryContainer basicLibs = embeddedScripts.getBasicLibraries();
- XNameContainer newLib = basicLibs.createLibrary( "EventHandlers" );
- String eventHandlerCode =
- "Option Explicit\n" +
- "\n" +
- "Sub OnLoad\n" +
- " Dim oCallback as Object\n" +
- " oCallback = createUnoService( \"" + getCallbackComponentServiceName() + "\" )\n" +
- "\n" +
- " ' as long as the Document is not passed to the Basic callbacks, we need to create\n" +
- " ' one ourself\n" +
- " Dim oEvent as new com.sun.star.document.DocumentEvent\n" +
- " oEvent.EventName = \"OnLoad\"\n" +
- " oEvent.Source = ThisComponent\n" +
- "\n" +
- " oCallback.documentEventOccured( oEvent )\n" +
- "End Sub\n";
- newLib.insertByName( "all", eventHandlerCode );
+ final XEmbeddedScripts embeddedScripts = (XEmbeddedScripts) UnoRuntime.queryInterface(XEmbeddedScripts.class,
+ databaseDoc);
+ final XStorageBasedLibraryContainer basicLibs = embeddedScripts.getBasicLibraries();
+ final XNameContainer newLib = basicLibs.createLibrary("EventHandlers");
+ final String eventHandlerCode =
+ "Option Explicit\n" +
+ "\n" +
+ "Sub OnLoad\n" +
+ " Dim oCallback as Object\n" +
+ " oCallback = createUnoService( \"" + getCallbackComponentServiceName() + "\" )\n" +
+ "\n" +
+ " ' as long as the Document is not passed to the Basic callbacks, we need to create\n" +
+ " ' one ourself\n" +
+ " Dim oEvent as new com.sun.star.document.DocumentEvent\n" +
+ " oEvent.EventName = \"OnLoad\"\n" +
+ " oEvent.Source = ThisComponent\n" +
+ "\n" +
+ " oCallback.documentEventOccured( oEvent )\n" +
+ "End Sub\n";
+ newLib.insertByName("all", eventHandlerCode);
// bind the macro to the OnLoad event
- String macroURI = "vnd.sun.star.script:EventHandlers.all.OnLoad?language=Basic&location=document";
- XEventsSupplier eventsSupplier = (XEventsSupplier)UnoRuntime.queryInterface( XEventsSupplier.class,
- databaseDoc );
- eventsSupplier.getEvents().replaceByName( "OnLoad", new PropertyValue[] {
- new PropertyValue( "EventType", 0, "Script", PropertyState.DIRECT_VALUE ),
- new PropertyValue( "Script", 0, macroURI, PropertyState.DIRECT_VALUE )
- } );
+ final String macroURI = "vnd.sun.star.script:EventHandlers.all.OnLoad?language=Basic&location=document";
+ final XEventsSupplier eventsSupplier = (XEventsSupplier) UnoRuntime.queryInterface(XEventsSupplier.class,
+ databaseDoc);
+ eventsSupplier.getEvents().replaceByName(ONLOAD, new PropertyValue[]
+ {
+ new PropertyValue("EventType", 0, "Script", PropertyState.DIRECT_VALUE),
+ new PropertyValue("Script", 0, macroURI, PropertyState.DIRECT_VALUE)
+ });
// store the document, and close it
- String documentURL = databaseDoc.getURL();
- documentURL = FileHelper.getOOoCompatibleFileURL( documentURL );
- XStorable storeDoc = (XStorable) UnoRuntime.queryInterface( XStorable.class,
- databaseDoc );
+ final String documentURL = FileHelper.getOOoCompatibleFileURL(databaseDoc.getURL());
+ final XStorable storeDoc = (XStorable) UnoRuntime.queryInterface(XStorable.class,
+ databaseDoc);
storeDoc.store();
- impl_closeDocument( databaseDoc );
+ impl_closeDocument(databaseDoc);
// ensure the macro security configuration is "ask the user for document macro execution"
- int oldSecurityLevel = impl_setMacroSecurityLevel( 1 );
+ final int oldSecurityLevel = impl_setMacroSecurityLevel(1);
// load it, again
- XComponentLoader loader = (XComponentLoader)UnoRuntime.queryInterface( XComponentLoader.class,
- getORB().createInstance( "com.sun.star.frame.Desktop" ) );
+ final XComponentLoader loader = (XComponentLoader) UnoRuntime.queryInterface(XComponentLoader.class,
+ getORB().createInstance("com.sun.star.frame.Desktop"));
m_loadDocState = STATE_LOADING_DOC;
// expected order of states is:
@@ -550,296 +567,342 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document.
// here) is called before the OnLoad notification is received - since the latter happens from within
// a Basic macro which is bound to the OnLoad event of the document.
- String context = "OnLoad";
- impl_startObservingEvents( context );
- databaseDoc = (XModel)UnoRuntime.queryInterface( XModel.class,
- loader.loadComponentFromURL( documentURL, "_blank", 0, impl_getMacroExecLoadArgs() ) );
- impl_stopObservingEvents( m_documentEvents, new String[] { "OnLoad" }, context );
+ final String context = ONLOAD;
+ impl_startObservingEvents(context);
+ databaseDoc = (XModel) UnoRuntime.queryInterface(XModel.class,
+ loader.loadComponentFromURL(documentURL, _BLANK, 0, impl_getMacroExecLoadArgs()));
+ impl_stopObservingEvents(m_documentEvents, new String[]
+ {
+ ONLOAD
+ }, context);
- assureEquals( "our provided interaction handler was not called", STATE_ON_LOAD_RECEIVED, m_loadDocState );
+ assureEquals("our provided interaction handler was not called", STATE_ON_LOAD_RECEIVED, m_loadDocState);
// restore macro security level
- impl_setMacroSecurityLevel( oldSecurityLevel );
+ impl_setMacroSecurityLevel(oldSecurityLevel);
// close the document
- impl_closeDocument( databaseDoc );
+ impl_closeDocument(databaseDoc);
}
// --------------------------------------------------------------------------------------------------------
public void testGlobalEvents() throws Exception, IOException
{
XModel databaseDoc = impl_createEmptyEmbeddedHSQLDocument();
- XStorable storeDoc = (XStorable) UnoRuntime.queryInterface( XStorable.class,
- databaseDoc );
+ final XStorable storeDoc = (XStorable) UnoRuntime.queryInterface(XStorable.class,
+ databaseDoc);
- String oldURL = null, newURL = null, context = null;
+ String context, newURL;
// XStorable.store
- oldURL = databaseDoc.getURL();
+ final String oldURL = databaseDoc.getURL();
context = "store";
- impl_startObservingEvents( context );
+ impl_startObservingEvents(context);
storeDoc.store();
- assureEquals( "store is not expected to change the document URL", databaseDoc.getURL(), oldURL );
- impl_stopObservingEvents( m_globalEvents, new String[] { "OnSave", "OnSaveDone" }, context );
+ assureEquals("store is not expected to change the document URL", databaseDoc.getURL(), oldURL);
+ impl_stopObservingEvents(m_globalEvents, new String[]
+ {
+ "OnSave", "OnSaveDone"
+ }, context);
// XStorable.storeToURL
context = "storeToURL";
- impl_startObservingEvents( context );
- storeDoc.storeToURL( createTempFileURL(), new PropertyValue[0] );
- assureEquals( "storetoURL is not expected to change the document URL", databaseDoc.getURL(), oldURL );
- impl_stopObservingEvents( m_globalEvents, new String[] { "OnSaveTo", "OnSaveToDone" }, context );
+ impl_startObservingEvents(context);
+ storeDoc.storeToURL(createTempFileURL(), new PropertyValue[0]);
+ assureEquals("storetoURL is not expected to change the document URL", databaseDoc.getURL(), oldURL);
+ impl_stopObservingEvents(m_globalEvents, new String[]
+ {
+ "OnSaveTo", "OnSaveToDone"
+ }, context);
// XStorable.storeAsURL
newURL = createTempFileURL();
context = "storeAsURL";
- impl_startObservingEvents( context );
- storeDoc.storeAsURL( newURL, new PropertyValue[0] );
- assureEquals( "storeAsURL is expected to change the document URL", databaseDoc.getURL(), newURL );
- impl_stopObservingEvents( m_globalEvents, new String[] { "OnSaveAs", "OnSaveAsDone" }, context );
+ impl_startObservingEvents(context);
+ storeDoc.storeAsURL(newURL, new PropertyValue[0]);
+ assureEquals("storeAsURL is expected to change the document URL", databaseDoc.getURL(), newURL);
+ impl_stopObservingEvents(m_globalEvents, new String[]
+ {
+ "OnSaveAs", "OnSaveAsDone"
+ }, context);
// XModifiable.setModified
- XModifiable modifyDoc = (XModifiable) UnoRuntime.queryInterface( XModifiable.class,
- databaseDoc );
+ final XModifiable modifyDoc = (XModifiable) UnoRuntime.queryInterface(XModifiable.class,
+ databaseDoc);
context = "setModified";
- impl_startObservingEvents( context );
- modifyDoc.setModified( true );
- assureEquals( "setModified didn't work", modifyDoc.isModified(), true );
- impl_stopObservingEvents( m_globalEvents, new String[] { "OnModifyChanged" }, context );
+ impl_startObservingEvents(context);
+ modifyDoc.setModified(true);
+ assureEquals("setModified didn't work", modifyDoc.isModified(), true);
+ impl_stopObservingEvents(m_globalEvents, new String[]
+ {
+ "OnModifyChanged"
+ }, context);
// XStorable.store, with implicit reset of the "Modified" flag
context = "store (2)";
- impl_startObservingEvents( context );
+ impl_startObservingEvents(context);
storeDoc.store();
- assureEquals( "'store' should implicitly reset the modified flag", modifyDoc.isModified(), false );
- impl_stopObservingEvents( m_globalEvents, new String[] { "OnSave", "OnSaveDone", "OnModifyChanged" }, context );
+ assureEquals("'store' should implicitly reset the modified flag", modifyDoc.isModified(), false);
+ impl_stopObservingEvents(m_globalEvents, new String[]
+ {
+ "OnSave", "OnSaveDone", "OnModifyChanged"
+ }, context);
// XComponentLoader.loadComponentFromURL
- newURL = copyToTempFile( databaseDoc.getURL() );
- XComponentLoader loader = (XComponentLoader)UnoRuntime.queryInterface( XComponentLoader.class,
- getORB().createInstance( "com.sun.star.frame.Desktop" ) );
+ newURL = copyToTempFile(databaseDoc.getURL());
+ final XComponentLoader loader = (XComponentLoader) UnoRuntime.queryInterface(XComponentLoader.class,
+ getORB().createInstance("com.sun.star.frame.Desktop"));
context = "loadComponentFromURL";
- impl_startObservingEvents( context );
- databaseDoc = (XModel) UnoRuntime.queryInterface( XModel.class,
- loader.loadComponentFromURL( newURL, "_blank", 0, impl_getDefaultLoadArgs() ) );
- impl_stopObservingEvents( m_globalEvents,
- new String[] { "OnLoadFinished", "OnViewCreated", "OnFocus", "OnLoad" }, context );
+ impl_startObservingEvents(context);
+ databaseDoc = (XModel) UnoRuntime.queryInterface(XModel.class,
+ loader.loadComponentFromURL(newURL, _BLANK, 0, impl_getDefaultLoadArgs()));
+ impl_stopObservingEvents(m_globalEvents,
+ new String[]
+ {
+ "OnLoadFinished", "OnViewCreated", "OnFocus", ONLOAD
+ }, context);
// closing a document by API
- XCloseable closeDoc = (XCloseable) UnoRuntime.queryInterface( XCloseable.class,
- databaseDoc );
+ final XCloseable closeDoc = (XCloseable) UnoRuntime.queryInterface(XCloseable.class,
+ databaseDoc);
context = "close (API)";
- impl_startObservingEvents( context );
- closeDoc.close( true );
- impl_stopObservingEvents( m_globalEvents,
- new String[] { "OnPrepareUnload", "OnViewClosed", "OnUnload" }, context );
+ impl_startObservingEvents(context);
+ closeDoc.close(true);
+ impl_stopObservingEvents(m_globalEvents,
+ new String[]
+ {
+ "OnPrepareUnload", "OnViewClosed", "OnUnload"
+ }, context);
// closing a document via UI
context = "close (UI)";
- impl_startObservingEvents( "prepare for '" + context + "'" );
- databaseDoc = (XModel)UnoRuntime.queryInterface( XModel.class,
- loader.loadComponentFromURL( newURL, "_blank", 0, impl_getDefaultLoadArgs() ) );
- impl_waitForEvent( m_globalEvents, "OnLoad", 5000 );
- // wait for all events to arrive - OnLoad should be the last one
-
- XDispatchProvider dispatchProvider = (XDispatchProvider) UnoRuntime.queryInterface( XDispatchProvider.class,
- databaseDoc.getCurrentController().getFrame() );
- URL url = impl_getURL( ".uno:CloseDoc" );
- XDispatch dispatcher = dispatchProvider.queryDispatch( url, "", 0 );
- impl_startObservingEvents( context );
- dispatcher.dispatch( url, new PropertyValue[0] );
- impl_stopObservingEvents( m_globalEvents,
- new String[] { "OnPrepareViewClosing", "OnViewClosed", "OnPrepareUnload", "OnUnload" }, context );
+ impl_startObservingEvents("prepare for '" + context + "'");
+ databaseDoc = (XModel) UnoRuntime.queryInterface(XModel.class,
+ loader.loadComponentFromURL(newURL, _BLANK, 0, impl_getDefaultLoadArgs()));
+ impl_waitForEvent(m_globalEvents, ONLOAD, 5000);
+ // wait for all events to arrive - OnLoad should be the last one
+
+ final XDispatchProvider dispatchProvider = (XDispatchProvider) UnoRuntime.queryInterface(XDispatchProvider.class,
+ databaseDoc.getCurrentController().getFrame());
+ final URL url = impl_getURL(".uno:CloseDoc");
+ final XDispatch dispatcher = dispatchProvider.queryDispatch(url, "", 0);
+ impl_startObservingEvents(context);
+ dispatcher.dispatch(url, new PropertyValue[0]);
+ impl_stopObservingEvents(m_globalEvents,
+ new String[]
+ {
+ "OnPrepareViewClosing", "OnViewClosed", "OnPrepareUnload", "OnUnload"
+ }, context);
// creating a new document
databaseDoc = impl_createDocument();
- XLoadable loadDoc = (XLoadable) UnoRuntime.queryInterface( XLoadable.class,
- databaseDoc );
+ final XLoadable loadDoc = (XLoadable) UnoRuntime.queryInterface(XLoadable.class,
+ databaseDoc);
context = "initNew";
- impl_startObservingEvents( context );
+ impl_startObservingEvents(context);
loadDoc.initNew();
- impl_stopObservingEvents( m_globalEvents, new String[] { "OnCreate" }, context );
+ impl_stopObservingEvents(m_globalEvents, new String[]
+ {
+ "OnCreate"
+ }, context);
- impl_startObservingEvents( context + " (cleanup)" );
- impl_closeDocument( databaseDoc );
- impl_waitForEvent( m_globalEvents, "OnUnload", 5000 );
+ impl_startObservingEvents(context + " (cleanup)");
+ impl_closeDocument(databaseDoc);
+ impl_waitForEvent(m_globalEvents, "OnUnload", 5000);
// focus changes
context = "activation";
// for this, load a database document ...
- impl_startObservingEvents( "prepare for '" + context + "'" );
- databaseDoc = (XModel)UnoRuntime.queryInterface( XModel.class,
- loader.loadComponentFromURL( newURL, "_blank", 0, impl_getDefaultLoadArgs() ) );
- int previousOnLoadEventPos = impl_waitForEvent( m_globalEvents, "OnLoad", 5000 );
+ impl_startObservingEvents("prepare for '" + context + "'");
+ databaseDoc = (XModel) UnoRuntime.queryInterface(XModel.class,
+ loader.loadComponentFromURL(newURL, _BLANK, 0, impl_getDefaultLoadArgs()));
+ final int previousOnLoadEventPos = impl_waitForEvent(m_globalEvents, ONLOAD, 5000);
// ... and another document ...
- String otherURL = copyToTempFile( databaseDoc.getURL() );
- XModel otherDoc = (XModel)UnoRuntime.queryInterface( XModel.class,
- loader.loadComponentFromURL( otherURL, "_blank", 0, impl_getDefaultLoadArgs() ) );
- impl_waitForEvent( m_globalEvents, "OnLoad", 5000, previousOnLoadEventPos + 1 );
- impl_raise( otherDoc );
+ final String otherURL = copyToTempFile(databaseDoc.getURL());
+ final XModel otherDoc = (XModel) UnoRuntime.queryInterface(XModel.class,
+ loader.loadComponentFromURL(otherURL, _BLANK, 0, impl_getDefaultLoadArgs()));
+ impl_waitForEvent(m_globalEvents, ONLOAD, 5000, previousOnLoadEventPos + 1);
+ impl_raise(otherDoc);
// ... and switch between the two
- impl_startObservingEvents( context );
- impl_raise( databaseDoc );
- impl_stopObservingEvents( m_globalEvents, new String[] { "OnUnfocus", "OnFocus" }, context );
+ impl_startObservingEvents(context);
+ impl_raise(databaseDoc);
+ impl_stopObservingEvents(m_globalEvents, new String[]
+ {
+ "OnUnfocus", "OnFocus"
+ }, context);
// cleanup
- impl_startObservingEvents( "cleanup after '" + context + "'" );
- impl_closeDocument( databaseDoc );
- impl_closeDocument( otherDoc );
+ impl_startObservingEvents("cleanup after '" + context + "'");
+ impl_closeDocument(databaseDoc);
+ impl_closeDocument(otherDoc);
}
// --------------------------------------------------------------------------------------------------------
- private URL impl_getURL( String _completeURL ) throws Exception
+ private URL impl_getURL(String _completeURL) throws Exception
{
- URL[] url = { new URL() };
+ final URL[] url =
+ {
+ new URL()
+ };
url[0].Complete = _completeURL;
- XURLTransformer urlTransformer = (XURLTransformer) UnoRuntime.queryInterface( XURLTransformer.class,
- getORB().createInstance( "com.sun.star.util.URLTransformer" ) );
- urlTransformer.parseStrict( url );
+ final XURLTransformer urlTransformer = (XURLTransformer) UnoRuntime.queryInterface(XURLTransformer.class,
+ getORB().createInstance("com.sun.star.util.URLTransformer"));
+ urlTransformer.parseStrict(url);
return url[0];
}
// --------------------------------------------------------------------------------------------------------
- private void impl_raise( XModel _document )
+ private void impl_raise(XModel _document)
{
- XFrame frame = _document.getCurrentController().getFrame();
- XTopWindow topWindow = (XTopWindow) UnoRuntime.queryInterface( XTopWindow.class,
- frame.getContainerWindow() );
+ final XFrame frame = _document.getCurrentController().getFrame();
+ final XTopWindow topWindow = (XTopWindow) UnoRuntime.queryInterface(XTopWindow.class,
+ frame.getContainerWindow());
topWindow.toFront();
}
// --------------------------------------------------------------------------------------------------------
- private void impl_startObservingEvents( String _context )
+ private void impl_startObservingEvents(String _context)
{
- log.println( " " + _context );
- synchronized ( m_documentEvents )
+ log.println(" " + _context);
+ synchronized (m_documentEvents)
{
m_documentEvents.clear();
}
- synchronized ( m_globalEvents )
+ synchronized (m_globalEvents)
{
m_globalEvents.clear();
}
}
// --------------------------------------------------------------------------------------------------------
- private void impl_stopObservingEvents( Vector _actualEvents, String[] _expectedEvents, String _context )
+ private void impl_stopObservingEvents(ArrayList _actualEvents, String[] _expectedEvents, String _context)
{
- synchronized ( _actualEvents )
+ synchronized (_actualEvents)
{
int actualEventCount = _actualEvents.size();
- while ( actualEventCount < _expectedEvents.length )
+ while (actualEventCount < _expectedEvents.length)
{
// well, it's possible not all events already arrived, yet - finally, some of them
// are notified asynchronously
// So, wait a few seconds.
try
{
- _actualEvents.wait( 5000 );
+ _actualEvents.wait(5000);
+ }
+ catch (InterruptedException ex)
+ {
}
- catch ( InterruptedException ex ) { }
- if ( actualEventCount == _actualEvents.size() )
- // the above wait was left because of the timeout, *not* because an event
- // arrived. Okay, we won't wait any longer, this is a failure.
+ if (actualEventCount == _actualEvents.size())
+ // the above wait was left because of the timeout, *not* because an event
+ // arrived. Okay, we won't wait any longer, this is a failure.
+ {
break;
+ }
actualEventCount = _actualEvents.size();
}
- assureEquals( "wrong event count for '" + _context + "'",
- _expectedEvents.length, _actualEvents.size() );
+ assureEquals("wrong event count for '" + _context + "'",
+ _expectedEvents.length, _actualEvents.size());
- for ( int i=0; i<_expectedEvents.length; ++i )
+ for (int i = 0; i < _expectedEvents.length; ++i)
{
- assureEquals( "wrong event at positon " + ( i + 1 ) + " for '" + _context + "'",
- _expectedEvents[i], _actualEvents.get(i) );
+ assureEquals("wrong event at positon " + (i + 1) + " for '" + _context + "'",
+ _expectedEvents[i], _actualEvents.get(i));
}
}
}
// --------------------------------------------------------------------------------------------------------
- int impl_waitForEvent( Vector _eventQueue, String _expectedEvent, int _maxMilliseconds )
+ int impl_waitForEvent(ArrayList _eventQueue, String _expectedEvent, int _maxMilliseconds)
{
- return impl_waitForEvent( _eventQueue, _expectedEvent, _maxMilliseconds, 0 );
+ return impl_waitForEvent(_eventQueue, _expectedEvent, _maxMilliseconds, 0);
}
// --------------------------------------------------------------------------------------------------------
- int impl_waitForEvent( Vector _eventQueue, String _expectedEvent, int _maxMilliseconds, int _firstQueueElementToCheck )
+ int impl_waitForEvent(ArrayList _eventQueue, String _expectedEvent, int _maxMilliseconds, int _firstQueueElementToCheck)
{
- synchronized ( _eventQueue )
+ synchronized (_eventQueue)
{
int waitedMilliseconds = 0;
- while ( waitedMilliseconds < _maxMilliseconds )
+ while (waitedMilliseconds < _maxMilliseconds)
{
- for ( int i=_firstQueueElementToCheck; i<_eventQueue.size(); ++i )
+ for (int i = _firstQueueElementToCheck; i < _eventQueue.size(); ++i)
{
- if ( _expectedEvent.equals( _eventQueue.get(i) ) )
- // found the event in the queue
+ if (_expectedEvent.equals(_eventQueue.get(i)))
+ // found the event in the queue
+ {
return i;
+ }
}
// wait a little, perhaps the event will still arrive
try
{
- _eventQueue.wait( 500 );
+ _eventQueue.wait(500);
waitedMilliseconds += 500;
}
- catch ( InterruptedException e ) { }
+ catch (InterruptedException e)
+ {
+ }
}
}
- failed( "expected event '" + _expectedEvent + "' did not arrive after " + _maxMilliseconds + " milliseconds" );
+ failed("expected event '" + _expectedEvent + "' did not arrive after " + _maxMilliseconds + " milliseconds");
return -1;
}
// --------------------------------------------------------------------------------------------------------
- void onDocumentEvent( DocumentEvent _Event )
+ void onDocumentEvent(DocumentEvent _Event)
{
- if ( _Event.EventName.equals( "OnTitleChanged" ) )
- // OnTitleChanged events are notified too often. This is known, and accepted.
- // (the deeper reason is that it's diffult to determine, in the DatabaseDocument implementatin,
- // when the title actually changed. In particular, when we do a saveAsURL, and then ask for a
- // title *before* the TitleHelper got the document's OnSaveAsDone event, then the wrong (old)
- // title is obtained.
+ if ("OnTitleChanged".equals(_Event.EventName))
+ // OnTitleChanged events are notified too often. This is known, and accepted.
+ // (the deeper reason is that it's diffult to determine, in the DatabaseDocument implementatin,
+ // when the title actually changed. In particular, when we do a saveAsURL, and then ask for a
+ // title *before* the TitleHelper got the document's OnSaveAsDone event, then the wrong (old)
+ // title is obtained.
+ {
return;
+ }
- if ( ( _Event.EventName.equals( "OnLoad" ) )
- && ( m_loadDocState != STATE_NOT_STARTED )
- )
+ if ((_Event.EventName.equals(ONLOAD)) && (m_loadDocState != STATE_NOT_STARTED))
{
- assureEquals( "OnLoad event must come *after* invocation of the interaction handler / user!",
- m_loadDocState, STATE_MACRO_EXEC_APPROVED );
+ assureEquals("OnLoad event must come *after* invocation of the interaction handler / user!",
+ m_loadDocState, STATE_MACRO_EXEC_APPROVED);
m_loadDocState = STATE_ON_LOAD_RECEIVED;
}
- synchronized ( m_documentEvents )
+ synchronized (m_documentEvents)
{
- m_documentEvents.add( _Event.EventName );
+ m_documentEvents.add(_Event.EventName);
m_documentEvents.notifyAll();
}
- log.println( " document event: " + _Event.EventName );
+ log.println(" document event: " + _Event.EventName);
}
// --------------------------------------------------------------------------------------------------------
- public void documentEventOccured( DocumentEvent _Event )
+ public void documentEventOccured(DocumentEvent _Event)
{
- if ( _Event.EventName.equals( "OnTitleChanged" ) )
- // ignore. See onDocumentEvent for a justification
+ if ("OnTitleChanged".equals(_Event.EventName))
+ // ignore. See onDocumentEvent for a justification
+ {
return;
+ }
- synchronized ( m_globalEvents )
+ synchronized (m_globalEvents)
{
- m_globalEvents.add( _Event.EventName );
+ m_globalEvents.add(_Event.EventName);
m_globalEvents.notifyAll();
}
- log.println( " global event: " + _Event.EventName );
+ log.println(" global event: " + _Event.EventName);
}
// --------------------------------------------------------------------------------------------------------
- public void disposing( EventObject _Event )
+ public void disposing(EventObject _Event)
{
// not interested in
}
diff --git a/dbaccess/qa/complex/dbaccess/FileHelper.java b/dbaccess/qa/complex/dbaccess/FileHelper.java
index fbe5f330b24d..12e041cdc7be 100644
--- a/dbaccess/qa/complex/dbaccess/FileHelper.java
+++ b/dbaccess/qa/complex/dbaccess/FileHelper.java
@@ -32,6 +32,7 @@ package complex.dbaccess;
public class FileHelper
{
+ private FileHelper(){}
static public String getOOoCompatibleFileURL( String _javaFileURL )
{
String returnURL = _javaFileURL;
diff --git a/dbaccess/qa/complex/dbaccess/Parser.java b/dbaccess/qa/complex/dbaccess/Parser.java
index a4305c031e1b..9067963cf184 100644
--- a/dbaccess/qa/complex/dbaccess/Parser.java
+++ b/dbaccess/qa/complex/dbaccess/Parser.java
@@ -31,7 +31,6 @@ package complex.dbaccess;
import com.sun.star.beans.XPropertySet;
import com.sun.star.container.XIndexAccess;
-import com.sun.star.container.XNameAccess;
import com.sun.star.sdb.XParametersSupplier;
import com.sun.star.sdb.XSingleSelectQueryComposer;
import com.sun.star.sdbc.DataType;
@@ -46,7 +45,8 @@ public class Parser extends CRMBasedTestCase
{
return new String[] {
"checkJoinSyntax",
- "checkParameterTypes"
+ "checkParameterTypes",
+ "checkWhere",
};
}
@@ -71,12 +71,48 @@ public class Parser extends CRMBasedTestCase
}
}
+ public void checkWhere() throws Exception
+ {
+ final XSingleSelectQueryComposer composer = createQueryComposer();
+ final String SELECT = "SELECT \"products\".\"Name\" FROM \"products\" WHERE ";
+ final String[] queries = new String[]
+ {
+ "\"ID\" in ( 1,2,3,4)"
+ ,"not ( \"ID\" in ( 1,2,3,4))"
+ ,"(1 = 1) is true"
+ ,"(1 = 1) is not false"
+ ,"(1 = 1) is not null"
+ ,"not ( (1 = 1) is not null)"
+ ,"'a' like 'a%'"
+ ,"not ( 'a' like 'a%')"
+ ,"'a' not like 'a%'"
+ ,"1 between 0 and 2"
+ ,"not ( 1 between 0 and 2 )"
+ ,"1 not between 3 and 4"
+ ,"1 not between ( select \"ID\" from \"categories\") and ( select \"ID\" from \"categories\")"
+ ,"1 = 1"
+ ,"0 < 1"
+ ,"not(0 < 1)"
+ ,"1 > 0"
+ ,"not(1 > 0)"
+ ,"1 <> 0"
+ ,"(1 <> 0 and 'a' = 'a' and 'c' = 'd') or (1 = 1 and 2 = 2 and 3 = 4)"
+ ,"not ( 1 <> 0 )"
+ ,"\"CategoryID\" in ( select \"ID\" from \"categories\")"
+ ,"not (\"CategoryID\" in ( select \"ID\" from \"categories\"))"
+ ,"\"CategoryID\" not in ( select \"ID\" from \"categories\")"
+ };
+ for (int i = 0; i < queries.length; i++)
+ {
+ composer.setQuery( SELECT + queries[i]);
+ }
+ }
// --------------------------------------------------------------------------------------------------------
/** verifies that aliases for inner queries work as expected
*/
public void checkJoinSyntax() throws Exception
{
- XSingleSelectQueryComposer composer = createQueryComposer();
+ final XSingleSelectQueryComposer composer = createQueryComposer();
// feed the composer with some statements. If any of those cannot be parsed, the composer
// will throw an exception - which is a regression then
@@ -85,6 +121,21 @@ public class Parser extends CRMBasedTestCase
"\"products\".\"Name\" " +
"FROM \"products\" RIGHT OUTER JOIN \"categories\" AS \"categories\" ON \"products\".\"CategoryID\" = \"categories\".\"ID\"" );
+ composer.setQuery(
+ "SELECT \"categories\".\"Name\", " +
+ "\"products\".\"Name\" " +
+ "FROM \"products\" LEFT OUTER JOIN \"categories\" AS \"categories\" ON \"products\".\"CategoryID\" = \"categories\".\"ID\"" );
+
+ composer.setQuery(
+ "SELECT \"categories\".\"Name\", " +
+ "\"products\".\"Name\" " +
+ "FROM \"products\" CROSS JOIN \"categories\" AS \"categories\"" );
+
+ composer.setQuery(
+ "SELECT \"categories\".\"Name\", " +
+ "\"products\".\"Name\" " +
+ "FROM \"products\" INNER JOIN \"categories\" AS \"categories\" ON \"products\".\"CategoryID\" = \"categories\".\"ID\"" );
+
// just to be sure the composer *really* parses upon setting the query: feed it with
// an unparseable statement
boolean caughtExpected = false;
@@ -101,27 +152,27 @@ public class Parser extends CRMBasedTestCase
}
// --------------------------------------------------------------------------------------------------------
- private void impl_checkParameters( final String _statement, final String[] _expectedParameterNames, final int[] _expectedParameterTypes, String _context ) throws Exception
+ private void impl_checkParameters( final String _statement, final String[] _expectedParameterNames, final int[] _expectedParameterTypes,final String _context ) throws Exception
{
- XSingleSelectQueryComposer composer = createQueryComposer();
+ final XSingleSelectQueryComposer composer = createQueryComposer();
composer.setQuery( _statement );
assureEquals( "checkParameterTypes: internal error", _expectedParameterNames.length, _expectedParameterTypes.length );
- XParametersSupplier paramSupp = (XParametersSupplier)UnoRuntime.queryInterface(
+ final XParametersSupplier paramSupp = (XParametersSupplier)UnoRuntime.queryInterface(
XParametersSupplier.class, composer );
- XIndexAccess parameters = paramSupp.getParameters();
+ final XIndexAccess parameters = paramSupp.getParameters();
assureEquals( "(ctx: " + _context + ") unexpected parameter count", _expectedParameterNames.length, parameters.getCount() );
for ( int i=0; i<parameters.getCount(); ++i )
{
- XPropertySet parameter = (XPropertySet)UnoRuntime.queryInterface( XPropertySet.class,
+ final XPropertySet parameter = (XPropertySet)UnoRuntime.queryInterface( XPropertySet.class,
parameters.getByIndex(i) );
- String name = (String)parameter.getPropertyValue( "Name" );
+ final String name = (String)parameter.getPropertyValue( "Name" );
assureEquals( "(ctx: " + _context + ") unexpected parameter name for parameter number " + ( i + 1 ), _expectedParameterNames[i], name );
- int type = ((Integer)parameter.getPropertyValue( "Type" )).intValue();
+ final int type = ((Integer)parameter.getPropertyValue( "Type" )).intValue();
assureEquals( "(ctx: " + _context + ") unexpected data type for parameter number " + ( i + 1 ), _expectedParameterTypes[i], type );
}
}
diff --git a/dbaccess/qa/complex/dbaccess/PropertyBag.java b/dbaccess/qa/complex/dbaccess/PropertyBag.java
index 5f1747fd94bc..b308465a129f 100644
--- a/dbaccess/qa/complex/dbaccess/PropertyBag.java
+++ b/dbaccess/qa/complex/dbaccess/PropertyBag.java
@@ -39,10 +39,11 @@ import com.sun.star.beans.*;
public class PropertyBag extends ComplexTestCase
{
+ private static final String VALUE = "Value";
private XPropertyContainer m_bag;
private XPropertySet m_set;
private XPropertyAccess m_access;
- private XMultiServiceFactory m_orb;
+ private XMultiServiceFactory m_orb = null;
public String[] getTestMethodNames()
{
@@ -73,7 +74,7 @@ public class PropertyBag extends ComplexTestCase
boolean caughtExpected = false;
try
{
- m_bag.addProperty( "", PropertyAttribute.BOUND, new Integer( 3 ) );
+ m_bag.addProperty( "", PropertyAttribute.BOUND, Integer.valueOf( 3 ) );
}
catch(com.sun.star.lang.IllegalArgumentException e) { caughtExpected = true; }
catch(com.sun.star.uno.Exception e) { }
@@ -84,8 +85,8 @@ public class PropertyBag extends ComplexTestCase
caughtExpected = false;
try
{
- m_bag.addProperty( "Value", PropertyAttribute.BOUND, new String( "" ) );
- m_bag.addProperty( "Value", PropertyAttribute.BOUND, new String( "" ) );
+ m_bag.addProperty( VALUE, PropertyAttribute.BOUND, "" );
+ m_bag.addProperty( VALUE, PropertyAttribute.BOUND, "" );
}
catch(com.sun.star.beans.PropertyExistException e) { caughtExpected = true; }
catch(com.sun.star.uno.Exception e) { }
@@ -97,7 +98,7 @@ public class PropertyBag extends ComplexTestCase
caughtExpected = false;
try
{
- m_bag.removeProperty( "Value" );
+ m_bag.removeProperty( VALUE);
}
catch(com.sun.star.beans.NotRemoveableException e) { caughtExpected = true; }
catch(com.sun.star.uno.Exception e) { }
@@ -119,8 +120,8 @@ public class PropertyBag extends ComplexTestCase
try
{
final String testValue = "someArbitraryValue";
- m_set.setPropertyValue( "Value", testValue );
- String currentValue = (String)m_set.getPropertyValue( "Value" );
+ m_set.setPropertyValue( VALUE , testValue);
+ final String currentValue = (String)m_set.getPropertyValue( VALUE);
if ( !currentValue.equals( testValue ) )
failed( "set property is not remembered" );
}
@@ -133,7 +134,7 @@ public class PropertyBag extends ComplexTestCase
caughtExpected = false;
try
{
- m_set.setPropertyValue( "Value", new Integer( 3 ) );
+ m_set.setPropertyValue( VALUE, Integer.valueOf( 3 ) );
}
catch(com.sun.star.lang.IllegalArgumentException e) { caughtExpected = true; }
catch(com.sun.star.uno.Exception e) { }
@@ -150,16 +151,16 @@ public class PropertyBag extends ComplexTestCase
// XPropertyAccess.setPropertyValues
final PropertyValue expectedValues[] =
{
- new PropertyValue( "BoolValue", -1, new Boolean( false ), PropertyState.DIRECT_VALUE ),
+ new PropertyValue( "BoolValue", -1, Boolean.FALSE, PropertyState.DIRECT_VALUE ),
new PropertyValue( "StringValue", -1, "some text", PropertyState.DIRECT_VALUE ),
- new PropertyValue( "IntegerValue", -1, new Integer( 3 ), PropertyState.DIRECT_VALUE ),
+ new PropertyValue( "IntegerValue", -1, Integer.valueOf( 3 ), PropertyState.DIRECT_VALUE ),
new PropertyValue( "InterfaceValue", -1, m_bag, PropertyState.DIRECT_VALUE )
};
m_access.setPropertyValues( expectedValues );
for ( int i=0; i<expectedValues.length; ++i )
{
- Object value = m_set.getPropertyValue( expectedValues[i].Name );
+ final Object value = m_set.getPropertyValue( expectedValues[i].Name );
if ( !value.equals( expectedValues[i].Value ) )
{
log.println( "property name : " + expectedValues[i].Name );
@@ -171,11 +172,11 @@ public class PropertyBag extends ComplexTestCase
// ---------------------------------
// XPropertyAccess.getPropertyValues
- PropertyValue currentValues[] = m_access.getPropertyValues();
+ final PropertyValue currentValues[] = m_access.getPropertyValues();
for ( int i=0; i<currentValues.length; ++i )
{
- String name = currentValues[i].Name;
- Object value = currentValues[i].Value;
+ final String name = currentValues[i].Name;
+ final Object value = currentValues[i].Value;
for ( int j=0; j<expectedValues.length; ++j )
{
if ( expectedValues[j].Name.equals( name ) )
@@ -201,9 +202,9 @@ public class PropertyBag extends ComplexTestCase
log.println( "checking proper dynamic of the set" );
createStandardBag( false );
- PropertyValue props[] =
+ final PropertyValue props[] =
{
- new PropertyValue( "BoolValue", -1, new Boolean( false ), PropertyState.DIRECT_VALUE),
+ new PropertyValue( "BoolValue", -1, Boolean.FALSE, PropertyState.DIRECT_VALUE),
new PropertyValue( "StringValue", -1, "test", PropertyState.DIRECT_VALUE ),
new PropertyValue( "SomeOtherStringValue", -1, "string value", PropertyState.DIRECT_VALUE )
};
@@ -228,7 +229,7 @@ public class PropertyBag extends ComplexTestCase
failed( "property bag failed to implicitly add unknown properties" );
// see whether this property was really added, and not just ignored
- PropertyValue newlyAdded = props[ props.length - 1 ];
+ final PropertyValue newlyAdded = props[ props.length - 1 ];
try
{
if ( !m_set.getPropertyValue( newlyAdded.Name ).equals( newlyAdded.Value ) )
@@ -262,7 +263,7 @@ public class PropertyBag extends ComplexTestCase
{
m_bag = null;
- Object initArgs[] = { new NamedValue( "AutomaticAddition", new Boolean( allowLazyAdding ) ) };
+ final Object initArgs[] = { new NamedValue( "AutomaticAddition", Boolean.valueOf( allowLazyAdding ) ) };
final String serviceName = "com.sun.star.beans.PropertyBag";
m_bag = (XPropertyContainer)UnoRuntime.queryInterface( XPropertyContainer.class,
@@ -273,11 +274,11 @@ public class PropertyBag extends ComplexTestCase
m_set = (XPropertySet)UnoRuntime.queryInterface( XPropertySet.class, m_bag );
m_access = (XPropertyAccess)UnoRuntime.queryInterface( XPropertyAccess.class, m_bag );
- Object properties[][] =
+ final Object properties[][] =
{
- { "BoolValue", new Boolean( true ) },
- { "StringValue", new String( "" ) },
- { "IntegerValue", new Integer( 3 ) },
+ { "BoolValue", Boolean.TRUE },
+ { "StringValue", "" },
+ { "IntegerValue", Integer.valueOf( 3 ) },
{ "InterfaceValue", (XInterface)m_bag }
};
for ( int i=0; i<properties.length; ++i )
diff --git a/dbaccess/qa/complex/dbaccess/Query.java b/dbaccess/qa/complex/dbaccess/Query.java
index d64e1a7c972e..684df2b65a25 100644
--- a/dbaccess/qa/complex/dbaccess/Query.java
+++ b/dbaccess/qa/complex/dbaccess/Query.java
@@ -41,7 +41,6 @@ import com.sun.star.uno.UnoRuntime;
public class Query extends complexlib.ComplexTestCase {
connectivity.tools.HsqlDatabase m_database;
- connectivity.tools.DataSource m_dataSource;
// --------------------------------------------------------------------------------------------------------
public String[] getTestMethodNames() {
@@ -63,14 +62,13 @@ public class Query extends complexlib.ComplexTestCase {
{
if ( m_database == null )
{
- CRMDatabase database = new CRMDatabase( getFactory() );
+ final CRMDatabase database = new CRMDatabase( getFactory() );
m_database = database.getDatabase();
- m_dataSource = m_database.getDataSource();
}
}
catch( Exception e )
{
- System.err.println( "could not create the test case, error message:\n" + e.getMessage() );
+ log.println( "could not create the test case, error message:\n" + e.getMessage() );
e.printStackTrace( System.err );
assure( "failed to created the test case", false );
}
@@ -89,25 +87,25 @@ public class Query extends complexlib.ComplexTestCase {
try
{
- XQueriesSupplier suppQueries = (XQueriesSupplier)UnoRuntime.queryInterface(
+ final XQueriesSupplier suppQueries = (XQueriesSupplier)UnoRuntime.queryInterface(
XQueriesSupplier.class, m_database.defaultConnection());
- XNameAccess queries = suppQueries.getQueries();
+ final XNameAccess queries = suppQueries.getQueries();
- String[] queryNames = new String[] { "parseable", "parseable native", "unparseable" };
- String[][] expectedColumnNames = new String[][] {
- new String[] { "ID", "Name", "Address", "City", "Postal" },
+ final String[] queryNames = new String[] { "parseable", "parseable native", "unparseable" };
+ final String[][] expectedColumnNames = new String[][] {
+ new String[] { "ID", "Name", "Address", "City", "Postal","Comment" },
new String[] { "TABLE_CATALOG", "TABLE_SCHEMA", "TABLE_NAME", "VIEW_DEFINITION", "CHECK_OPTION", "IS_UPDATABLE", "VALID" },
new String[] { "ID_VARCHAR" }
};
for ( int i = 0; i < queryNames.length; ++i )
{
- XPropertySet query = (XPropertySet)UnoRuntime.queryInterface(
+ final XPropertySet query = (XPropertySet)UnoRuntime.queryInterface(
XPropertySet.class, queries.getByName( queryNames[i] ) );
- XColumnsSupplier suppCols = (XColumnsSupplier)UnoRuntime.queryInterface(
+ final XColumnsSupplier suppCols = (XColumnsSupplier)UnoRuntime.queryInterface(
XColumnsSupplier.class, query);
- XIndexAccess columns = (XIndexAccess)UnoRuntime.queryInterface(
+ final XIndexAccess columns = (XIndexAccess)UnoRuntime.queryInterface(
XIndexAccess.class, suppCols.getColumns());
// check whether the columns supplied by the query match what we expected
@@ -115,7 +113,7 @@ public class Query extends complexlib.ComplexTestCase {
columns.getCount() == expectedColumnNames[i].length );
for ( int col = 0; col < columns.getCount(); ++col )
{
- XNamed columnName = (XNamed)UnoRuntime.queryInterface(
+ final XNamed columnName = (XNamed)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/QueryInQuery.java b/dbaccess/qa/complex/dbaccess/QueryInQuery.java
index b06d57d05c59..15e82d7d1bfb 100644
--- a/dbaccess/qa/complex/dbaccess/QueryInQuery.java
+++ b/dbaccess/qa/complex/dbaccess/QueryInQuery.java
@@ -32,7 +32,6 @@ package complex.dbaccess;
import com.sun.star.container.ElementExistException;
import com.sun.star.lang.IllegalArgumentException;
import com.sun.star.lang.WrappedTargetException;
-import com.sun.star.lang.XMultiServiceFactory;
import com.sun.star.sdb.CommandType;
import com.sun.star.sdbc.SQLException;
import connectivity.tools.HsqlColumnDescriptor;
@@ -43,6 +42,7 @@ import com.sun.star.sdbc.XResultSet;
public class QueryInQuery extends CRMBasedTestCase
{
+ private static final String QUERY_PRODUCTS = "query products";
// --------------------------------------------------------------------------------------------------------
public String[] getTestMethodNames()
{
@@ -67,7 +67,7 @@ public class QueryInQuery extends CRMBasedTestCase
try
{
super.createTestCase();
- m_database.getDatabase().getDataSource().createQuery( "query products", "SELECT * FROM \"products\"" );
+ m_database.getDatabase().getDataSource().createQuery( QUERY_PRODUCTS,"SELECT * FROM \"products\"");
}
catch ( Exception e )
{
@@ -79,10 +79,10 @@ public class QueryInQuery extends CRMBasedTestCase
// --------------------------------------------------------------------------------------------------------
private void verifyEqualRowSetContent( int _outerCommandType, String _outerCommand, int _innerCommandType, String _innerCommand ) throws SQLException
{
- RowSet outerRowSet = m_database.getDatabase().createRowSet( _outerCommandType, _outerCommand );
+ final RowSet outerRowSet = m_database.getDatabase().createRowSet( _outerCommandType, _outerCommand );
outerRowSet.execute();
- RowSet innerRowSet = m_database.getDatabase().createRowSet( _innerCommandType, _innerCommand );
+ final RowSet innerRowSet = m_database.getDatabase().createRowSet( _innerCommandType, _innerCommand );
innerRowSet.execute();
outerRowSet.last();
@@ -110,7 +110,7 @@ public class QueryInQuery extends CRMBasedTestCase
{
verifyEqualRowSetContent(
CommandType.COMMAND, "SELECT * FROM \"query products\"",
- CommandType.QUERY, "query products" );
+ CommandType.QUERY,QUERY_PRODUCTS);
}
// --------------------------------------------------------------------------------------------------------
@@ -123,7 +123,7 @@ public class QueryInQuery extends CRMBasedTestCase
CommandType.COMMAND, "SELECT \"ID\" FROM \"products\"" );
verifyEqualRowSetContent(
CommandType.COMMAND, "SELECT \"PROD\".* FROM \"query products\" AS \"PROD\"",
- CommandType.QUERY, "query products" );
+ CommandType.QUERY,QUERY_PRODUCTS);
}
// --------------------------------------------------------------------------------------------------------
@@ -144,7 +144,7 @@ public class QueryInQuery extends CRMBasedTestCase
caughtExpected );
// create a table with a name which is used by a query
- HsqlTableDescriptor table = new HsqlTableDescriptor( "query products",
+ final HsqlTableDescriptor table = new HsqlTableDescriptor( QUERY_PRODUCTS,
new HsqlColumnDescriptor[] {
new HsqlColumnDescriptor( "ID", "INTEGER" ),
new HsqlColumnDescriptor( "Name", "VARCHAR(50)" ) } );
@@ -169,7 +169,7 @@ public class QueryInQuery extends CRMBasedTestCase
m_database.getDatabase().getDataSource().createQuery( "orders level 3", "SELECT * FROM \"orders level 2\"" );
m_database.getDatabase().getDataSource().createQuery( "orders level 0", "SELECT * FROM \"orders level 3\"" );
- RowSet rowSet = m_database.getDatabase().createRowSet( CommandType.QUERY, "orders level 0" );
+ final RowSet rowSet = m_database.getDatabase().createRowSet( CommandType.QUERY, "orders level 0" );
boolean caughtExpected = false;
try { rowSet.execute(); }
@@ -183,8 +183,9 @@ public class QueryInQuery extends CRMBasedTestCase
{
try
{
- XStatement statement = m_database.getConnection().createStatement();
- XResultSet resultSet = statement.executeQuery( "SELECT * FROM \"query products\"" );
+ final XStatement statement = m_database.getConnection().createStatement();
+ final XResultSet resultSet = statement.executeQuery( "SELECT * FROM \"query products\"" );
+ assure( "Result Set is null", resultSet != null );
}
catch( SQLException e )
{
diff --git a/dbaccess/qa/complex/dbaccess/RowSet.java b/dbaccess/qa/complex/dbaccess/RowSet.java
index 8e0161187c3e..d9145d7aaee8 100644
--- a/dbaccess/qa/complex/dbaccess/RowSet.java
+++ b/dbaccess/qa/complex/dbaccess/RowSet.java
@@ -29,102 +29,128 @@
************************************************************************/
package complex.dbaccess;
+import com.sun.star.beans.PropertyVetoException;
+import com.sun.star.beans.UnknownPropertyException;
+import com.sun.star.beans.XPropertySet;
import com.sun.star.container.XIndexAccess;
-import com.sun.star.uno.UnoRuntime;
-import com.sun.star.beans.*;
-import com.sun.star.lang.*;
-import com.sun.star.sdbcx.*;
-import com.sun.star.sdbc.*;
-import com.sun.star.sdb.*;
+import com.sun.star.lang.WrappedTargetException;
+import com.sun.star.lang.XComponent;
import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.sdb.CommandType;
+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;
+import com.sun.star.sdbc.XResultSetUpdate;
+import com.sun.star.sdbc.XRow;
+import com.sun.star.sdbc.XRowSet;
+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 connectivity.tools.HsqlDatabase;
-
import complexlib.ComplexTestCase;
-import complexlib.Assurance.AssureException;
-
+import connectivity.tools.DataSource;
+import connectivity.tools.HsqlDatabase;
+import java.lang.reflect.Method;
+import java.util.Random;
-public class RowSet extends ComplexTestCase {
+public class RowSet extends ComplexTestCase
+{
static final int MAX_TABLE_ROWS = 100;
static final int MAX_FETCH_ROWS = 10;
-
- HsqlDatabase m_database;
- connectivity.tools.DataSource
- m_dataSource;
- XRowSet m_rowSet;
- XResultSet m_resultSet;
- XResultSetUpdate m_resultSetUpdate;
- XRow m_row;
- XRowLocate m_rowLocate;
- XPropertySet m_rowSetProperties;
+ private static final String NEXT = "next";
+ private static final String TEST21 = "Test21";
+ HsqlDatabase m_database;
+ DataSource m_dataSource;
+ XRowSet m_rowSet;
+ XResultSet m_resultSet;
+ XResultSetUpdate m_resultSetUpdate;
+ XRow m_row;
+ XRowLocate m_rowLocate;
+ XPropertySet m_rowSetProperties;
XParametersSupplier m_paramsSupplier;
// --------------------------------------------------------------------------------------------------------
class ResultSetMovementStress implements Runnable
{
- XResultSet m_resultSet;
- XRow m_row;
- int m_id;
- public ResultSetMovementStress(XResultSet _resultSet,int _id) throws java.lang.Exception {
+
+ XResultSet m_resultSet;
+ XRow m_row;
+ int m_id;
+
+ public ResultSetMovementStress(XResultSet _resultSet, int _id) throws java.lang.Exception
+ {
m_resultSet = _resultSet;
- m_row = (XRow)UnoRuntime.queryInterface(XRow.class,m_resultSet);
+ m_row = (XRow) UnoRuntime.queryInterface(XRow.class, m_resultSet);
m_id = _id;
}
+
public void run()
{
try
{
m_resultSet.beforeFirst();
- for ( int i = 0; m_resultSet.next(); ++i )
+ for (int i = 0; m_resultSet.next(); ++i)
{
int pos = m_resultSet.getRow();
- int val = m_row.getInt(1);
+ // final int val = m_row.getInt(1);
// log.println("Clone Move(" + m_id +") before i: " + (i+1) + " Pos: " + pos + " Val: " + val);
- testPosition( m_resultSet, m_row, i + 1, "clone move(" + m_id +")" );
+ testPosition(m_resultSet, m_row, i + 1, "clone move(" + m_id + ")");
// val = m_row.getInt(1);
// log.println("Clone Move(" + m_id +") after i: " + (i+1) + " Pos: " + pos + " Val: " + val);
int pos2 = m_resultSet.getRow();
- assure("ResultSetMovementStress wrong position: " + i + " Pos1: " + pos + " Pos2: " + pos2,pos == pos2);
+ assure("ResultSetMovementStress wrong position: " + i + " Pos1: " + pos + " Pos2: " + pos2, pos == pos2);
}
- }catch(AssureException e){
- }catch(Exception e){
- assure("ResultSetMovementStress(" + m_id + ") failed: " + e,false);
+ }
+ catch (Exception e)
+ {
+ assure("ResultSetMovementStress(" + m_id + ") failed: " + e, false);
}
}
}
// --------------------------------------------------------------------------------------------------------
- public String[] getTestMethodNames() {
+
+ public String[] getTestMethodNames()
+ {
return new String[]
- {
- "testRowSet",
- "testRowSetEvents",
- "testDeleteBehavior",
- "testCloneMovesPlusDeletions",
- "testCloneMovesPlusInsertions",
- "testParameters"
- };
+ {
+ "testRowSet",
+ "testRowSetEvents",
+ "testDeleteBehavior",
+ "testCloneMovesPlusDeletions",
+ "testCloneMovesPlusInsertions",
+ "testParameters"
+ };
}
// --------------------------------------------------------------------------------------------------------
- public String getTestObjectName() {
+ public String getTestObjectName()
+ {
return "RowSet";
}
// --------------------------------------------------------------------------------------------------------
- private void createTestCase( boolean _defaultRowSet )
+ private void createTestCase(boolean _defaultRowSet)
{
- if ( m_database == null )
+ if (m_database == null)
{
try
{
- CRMDatabase database = new CRMDatabase( getFactory() );
+ final CRMDatabase database = new CRMDatabase(getFactory());
m_database = database.getDatabase();
m_dataSource = m_database.getDataSource();
}
- catch(Exception e)
+ catch (Exception e)
{
- assure( "could not create the embedded HSQL database: " + e.getMessage(), false );
+ assure("could not create the embedded HSQL database: " + e.getMessage(), false);
}
}
@@ -132,20 +158,21 @@ public class RowSet extends ComplexTestCase {
{
createStruture();
}
- catch( SQLException e )
+ catch (SQLException e)
{
- assure( "could not connect to the database/table structure, error message:\n" + e.getMessage(), false );
+ assure("could not connect to the database/table structure, error message:\n" + e.getMessage(), false);
}
- if ( _defaultRowSet )
- createRowSet( "TEST1", CommandType.TABLE, true, true );
+ if (_defaultRowSet)
+ {
+ createRowSet("TEST1", CommandType.TABLE, true, true);
+ }
}
-
// --------------------------------------------------------------------------------------------------------
private XMultiServiceFactory getFactory()
{
- return (XMultiServiceFactory)param.getMSF();
+ return (XMultiServiceFactory) param.getMSF();
}
// --------------------------------------------------------------------------------------------------------
@@ -157,9 +184,9 @@ public class RowSet extends ComplexTestCase {
* @param execute
* determines whether the RowSet should be executed
*/
- private void createRowSet( String command, int commandType, boolean execute )
+ private void createRowSet(String command, int commandType, boolean execute)
{
- createRowSet( command, commandType, execute, false );
+ createRowSet(command, commandType, execute, false);
}
// --------------------------------------------------------------------------------------------------------
@@ -173,50 +200,55 @@ public class RowSet extends ComplexTestCase {
* @param execute
* determines whether the RowSet should be executed
*/
- private void createRowSet( String command, int commandType, boolean execute, boolean limitFetchSize )
+ private void createRowSet(String command, int commandType, boolean execute, boolean limitFetchSize)
{
try
{
- m_rowSet = (XRowSet)UnoRuntime.queryInterface(XRowSet.class,
- getFactory().createInstance("com.sun.star.sdb.RowSet"));
- XPropertySet rowSetProperties = (XPropertySet)UnoRuntime.queryInterface( XPropertySet.class, m_rowSet );
- rowSetProperties.setPropertyValue( "Command", command );
- rowSetProperties.setPropertyValue( "CommandType", new Integer( commandType ) );
- rowSetProperties.setPropertyValue( "ActiveConnection",m_database.defaultConnection() );
- if ( limitFetchSize )
- rowSetProperties.setPropertyValue( "FetchSize", new Integer( 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 );
-
- if ( execute )
+ m_rowSet = (XRowSet) UnoRuntime.queryInterface(XRowSet.class,
+ getFactory().createInstance("com.sun.star.sdb.RowSet"));
+ final XPropertySet rowSetProperties = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, m_rowSet);
+ rowSetProperties.setPropertyValue("Command", command);
+ rowSetProperties.setPropertyValue("CommandType", Integer.valueOf(commandType));
+ rowSetProperties.setPropertyValue("ActiveConnection", m_database.defaultConnection());
+ 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);
+
+ if (execute)
+ {
m_rowSet.execute();
+ }
}
- catch ( java.lang.Exception e )
+ catch (Exception e)
{
- assure( "caught an exception while creating the RowSet. Type:\n" + e.getClass().toString() + "\nMessage:\n" + e.getMessage(), false );
+ assure("caught an exception while creating the RowSet. Type:\n" + e.getClass().toString() + "\nMessage:\n" + e.getMessage(), false);
}
}
// --------------------------------------------------------------------------------------------------------
- public void testRowSet() throws java.lang.Exception {
+ public void testRowSet() throws java.lang.Exception
+ {
log.println("testing testRowSet");
- createTestCase( true );
+ createTestCase(true);
// sequential postioning
m_resultSet.beforeFirst();
- testSequentialPositining(m_resultSet,m_row);
+ testSequentialPositining(m_resultSet, m_row);
// absolute positioning
- testAbsolutePositioning(m_resultSet,m_row);
+ testAbsolutePositioning(m_resultSet, m_row);
// 3rd test
- test3(createClone(),m_resultSet);
+ test3(createClone(), m_resultSet);
// 4th test
test4(m_resultSet);
@@ -227,201 +259,213 @@ public class RowSet extends ComplexTestCase {
// --------------------------------------------------------------------------------------------------------
XResultSet createClone() throws SQLException
{
- XResultSetAccess rowAcc = (XResultSetAccess)UnoRuntime.queryInterface( XResultSetAccess.class, m_rowSet );
+ final XResultSetAccess rowAcc = (XResultSetAccess) UnoRuntime.queryInterface(XResultSetAccess.class, m_rowSet);
return rowAcc.createResultSet();
}
// --------------------------------------------------------------------------------------------------------
void createStruture() throws SQLException
{
- m_database.executeSQL( "DROP TABLE \"TEST1\" IF EXISTS" );
- m_database.executeSQL( "CREATE TABLE \"TEST1\" (\"ID\" integer not null primary key, \"col2\" varchar(50) )" );
-
- XConnection connection = m_database.defaultConnection();
- XPreparedStatement prep = connection.prepareStatement("INSERT INTO \"TEST1\" values (?,?)");
- XParameters para = (XParameters)UnoRuntime.queryInterface(XParameters.class,prep);
- for(int i=1 ; i <= MAX_TABLE_ROWS ; ++i){
- para.setInt(1, i );
+ 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 XPreparedStatement prep = connection.prepareStatement("INSERT INTO \"TEST1\" values (?,?)");
+ final XParameters para = (XParameters) UnoRuntime.queryInterface(XParameters.class, prep);
+ for (int i = 1; i <= MAX_TABLE_ROWS; ++i)
+ {
+ para.setInt(1, i);
para.setString(2, "Test" + i);
prep.executeUpdate();
}
- XTablesSupplier suppTables = (XTablesSupplier)UnoRuntime.queryInterface( XTablesSupplier.class, connection );
- XRefreshable refresh = (XRefreshable)UnoRuntime.queryInterface( XRefreshable.class, suppTables.getTables() );
+ final XTablesSupplier suppTables = (XTablesSupplier) UnoRuntime.queryInterface(XTablesSupplier.class, connection);
+ final XRefreshable refresh = (XRefreshable) UnoRuntime.queryInterface(XRefreshable.class, suppTables.getTables());
refresh.refresh();
}
// --------------------------------------------------------------------------------------------------------
- void testPosition(XResultSet m_resultSet,XRow m_row,int expectedValue,String location) throws SQLException
+ void testPosition(XResultSet m_resultSet, XRow m_row, int expectedValue, String location) throws SQLException
{
- int val = m_row.getInt(1);
- int pos = m_resultSet.getRow();
- assure( location + ": value/position do not match: " + pos + " (pos) != " + val + " (val)", val == pos );
- assure( location + ": value/position are not as expected: " + val + " (val) != " + expectedValue + " (expected)", val == expectedValue );
+ final int val = m_row.getInt(1);
+ final int pos = m_resultSet.getRow();
+ assure(location + ": value/position do not match: " + pos + " (pos) != " + val + " (val)", val == pos);
+ assure(location + ": value/position are not as expected: " + val + " (val) != " + expectedValue + " (expected)", val == expectedValue);
}
// --------------------------------------------------------------------------------------------------------
- void testSequentialPositining(XResultSet _resultSet,XRow _row)
+ void testSequentialPositining(XResultSet _resultSet, XRow _row)
{
try
{
// 1st test
- int i=1;
- while(_resultSet.next())
+ int i = 1;
+ while (_resultSet.next())
{
- testPosition( _resultSet, _row, i, "testSequentialPositining" );
+ testPosition(_resultSet, _row, i, "testSequentialPositining");
++i;
}
}
- catch(AssureException e)
- {
- }
- catch(Exception e)
+ catch (Exception e)
{
- assure("testSequentialPositining failed: " + e,false);
+ assure("testSequentialPositining failed: " + e, false);
}
}
// --------------------------------------------------------------------------------------------------------
- void testAbsolutePositioning(XResultSet _resultSet,XRow _row){
- try{
- for(int i = 1 ; i <= MAX_FETCH_ROWS ; ++i){
- int calcPos = (MAX_TABLE_ROWS % i) + 1;
- assure( "testAbsolutePositioning failed", _resultSet.absolute(calcPos) );
- testPosition( _resultSet, _row, calcPos, "testAbsolutePositioning" );
+ void testAbsolutePositioning(XResultSet _resultSet, XRow _row)
+ {
+ try
+ {
+ for (int i = 1; i <= MAX_FETCH_ROWS; ++i)
+ {
+ final int calcPos = (MAX_TABLE_ROWS % i) + 1;
+ assure("testAbsolutePositioning failed", _resultSet.absolute(calcPos));
+ testPosition(_resultSet, _row, calcPos, "testAbsolutePositioning");
}
- }catch(AssureException e){
- }catch(Exception e){
- assure("testAbsolutePositioning failed: " + e,false);
- }
+ }
+ catch (Exception e)
+ {
+ assure("testAbsolutePositioning failed: " + e, false);
+ }
}
// --------------------------------------------------------------------------------------------------------
- void test3(XResultSet clone,XResultSet _resultSet){
- try{
- XRow _row = (XRow)UnoRuntime.queryInterface(XRow.class,_resultSet);
- XRow cloneRow = (XRow)UnoRuntime.queryInterface(XRow.class,clone);
- for(int i = 1 ; i <= MAX_FETCH_ROWS ; ++i){
- int calcPos = (MAX_TABLE_ROWS % i) + 1;
- if ( clone.absolute(calcPos) )
+ void test3(XResultSet clone, XResultSet _resultSet)
+ {
+ try
+ {
+ final XRow _row = (XRow) UnoRuntime.queryInterface(XRow.class, _resultSet);
+ final XRow cloneRow = (XRow) UnoRuntime.queryInterface(XRow.class, clone);
+ for (int i = 1; i <= MAX_FETCH_ROWS; ++i)
+ {
+ final int calcPos = (MAX_TABLE_ROWS % i) + 1;
+ if (clone.absolute(calcPos))
{
- testPosition( clone, cloneRow, calcPos, "test3" );
- testAbsolutePositioning(_resultSet,_row);
- testAbsolutePositioning(clone,cloneRow);
+ testPosition(clone, cloneRow, calcPos, "test3");
+ testAbsolutePositioning(_resultSet, _row);
+ testAbsolutePositioning(clone, cloneRow);
}
}
- }catch(AssureException e){
- }catch(Exception e){
- assure("test3 failed: " + e,false);
- }
+ }
+ catch (Exception e)
+ {
+ assure("test3 failed: " + e, false);
+ }
}
// --------------------------------------------------------------------------------------------------------
- void test4(XResultSet _resultSet){
- try{
- XRow _row = (XRow)UnoRuntime.queryInterface(XRow.class,_resultSet);
+ void test4(XResultSet _resultSet)
+ {
+ try
+ {
+ final XRow _row = (XRow) UnoRuntime.queryInterface(XRow.class, _resultSet);
_resultSet.beforeFirst();
- for(int i = 1 ; i <= MAX_TABLE_ROWS ; ++i){
+ for (int i = 1; i <= MAX_TABLE_ROWS; ++i)
+ {
_resultSet.next();
- XResultSet clone = createClone();
- XRow cloneRow = (XRow)UnoRuntime.queryInterface(XRow.class,clone);
- int calcPos = MAX_TABLE_ROWS - 1;
- if ( calcPos != 0 && clone.absolute(calcPos) )
+ final XResultSet clone = createClone();
+ final XRow cloneRow = (XRow) UnoRuntime.queryInterface(XRow.class, clone);
+ final int calcPos = MAX_TABLE_ROWS - 1;
+ if (calcPos != 0 && clone.absolute(calcPos))
{
- testPosition( clone, cloneRow, calcPos, "test4: clone" );
- testPosition( _resultSet, _row, i, "test4: rowset" );
+ testPosition(clone, cloneRow, calcPos, "test4: clone");
+ testPosition(_resultSet, _row, i, "test4: rowset");
}
}
- }catch(AssureException e){
- }catch(Exception e){
- assure("test4 failed: " + e,false);
- }
+ }
+ catch (Exception e)
+ {
+ assure("test4 failed: " + e, false);
+ }
}
// --------------------------------------------------------------------------------------------------------
- void testConcurrentAccess(XResultSet _resultSet)
- {
+ void testConcurrentAccess(XResultSet _resultSet)
+ {
log.println("testing Thread");
try
{
- XRow _row = (XRow)UnoRuntime.queryInterface(XRow.class,_resultSet);
+ // final XRow _row = (XRow)UnoRuntime.queryInterface(XRow.class,_resultSet);
_resultSet.beforeFirst();
final int numberOfThreads = 10;
- Thread threads[] = new Thread[numberOfThreads];
- for ( int i=0; i<numberOfThreads; ++i )
+ final Thread threads[] = new Thread[numberOfThreads];
+ for (int i = 0; i < numberOfThreads; ++i)
{
- threads[i] = new Thread( new ResultSetMovementStress( createClone(), i ) );
- System.out.println( "starting thread " + String.valueOf(i+1) + " of " + String.valueOf( numberOfThreads ) );
+ threads[i] = new Thread(new ResultSetMovementStress(createClone(), i));
+ log.println("starting thread " + (i + 1) + " of " + (numberOfThreads));
threads[i].start();
}
- for ( int i=0; i<numberOfThreads; ++i )
+ for (int i = 0; i < numberOfThreads; ++i)
+ {
threads[i].join();
+ }
}
- catch(AssureException e)
- {
- }
- catch(Exception e)
+ catch (Exception e)
{
- e.printStackTrace();
- assure("testConcurrentAccess failed: " + e,false);
+ assure("testConcurrentAccess failed: " + e, false);
}
}
// --------------------------------------------------------------------------------------------------------
- public void testRowSetEvents() throws java.lang.Exception {
+
+ public void testRowSetEvents() throws java.lang.Exception
+ {
log.println("testing RowSet Events");
- createTestCase( true );
+ createTestCase(true);
// first we create our RowSet object
- RowSetEventListener pRow = new RowSetEventListener(this);
+ final RowSetEventListener pRow = new RowSetEventListener();
- XColumnsSupplier colSup = (XColumnsSupplier)UnoRuntime.queryInterface(XColumnsSupplier.class,m_rowSet);
- XPropertySet col = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class,colSup.getColumns().getByName("ID"));
+ final XColumnsSupplier colSup = (XColumnsSupplier) UnoRuntime.queryInterface(XColumnsSupplier.class, m_rowSet);
+ final XPropertySet col = (XPropertySet) 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);
- XRowSetApproveBroadcaster xApBroad = (XRowSetApproveBroadcaster)UnoRuntime.queryInterface(XRowSetApproveBroadcaster.class,m_resultSet);
+ final XRowSetApproveBroadcaster xApBroad = (XRowSetApproveBroadcaster) UnoRuntime.queryInterface(XRowSetApproveBroadcaster.class, m_resultSet);
xApBroad.addRowSetApproveListener(pRow);
m_rowSet.addRowSetListener(pRow);
// do some movements to check if we got all notifications
- Class cResSet = java.lang.Class.forName("com.sun.star.sdbc.XResultSet");
- boolean moves[] = new boolean[9];
- for( int i = 0; i < moves.length; ++i)
+ final Class cResSet = Class.forName("com.sun.star.sdbc.XResultSet");
+ final boolean moves[] = new boolean[9];
+ for (int i = 0; i < moves.length; ++i)
+ {
moves[i] = false;
+ }
moves[RowSetEventListener.APPROVE_CURSOR_MOVE] = true;
moves[RowSetEventListener.COLUMN_VALUE] = true;
moves[RowSetEventListener.CURSOR_MOVED] = true;
moves[RowSetEventListener.IS_ROW_COUNT_FINAL] = true;
moves[RowSetEventListener.ROW_COUNT] = true;
- testCursorMove(m_resultSet,cResSet.getMethod("afterLast",(Class[])null),pRow,moves,null);
+ testCursorMove(m_resultSet, cResSet.getMethod("afterLast", (Class[]) null), pRow, moves, null);
moves[RowSetEventListener.IS_ROW_COUNT_FINAL] = false;
moves[RowSetEventListener.ROW_COUNT] = false;
- testCursorMove(m_resultSet,cResSet.getMethod("next",(Class[])null),pRow,moves,null);
- testCursorMove(m_resultSet,cResSet.getMethod("next",(Class[])null),pRow,moves,null);
- testCursorMove(m_resultSet,cResSet.getMethod("next",(Class[])null),pRow,moves,null);
- testCursorMove(m_resultSet,cResSet.getMethod("last",(Class[])null),pRow,moves,null);
- testCursorMove(m_resultSet,cResSet.getMethod("next",(Class[])null),pRow,moves,null);
- testCursorMove(m_resultSet,cResSet.getMethod("first",(Class[])null),pRow,moves,null);
- testCursorMove(m_resultSet,cResSet.getMethod("previous",(Class[])null),pRow,moves,null);
- testCursorMove(m_resultSet,cResSet.getMethod("next",(Class[])null),pRow,moves,null);
+ testCursorMove(m_resultSet, cResSet.getMethod(NEXT, (Class[]) null), pRow, moves, null);
+ testCursorMove(m_resultSet, cResSet.getMethod(NEXT, (Class[]) null), pRow, moves, null);
+ testCursorMove(m_resultSet, cResSet.getMethod(NEXT, (Class[]) null), pRow, moves, null);
+ testCursorMove(m_resultSet, cResSet.getMethod("last", (Class[]) null), pRow, moves, null);
+ testCursorMove(m_resultSet, cResSet.getMethod(NEXT, (Class[]) null), pRow, moves, null);
+ testCursorMove(m_resultSet, cResSet.getMethod("first", (Class[]) null), pRow, moves, null);
+ 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;
- XRowUpdate updRow = (XRowUpdate)UnoRuntime.queryInterface(XRowUpdate.class,m_resultSet);
- updRow.updateString(2,"Test21");
- testCursorMove(m_resultSet,cResSet.getMethod("next",(Class[])null),pRow,moves,null);
+ final XRowUpdate updRow = (XRowUpdate) 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;
- Class cupd = java.lang.Class.forName("com.sun.star.sdbc.XResultSetUpdate");
- XResultSetUpdate upd = (XResultSetUpdate)UnoRuntime.queryInterface(XResultSetUpdate.class,m_resultSet);
- testCursorMove(upd,cupd.getMethod("moveToInsertRow",(Class[])null),pRow,moves,null);
+ final Class cupd = Class.forName("com.sun.star.sdbc.XResultSetUpdate");
+ final XResultSetUpdate upd = (XResultSetUpdate) UnoRuntime.queryInterface(XResultSetUpdate.class, m_resultSet);
+ testCursorMove(upd, cupd.getMethod("moveToInsertRow", (Class[]) null), pRow, moves, null);
updRow.updateInt(1, MAX_TABLE_ROWS + 2);
updRow.updateString(2, "HHHH");
@@ -432,108 +476,110 @@ public class RowSet extends ComplexTestCase {
moves[RowSetEventListener.ROW_COUNT] = true;
moves[RowSetEventListener.APPROVE_ROW_CHANGE] = true;
moves[RowSetEventListener.ROW_CHANGED] = true;
- testCursorMove(upd,cupd.getMethod("insertRow",(Class[])null),pRow,moves,null);
+ testCursorMove(upd, cupd.getMethod("insertRow", (Class[]) null), pRow, moves, null);
moves[RowSetEventListener.IS_NEW] = false;
moves[RowSetEventListener.ROW_COUNT] = false;
m_resultSet.first();
updRow.updateInt(1, MAX_TABLE_ROWS + 3);
updRow.updateString(2, "__");
- testCursorMove(upd,cupd.getMethod("updateRow",(Class[])null),pRow,moves,null);
+ testCursorMove(upd, cupd.getMethod("updateRow", (Class[]) null), pRow, moves, null);
moves[RowSetEventListener.IS_NEW] = true;
moves[RowSetEventListener.ROW_COUNT] = true;
m_resultSet.first();
- testCursorMove(upd,cupd.getMethod("deleteRow",(Class[])null),pRow,moves,null);
+ testCursorMove(upd, cupd.getMethod("deleteRow", (Class[]) null), pRow, moves, null);
moves[RowSetEventListener.IS_NEW] = false;
moves[RowSetEventListener.COLUMN_VALUE] = true;
moves[RowSetEventListener.ROW_COUNT] = false;
m_resultSet.first();
- updRow.updateString(2,"Test21");
- testCursorMove(m_resultSet,cResSet.getMethod("refreshRow",(Class[])null),pRow,moves,null);
+ updRow.updateString(2, TEST21);
+ testCursorMove(m_resultSet, cResSet.getMethod("refreshRow", (Class[]) null), pRow, moves, null);
m_resultSet.first();
- updRow.updateString(2,"Test21");
- testCursorMove(upd,cupd.getMethod("cancelRowUpdates",(Class[])null),pRow,moves,null);
+ updRow.updateString(2, TEST21);
+ testCursorMove(upd, cupd.getMethod("cancelRowUpdates", (Class[]) null), pRow, moves, null);
- for( int i = 0; i < moves.length; ++i)
+ for (int i = 0; i < moves.length; ++i)
+ {
moves[i] = false;
+ }
moves[RowSetEventListener.APPROVE_CURSOR_MOVE] = true;
moves[RowSetEventListener.COLUMN_VALUE] = true;
moves[RowSetEventListener.CURSOR_MOVED] = true;
- Class cloc = java.lang.Class.forName("com.sun.star.sdbcx.XRowLocate");
+ final Class cloc = Class.forName("com.sun.star.sdbcx.XRowLocate");
m_resultSet.first();
- Object bookmark = m_rowLocate.getBookmark();
+ final Object bookmark = m_rowLocate.getBookmark();
m_resultSet.next();
- Object temp[] = new Object[1];
+ final Object temp[] = new Object[1];
temp[0] = bookmark;
Class ctemp[] = new Class[1];
ctemp[0] = Object.class;
- testCursorMove(m_rowLocate,cloc.getMethod("moveToBookmark",ctemp),pRow,moves,temp);
+ testCursorMove(m_rowLocate, cloc.getMethod("moveToBookmark", ctemp), pRow, moves, temp);
- Object temp2[] = new Object[2];
+ final Object temp2[] = new Object[2];
temp2[0] = bookmark;
- temp2[1] = new Integer(1);
- Class ctemp2[] = new Class[2];
+ temp2[1] = Integer.valueOf(1);
+ final Class ctemp2[] = new Class[2];
ctemp2[0] = Object.class;
ctemp2[1] = int.class;
- testCursorMove(m_rowLocate,cloc.getMethod("moveRelativeToBookmark",ctemp2),pRow,moves,temp2);
+ testCursorMove(m_rowLocate, cloc.getMethod("moveRelativeToBookmark", ctemp2), pRow, moves, temp2);
- for( int i = 0; i < moves.length; ++i)
+ for (int i = 0; i < moves.length; ++i)
+ {
moves[i] = false;
+ }
moves[RowSetEventListener.APPROVE_ROW_CHANGE] = true;
moves[RowSetEventListener.ROW_CHANGED] = true;
moves[RowSetEventListener.ROW_COUNT] = true;
- Class cdelRows = java.lang.Class.forName("com.sun.star.sdbcx.XDeleteRows");
+ final Class cdelRows = Class.forName("com.sun.star.sdbcx.XDeleteRows");
ctemp[0] = Object[].class;
- XDeleteRows delRows = (XDeleteRows)UnoRuntime.queryInterface(XDeleteRows.class,m_resultSet);
- Object bookmarks[] = new Object[5];
+ final XDeleteRows delRows = (XDeleteRows) UnoRuntime.queryInterface(XDeleteRows.class, m_resultSet);
+ final Object bookmarks[] = new Object[5];
m_resultSet.first();
- for ( int i = 0; i < bookmarks.length ; ++i ){
+ for (int i = 0; i < bookmarks.length; ++i)
+ {
m_resultSet.next();
bookmarks[i] = m_rowLocate.getBookmark();
}
temp[0] = bookmarks;
- testCursorMove(delRows,cdelRows.getMethod("deleteRows",ctemp),pRow,moves,temp);
+ testCursorMove(delRows, cdelRows.getMethod("deleteRows", ctemp), pRow, moves, temp);
// now destroy the RowSet
- XComponent xComp = (XComponent)UnoRuntime.queryInterface(XComponent.class,m_resultSet);
+ final XComponent xComp = (XComponent) UnoRuntime.queryInterface(XComponent.class, m_resultSet);
xComp.dispose();
}
// --------------------------------------------------------------------------------------------------------
- private void testCursorMove(Object res
- ,java.lang.reflect.Method _method
- , RowSetEventListener _evt
- , boolean _must[]
- , Object args[]) throws java.lang.Exception {
+ private void testCursorMove(Object res, Method _method, RowSetEventListener _evt, boolean _must[], Object args[]) throws java.lang.Exception
+ {
_evt.clearCalling();
- _method.invoke(res,args);
+ _method.invoke(res, args);
log.println("testing events for " + _method.getName());
- int calling[] = _evt.getCalling();
+ final int calling[] = _evt.getCalling();
int pos = 1;
- assure("Callings are not in the correct order for APPROVE_CURSOR_MOVE " ,
- ( !_must[RowSetEventListener.APPROVE_CURSOR_MOVE] || calling[RowSetEventListener.APPROVE_CURSOR_MOVE] == -1) || calling[RowSetEventListener.APPROVE_CURSOR_MOVE] == pos++ );
- assure("Callings are not in the correct order for APPROVE_ROW_CHANGE" ,
- ( !_must[ RowSetEventListener.APPROVE_ROW_CHANGE] || calling[RowSetEventListener.APPROVE_ROW_CHANGE] == -1) || calling[RowSetEventListener.APPROVE_ROW_CHANGE] == pos++);
- assure("Callings are not in the correct order for COLUMN_VALUE" ,
- ( !_must[RowSetEventListener.COLUMN_VALUE] || calling[RowSetEventListener.COLUMN_VALUE] == -1) || calling[RowSetEventListener.COLUMN_VALUE] == pos++);
- assure("Callings are not in the correct order for CURSOR_MOVED" ,
- ( !_must[RowSetEventListener.CURSOR_MOVED] || calling[RowSetEventListener.CURSOR_MOVED] == -1) || calling[RowSetEventListener.CURSOR_MOVED] == pos++);
- assure("Callings are not in the correct order for ROW_CHANGED" ,
- ( !_must[ RowSetEventListener.ROW_CHANGED] || calling[RowSetEventListener.ROW_CHANGED] == -1) || calling[RowSetEventListener.ROW_CHANGED] == pos++);
- assure("Callings are not in the correct order for IS_MODIFIED" ,
- ( !_must[ RowSetEventListener.IS_MODIFIED] || calling[RowSetEventListener.IS_MODIFIED] == -1) || calling[RowSetEventListener.IS_MODIFIED] == pos++);
- assure("Callings are not in the correct order for IS_NEW" ,
- ( !_must[ RowSetEventListener.IS_NEW] || calling[RowSetEventListener.IS_NEW] == -1) || calling[RowSetEventListener.IS_NEW] == pos++);
- assure("Callings are not in the correct order for ROW_COUNT" ,
- ( !_must[ RowSetEventListener.ROW_COUNT] || calling[RowSetEventListener.ROW_COUNT] == -1) || calling[RowSetEventListener.ROW_COUNT] == pos++);
- assure("Callings are not in the correct order for IS_ROW_COUNT_FINAL" ,
- ( !_must[ RowSetEventListener.IS_ROW_COUNT_FINAL] || calling[RowSetEventListener.IS_ROW_COUNT_FINAL] == -1) || calling[RowSetEventListener.IS_ROW_COUNT_FINAL] == pos++);
+ assure("Callings are not in the correct order for APPROVE_CURSOR_MOVE ",
+ (!_must[RowSetEventListener.APPROVE_CURSOR_MOVE] || calling[RowSetEventListener.APPROVE_CURSOR_MOVE] == -1) || calling[RowSetEventListener.APPROVE_CURSOR_MOVE] == pos++);
+ assure("Callings are not in the correct order for APPROVE_ROW_CHANGE",
+ (!_must[RowSetEventListener.APPROVE_ROW_CHANGE] || calling[RowSetEventListener.APPROVE_ROW_CHANGE] == -1) || calling[RowSetEventListener.APPROVE_ROW_CHANGE] == pos++);
+ assure("Callings are not in the correct order for COLUMN_VALUE",
+ (!_must[RowSetEventListener.COLUMN_VALUE] || calling[RowSetEventListener.COLUMN_VALUE] == -1) || calling[RowSetEventListener.COLUMN_VALUE] == pos++);
+ assure("Callings are not in the correct order for CURSOR_MOVED",
+ (!_must[RowSetEventListener.CURSOR_MOVED] || calling[RowSetEventListener.CURSOR_MOVED] == -1) || calling[RowSetEventListener.CURSOR_MOVED] == pos++);
+ assure("Callings are not in the correct order for ROW_CHANGED",
+ (!_must[RowSetEventListener.ROW_CHANGED] || calling[RowSetEventListener.ROW_CHANGED] == -1) || calling[RowSetEventListener.ROW_CHANGED] == pos++);
+ assure("Callings are not in the correct order for IS_MODIFIED",
+ (!_must[RowSetEventListener.IS_MODIFIED] || calling[RowSetEventListener.IS_MODIFIED] == -1) || calling[RowSetEventListener.IS_MODIFIED] == pos++);
+ assure("Callings are not in the correct order for IS_NEW",
+ (!_must[RowSetEventListener.IS_NEW] || calling[RowSetEventListener.IS_NEW] == -1) || calling[RowSetEventListener.IS_NEW] == pos++);
+ assure("Callings are not in the correct order for ROW_COUNT",
+ (!_must[RowSetEventListener.ROW_COUNT] || calling[RowSetEventListener.ROW_COUNT] == -1) || calling[RowSetEventListener.ROW_COUNT] == pos++);
+ assure("Callings are not in the correct order for IS_ROW_COUNT_FINAL",
+ (!_must[RowSetEventListener.IS_ROW_COUNT_FINAL] || calling[RowSetEventListener.IS_ROW_COUNT_FINAL] == -1) || calling[RowSetEventListener.IS_ROW_COUNT_FINAL] == pos);
_evt.clearCalling();
}
@@ -543,7 +589,7 @@ public class RowSet extends ComplexTestCase {
*/
private int currentRowCount() throws UnknownPropertyException, WrappedTargetException
{
- Integer rowCount = (Integer)m_rowSetProperties.getPropertyValue( "RowCount" );
+ final Integer rowCount = (Integer) m_rowSetProperties.getPropertyValue("RowCount");
return rowCount.intValue();
}
@@ -552,9 +598,9 @@ public class RowSet extends ComplexTestCase {
*/
private int positionRandom() throws SQLException, UnknownPropertyException, WrappedTargetException
{
- int position = (new java.util.Random()).nextInt( currentRowCount() - 2 ) + 2;
- assure( "sub task failed: could not position to row no. " + (new Integer( position )).toString(),
- m_resultSet.absolute( position ) );
+ final int position = (new Random()).nextInt(currentRowCount() - 2) + 2;
+ assure("sub task failed: could not position to row no. " + (Integer.valueOf(position)).toString(),
+ m_resultSet.absolute(position));
return m_resultSet.getRow();
}
@@ -568,16 +614,16 @@ public class RowSet extends ComplexTestCase {
private int deleteRandom() throws SQLException, UnknownPropertyException, WrappedTargetException
{
// check if the current position and the row count in the result set is changed by a deletion (it should not)
- int positionBefore = positionRandom();
- int rowCountBefore = currentRowCount();
+ final int positionBefore = positionRandom();
+ final int rowCountBefore = currentRowCount();
m_resultSetUpdate.deleteRow();
- int positionAfter = m_resultSet.getRow();
- int rowCountAfter = currentRowCount();
- assure( "position changed during |deleteRow| (it should not)", positionAfter == positionBefore );
- assure( "row count changed with a |deleteRow| (it should not)", rowCountBefore == rowCountAfter );
- assure( "RowSet does not report the current row as deleted after |deleteRow|", m_resultSet.rowDeleted() );
+ final int positionAfter = m_resultSet.getRow();
+ final int rowCountAfter = currentRowCount();
+ assure("position changed during |deleteRow| (it should not)", positionAfter == positionBefore);
+ assure("row count changed with a |deleteRow| (it should not)", rowCountBefore == rowCountAfter);
+ assure("RowSet does not report the current row as deleted after |deleteRow|", m_resultSet.rowDeleted());
return positionBefore;
}
@@ -585,11 +631,11 @@ public class RowSet extends ComplexTestCase {
// --------------------------------------------------------------------------------------------------------
public void testDeleteBehavior() throws Exception
{
- createTestCase( true );
+ createTestCase(true);
// ensure that all records are known
m_resultSet.last();
- int initialRowCount = currentRowCount();
+ final int initialRowCount = currentRowCount();
// delete a random row
int deletedRow = deleteRandom();
@@ -597,92 +643,119 @@ public class RowSet extends ComplexTestCase {
// .....................................................................................................
// asking for the bookmark of a deleted row should fail
boolean caughtException = false;
- try { m_rowLocate.getBookmark(); }
- catch ( SQLException e ) { caughtException = true; }
- assure( "asking for the bookmark of a deleted row should throw an exception", caughtException );
+ try
+ {
+ m_rowLocate.getBookmark();
+ }
+ catch (SQLException e)
+ {
+ caughtException = true;
+ }
+ assure("asking for the bookmark of a deleted row should throw an exception", caughtException);
// .....................................................................................................
// isXXX methods should return |false| on a deleted row
- assure( "one of the isFoo failed after |deleteRow|", !m_resultSet.isBeforeFirst() && !m_resultSet.isAfterLast() && !m_resultSet.isFirst() && !m_resultSet.isLast() );
- // note that we can assume that isFirst / isLast also return |false|, since deleteRandom did
- // not position on the first or last record, but inbetween
+ assure("one of the isFoo failed after |deleteRow|", !m_resultSet.isBeforeFirst() && !m_resultSet.isAfterLast() && !m_resultSet.isFirst() && !m_resultSet.isLast());
+ // note that we can assume that isFirst / isLast also return |false|, since deleteRandom did
+ // not position on the first or last record, but inbetween
// .....................................................................................................
// check if moving away from this row in either direction yields the expected results
- assure( "|previous| after |deleteRow| failed", m_resultSet.previous() );
- int positionPrevious = m_resultSet.getRow();
- assure( "position after |previous| after |deleteRow| is not as expected", positionPrevious == deletedRow - 1 );
+ assure("|previous| after |deleteRow| failed", m_resultSet.previous());
+ final int positionPrevious = m_resultSet.getRow();
+ assure("position after |previous| after |deleteRow| is not as expected", positionPrevious == deletedRow - 1);
deletedRow = deleteRandom();
- assure( "|next| after |deleteRow| failed", m_resultSet.next() );
- int positionAfter = m_resultSet.getRow();
- assure( "position after |next| after |deleteRow| is not as expected", positionAfter == deletedRow );
- // since the deleted record "vanishs" as soon as the cursor is moved away from it, the absolute position does
- // not change with a |next| call here
+ assure("|next| after |deleteRow| failed", m_resultSet.next());
+ final int positionAfter = m_resultSet.getRow();
+ assure("position after |next| after |deleteRow| is not as expected", positionAfter == deletedRow);
+ // since the deleted record "vanishs" as soon as the cursor is moved away from it, the absolute position does
+ // not change with a |next| call here
// .....................................................................................................
// check if the deleted rows really vanished after moving away from them
- assure( "row count did not change as expected after two deletions", initialRowCount - 2 == currentRowCount() );
+ assure("row count did not change as expected after two deletions", initialRowCount - 2 == currentRowCount());
// .....................................................................................................
// check if the deleted row vanishes after moving to the insertion row
- int rowCountBefore = currentRowCount();
- int deletedPos = deleteRandom();
+ final int rowCountBefore = currentRowCount();
+ final int deletedPos = deleteRandom();
m_resultSetUpdate.moveToInsertRow();
- assure( "moving to the insertion row immediately after |deleteRow| does not adjust the row count", rowCountBefore == currentRowCount() + 1 );
+ assure("moving to the insertion row immediately after |deleteRow| does not adjust the row count", rowCountBefore == currentRowCount() + 1);
m_resultSetUpdate.moveToCurrentRow();
- assure( "|moveToCurrentRow| after |deleteRow| + |moveToInsertRow| results in unexpected position",
- ( m_resultSet.getRow() == deletedPos ) && !m_resultSet.rowDeleted() );
+ assure("|moveToCurrentRow| after |deleteRow| + |moveToInsertRow| results in unexpected position",
+ (m_resultSet.getRow() == deletedPos) && !m_resultSet.rowDeleted());
// the same, but this time with deleting the first row (which is not covered by deleteRandom)
m_resultSet.last();
m_resultSetUpdate.deleteRow();
m_resultSetUpdate.moveToInsertRow();
m_resultSetUpdate.moveToCurrentRow();
- assure( "|last| + |deleteRow| + |moveToInsertRow| + |moveToCurrentRow| results in wrong state", m_resultSet.isAfterLast() );
+ assure("|last| + |deleteRow| + |moveToInsertRow| + |moveToCurrentRow| results in wrong state", m_resultSet.isAfterLast());
// .....................................................................................................
// check if deleting a deleted row fails as expected
deleteRandom();
caughtException = false;
- try { m_resultSetUpdate.deleteRow(); }
- catch( SQLException e ) { caughtException = true; }
- assure( "deleting a deleted row succeeded - it shouldn't", caughtException );
+ try
+ {
+ m_resultSetUpdate.deleteRow();
+ }
+ catch (SQLException e)
+ {
+ caughtException = true;
+ }
+ assure("deleting a deleted row succeeded - it shouldn't", caughtException);
// .....................................................................................................
// check if deleteRows fails if it contains the bookmark of a previously-deleted row
m_resultSet.first();
- Object firstBookmark = m_rowLocate.getBookmark();
+ final Object firstBookmark = m_rowLocate.getBookmark();
positionRandom();
- Object deleteBookmark = m_rowLocate.getBookmark();
+ final Object deleteBookmark = m_rowLocate.getBookmark();
m_resultSetUpdate.deleteRow();
- XDeleteRows multiDelete = (XDeleteRows)UnoRuntime.queryInterface( XDeleteRows.class, m_resultSet );
- int[] deleteSuccess = multiDelete.deleteRows(new Object[]{firstBookmark, deleteBookmark});
- assure( "XDeleteRows::deleteRows with the bookmark of an already-deleted row failed",
- ( deleteSuccess.length == 2 ) && ( deleteSuccess[0] != 0 ) && ( deleteSuccess[1] == 0 ) );
+ final XDeleteRows multiDelete = (XDeleteRows) UnoRuntime.queryInterface(XDeleteRows.class, m_resultSet);
+ final int[] deleteSuccess = multiDelete.deleteRows(new Object[]
+ {
+ firstBookmark, deleteBookmark
+ });
+ assure("XDeleteRows::deleteRows with the bookmark of an already-deleted row failed",
+ (deleteSuccess.length == 2) && (deleteSuccess[0] != 0) && (deleteSuccess[1] == 0));
// .....................................................................................................
// check if refreshing a deleted row fails as expected
deleteRandom();
caughtException = false;
- try { m_resultSet.refreshRow(); }
- catch( SQLException e ) { caughtException = true; }
- assure( "refreshing a deleted row succeeded - it shouldn't", caughtException );
+ try
+ {
+ m_resultSet.refreshRow();
+ }
+ catch (SQLException e)
+ {
+ caughtException = true;
+ }
+ assure("refreshing a deleted row succeeded - it shouldn't", caughtException);
// .....................................................................................................
// rowUpdated/rowDeleted
deleteRandom();
- assure( "rowDeleted and/or rowUpdated are wrong on a deleted row", !m_resultSet.rowUpdated() && !m_resultSet.rowInserted() );
+ assure("rowDeleted and/or rowUpdated are wrong on a deleted row", !m_resultSet.rowUpdated() && !m_resultSet.rowInserted());
// .....................................................................................................
// updating values in a deleted row should fail
deleteRandom();
- XRowUpdate rowUpdated = (XRowUpdate)UnoRuntime.queryInterface( XRowUpdate.class, m_resultSet );
+ final XRowUpdate rowUpdated = (XRowUpdate) UnoRuntime.queryInterface(XRowUpdate.class, m_resultSet);
caughtException = false;
- try { rowUpdated.updateString( 2, "Test21" ); }
- catch( SQLException e ) { caughtException = true; }
- assure( "updating values in a deleted row should not succeed", caughtException );
+ try
+ {
+ rowUpdated.updateString(2, TEST21);
+ }
+ catch (SQLException e)
+ {
+ caughtException = true;
+ }
+ assure("updating values in a deleted row should not succeed", caughtException);
}
// --------------------------------------------------------------------------------------------------------
@@ -691,67 +764,66 @@ public class RowSet extends ComplexTestCase {
*/
public void testCloneMovesPlusDeletions() throws SQLException, UnknownPropertyException, WrappedTargetException
{
- createTestCase( true );
+ createTestCase(true);
// ensure that all records are known
m_resultSet.last();
- XResultSet clone = createClone();
- XRowLocate cloneRowLocate = (XRowLocate)UnoRuntime.queryInterface( XRowLocate.class, clone );
+ final XResultSet clone = createClone();
+ final XRowLocate cloneRowLocate = (XRowLocate) UnoRuntime.queryInterface(XRowLocate.class, clone);
positionRandom();
// .....................................................................................................
// move the clone to the same record as the RowSet, and delete this record
- cloneRowLocate.moveToBookmark( m_rowLocate.getBookmark() );
- int clonePosition = clone.getRow();
+ cloneRowLocate.moveToBookmark(m_rowLocate.getBookmark());
+ final int clonePosition = clone.getRow();
m_resultSetUpdate.deleteRow();
- assure( "clone doesn't know that its current row has been deleted via the RowSet", clone.rowDeleted() );
- assure( "clone's position changed somehow during deletion", clonePosition == clone.getRow() );
+ assure("clone doesn't know that its current row has been deleted via the RowSet", clone.rowDeleted());
+ assure("clone's position changed somehow during deletion", clonePosition == clone.getRow());
// .....................................................................................................
// move the row set away from the deleted record. This should still not touch the state of the clone
m_resultSet.previous();
- assure( "clone doesn't know (anymore) that its current row has been deleted via the RowSet", clone.rowDeleted() );
- assure( "clone's position changed somehow during deletion and RowSet-movement", clonePosition == clone.getRow() );
+ assure("clone doesn't know (anymore) that its current row has been deleted via the RowSet", clone.rowDeleted());
+ assure("clone's position changed somehow during deletion and RowSet-movement", clonePosition == clone.getRow());
// .....................................................................................................
// move the clone away from the deleted record
clone.next();
- assure( "clone still assumes that its row is deleted - but we already moved it", !clone.rowDeleted() );
+ assure("clone still assumes that its row is deleted - but we already moved it", !clone.rowDeleted());
// .....................................................................................................
// check whether deleting the extremes (first / last) work
m_resultSet.first();
- cloneRowLocate.moveToBookmark( m_rowLocate.getBookmark() );
+ cloneRowLocate.moveToBookmark(m_rowLocate.getBookmark());
m_resultSetUpdate.deleteRow();
clone.previous();
- assure( "deleting the first record left the clone in a strange state (after |previous|)", clone.isBeforeFirst() );
+ assure("deleting the first record left the clone in a strange state (after |previous|)", clone.isBeforeFirst());
clone.next();
- assure( "deleting the first record left the clone in a strange state (after |previous| + |next|)", clone.isFirst() );
+ assure("deleting the first record left the clone in a strange state (after |previous| + |next|)", clone.isFirst());
m_resultSet.last();
- cloneRowLocate.moveToBookmark( m_rowLocate.getBookmark() );
+ cloneRowLocate.moveToBookmark(m_rowLocate.getBookmark());
m_resultSetUpdate.deleteRow();
clone.next();
- assure( "deleting the last record left the clone in a strange state (after |next|)", clone.isAfterLast() );
+ assure("deleting the last record left the clone in a strange state (after |next|)", clone.isAfterLast());
clone.previous();
- assure( "deleting the first record left the clone in a strange state (after |next| + |previous|)", clone.isLast() );
+ assure("deleting the first record left the clone in a strange state (after |next| + |previous|)", clone.isLast());
// .....................................................................................................
// check whether movements of the clone interfere with movements of the RowSet, if the latter is on a deleted row
- int positionBefore = positionRandom();
+ final int positionBefore = positionRandom();
m_resultSetUpdate.deleteRow();
- assure( "|deleteRow|, but no |rowDeleted| (this should have been found much earlier!)", m_resultSet.rowDeleted() );
+ assure("|deleteRow|, but no |rowDeleted| (this should have been found much earlier!)", m_resultSet.rowDeleted());
clone.beforeFirst();
- while ( clone.next() )
- ;
- assure( "row set forgot that the current row is deleted", m_resultSet.rowDeleted() );
+ while (clone.next());
+ assure("row set forgot that the current row is deleted", m_resultSet.rowDeleted());
- assure( "moving to the next record after |deleteRow| and clone moves failed", m_resultSet.next() );
- assure( "wrong position after |deleteRow| and clone movement", !m_resultSet.isAfterLast() && !m_resultSet.isBeforeFirst() );
- assure( "wrong absolute position after |deleteRow| and clone movement", m_resultSet.getRow() == positionBefore );
+ assure("moving to the next record after |deleteRow| and clone moves failed", m_resultSet.next());
+ assure("wrong position after |deleteRow| and clone movement", !m_resultSet.isAfterLast() && !m_resultSet.isBeforeFirst());
+ assure("wrong absolute position after |deleteRow| and clone movement", m_resultSet.getRow() == positionBefore);
}
// --------------------------------------------------------------------------------------------------------
@@ -760,99 +832,102 @@ public class RowSet extends ComplexTestCase {
*/
public void testCloneMovesPlusInsertions() throws SQLException, UnknownPropertyException, WrappedTargetException, PropertyVetoException, com.sun.star.lang.IllegalArgumentException
{
- createTestCase( true );
+ createTestCase(true);
// ensure that all records are known
- m_rowSetProperties.setPropertyValue( "FetchSize", new Integer( 10 ) );
+ m_rowSetProperties.setPropertyValue("FetchSize", Integer.valueOf(10));
- XResultSet clone = createClone();
- XRow cloneRow = (XRow)UnoRuntime.queryInterface( XRow.class, clone );
+ final XResultSet clone = createClone();
+ final XRow cloneRow = (XRow) UnoRuntime.queryInterface(XRow.class, clone);
// .....................................................................................................
// first check the basic scenario without the |moveToInsertRow| |moveToCurrentRow|, to ensure that
// really those are broken, if at all
m_resultSet.last();
clone.first();
- clone.absolute( 11 );
+ clone.absolute(11);
clone.first();
- int rowValue1 = m_row.getInt(1);
- int rowPos = m_resultSet.getRow();
- int rowValue2 = m_row.getInt(1);
- assure( "repeated query for the same column value delivers different values (" + rowValue1 + " and " + rowValue2 + ") on row: " + rowPos,
- rowValue1 == rowValue2 );
+ final int rowValue1 = m_row.getInt(1);
+ final int rowPos = m_resultSet.getRow();
+ final int rowValue2 = m_row.getInt(1);
+ assure("repeated query for the same column value delivers different values (" + rowValue1 + " and " + rowValue2 + ") on row: " + rowPos,
+ rowValue1 == rowValue2);
- testPosition( clone, cloneRow, 1, "mixed clone/rowset move: clone check" );
- testPosition( m_resultSet, m_row, MAX_TABLE_ROWS, "mixed clone/rowset move: rowset check" );
+ testPosition(clone, cloneRow, 1, "mixed clone/rowset move: clone check");
+ testPosition(m_resultSet, m_row, MAX_TABLE_ROWS, "mixed clone/rowset move: rowset check");
// .....................................................................................................
// now the complete scenario
m_resultSet.last();
m_resultSetUpdate.moveToInsertRow();
clone.first();
- clone.absolute( 11 );
+ clone.absolute(11);
clone.first();
m_resultSetUpdate.moveToCurrentRow();
- testPosition( clone, cloneRow, 1, "mixed clone/rowset move/insertion: clone check" );
- testPosition( m_resultSet, m_row, 100, "mixed clone/rowset move/insertion: rowset check" );
+ testPosition(clone, cloneRow, 1, "mixed clone/rowset move/insertion: clone check");
+ testPosition(m_resultSet, m_row, 100, "mixed clone/rowset move/insertion: rowset check");
}
// --------------------------------------------------------------------------------------------------------
private void testTableParameters()
{
// for a row set simply based on a table, there should be not parameters at all
- createRowSet( "products", CommandType.TABLE, false );
+ createRowSet("products", CommandType.TABLE, false);
try
{
- verifyParameters( new String[] {}, "testTableParameters" );
+ verifyParameters(new String[]
+ {
+ }, "testTableParameters");
}
- catch( AssureException e ) { throw e; }
- catch( Exception e )
+ catch (Exception e)
{
- assure( "testing the parameters of a table failed" + e.getMessage(), false );
+ assure("testing the parameters of a table failed" + e.getMessage(), false);
}
}
// --------------------------------------------------------------------------------------------------------
+
private void testParametersAfterNormalExecute()
{
try
{
- createRowSet( "SELECT * FROM \"customers\"", CommandType.COMMAND, true );
- m_rowSetProperties.setPropertyValue( "Command", "SELECT * FROM \"customers\" WHERE \"City\" = :city");
- XParameters rowsetParams = (XParameters)UnoRuntime.queryInterface( XParameters.class,
- m_rowSet );
- rowsetParams.setString( 1, "London" );
+ 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);
+ rowsetParams.setString(1, "London");
m_rowSet.execute();
}
- catch( AssureException e ) { throw e; }
- catch( Exception e )
+ catch (Exception e)
{
- assure( "testing the parameters of a table failed" + e.getMessage(), false );
+ assure("testing the parameters of a table failed" + e.getMessage(), false);
}
}
// --------------------------------------------------------------------------------------------------------
- private void verifyParameters( String[] _paramNames, String _context ) throws com.sun.star.uno.Exception
+ private void verifyParameters(String[] _paramNames, String _context) throws com.sun.star.uno.Exception
{
- XIndexAccess params = m_paramsSupplier.getParameters();
- int expected = _paramNames.length;
- int found = params != null ? params.getCount() : 0;
+ final XIndexAccess params = m_paramsSupplier.getParameters();
+ final int expected = _paramNames.length;
+ final int found = params != null ? params.getCount() : 0;
- assure( "wrong number of parameters (expected: " + expected + ", found: " + found + ") in " + _context,
- found == expected );
+ assure("wrong number of parameters (expected: " + expected + ", found: " + found + ") in " + _context,
+ found == expected);
- if ( found == 0 )
+ if (found == 0)
+ {
return;
+ }
- for ( int i=0; i<expected; ++i )
+ for (int i = 0; i < expected; ++i)
{
- XPropertySet parameter = (XPropertySet)UnoRuntime.queryInterface( XPropertySet.class,
- params.getByIndex(i) );
+ final XPropertySet parameter = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class,
+ params.getByIndex(i));
- String expectedName = _paramNames[i];
- String foundName = (String)parameter.getPropertyValue( "Name" );
- assure( "wrong parameter name (expected: " + expectedName + ", found: " + foundName + ") in" + _context,
- expectedName.equals( foundName ) );
+ final String expectedName = _paramNames[i];
+ final String foundName = (String) parameter.getPropertyValue("Name");
+ assure("wrong parameter name (expected: " + expectedName + ", found: " + foundName + ") in" + _context,
+ expectedName.equals(foundName));
}
}
@@ -863,14 +938,16 @@ public class RowSet extends ComplexTestCase {
{
// for a row set based on a parametrized query, those parameters should be properly
// recognized
- m_dataSource.createQuery( "products like", "SELECT * FROM \"products\" WHERE \"Name\" LIKE :product_name" );
- createRowSet( "products like", CommandType.QUERY, false );
- verifyParameters( new String[] { "product_name" }, "testParametrizedQuery" );
+ m_dataSource.createQuery("products like", "SELECT * FROM \"products\" WHERE \"Name\" LIKE :product_name");
+ createRowSet("products like", CommandType.QUERY, false);
+ verifyParameters(new String[]
+ {
+ "product_name"
+ }, "testParametrizedQuery");
}
- catch( AssureException e ) { throw e; }
- catch( Exception e )
+ catch (Exception e)
{
- assure( "testing the parameters of a parametrized query failed" + e.getMessage(), false );
+ assure("testing the parameters of a parametrized query failed" + e.getMessage(), false);
}
}
@@ -879,38 +956,37 @@ public class RowSet extends ComplexTestCase {
{
try
{
- createRowSet( "products like", CommandType.QUERY, false );
+ 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
- XParameters rowsetParams = (XParameters)UnoRuntime.queryInterface( XParameters.class,
- m_rowSet );
- rowsetParams.setString( 1, "Apples" );
+ final XParameters rowsetParams = (XParameters) 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) );
- Object firstParamValue = firstParam.getPropertyValue( "Value" );
+ XPropertySet firstParam = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, params.getByIndex(0));
+ Object firstParamValue = firstParam.getPropertyValue("Value");
- assure( "XParameters and the parameters container do not properly interact",
- firstParamValue.equals( "Apples" ) );
+ assure("XParameters and the parameters container do not properly interact",
+ "Apples".equals(firstParamValue));
// let's see whether this also survices an execute of the row set
- rowsetParams.setString( 1, "Oranges" );
+ rowsetParams.setString(1, "Oranges");
m_rowSet.execute();
{
// TODO: the following would not be necessary if the parameters container would *survive*
// 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 = (XPropertySet) 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",
- firstParamValue.equals( "Oranges" ) );
+ firstParamValue = firstParam.getPropertyValue("Value");
+ assure("XParameters and the parameters container do not properly interact, after the row set has been executed",
+ "Oranges".equals(firstParamValue));
}
- catch( AssureException e ) { throw e; }
- catch( Exception e )
+ catch (Exception e)
{
- assure( "could not text the relationship between XParameters and XParametersSupplier" + e.getMessage(), false );
+ assure("could not text the relationship between XParameters and XParametersSupplier" + e.getMessage(), false);
}
}
@@ -919,19 +995,23 @@ public class RowSet extends ComplexTestCase {
{
try
{
- createRowSet( "SELECT * FROM \"customers\"", CommandType.COMMAND, false );
- m_rowSetProperties.setPropertyValue( "Filter", "\"City\" = :city" );
-
- m_rowSetProperties.setPropertyValue( "ApplyFilter", new Boolean( true ) );
- verifyParameters( new String[] { "city" }, "testParametersInFilter" );
-
- m_rowSetProperties.setPropertyValue( "ApplyFilter", new Boolean( false ) );
- verifyParameters( new String[] {}, "testParametersInFilter" );
+ createRowSet("SELECT * FROM \"customers\"", CommandType.COMMAND, false);
+ m_rowSetProperties.setPropertyValue("Filter", "\"City\" = :city");
+
+ m_rowSetProperties.setPropertyValue("ApplyFilter", Boolean.TRUE);
+ verifyParameters(new String[]
+ {
+ "city"
+ }, "testParametersInFilter");
+
+ m_rowSetProperties.setPropertyValue("ApplyFilter", Boolean.FALSE);
+ verifyParameters(new String[]
+ {
+ }, "testParametersInFilter");
}
- catch( AssureException e ) { throw e; }
- catch( Exception e )
+ catch (Exception e)
{
- assure( "testing the parameters within a WHERE clause failed" + e.getMessage(), false );
+ assure("testing the parameters within a WHERE clause failed" + e.getMessage(), false);
}
}
@@ -940,8 +1020,8 @@ public class RowSet extends ComplexTestCase {
*/
public void testParameters()
{
- createTestCase( false );
- // use an own RowSet instance, not the one which is also used for the other cases
+ createTestCase(false);
+ // use an own RowSet instance, not the one which is also used for the other cases
testTableParameters();
testParametrizedQuery();
@@ -950,6 +1030,6 @@ public class RowSet extends ComplexTestCase {
testParametersAfterNormalExecute();
testParametersInteraction();
- }
+ }
}
diff --git a/dbaccess/qa/complex/dbaccess/RowSetEventListener.java b/dbaccess/qa/complex/dbaccess/RowSetEventListener.java
index 774947ecc2dc..91c742321534 100644
--- a/dbaccess/qa/complex/dbaccess/RowSetEventListener.java
+++ b/dbaccess/qa/complex/dbaccess/RowSetEventListener.java
@@ -48,12 +48,10 @@ public class RowSetEventListener implements XRowSetApproveListener,XRowSetListen
public static final int ROW_COUNT = 7;
public static final int IS_ROW_COUNT_FINAL = 8;
- RowSet rowset;
int callPos = 1;
int calling [];
- RowSetEventListener(RowSet _rowset){
- rowset = _rowset;
+ RowSetEventListener(){
calling = new int [9];
clearCalling();
}
@@ -100,15 +98,15 @@ public class RowSetEventListener implements XRowSetApproveListener,XRowSetListen
}
public void propertyChange(com.sun.star.beans.PropertyChangeEvent propertyChangeEvent) {
- if ( propertyChangeEvent.PropertyName.equals("Value") ){
+ if ( "Value".equals(propertyChangeEvent.PropertyName) ){
calling[COLUMN_VALUE] = callPos++;
- } else if ( propertyChangeEvent.PropertyName.equals("IsModified") ){
+ } else if ( "IsModified".equals(propertyChangeEvent.PropertyName) ){
calling[IS_MODIFIED] = callPos++;
- } else if ( propertyChangeEvent.PropertyName.equals("IsNew") ){
+ } else if ( "IsNew".equals(propertyChangeEvent.PropertyName) ){
calling[IS_NEW] = callPos++;
- } else if ( propertyChangeEvent.PropertyName.equals("RowCount") ){
+ } else if ( "RowCount".equals(propertyChangeEvent.PropertyName) ){
calling[ROW_COUNT] = callPos++;
- } else if ( propertyChangeEvent.PropertyName.equals("IsRowCountFinal") ){
+ } else if ( "IsRowCountFinal".equals(propertyChangeEvent.PropertyName) ){
calling[IS_ROW_COUNT_FINAL] = callPos++;
}
}
diff --git a/dbaccess/qa/complex/dbaccess/SingleSelectQueryComposer.java b/dbaccess/qa/complex/dbaccess/SingleSelectQueryComposer.java
index c73ce6496c88..7b0aed460dc8 100755
--- a/dbaccess/qa/complex/dbaccess/SingleSelectQueryComposer.java
+++ b/dbaccess/qa/complex/dbaccess/SingleSelectQueryComposer.java
@@ -32,36 +32,35 @@ package complex.dbaccess;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.beans.*;
import com.sun.star.sdbcx.*;
-import com.sun.star.sdbc.*;
import com.sun.star.sdb.*;
import com.sun.star.container.*;
-import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.sdbc.DataType;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
-import java.util.logging.Level;
-import java.util.logging.Logger;
public class SingleSelectQueryComposer extends CRMBasedTestCase
{
- private XSingleSelectQueryComposer m_composer;
- private final String complexFilter = "( \"ID\" = 1 AND \"Postal\" = '4' )" +
- " OR ( \"ID\" = 2 AND \"Postal\" = '5' )" +
- " OR ( \"ID\" = '3' AND \"Postal\" = '6' AND \"Address\" = '7' )" +
- " OR ( \"Address\" = '8' )" +
- " OR ( \"Postal\" = '9' )";
- private final String innerProductsQuery = "products (inner)";
+ private XSingleSelectQueryComposer m_composer = null;
+ private final static String COMPLEXFILTER = "( \"ID\" = 1 AND \"Postal\" = '4' )" +
+ " OR ( \"ID\" = 2 AND \"Postal\" = '5' )" +
+ " OR ( \"ID\" = '3' AND \"Postal\" = '6' AND \"Address\" = '7' )" +
+ " OR ( \"Address\" = '8' )" +
+ " OR ( \"Postal\" = '9' )";
+ private final static String INNERPRODUCTSQUERY = "products (inner)";
// --------------------------------------------------------------------------------------------------------
public String[] getTestMethodNames()
{
- return new String[] {
- "testAttributes",
- "testSubQueries",
- "testParameters",
- "testDisjunctiveNormalForm"
- };
+ return new String[]
+ {
+ "testAttributes",
+ "testSubQueries",
+ "testParameters",
+ "testDisjunctiveNormalForm",
+ "testConditionByColumn"
+ };
}
// --------------------------------------------------------------------------------------------------------
@@ -73,7 +72,7 @@ public class SingleSelectQueryComposer extends CRMBasedTestCase
// --------------------------------------------------------------------------------------------------------
private void createQueries() throws Exception
{
- m_database.getDatabase().getDataSource().createQuery( innerProductsQuery, "SELECT * FROM \"products\"" );
+ m_database.getDatabase().getDataSource().createQuery(INNERPRODUCTSQUERY, "SELECT * FROM \"products\"");
}
// --------------------------------------------------------------------------------------------------------
@@ -88,32 +87,48 @@ public class SingleSelectQueryComposer extends CRMBasedTestCase
m_composer = createQueryComposer();
}
- catch ( Exception e )
+ catch (Exception e)
{
- assure( "caught an exception (" + e.getMessage() + ") while creating the test case", false );
+ assure("caught an exception (" + e.getMessage() + ") while creating the test case", false);
}
}
// --------------------------------------------------------------------------------------------------------
- private void checkAttributeAccess( String _attributeName, String _attributeValue )
+ private void checkAttributeAccess(String _attributeName, String _attributeValue)
{
- log.println( "setting " + _attributeName + " to " + _attributeValue );
+ log.println("setting " + _attributeName + " to " + _attributeValue);
String realValue = null;
try
{
- Class composerClass = m_composer.getClass();
- Method attributeGetter = composerClass.getMethod( "get" + _attributeName, new Class[] {} );
- Method attributeSetter = composerClass.getMethod( "set" + _attributeName, new Class[] { String.class } );
-
- attributeSetter.invoke( m_composer, new Object[] { _attributeValue } );
- realValue = (String)attributeGetter.invoke( m_composer, new Object[] {} );
+ final Class composerClass = m_composer.getClass();
+ final Method attributeGetter = composerClass.getMethod("get" + _attributeName, new Class[]
+ {
+ });
+ final Method attributeSetter = composerClass.getMethod("set" + _attributeName, new Class[]
+ {
+ String.class
+ });
+
+ attributeSetter.invoke(m_composer, new Object[]
+ {
+ _attributeValue
+ });
+ realValue = (String) attributeGetter.invoke(m_composer, new Object[]
+ {
+ });
+ }
+ catch (NoSuchMethodException e)
+ {
+ }
+ catch (IllegalAccessException e)
+ {
+ }
+ catch (InvocationTargetException e)
+ {
}
- catch ( NoSuchMethodException e ) { }
- catch ( IllegalAccessException e ) { }
- catch ( InvocationTargetException e ) { }
- assure( "set/get" + _attributeName + " not working as expected (set: " + _attributeValue + ", get: " + ( realValue != null ? realValue : "null" ) + ")",
- realValue.equals( _attributeValue ) );
- log.println( " (results in " + (String)m_composer.getQuery() + ")" );
+ assure("set/get" + _attributeName + " not working as expected (set: " + _attributeValue + ", get: " + (realValue != null ? realValue : "null") + ")",
+ realValue.equals(_attributeValue));
+ log.println(" (results in " + (String) m_composer.getQuery() + ")");
}
/** tests accessing attributes of the composer (order, filter, group by, having)
@@ -124,48 +139,47 @@ public class SingleSelectQueryComposer extends CRMBasedTestCase
try
{
- log.println("check setQuery");
- final String simpleQuery = "SELECT * FROM \"customers\"";
- m_composer.setQuery( simpleQuery );
- assure( "set/getQuery inconsistent", m_composer.getQuery().equals( simpleQuery ) );
-
- checkAttributeAccess( "Filter", "\"Name\" = 'oranges'" );
- checkAttributeAccess( "Group", "\"City\"" );
- checkAttributeAccess( "Order", "\"Address\"" );
- checkAttributeAccess( "HavingClause", "\"ID\" <> 4" );
-
- XIndexAccess orderColumns = m_composer.getOrderColumns();
- assure( "Order columns doesn't exist: \"Address\"",
- orderColumns != null && orderColumns.getCount() == 1 && orderColumns.getByIndex(0) != null );
-
- XIndexAccess groupColumns = m_composer.getGroupColumns();
- assure( "Group columns doesn't exist: \"City\"",
- groupColumns != null && groupColumns.getCount() == 1 && groupColumns.getByIndex(0) != null );
-
- // XColumnsSupplier
- XColumnsSupplier xSelectColumns = (XColumnsSupplier)
- UnoRuntime.queryInterface(XColumnsSupplier.class,m_composer);
- assure( "no select columns, or wrong number of select columns",
- xSelectColumns != null && xSelectColumns.getColumns() != null && xSelectColumns.getColumns().getElementNames().length == 5 );
-
- // structured filter
- m_composer.setQuery("SELECT \"ID\", \"Postal\", \"Address\" FROM \"customers\"");
- m_composer.setFilter(complexFilter);
- PropertyValue[][] aStructuredFilter = m_composer.getStructuredFilter();
- m_composer.setFilter("");
- m_composer.setStructuredFilter(aStructuredFilter);
- assure("Structured Filter not identical" , m_composer.getFilter().equals(complexFilter));
-
- // structured having clause
- m_composer.setHavingClause(complexFilter);
- PropertyValue[][] aStructuredHaving = m_composer.getStructuredHavingClause();
- m_composer.setHavingClause("");
- m_composer.setStructuredHavingClause(aStructuredHaving);
- assure("Structured Having Clause not identical" , m_composer.getHavingClause().equals(complexFilter));
- }
- catch(Exception e)
+ log.println("check setQuery");
+ final String simpleQuery = "SELECT * FROM \"customers\"";
+ m_composer.setQuery(simpleQuery);
+ assure("set/getQuery inconsistent", m_composer.getQuery().equals(simpleQuery));
+
+ checkAttributeAccess("Filter", "\"Name\" = 'oranges'");
+ checkAttributeAccess("Group", "\"City\"");
+ checkAttributeAccess("Order", "\"Address\"");
+ checkAttributeAccess("HavingClause", "\"ID\" <> 4");
+
+ final XIndexAccess orderColumns = m_composer.getOrderColumns();
+ assure("Order columns doesn't exist: \"Address\"",
+ orderColumns != null && orderColumns.getCount() == 1 && orderColumns.getByIndex(0) != null);
+
+ final XIndexAccess groupColumns = m_composer.getGroupColumns();
+ assure("Group columns doesn't exist: \"City\"",
+ groupColumns != null && groupColumns.getCount() == 1 && groupColumns.getByIndex(0) != null);
+
+ // XColumnsSupplier
+ final XColumnsSupplier xSelectColumns = (XColumnsSupplier) UnoRuntime.queryInterface(XColumnsSupplier.class, m_composer);
+ assure("no select columns, or wrong number of select columns",
+ xSelectColumns != null && xSelectColumns.getColumns() != null && xSelectColumns.getColumns().getElementNames().length == 6);
+
+ // structured filter
+ m_composer.setQuery("SELECT \"ID\", \"Postal\", \"Address\" FROM \"customers\"");
+ m_composer.setFilter(COMPLEXFILTER);
+ final PropertyValue[][] aStructuredFilter = m_composer.getStructuredFilter();
+ m_composer.setFilter("");
+ m_composer.setStructuredFilter(aStructuredFilter);
+ assure("Structured Filter not identical", m_composer.getFilter().equals(COMPLEXFILTER));
+
+ // structured having clause
+ m_composer.setHavingClause(COMPLEXFILTER);
+ final PropertyValue[][] aStructuredHaving = m_composer.getStructuredHavingClause();
+ m_composer.setHavingClause("");
+ m_composer.setStructuredHavingClause(aStructuredHaving);
+ assure("Structured Having Clause not identical", m_composer.getHavingClause().equals(COMPLEXFILTER));
+ }
+ catch (Exception e)
{
- assure("Exception caught: " + e,false);
+ assure("Exception caught: " + e, false);
}
}
@@ -173,18 +187,17 @@ public class SingleSelectQueryComposer extends CRMBasedTestCase
*/
public void testSubQueries() throws Exception
{
- m_composer.setQuery( "SELECT * from \"" + innerProductsQuery + "\"" );
- final XTablesSupplier suppTables = (XTablesSupplier)UnoRuntime.queryInterface(
- XTablesSupplier.class, m_composer );
+ m_composer.setQuery("SELECT * from \"" + INNERPRODUCTSQUERY + "\"");
+ final XTablesSupplier suppTables = (XTablesSupplier) UnoRuntime.queryInterface(
+ XTablesSupplier.class, m_composer);
final XNameAccess tables = suppTables.getTables();
- assure( "a simple SELECT * FROM <query> could not be parsed",
- tables != null && tables.hasByName( innerProductsQuery ) );
+ assure("a simple SELECT * FROM <query> could not be parsed",
+ tables != null && tables.hasByName(INNERPRODUCTSQUERY));
- final String sInnerCommand = m_database.getDatabase().getDataSource().getQueryDefinition( innerProductsQuery ).getCommand();
+ final String sInnerCommand = m_database.getDatabase().getDataSource().getQueryDefinition(INNERPRODUCTSQUERY).getCommand();
final String sExecutableQuery = m_composer.getQueryWithSubstitution();
- assure( "simple query containing a sub query improperly parsed to SDBC level statement: \n1. " + sExecutableQuery
- + "\n2. " + "SELECT * FROM ( " + sInnerCommand + " ) AS \"" + innerProductsQuery + "\"",
- sExecutableQuery.equals( "SELECT * FROM ( " + sInnerCommand + " ) AS \"" + innerProductsQuery + "\"") );
+ assure("simple query containing a sub query improperly parsed to SDBC level statement: \n1. " + sExecutableQuery + "\n2. " + "SELECT * FROM ( " + sInnerCommand + " ) AS \"" + INNERPRODUCTSQUERY + "\"",
+ sExecutableQuery.equals("SELECT * FROM ( " + sInnerCommand + " ) AS \"" + INNERPRODUCTSQUERY + "\""));
}
/** tests the XParametersSupplier functionality
@@ -194,60 +207,95 @@ public class SingleSelectQueryComposer extends CRMBasedTestCase
try
{
// "orders for customers" is a query with a named parameter (based on another query)
- m_database.getDatabase().getDataSource().createQuery( "orders for customer", "SELECT * FROM \"all orders\" WHERE \"Customer Name\" LIKE :cname" );
+ m_database.getDatabase().getDataSource().createQuery("orders for customer", "SELECT * FROM \"all orders\" WHERE \"Customer Name\" LIKE :cname");
// "orders for customer and product" is query based on "orders for customers", adding an additional,
// anonymous parameter
- m_database.getDatabase().getDataSource().createQuery( "orders for customer and product", "SELECT * FROM \"orders for customer\" WHERE \"Product Name\" LIKE ?" );
+ m_database.getDatabase().getDataSource().createQuery("orders for customer and product", "SELECT * FROM \"orders for customer\" WHERE \"Product Name\" LIKE ?");
- m_composer.setQuery( m_database.getDatabase().getDataSource().getQueryDefinition( "orders for customer and product" ).getCommand() );
- XParametersSupplier suppParams = (XParametersSupplier)UnoRuntime.queryInterface(
- XParametersSupplier.class, m_composer );
- XIndexAccess parameters = suppParams.getParameters();
+ m_composer.setQuery(m_database.getDatabase().getDataSource().getQueryDefinition("orders for customer and product").getCommand());
+ final XParametersSupplier suppParams = (XParametersSupplier) UnoRuntime.queryInterface(
+ XParametersSupplier.class, m_composer);
+ final XIndexAccess parameters = suppParams.getParameters();
- String expectedParamNames[] = {
+ final String expectedParamNames[] =
+ {
"cname",
"Product Name"
};
- int paramCount = parameters.getCount();
- assure( "composer did find wrong number of parameters in the nested queries.",
- paramCount == expectedParamNames.length );
+ final int paramCount = parameters.getCount();
+ assure("composer did find wrong number of parameters in the nested queries.",
+ paramCount == expectedParamNames.length);
- for ( int i = 0; i < paramCount; ++i )
+ for (int i = 0; i < paramCount; ++i)
{
- XPropertySet parameter = (XPropertySet)UnoRuntime.queryInterface(
- XPropertySet.class, parameters.getByIndex(i) );
- String paramName = (String)parameter.getPropertyValue( "Name" );
- assure( "wrong parameter name at position " + ( i + 1 ) + " (expected: " + expectedParamNames[i] + ", found: " + paramName + ")",
- paramName.equals( expectedParamNames[i] ) );
+ final XPropertySet parameter = (XPropertySet) UnoRuntime.queryInterface(
+ XPropertySet.class, parameters.getByIndex(i));
+ final String paramName = (String) parameter.getPropertyValue("Name");
+ assure("wrong parameter name at position " + (i + 1) + " (expected: " + expectedParamNames[i] + ", found: " + paramName + ")",
+ paramName.equals(expectedParamNames[i]));
}
}
- catch( Exception e )
+ catch (Exception e)
{
- assure( "caught an exception: " + e, false );
+ assure("caught an exception: " + e, false);
}
}
- private void impl_testDisjunctiveNormalForm( String _query, PropertyValue[][] _expectedDNF )
+ public void testConditionByColumn()
{
- try { m_composer.setQuery( _query ); }
- catch ( Exception e )
+ try
+ {
+ m_composer.setQuery("SELECT * FROM \"customers\"");
+
+ final Object initArgs[] =
+ {
+ new NamedValue("AutomaticAddition", Boolean.valueOf(true))
+ };
+ final String serviceName = "com.sun.star.beans.PropertyBag";
+ final XPropertyContainer filter = (XPropertyContainer) UnoRuntime.queryInterface(XPropertyContainer.class,
+ getORB().createInstanceWithArguments(serviceName, initArgs));
+ filter.addProperty("Name", PropertyAttribute.MAYBEVOID, "Comment");
+ filter.addProperty("RealName", PropertyAttribute.MAYBEVOID, "Comment");
+ filter.addProperty("TableName", PropertyAttribute.MAYBEVOID, "customers");
+ filter.addProperty("Value", PropertyAttribute.MAYBEVOID, "Good one.");
+ filter.addProperty("Type", PropertyAttribute.MAYBEVOID, Integer.valueOf(DataType.LONGVARCHAR));
+ final XPropertySet column = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class,filter);
+
+ m_composer.appendFilterByColumn(column, true);
+ assure("At least one row should exist",m_database.getConnection().createStatement().executeQuery(m_composer.getQuery()).next());
+
+ }
+ catch (Exception e)
+ {
+ // this is an error: the query is expected to be parseable
+ assure("caught an exception: " + e, false);
+ }
+ }
+
+ private void impl_testDisjunctiveNormalForm(String _query, PropertyValue[][] _expectedDNF)
+ {
+ try
+ {
+ m_composer.setQuery(_query);
+ }
+ catch (Exception e)
{
// this is an error: the query is expected to be parseable
- assure( "caught an exception: " + e, false );
+ assure("caught an exception: " + e, false);
}
- PropertyValue[][] disjunctiveNormalForm = m_composer.getStructuredFilter();
+ final PropertyValue[][] disjunctiveNormalForm = m_composer.getStructuredFilter();
- assureEquals( "DNF: wrong number of rows", _expectedDNF.length, disjunctiveNormalForm.length );
- for ( int i=0; i<_expectedDNF.length; ++i )
+ assureEquals("DNF: wrong number of rows", _expectedDNF.length, disjunctiveNormalForm.length);
+ for (int i = 0; i < _expectedDNF.length; ++i)
{
- assureEquals( "DNF: wrong number of columns in row " + i, _expectedDNF[i].length, disjunctiveNormalForm[i].length );
- for ( int j=0; j<_expectedDNF[i].length; ++j )
+ assureEquals("DNF: wrong number of columns in row " + i, _expectedDNF[i].length, disjunctiveNormalForm[i].length);
+ for (int j = 0; j < _expectedDNF[i].length; ++j)
{
- assureEquals( "DNF: wrong content in column " + j + ", row " + i,
- _expectedDNF[i][j].Name, disjunctiveNormalForm[i][j].Name );
+ assureEquals("DNF: wrong content in column " + j + ", row " + i,
+ _expectedDNF[i][j].Name, disjunctiveNormalForm[i][j].Name);
}
}
}
@@ -259,56 +307,61 @@ public class SingleSelectQueryComposer extends CRMBasedTestCase
{
// a simple case: WHERE clause simply is a combination of predicates knitted with AND
String query =
- "SELECT \"customers\".\"Name\", " +
- "\"customers\".\"Address\", " +
- "\"customers\".\"City\", " +
- "\"customers\".\"Postal\", " +
- "\"products\".\"Name\" " +
- "FROM \"orders\", \"customers\", \"orders_details\", \"products\" " +
- "WHERE ( \"orders\".\"CustomerID\" = \"customers\".\"ID\" " +
- "AND \"orders_details\".\"OrderID\" = \"orders\".\"ID\" " +
- "AND \"orders_details\".\"ProductID\" = \"products\".\"ID\" " +
- ") ";
-
- impl_testDisjunctiveNormalForm( query, new PropertyValue[][] {
- new PropertyValue[] {
- new PropertyValue( "CustomerID", SQLFilterOperator.EQUAL, "\"customers\".\"ID\"", PropertyState.DIRECT_VALUE ),
- new PropertyValue( "OrderID", SQLFilterOperator.EQUAL, "\"orders\".\"ID\"", PropertyState.DIRECT_VALUE ),
- new PropertyValue( "ProductID", SQLFilterOperator.EQUAL, "\"products\".\"ID\"", PropertyState.DIRECT_VALUE )
- } }
- );
+ "SELECT \"customers\".\"Name\", " +
+ "\"customers\".\"Address\", " +
+ "\"customers\".\"City\", " +
+ "\"customers\".\"Postal\", " +
+ "\"products\".\"Name\" " +
+ "FROM \"orders\", \"customers\", \"orders_details\", \"products\" " +
+ "WHERE ( \"orders\".\"CustomerID\" = \"customers\".\"ID\" " +
+ "AND \"orders_details\".\"OrderID\" = \"orders\".\"ID\" " +
+ "AND \"orders_details\".\"ProductID\" = \"products\".\"ID\" " +
+ ") ";
+
+ impl_testDisjunctiveNormalForm(query, new PropertyValue[][]
+ {
+ new PropertyValue[]
+ {
+ new PropertyValue("CustomerID", SQLFilterOperator.EQUAL, "\"customers\".\"ID\"", PropertyState.DIRECT_VALUE),
+ new PropertyValue("OrderID", SQLFilterOperator.EQUAL, "\"orders\".\"ID\"", PropertyState.DIRECT_VALUE),
+ new PropertyValue("ProductID", SQLFilterOperator.EQUAL, "\"products\".\"ID\"", PropertyState.DIRECT_VALUE)
+ }
+ });
// somewhat more challenging: One of the conjunction terms is a disjunction itself
query =
- "SELECT \"customers\".\"Name\", " +
- "\"customers\".\"Address\", " +
- "\"customers\".\"City\", " +
- "\"customers\".\"Postal\", " +
- "\"products\".\"Name\" " +
- "FROM \"orders\", \"customers\", \"orders_details\", \"products\" " +
- "WHERE ( \"orders\".\"CustomerID\" = \"customers\".\"ID\" " +
- "AND \"orders_details\".\"OrderID\" = \"orders\".\"ID\" " +
- "AND \"orders_details\".\"ProductID\" = \"products\".\"ID\" " +
- ") " +
- "AND " +
- "( \"products\".\"Name\" = 'Apples' " +
- "OR \"products\".\"ID\" = 2 " +
- ")";
-
- impl_testDisjunctiveNormalForm( query, new PropertyValue[][] {
- new PropertyValue[] {
- new PropertyValue( "CustomerID", SQLFilterOperator.EQUAL, "\"customers\".\"ID\"", PropertyState.DIRECT_VALUE ),
- new PropertyValue( "OrderID", SQLFilterOperator.EQUAL, "\"orders\".\"ID\"", PropertyState.DIRECT_VALUE ),
- new PropertyValue( "ProductID", SQLFilterOperator.EQUAL, "\"products\".\"ID\"", PropertyState.DIRECT_VALUE ),
- new PropertyValue( "Name", SQLFilterOperator.EQUAL, "Apples", PropertyState.DIRECT_VALUE )
- },
- new PropertyValue[] {
- new PropertyValue( "CustomerID", SQLFilterOperator.EQUAL, "\"customers\".\"ID\"", PropertyState.DIRECT_VALUE ),
- new PropertyValue( "OrderID", SQLFilterOperator.EQUAL, "\"orders\".\"ID\"", PropertyState.DIRECT_VALUE ),
- new PropertyValue( "ProductID", SQLFilterOperator.EQUAL, "\"products\".\"ID\"", PropertyState.DIRECT_VALUE ),
- new PropertyValue( "ID", SQLFilterOperator.EQUAL, new Integer(2), PropertyState.DIRECT_VALUE )
- } }
- );
+ "SELECT \"customers\".\"Name\", " +
+ "\"customers\".\"Address\", " +
+ "\"customers\".\"City\", " +
+ "\"customers\".\"Postal\", " +
+ "\"products\".\"Name\" " +
+ "FROM \"orders\", \"customers\", \"orders_details\", \"products\" " +
+ "WHERE ( \"orders\".\"CustomerID\" = \"customers\".\"ID\" " +
+ "AND \"orders_details\".\"OrderID\" = \"orders\".\"ID\" " +
+ "AND \"orders_details\".\"ProductID\" = \"products\".\"ID\" " +
+ ") " +
+ "AND " +
+ "( \"products\".\"Name\" = 'Apples' " +
+ "OR \"products\".\"ID\" = 2 " +
+ ")";
+
+ impl_testDisjunctiveNormalForm(query, new PropertyValue[][]
+ {
+ new PropertyValue[]
+ {
+ new PropertyValue("CustomerID", SQLFilterOperator.EQUAL, "\"customers\".\"ID\"", PropertyState.DIRECT_VALUE),
+ new PropertyValue("OrderID", SQLFilterOperator.EQUAL, "\"orders\".\"ID\"", PropertyState.DIRECT_VALUE),
+ new PropertyValue("ProductID", SQLFilterOperator.EQUAL, "\"products\".\"ID\"", PropertyState.DIRECT_VALUE),
+ new PropertyValue("Name", SQLFilterOperator.EQUAL, "Apples", PropertyState.DIRECT_VALUE)
+ },
+ new PropertyValue[]
+ {
+ new PropertyValue("CustomerID", SQLFilterOperator.EQUAL, "\"customers\".\"ID\"", PropertyState.DIRECT_VALUE),
+ new PropertyValue("OrderID", SQLFilterOperator.EQUAL, "\"orders\".\"ID\"", PropertyState.DIRECT_VALUE),
+ new PropertyValue("ProductID", SQLFilterOperator.EQUAL, "\"products\".\"ID\"", PropertyState.DIRECT_VALUE),
+ new PropertyValue("ID", SQLFilterOperator.EQUAL, Integer.valueOf(2), PropertyState.DIRECT_VALUE)
+ }
+ });
}
}
diff --git a/dbaccess/qa/complex/dbaccess/TestCase.java b/dbaccess/qa/complex/dbaccess/TestCase.java
index fddf055b011e..89b1f9ede56b 100644
--- a/dbaccess/qa/complex/dbaccess/TestCase.java
+++ b/dbaccess/qa/complex/dbaccess/TestCase.java
@@ -55,7 +55,7 @@ public abstract class TestCase extends complexlib.ComplexTestCase
XComponentContext context = null;
try
{
- XPropertySet orbProps = (XPropertySet) UnoRuntime.queryInterface( XPropertySet.class, getORB() );
+ final XPropertySet orbProps = (XPropertySet) UnoRuntime.queryInterface( XPropertySet.class, getORB() );
context = (XComponentContext)UnoRuntime.queryInterface( XComponentContext.class,
orbProps.getPropertyValue( "DefaultContext" ) );
}
@@ -84,9 +84,9 @@ public abstract class TestCase extends complexlib.ComplexTestCase
*/
protected final String createTempFileURL() throws IOException
{
- File documentFile = java.io.File.createTempFile( getTestObjectName(), ".odb" );
+ final File documentFile = java.io.File.createTempFile( getTestObjectName(), ".odb" );
documentFile.deleteOnExit();
- return documentFile.getAbsoluteFile().toURL().toString();
+ return documentFile.getAbsoluteFile().toURI().toURL().toString();
}
// --------------------------------------------------------------------------------------------------------
@@ -97,7 +97,7 @@ public abstract class TestCase extends complexlib.ComplexTestCase
*/
protected final String copyToTempFile( String _sourceURL ) throws IOException
{
- String targetURL = createTempFileURL();
+ final String targetURL = createTempFileURL();
try
{
FileTools.copyFile( new File( new URI( _sourceURL ) ), new File( new URI( targetURL ) ) );
diff --git a/dbaccess/qa/complex/dbaccess/UISettings.java b/dbaccess/qa/complex/dbaccess/UISettings.java
index a755b39aa63c..23fe10618810 100644
--- a/dbaccess/qa/complex/dbaccess/UISettings.java
+++ b/dbaccess/qa/complex/dbaccess/UISettings.java
@@ -39,9 +39,6 @@ import com.sun.star.lang.XComponent;
import com.sun.star.sdb.application.XDatabaseDocumentUI;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.util.XCloseable;
-import helper.URLHelper;
-import java.io.File;
-import java.net.URI;
public class UISettings extends TestCase
{
@@ -64,11 +61,11 @@ public class UISettings extends TestCase
*/
public void checkTableFormattingPersistence() throws java.lang.Exception
{
- CRMDatabase database = new CRMDatabase( getORB() );
+ final CRMDatabase database = new CRMDatabase( getORB() );
// load the document
String docURL = database.getDatabase().getDocumentURL();
- XComponentLoader loader = (XComponentLoader)UnoRuntime.queryInterface( XComponentLoader.class,
+ 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[] {} ) );
@@ -87,7 +84,7 @@ public class UISettings extends TestCase
// change the table's formatting
tableControlModel.setPropertyValue( "FontName", "Andale Sans UI" );
- tableControlModel.setPropertyValue( "FontHeight", new Float( 20 ) );
+ tableControlModel.setPropertyValue( "FontHeight", Float.valueOf( 20 ) );
tableControlModel.setPropertyValue( "FontSlant", FontSlant.ITALIC );
// close the table
@@ -126,7 +123,7 @@ public class UISettings extends TestCase
// close the doc
docUI.closeSubComponents();
- XCloseable closeDoc = (XCloseable)UnoRuntime.queryInterface( XCloseable.class,
+ final XCloseable closeDoc = (XCloseable)UnoRuntime.queryInterface( XCloseable.class,
doc );
closeDoc.close( true );
}
diff --git a/dbaccess/qa/complex/dbaccess/dbaccess.sce b/dbaccess/qa/complex/dbaccess/dbaccess.sce
index 9b17f0cd9f84..c5fa408ff273 100644
--- a/dbaccess/qa/complex/dbaccess/dbaccess.sce
+++ b/dbaccess/qa/complex/dbaccess/dbaccess.sce
@@ -7,4 +7,6 @@
-o complex.dbaccess.DataSource
-o complex.dbaccess.Parser
-o complex.dbaccess.ApplicationController
+-o complex.dbaccess.CopyTableWizard
-o complex.dbaccess.UISettings
+-o complex.dbaccess.Beamer
diff --git a/dbaccess/source/core/api/RowSet.cxx b/dbaccess/source/core/api/RowSet.cxx
index ebbb982a6305..8f84d073f83e 100644
--- a/dbaccess/source/core/api/RowSet.cxx
+++ b/dbaccess/source/core/api/RowSet.cxx
@@ -2859,7 +2859,7 @@ ORowSetClone::ORowSetClone( const ::comphelper::ComponentContext& _rContext, ORo
// sdb.RowSet Properties
// registerProperty(PROPERTY_CURSORNAME, PROPERTY_ID_CURSORNAME, PropertyAttribute::READONLY, &m_aDataSourceName, ::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL)));
-
+ registerMayBeVoidProperty(PROPERTY_ACTIVE_CONNECTION,PROPERTY_ID_ACTIVE_CONNECTION, PropertyAttribute::MAYBEVOID|PropertyAttribute::READONLY, &rParent.m_aActiveConnection, ::getCppuType(reinterpret_cast< Reference< XConnection >* >(NULL)));
registerProperty(PROPERTY_RESULTSETCONCURRENCY, PROPERTY_ID_RESULTSETCONCURRENCY, PropertyAttribute::READONLY, &m_nResultSetConcurrency,::getCppuType(reinterpret_cast< sal_Int32*>(NULL)));
registerProperty(PROPERTY_RESULTSETTYPE, PROPERTY_ID_RESULTSETTYPE, PropertyAttribute::READONLY, &m_nResultSetType, ::getCppuType(reinterpret_cast< sal_Int32*>(NULL)));
registerProperty(PROPERTY_FETCHDIRECTION, PROPERTY_ID_FETCHDIRECTION, PropertyAttribute::TRANSIENT, &m_nFetchDirection, ::getCppuType(reinterpret_cast< sal_Int32*>(NULL)));
diff --git a/dbaccess/source/core/api/RowSetBase.cxx b/dbaccess/source/core/api/RowSetBase.cxx
index da50983d72ad..a8894bcf5f1b 100644
--- a/dbaccess/source/core/api/RowSetBase.cxx
+++ b/dbaccess/source/core/api/RowSetBase.cxx
@@ -226,7 +226,10 @@ void SAL_CALL ORowSetBase::disposing(void)
m_pColumns->disposing();
}
if ( m_pCache )
+ {
m_pCache->deregisterOldRow(m_aOldRow);
+ m_pCache->deleteIterator(this);
+ }
m_pCache = NULL;
}
// -------------------------------------------------------------------------
diff --git a/dbaccess/source/core/api/RowSetCache.cxx b/dbaccess/source/core/api/RowSetCache.cxx
index 1472516faca5..a96de4b9fbe1 100644
--- a/dbaccess/source/core/api/RowSetCache.cxx
+++ b/dbaccess/source/core/api/RowSetCache.cxx
@@ -1359,6 +1359,21 @@ ORowSetCacheIterator ORowSetCache::createIterator(ORowSetBase* _pRowSet)
return ORowSetCacheIterator(m_aCacheIterators.insert(m_aCacheIterators.begin(),ORowSetCacheMap::value_type(m_aCacheIterators.size()+1,aHelper)),this,_pRowSet);
}
// -----------------------------------------------------------------------------
+void ORowSetCache::deleteIterator(const ORowSetBase* _pRowSet)
+{
+ ORowSetCacheMap::iterator aCacheIter = m_aCacheIterators.begin();
+ for(;aCacheIter != m_aCacheIterators.end();)
+ {
+ if ( aCacheIter->second.pRowSet == _pRowSet )
+ {
+ m_aCacheIterators.erase(aCacheIter);
+ aCacheIter = m_aCacheIterators.begin();
+ } // if ( aCacheIter->second.pRowSet == _pRowSet )
+ else
+ ++aCacheIter;
+ }
+}
+// -----------------------------------------------------------------------------
void ORowSetCache::rotateCacheIterator(ORowSetMatrix::difference_type _nDist)
{
if(_nDist)
diff --git a/dbaccess/source/core/api/RowSetCache.hxx b/dbaccess/source/core/api/RowSetCache.hxx
index 81b74a6a6d13..0576aa68ac02 100644
--- a/dbaccess/source/core/api/RowSetCache.hxx
+++ b/dbaccess/source/core/api/RowSetCache.hxx
@@ -202,6 +202,7 @@ namespace dbaccess
// called from the rowset when a updateXXX was called for the first time
void setUpdateIterator(const ORowSetMatrix::iterator& _rOriginalRow);
ORowSetCacheIterator createIterator(ORowSetBase* _pRowSet);
+ void deleteIterator(const ORowSetBase* _pRowSet);
// sets the size of the matrix
void setMaxRowSize(sal_Int32 _nSize);
diff --git a/dbaccess/source/core/api/SingleSelectQueryComposer.cxx b/dbaccess/source/core/api/SingleSelectQueryComposer.cxx
index a6ca701e0835..548b99fd565a 100644
--- a/dbaccess/source/core/api/SingleSelectQueryComposer.cxx
+++ b/dbaccess/source/core/api/SingleSelectQueryComposer.cxx
@@ -1457,7 +1457,8 @@ void OSingleSelectQueryComposer::setConditionByColumn( const Reference< XPropert
if ( !column.is()
|| !column->getPropertySetInfo()->hasPropertyByName(PROPERTY_VALUE)
- || !column->getPropertySetInfo()->hasPropertyByName(PROPERTY_NAME) )
+ || !column->getPropertySetInfo()->hasPropertyByName(PROPERTY_NAME)
+ || !column->getPropertySetInfo()->hasPropertyByName(PROPERTY_TYPE))
throw SQLException(DBACORE_RESSTRING(RID_STR_COLUMN_NOT_VALID),*this,SQLSTATE_GENERAL,1000,Any() );
sal_Int32 nType = 0;
diff --git a/dbaccess/source/core/dataaccess/databasecontext.cxx b/dbaccess/source/core/dataaccess/databasecontext.cxx
index 9bc92a003c9a..22f3aa7c5bd7 100644
--- a/dbaccess/source/core/dataaccess/databasecontext.cxx
+++ b/dbaccess/source/core/dataaccess/databasecontext.cxx
@@ -610,6 +610,11 @@ void ODatabaseContext::revokeObject(const rtl::OUString& _rName) throw( Exceptio
aThisDriverSettings.getNodeValue(getDbLocationNodeName()) >>= sURL;
sURL = SvtPathOptions().SubstituteVariable(sURL);
+ if ( m_aDatabaseObjects.find( _rName ) != m_aDatabaseObjects.end() )
+ {
+ m_aDatasourceProperties[ sURL ] = m_aDatasourceProperties[ _rName ];
+ }
+
// check if URL is already loaded
ObjectCacheIterator aExistent = m_aDatabaseObjects.find(sURL);
if ( aExistent != m_aDatabaseObjects.end() )
diff --git a/dbaccess/source/core/misc/dsntypes.cxx b/dbaccess/source/core/misc/dsntypes.cxx
index bae4c42b8571..eb2e1ed6de67 100644
--- a/dbaccess/source/core/misc/dsntypes.cxx
+++ b/dbaccess/source/core/misc/dsntypes.cxx
@@ -317,15 +317,18 @@ bool ODsnTypeCollection::isEmbeddedDatabase( const ::rtl::OUString& _sURL ) cons
::rtl::OUString ODsnTypeCollection::getEmbeddedDatabase() const
{
::rtl::OUString sEmbeddedDatabaseURL;
- static const ::rtl::OUString s_sNodeName(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.Office.DataAccess/EmbeddedDatabases")); ///Installed
+ static const ::rtl::OUString s_sNodeName(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.Office.DataAccess")); ///Installed
const ::utl::OConfigurationTreeRoot aInstalled = ::utl::OConfigurationTreeRoot::createWithServiceFactory(m_xFactory, s_sNodeName, -1, ::utl::OConfigurationTreeRoot::CM_READONLY);
if ( aInstalled.isValid() )
{
- static const ::rtl::OUString s_sValue(RTL_CONSTASCII_USTRINGPARAM("DefaultEmbeddedDatabase/Value"));
+ if ( aInstalled.hasByName("EmbeddedDatabases/DefaultEmbeddedDatabase/Value") )
+ {
+ static const ::rtl::OUString s_sValue(RTL_CONSTASCII_USTRINGPARAM("EmbeddedDatabases/DefaultEmbeddedDatabase/Value"));
- aInstalled.getNodeValue(s_sValue) >>= sEmbeddedDatabaseURL;
- if ( sEmbeddedDatabaseURL.getLength() )
- aInstalled.getNodeValue(s_sValue + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/")) + sEmbeddedDatabaseURL + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/URL"))) >>= sEmbeddedDatabaseURL;
+ aInstalled.getNodeValue(s_sValue) >>= sEmbeddedDatabaseURL;
+ if ( sEmbeddedDatabaseURL.getLength() )
+ aInstalled.getNodeValue(s_sValue + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/")) + sEmbeddedDatabaseURL + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/URL"))) >>= sEmbeddedDatabaseURL;
+ }
} // if ( aInstalled.isValid() )
if ( !sEmbeddedDatabaseURL.getLength() )
sEmbeddedDatabaseURL = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdbc:embedded:hsqldb"));
diff --git a/dbaccess/source/sdbtools/resource/sdbt_strings.src b/dbaccess/source/sdbtools/resource/sdbt_strings.src
index 599841c0806f..6ba41289b8ca 100644
--- a/dbaccess/source/sdbtools/resource/sdbt_strings.src
+++ b/dbaccess/source/sdbtools/resource/sdbt_strings.src
@@ -64,5 +64,5 @@ String STR_INVALID_COMPOSITION_TYPE
String STR_INVALID_COMMAND_TYPE
{
- Text [ en-US ] = "Invalid command type - only TABLE and AND QUERY from com.sun.star.sdb.CommandType are allowed.";
+ Text [ en-US ] = "Invalid command type - only TABLE and QUERY from com.sun.star.sdb.CommandType are allowed.";
};
diff --git a/dbaccess/source/ui/app/AppController.cxx b/dbaccess/source/ui/app/AppController.cxx
index 99c29398fc33..b87b7706d87f 100644
--- a/dbaccess/source/ui/app/AppController.cxx
+++ b/dbaccess/source/ui/app/AppController.cxx
@@ -155,7 +155,7 @@
#ifndef _DBAUI_LISTVIEWITEMS_HXX_
#include "listviewitems.hxx"
#endif
-#include "ExtensionNotPresent.hxx"
+
#ifndef DBAUI_APPDETAILVIEW_HXX
#include "AppDetailView.hxx"
#endif
diff --git a/dbaccess/source/ui/app/AppControllerDnD.cxx b/dbaccess/source/ui/app/AppControllerDnD.cxx
index c532c0d45fe7..a509986e8849 100644
--- a/dbaccess/source/ui/app/AppControllerDnD.cxx
+++ b/dbaccess/source/ui/app/AppControllerDnD.cxx
@@ -719,19 +719,24 @@ sal_Bool OApplicationController::paste( ElementType _eType,const ::svx::ODataAcc
}
// the target object name (as we'll suggest it to the user)
- String sTargetName;
- Reference< XNameAccess > xQueries;
+ ::rtl::OUString sTargetName;
try
{
- // the query container
- xQueries.set(getQueryDefintions(),UNO_QUERY);
- String aQueryDefaultName = String(ModuleRes(STR_QRY_TITLE));
- aQueryDefaultName = aQueryDefaultName.GetToken(0,' ');
- sTargetName = ::dbtools::createUniqueName(xQueries,aQueryDefaultName);
+ if ( CommandType::QUERY == nCommandType )
+ sTargetName = sCommand;
+
+ if ( !sTargetName.getLength() )
+ {
+ String sDefaultName = String( ModuleRes( STR_QRY_TITLE ) );
+ sDefaultName = sDefaultName.GetToken( 0, ' ' );
+
+ Reference< XNameAccess > xQueries( getQueryDefintions(), UNO_QUERY_THROW );
+ sTargetName = ::dbtools::createUniqueName( xQueries, sDefaultName, sal_False );
+ }
}
- catch(Exception)
+ catch(const Exception&)
{
- OSL_ENSURE(0,"could not create query default name!");
+ DBG_UNHANDLED_EXCEPTION();
}
Reference< XPropertySet > xQuery;
@@ -742,16 +747,14 @@ sal_Bool OApplicationController::paste( ElementType _eType,const ::svx::ODataAcc
try
{
// the concrete query
- Reference< XDataSource > xDataSource( getDataSourceByName( sDataSourceName, getView(), getORB(), NULL ) );
- Reference< XQueryDefinitionsSupplier > xSourceQuerySup( xDataSource, UNO_QUERY );
- if ( xSourceQuerySup.is() )
- xQueries.set(xSourceQuerySup->getQueryDefinitions(),UNO_QUERY);
-
- if ( xQueries.is() && xQueries->hasByName(sCommand) )
+ Reference< XQueryDefinitionsSupplier > xSourceQuerySup(
+ getDataSourceByName( sDataSourceName, getView(), getORB(), NULL ),
+ UNO_QUERY_THROW );
+ Reference< XNameAccess > xQueries( xSourceQuerySup->getQueryDefinitions(), UNO_SET_THROW );
+ if ( xQueries->hasByName( sCommand ) )
{
- xQuery.set(xQueries->getByName(sCommand),UNO_QUERY);
- bSuccess = xQuery.is();
- xQueries.clear();
+ xQuery.set( xQueries->getByName(sCommand), UNO_QUERY_THROW );
+ bSuccess = true;
}
}
catch(SQLException&) { throw; } // caught and handled by the outer catch
@@ -780,19 +783,28 @@ sal_Bool OApplicationController::paste( ElementType _eType,const ::svx::ODataAcc
// here we have everything needed to create a new query object ...
// ... ehm, except a new name
ensureConnection();
- DynamicTableOrQueryNameCheck aNameChecker( getConnection(), CommandType::QUERY );
- OSaveAsDlg aAskForName( getView(),
- CommandType::QUERY,
- getORB(),
- getConnection(),
- sTargetName,
- aNameChecker,
- SAD_ADDITIONAL_DESCRIPTION | SAD_TITLE_PASTE_AS);
- if ( RET_OK != aAskForName.Execute() )
- // cancelled by the user
- return sal_False;
- sTargetName = aAskForName.getName();
+ DynamicTableOrQueryNameCheck aNameChecker( getConnection(), CommandType::QUERY );
+ ::dbtools::SQLExceptionInfo aDummy;
+ bool bNeedAskForName = ( sCommand.getLength() == 0 )
+ /* we did not have a source name, so the target name was auto-generated */
+ || ( !aNameChecker.isNameValid( sTargetName, aDummy ) );
+ /* name is invalid in the target DB (e.g. because it already
+ has a /table/ with that name) */
+ if ( bNeedAskForName )
+ {
+ OSaveAsDlg aAskForName( getView(),
+ CommandType::QUERY,
+ getORB(),
+ getConnection(),
+ sTargetName,
+ aNameChecker,
+ SAD_ADDITIONAL_DESCRIPTION | SAD_TITLE_PASTE_AS);
+ if ( RET_OK != aAskForName.Execute() )
+ // cancelled by the user
+ return sal_False;
+ sTargetName = aAskForName.getName();
+ }
// create a new object
Reference< XPropertySet > xNewQuery(xQueryFactory->createInstance(), UNO_QUERY);
diff --git a/dbaccess/source/ui/browser/brwctrlr.cxx b/dbaccess/source/ui/browser/brwctrlr.cxx
index 94160b21a134..ddfb583f65c9 100644
--- a/dbaccess/source/ui/browser/brwctrlr.cxx
+++ b/dbaccess/source/ui/browser/brwctrlr.cxx
@@ -1344,8 +1344,11 @@ void SbaXDataBrowserController::frameAction(const ::com::sun::star::frame::Frame
//------------------------------------------------------------------------------
IMPL_LINK( SbaXDataBrowserController, OnAsyncDisplayError, void*, /* _pNotInterestedIn */ )
{
- OSQLMessageBox aDlg( getBrowserView(), m_aCurrentError );
- aDlg.Execute();
+ if ( m_aCurrentError.isValid() )
+ {
+ OSQLMessageBox aDlg( getBrowserView(), m_aCurrentError );
+ aDlg.Execute();
+ }
return 0L;
}
@@ -1541,8 +1544,14 @@ FeatureState SbaXDataBrowserController::GetState(sal_uInt16 nId) const
}
break;
- case ID_BROWSER_PASTE:
case ID_BROWSER_COPY:
+ if ( getBrowserView()->getVclControl()->GetSelectRowCount() )
+ {
+ aReturn.bEnabled = m_aCurrentFrame.isActive();
+ break;
+ }
+ // run through
+ case ID_BROWSER_PASTE:
case ID_BROWSER_CUT:
{
CellControllerRef xCurrentController = getBrowserView()->getVclControl()->Controller();
@@ -1988,6 +1997,12 @@ void SbaXDataBrowserController::Execute(sal_uInt16 nId, const Sequence< Property
break;
case ID_BROWSER_COPY:
+ if ( getBrowserView()->getVclControl()->GetSelectRowCount() > 0 )
+ {
+ getBrowserView()->getVclControl()->CopySelectedRowsToClipboard();
+ break;
+ }
+ // run through
case ID_BROWSER_CUT:
case ID_BROWSER_PASTE:
{
@@ -2002,9 +2017,9 @@ void SbaXDataBrowserController::Execute(sal_uInt16 nId, const Sequence< Property
Edit& rEdit = (Edit&)xCurrentController->GetWindow();
switch (nId)
{
- case ID_BROWSER_CUT : rEdit.Cut(); break;
- case SID_COPY : rEdit.Copy(); break;
- case ID_BROWSER_PASTE : rEdit.Paste(); break;
+ case ID_BROWSER_CUT : rEdit.Cut(); break;
+ case SID_COPY : rEdit.Copy(); break;
+ case ID_BROWSER_PASTE : rEdit.Paste(); break;
}
if (ID_BROWSER_CUT == nId || ID_BROWSER_PASTE == nId)
{
diff --git a/dbaccess/source/ui/browser/dbexchange.cxx b/dbaccess/source/ui/browser/dbexchange.cxx
index 5a6f11ebf840..70caccc10a3e 100644
--- a/dbaccess/source/ui/browser/dbexchange.cxx
+++ b/dbaccess/source/ui/browser/dbexchange.cxx
@@ -61,6 +61,7 @@
#ifndef _SVX_DATACCESSDESCRIPTOR_HXX_
#include <svx/dataaccessdescriptor.hxx>
#endif
+#include "UITools.hxx"
namespace dbaui
@@ -141,7 +142,8 @@ namespace dbaui
// -----------------------------------------------------------------------------
ODataClipboard::ODataClipboard( const Reference< XPropertySet >& _rxLivingForm,
const Sequence< Any >& _rSelectedRows,
- const Reference< XResultSet>& _rxResultSet)
+ const Reference< XResultSet>& _rxResultSet,
+ const Reference< XMultiServiceFactory >& _rxORB)
:ODataAccessObjectTransferable( _rxLivingForm )
,m_pHtml(NULL)
,m_pRtf(NULL)
@@ -158,6 +160,20 @@ namespace dbaui
getDescriptor()[daCursor] <<= _rxResultSet;
addCompatibleSelectionDescription( _rSelectedRows );
+ if ( xConnection.is() && _rxORB.is() )
+ {
+ Reference< XNumberFormatter > xFormatter( getNumberFormatter( xConnection, _rxORB ) );
+ if ( xFormatter.is() )
+ {
+ m_pHtml = new OHTMLImportExport( getDescriptor(),_rxORB, xFormatter );
+ m_aEventListeners.push_back( m_pHtml );
+
+ m_pRtf = new ORTFImportExport( getDescriptor(),_rxORB, xFormatter );
+ m_aEventListeners.push_back( m_pRtf );
+ }
+ }
+
+
osl_decrementInterlockedCount( &m_refCount );
}
diff --git a/dbaccess/source/ui/browser/dsEntriesNoExp.cxx b/dbaccess/source/ui/browser/dsEntriesNoExp.cxx
index 4880e9197170..16859283c9b7 100644
--- a/dbaccess/source/ui/browser/dsEntriesNoExp.cxx
+++ b/dbaccess/source/ui/browser/dsEntriesNoExp.cxx
@@ -165,7 +165,9 @@ void SbaTableQueryBrowser::SelectionChanged()
InvalidateFeature(ID_BROWSER_INSERTCOLUMNS);
InvalidateFeature(ID_BROWSER_INSERTCONTENT);
InvalidateFeature(ID_BROWSER_FORMLETTER);
- }
+ } // if ( !m_bShowMenu )
+ InvalidateFeature(ID_BROWSER_COPY);
+ InvalidateFeature(ID_BROWSER_CUT);
}
//------------------------------------------------------------------------------
void SbaTableQueryBrowser::describeSupportedFeatures()
diff --git a/dbaccess/source/ui/browser/sbagrid.cxx b/dbaccess/source/ui/browser/sbagrid.cxx
index 0251b6f653b8..1ca1a737dfd2 100644
--- a/dbaccess/source/ui/browser/sbagrid.cxx
+++ b/dbaccess/source/ui/browser/sbagrid.cxx
@@ -983,9 +983,16 @@ void SbaGridControl::PreExecuteRowContextMenu(sal_uInt16 nRow, PopupMenu& rMenu)
rMenu.InsertItem(ID_BROWSER_ROWHEIGHT, aNewItems.GetItemText(ID_BROWSER_ROWHEIGHT), 0, nPos++);
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 (nPos)
- rMenu.InsertSeparator(nPos);
}
//------------------------------------------------------------------------------
@@ -1145,6 +1152,9 @@ void SbaGridControl::PostExecuteRowContextMenu(sal_uInt16 nRow, const PopupMenu&
case ID_BROWSER_ROWHEIGHT:
SetRowHeight();
break;
+ case ID_BROWSER_COPY:
+ CopySelectedRowsToClipboard();
+ break;
default:
FmGridControl::PostExecuteRowContextMenu(nRow, rMenu, nExecutionResult);
@@ -1418,10 +1428,23 @@ void SbaGridControl::DoColumnDrag(sal_uInt16 nColumnPos)
}
// -----------------------------------------------------------------------
-void SbaGridControl::DoRowDrag(sal_Int16 nRowPos)
+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::DoRowDrag : invalid data source !");
+ DBG_ASSERT(xDataSource.is(), "SbaGridControl::implTransferSelectedRows : invalid data source !");
// build the sequence of numbers of selected rows
Sequence< Any > aSelectedRows;
@@ -1452,10 +1475,13 @@ void SbaGridControl::DoRowDrag(sal_Int16 nRowPos)
if ( xResultSetAccess.is() )
xRowSetClone = xResultSetAccess->createResultSet();
- ODataClipboard* pTransfer = new ODataClipboard(xDataSource, aSelectedRows,xRowSetClone);
+ ODataClipboard* pTransfer = new ODataClipboard(xDataSource, aSelectedRows,xRowSetClone, getServiceManager());
Reference< XTransferable > xEnsureDelete = pTransfer;
- pTransfer->StartDrag(this, DND_ACTION_COPY | DND_ACTION_LINK);
+ if ( _bTrueIfClipboardFalseIfDrag )
+ pTransfer->CopyToClipboard( this );
+ else
+ pTransfer->StartDrag(this, DND_ACTION_COPY | DND_ACTION_LINK);
}
catch(Exception&)
{
diff --git a/dbaccess/source/ui/browser/sbagrid.src b/dbaccess/source/ui/browser/sbagrid.src
index 8bcba2ffc3b8..aa86ed799657 100644
--- a/dbaccess/source/ui/browser/sbagrid.src
+++ b/dbaccess/source/ui/browser/sbagrid.src
@@ -84,6 +84,10 @@ Menu RID_SBA_GRID_ROWCTXMENU
HelpID = HID_BROWSER_ROWHEIGHT ;
Text [ en-US ] = "Row Height..." ;
};
+ MenuItem
+ {
+ ITEM_EDIT_COPY
+ };
};
};
diff --git a/dbaccess/source/ui/browser/unodatbr.cxx b/dbaccess/source/ui/browser/unodatbr.cxx
index 98caa841c84c..3c26b06aa003 100644
--- a/dbaccess/source/ui/browser/unodatbr.cxx
+++ b/dbaccess/source/ui/browser/unodatbr.cxx
@@ -1547,25 +1547,6 @@ void SbaTableQueryBrowser::LoadFinished(sal_Bool _bWasSynch)
// if the form has been loaded, this means that our "selection" has changed
EventObject aEvent( *this );
m_aSelectionListeners.notifyEach( &XSelectionChangeListener::selectionChanged, aEvent );
-
- // update our database document
- Reference< XModel > xDocument;
- try
- {
- Reference< XPropertySet > xCursorProps( getRowSet(), UNO_QUERY_THROW );
- Reference< XConnection > xConnection( xCursorProps->getPropertyValue( PROPERTY_ACTIVE_CONNECTION ), UNO_QUERY );
- if ( xConnection.is() )
- {
- Reference< XChild > xChild( xConnection, UNO_QUERY_THROW );
- Reference< XDocumentDataSource > xDataSource( xChild->getParent(), UNO_QUERY_THROW );
- xDocument.set( xDataSource->getDatabaseDocument(), UNO_QUERY_THROW );
- }
- }
- catch( const Exception& )
- {
- DBG_UNHANDLED_EXCEPTION();
- }
- m_xCurrentDatabaseDocument = xDocument;
}
//------------------------------------------------------------------------------
@@ -1758,7 +1739,13 @@ FeatureState SbaTableQueryBrowser::GetState(sal_uInt16 nId) const
if (getBrowserView() && getBrowserView()->getVclControl() && !getBrowserView()->getVclControl()->IsEditing())
{
SbaGridControl* pControl = getBrowserView()->getVclControl();
- aReturn.bEnabled = pControl->canCopyCellText(pControl->GetCurRow(), pControl->GetCurColumnId());
+ if ( pControl->GetSelectRowCount() )
+ {
+ aReturn.bEnabled = m_aCurrentFrame.isActive();
+ break;
+ } // if ( getBrowserView()->getVclControl()->GetSelectRowCount() )
+ else
+ aReturn.bEnabled = pControl->canCopyCellText(pControl->GetCurRow(), pControl->GetCurColumnId());
break;
}
// NO break here
@@ -1954,7 +1941,7 @@ void SbaTableQueryBrowser::Execute(sal_uInt16 nId, const Sequence< PropertyValue
{
copyEntry(m_pTreeView->getListBox().GetCurEntry());
}
- else if (getBrowserView() && getBrowserView()->getVclControl() && !getBrowserView()->getVclControl()->IsEditing())
+ else if (getBrowserView() && getBrowserView()->getVclControl() && !getBrowserView()->getVclControl()->IsEditing() && getBrowserView()->getVclControl()->GetSelectRowCount() < 1)
{
SbaGridControl* pControl = getBrowserView()->getVclControl();
pControl->copyCellText(pControl->GetCurRow(), pControl->GetCurColumnId());
@@ -3713,8 +3700,25 @@ void SbaTableQueryBrowser::postReloadForm()
Reference< XEmbeddedScripts > SAL_CALL SbaTableQueryBrowser::getScriptContainer() throw (RuntimeException)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaTableQueryBrowser::getScriptContainer" );
- Reference< XEmbeddedScripts > xScripts( m_xCurrentDatabaseDocument, UNO_QUERY );
- OSL_ENSURE( xScripts.is() || !m_xCurrentDatabaseDocument.is(),
+ // update our database document
+ Reference< XModel > xDocument;
+ try
+ {
+ Reference< XPropertySet > xCursorProps( getRowSet(), UNO_QUERY_THROW );
+ Reference< XConnection > xConnection( xCursorProps->getPropertyValue( PROPERTY_ACTIVE_CONNECTION ), UNO_QUERY );
+ if ( xConnection.is() )
+ {
+ Reference< XChild > xChild( xConnection, UNO_QUERY_THROW );
+ Reference< XDocumentDataSource > xDataSource( xChild->getParent(), UNO_QUERY_THROW );
+ xDocument.set( xDataSource->getDatabaseDocument(), UNO_QUERY_THROW );
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ Reference< XEmbeddedScripts > xScripts( xDocument, UNO_QUERY );
+ OSL_ENSURE( xScripts.is() || !xDocument.is(),
"SbaTableQueryBrowser::getScriptContainer: invalid database document!" );
return xScripts;
}
diff --git a/dbaccess/source/ui/dlg/generalpage.cxx b/dbaccess/source/ui/dlg/generalpage.cxx
index 71708e6e87f3..66b36bd1a3f8 100644
--- a/dbaccess/source/ui/dlg/generalpage.cxx
+++ b/dbaccess/source/ui/dlg/generalpage.cxx
@@ -559,7 +559,8 @@ namespace dbaui
}
if ( aFileDlg.Execute() == ERRCODE_NONE )
{
- if ( aFileDlg.GetCurrentFilter() != pFilter->GetUIName() )
+ String sPath = aFileDlg.GetPath();
+ if ( aFileDlg.GetCurrentFilter() != pFilter->GetUIName() || !pFilter->GetWildcard().Matches(sPath) )
{
String sMessage(ModuleRes(STR_ERR_USE_CONNECT_TO));
InfoBox aError(this, sMessage);
@@ -568,7 +569,7 @@ namespace dbaui
OnSetupModeSelected(&m_aRB_GetExistingDatabase);
return 0L;
}
- m_aBrowsedDocument.sURL = aFileDlg.GetPath();
+ m_aBrowsedDocument.sURL = sPath;
m_aBrowsedDocument.sFilter = String();
m_aChooseDocumentHandler.Call( this );
return 1L;
diff --git a/dbaccess/source/ui/dlg/makefile.mk b/dbaccess/source/ui/dlg/makefile.mk
index b0c991b176be..ceeac9f8cdc7 100644
--- a/dbaccess/source/ui/dlg/makefile.mk
+++ b/dbaccess/source/ui/dlg/makefile.mk
@@ -80,7 +80,6 @@ SRC1FILES = \
advancedsettings.src\
UserAdminDlg.src \
sqlmessage.src \
- ExtensionNotPresent.src \
textconnectionsettings.src
@@ -119,7 +118,6 @@ EXCEPTIONSFILES= \
$(SLO)$/dbfindex.obj \
$(SLO)$/DriverSettings.obj \
$(SLO)$/odbcconfig.obj \
- $(SLO)$/ExtensionNotPresent.obj \
$(SLO)$/advancedsettings.obj \
$(SLO)$/datasourceui.obj \
$(SLO)$/textconnectionsettings.obj
diff --git a/dbaccess/source/ui/dlg/queryfilter.cxx b/dbaccess/source/ui/dlg/queryfilter.cxx
index 0241fab2a2c5..ff8ceca88ce6 100644
--- a/dbaccess/source/ui/dlg/queryfilter.cxx
+++ b/dbaccess/source/ui/dlg/queryfilter.cxx
@@ -6,9 +6,6 @@
*
* OpenOffice.org - a multi-platform office productivity suite
*
- * $RCSfile: queryfilter.cxx,v $
- * $Revision: 1.36.66.1 $
- *
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
@@ -382,7 +379,16 @@ sal_Bool DlgFilterCrit::getCondition(const ListBox& _rField,const ListBox& _rCom
if ( xInfo->hasPropertyByName(PROPERTY_REALNAME) )
{
if ( xInfo->hasPropertyByName(PROPERTY_TABLENAME) )
+ {
xColumn->getPropertyValue(PROPERTY_TABLENAME) >>= sTableName;
+ if ( sTableName.getLength() )
+ {
+ // properly quote all parts of the table name, so e.g. <schema>.<table> becomes "<schema>"."<table>"
+ ::rtl::OUString aCatlog,aSchema,aTable;
+ ::dbtools::qualifiedNameComponents( m_xMetaData, sTableName, aCatlog, aSchema, aTable, ::dbtools::eInDataManipulation );
+ sTableName = ::dbtools::composeTableName( m_xMetaData, aCatlog, aSchema, aTable, sal_True, ::dbtools::eInDataManipulation );
+ }
+ }
xColumn->getPropertyValue(PROPERTY_REALNAME) >>= _rFilter.Name;
static ::rtl::OUString sAgg(RTL_CONSTASCII_USTRINGPARAM("AggregateFunction"));
if ( xInfo->hasPropertyByName(sAgg) )
@@ -398,7 +404,6 @@ sal_Bool DlgFilterCrit::getCondition(const ListBox& _rField,const ListBox& _rCom
if ( sTableName.getLength() )
{
static ::rtl::OUString sSep(RTL_CONSTASCII_USTRINGPARAM("."));
- sTableName = ::dbtools::quoteName(aQuote,sTableName);
sTableName += sSep;
sTableName += _rFilter.Name;
_rFilter.Name = sTableName;
diff --git a/dbaccess/source/ui/dlg/sqlmessage.cxx b/dbaccess/source/ui/dlg/sqlmessage.cxx
index cc8f01dd4daf..b27429092f60 100644
--- a/dbaccess/source/ui/dlg/sqlmessage.cxx
+++ b/dbaccess/source/ui/dlg/sqlmessage.cxx
@@ -539,14 +539,17 @@ void OSQLMessageBox::impl_positionControls()
{
OSL_PRECOND( !m_pImpl->aDisplayInfo.empty(), "OSQLMessageBox::impl_positionControls: nothing to display at all?" );
- const ExceptionDisplayInfo& rFirstInfo = *m_pImpl->aDisplayInfo.begin();
+
+ if ( m_pImpl->aDisplayInfo.empty() )
+ return;
const ExceptionDisplayInfo* pSecondInfo = NULL;
+
+ const ExceptionDisplayInfo& rFirstInfo = *m_pImpl->aDisplayInfo.begin();
if ( m_pImpl->aDisplayInfo.size() > 1 )
pSecondInfo = &m_pImpl->aDisplayInfo[1];
-
- // one or two texts to display?
String sPrimary, sSecondary;
sPrimary = rFirstInfo.sMessage;
+ // one or two texts to display?
if ( pSecondInfo )
{
// we show two elements in the main dialog if and only if one of
diff --git a/dbaccess/source/ui/inc/IUpdateHelper.hxx b/dbaccess/source/ui/inc/IUpdateHelper.hxx
index acf4038fbcc0..aff1072153c1 100644
--- a/dbaccess/source/ui/inc/IUpdateHelper.hxx
+++ b/dbaccess/source/ui/inc/IUpdateHelper.hxx
@@ -30,6 +30,10 @@
#ifndef DBAUI_IUPDATEHELPER_HXX
#define DBAUI_IUPDATEHELPER_HXX
+#include <com/sun/star/util/Date.hpp>
+#include <com/sun/star/util/DateTime.hpp>
+#include <com/sun/star/util/Time.hpp>
+
namespace dbaui
{
class SAL_NO_VTABLE IUpdateHelper
@@ -39,6 +43,9 @@ namespace dbaui
virtual void updateDouble(sal_Int32 _nPos,const double& _nValue) = 0;
virtual void updateInt(sal_Int32 _nPos,const sal_Int32& _nValue) = 0;
virtual void updateNull(sal_Int32 _nPos, ::sal_Int32 sqlType) = 0;
+ virtual void updateDate(sal_Int32 _nPos,const ::com::sun::star::util::Date& _nValue) = 0;
+ virtual void updateTime(sal_Int32 _nPos,const ::com::sun::star::util::Time& _nValue) = 0;
+ virtual void updateTimestamp(sal_Int32 _nPos,const ::com::sun::star::util::DateTime& _nValue) = 0;
virtual void moveToInsertRow() = 0;
virtual void insertRow() = 0;
};
diff --git a/dbaccess/source/ui/inc/TokenWriter.hxx b/dbaccess/source/ui/inc/TokenWriter.hxx
index 2eb162a05020..27a103e1af8a 100644
--- a/dbaccess/source/ui/inc/TokenWriter.hxx
+++ b/dbaccess/source/ui/inc/TokenWriter.hxx
@@ -173,7 +173,7 @@ namespace dbaui
class ORTFImportExport : public ODatabaseImportExport
{
-
+ void appendRow(::rtl::OString* pHorzChar,sal_Int32 _nColumnCount,sal_Int32& k,sal_Int32& kk);
public:
// export data
ORTFImportExport( const ::svx::ODataAccessDescriptor& _aDataDescriptor,
diff --git a/dbaccess/source/ui/inc/dbexchange.hxx b/dbaccess/source/ui/inc/dbexchange.hxx
index dd93d241a912..6627e3b2af1d 100644
--- a/dbaccess/source/ui/inc/dbexchange.hxx
+++ b/dbaccess/source/ui/inc/dbexchange.hxx
@@ -89,12 +89,11 @@ namespace dbaui
const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB
);
- /** with this ctor, only the object descriptor format will be provided
- */
ODataClipboard(
const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxLivingForm,
const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& _rSelectedRows,
- const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet>& _rxResultSet
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet>& _rxResultSet,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB
);
DECLARE_XINTERFACE( )
diff --git a/dbaccess/source/ui/inc/sbagrid.hxx b/dbaccess/source/ui/inc/sbagrid.hxx
index 41e99ca0124b..60c879d3fbb7 100644
--- a/dbaccess/source/ui/inc/sbagrid.hxx
+++ b/dbaccess/source/ui/inc/sbagrid.hxx
@@ -299,6 +299,12 @@ namespace dbaui
virtual ::rtl::OUString GetAccessibleObjectDescription( ::svt::AccessibleBrowseBoxObjType eObjType,sal_Int32 _nPosition = -1) const;
virtual void DeleteSelectedRows();
+ /** copies the currently selected rows to the clipboard
+ @precond
+ at least one row is selected
+ */
+ void CopySelectedRowsToClipboard();
+
protected:
// DragSourceHelper overridables
@@ -348,6 +354,7 @@ namespace dbaui
private:
sal_Bool IsReadOnlyDB() const;
+ void implTransferSelectedRows( sal_Int16 nRowPos, bool _bTrueIfClipboardFalseIfDrag );
private:
using FmGridControl::AcceptDrop;
diff --git a/dbaccess/source/ui/inc/unodatbr.hxx b/dbaccess/source/ui/inc/unodatbr.hxx
index 9354aa943a93..c6315cc1db22 100644
--- a/dbaccess/source/ui/inc/unodatbr.hxx
+++ b/dbaccess/source/ui/inc/unodatbr.hxx
@@ -130,7 +130,6 @@ namespace dbaui
::com::sun::star::uno::Reference< ::com::sun::star::i18n::XCollator > m_xCollator;
::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > m_xCurrentFrameParent;
::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > m_xMainToolbar;
- ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > m_xCurrentDatabaseDocument;
// ---------------------------
struct ExternalFeature
diff --git a/dbaccess/source/ui/misc/DExport.cxx b/dbaccess/source/ui/misc/DExport.cxx
index e55508a67608..aaa1e9ce1ff4 100644
--- a/dbaccess/source/ui/misc/DExport.cxx
+++ b/dbaccess/source/ui/misc/DExport.cxx
@@ -353,8 +353,8 @@ void ODatabaseExport::insertValueIntoColumn()
{
Reference< XNumberFormatsSupplier > xSupplier = m_xFormatter->getNumberFormatsSupplier();
Reference<XNumberFormatTypes> xNumType(xSupplier->getNumberFormats(),UNO_QUERY);
- sal_Int16 nFormats[] = { NumberFormat::DATETIME
- ,NumberFormat::DATETIME
+ sal_Int16 nFormats[] = {
+ NumberFormat::DATETIME
,NumberFormat::DATE
,NumberFormat::TIME
,NumberFormat::NUMBER
@@ -393,13 +393,17 @@ void ODatabaseExport::insertValueIntoColumn()
switch(nType)
{
case NumberFormat::DATE:
+ m_pUpdateHelper->updateDate(nPos,::dbtools::DBTypeConversion::toDate(fOutNumber,m_aNullDate));
+ break;
case NumberFormat::DATETIME:
- fOutNumber = ::dbtools::DBTypeConversion::toStandardDbDate(m_aNullDate,fOutNumber);
+ m_pUpdateHelper->updateTimestamp(nPos,::dbtools::DBTypeConversion::toDateTime(fOutNumber,m_aNullDate));
+ break;
+ case NumberFormat::TIME:
+ m_pUpdateHelper->updateTime(nPos,::dbtools::DBTypeConversion::toTime(fOutNumber));
break;
default:
- ;
+ m_pUpdateHelper->updateDouble(nPos,fOutNumber);
}
- m_pUpdateHelper->updateDouble(nPos,fOutNumber);//::dbtools::DBTypeConversion::getStandardDate()
}
catch(Exception&)
{
diff --git a/dbaccess/source/ui/misc/TokenWriter.cxx b/dbaccess/source/ui/misc/TokenWriter.cxx
index 38643109d675..02765c333c21 100644
--- a/dbaccess/source/ui/misc/TokenWriter.cxx
+++ b/dbaccess/source/ui/misc/TokenWriter.cxx
@@ -95,6 +95,7 @@ const static char __FAR_DATA sFontFamily[] = "font-family: ";
const static char __FAR_DATA sFontSize[] = "font-size: ";
#define SBA_FORMAT_SELECTION_COUNT 4
+#define CELL_X 1437
DBG_NAME(ODatabaseImportExport)
//======================================================================
@@ -479,12 +480,9 @@ BOOL ORTFImportExport::Write()
(*m_pStream) << ";\\red255\\green255\\blue255;\\red192\\green192\\blue192;}"
<< ODatabaseImportExport::sNewLine;
- sal_Int32 nCellx = 1437;
::rtl::OString aTRRH("\\trrh-270\\pard\\intbl");
::rtl::OString aFS("\\fs20\\f0\\cf0\\cb2");
- ::rtl::OString aFS2("\\fs20\\f1\\cf0\\cb1");
::rtl::OString aCell1("\\clbrdrl\\brdrs\\brdrcf0\\clbrdrt\\brdrs\\brdrcf0\\clbrdrb\\brdrs\\brdrcf0\\clbrdrr\\brdrs\\brdrcf0\\clshdng10000\\clcfpat2\\cellx");
- ::rtl::OString aCell2("\\clbrdrl\\brdrs\\brdrcf2\\clbrdrt\\brdrs\\brdrcf2\\clbrdrb\\brdrs\\brdrcf2\\clbrdrr\\brdrs\\brdrcf2\\clshdng10000\\clcfpat1\\cellx");
(*m_pStream) << OOO_STRING_SVTOOLS_RTF_TROWD << OOO_STRING_SVTOOLS_RTF_TRGAPH;
m_pStream->WriteNumber(40);
@@ -508,7 +506,7 @@ BOOL ORTFImportExport::Write()
for( sal_Int32 i=1; i<=nCount; ++i )
{
(*m_pStream) << aCell1;
- m_pStream->WriteNumber(i*nCellx);
+ m_pStream->WriteNumber(i*CELL_X);
(*m_pStream) << ODatabaseImportExport::sNewLine;
}
@@ -572,65 +570,30 @@ BOOL ORTFImportExport::Write()
Reference< XRowSet > xRowSet(m_xRow,UNO_QUERY);
sal_Int32 k=1;
sal_Int32 kk=0;
- m_xResultSet->beforeFirst(); // set back before the first row
- while(m_xResultSet->next())
+ if(m_aSelection.getLength())
{
- if(!m_pRowMarker || m_pRowMarker[kk] == k)
+ const Any* pSelIter = m_aSelection.getConstArray();
+ const Any* pEnd = pSelIter + m_aSelection.getLength();
+ sal_Bool bContinue = sal_True;
+ for(;pSelIter != pEnd && bContinue;++pSelIter)
{
- ++kk;
- (*m_pStream) << OOO_STRING_SVTOOLS_RTF_TROWD << OOO_STRING_SVTOOLS_RTF_TRGAPH;
- m_pStream->WriteNumber(40);
- (*m_pStream) << ODatabaseImportExport::sNewLine;
-
- for ( sal_Int32 i=1; i<=nCount; ++i )
- {
- (*m_pStream) << aCell2;
- m_pStream->WriteNumber(i*nCellx);
- (*m_pStream) << ODatabaseImportExport::sNewLine;
- }
-
- (*m_pStream) << '{';
- (*m_pStream) << aTRRH;
- for ( sal_Int32 i=1; i<=nCount; ++i )
- {
- (*m_pStream) << ODatabaseImportExport::sNewLine;
- (*m_pStream) << '{';
- (*m_pStream) << pHorzChar[i-1];
+ sal_Int32 nPos = -1;
+ *pSelIter >>= nPos;
+ OSL_ENSURE(nPos != -1,"Invalid posiotion!");
+ bContinue = (m_xResultSet->absolute(nPos));
+ if ( bContinue )
+ appendRow(pHorzChar,nCount,k,kk);
- if ( bBold ) (*m_pStream) << OOO_STRING_SVTOOLS_RTF_B;
- if ( bItalic ) (*m_pStream) << OOO_STRING_SVTOOLS_RTF_I;
- if ( bUnderline ) (*m_pStream) << OOO_STRING_SVTOOLS_RTF_UL;
- if ( bStrikeout ) (*m_pStream) << OOO_STRING_SVTOOLS_RTF_STRIKE;
-
- (*m_pStream) << aFS2;
- (*m_pStream) << ' ';
-
- try
- {
- Reference<XPropertySet> xColumn(m_xRowSetColumns->getByIndex(i-1),UNO_QUERY_THROW);
- dbtools::FormattedColumnValue aFormatedValue(aContext,xRowSet,xColumn);
- ::rtl::OUString sValue = aFormatedValue.getFormattedValue();
- // m_xRow->getString(i);
- //if (!m_xRow->wasNull())
- if ( sValue.getLength() )
- RTFOutFuncs::Out_String(*m_pStream,sValue,m_eDestEnc);
- }
- catch (Exception&)
- {
- OSL_ENSURE(0,"RTF WRITE!");
- }
-
- (*m_pStream) << OOO_STRING_SVTOOLS_RTF_CELL;
- (*m_pStream) << '}';
- (*m_pStream) << ODatabaseImportExport::sNewLine;
- (*m_pStream) << OOO_STRING_SVTOOLS_RTF_PARD << OOO_STRING_SVTOOLS_RTF_INTBL;
- }
- (*m_pStream) << OOO_STRING_SVTOOLS_RTF_ROW << ODatabaseImportExport::sNewLine;
- (*m_pStream) << '}';
}
- ++k;
+ } // if(m_aSelection.getLength())
+ else
+ {
+ m_xResultSet->beforeFirst(); // set back before the first row
+ while(m_xResultSet->next())
+ {
+ appendRow(pHorzChar,nCount,k,kk);
+ }
}
-
delete [] pHorzChar;
}
@@ -638,6 +601,75 @@ BOOL ORTFImportExport::Write()
(*m_pStream) << (BYTE) 0;
return ((*m_pStream).GetError() == SVSTREAM_OK);
}
+// -----------------------------------------------------------------------------
+void ORTFImportExport::appendRow(::rtl::OString* pHorzChar,sal_Int32 _nColumnCount,sal_Int32& k,sal_Int32& kk)
+{
+ if(!m_pRowMarker || m_pRowMarker[kk] == k)
+ {
+ ++kk;
+ (*m_pStream) << OOO_STRING_SVTOOLS_RTF_TROWD << OOO_STRING_SVTOOLS_RTF_TRGAPH;
+ m_pStream->WriteNumber(40);
+ (*m_pStream) << ODatabaseImportExport::sNewLine;
+
+ static const ::rtl::OString aCell2("\\clbrdrl\\brdrs\\brdrcf2\\clbrdrt\\brdrs\\brdrcf2\\clbrdrb\\brdrs\\brdrcf2\\clbrdrr\\brdrs\\brdrcf2\\clshdng10000\\clcfpat1\\cellx");
+ static const ::rtl::OString aTRRH("\\trrh-270\\pard\\intbl");
+
+ for ( sal_Int32 i=1; i<=_nColumnCount; ++i )
+ {
+ (*m_pStream) << aCell2;
+ m_pStream->WriteNumber(i*CELL_X);
+ (*m_pStream) << ODatabaseImportExport::sNewLine;
+ }
+
+ const BOOL bBold = ( ::com::sun::star::awt::FontWeight::BOLD == m_aFont.Weight );
+ const BOOL bItalic = ( ::com::sun::star::awt::FontSlant_ITALIC == m_aFont.Slant );
+ const BOOL bUnderline = ( ::com::sun::star::awt::FontUnderline::NONE != m_aFont.Underline );
+ const BOOL bStrikeout = ( ::com::sun::star::awt::FontStrikeout::NONE != m_aFont.Strikeout );
+ static const ::rtl::OString aFS2("\\fs20\\f1\\cf0\\cb1");
+ ::comphelper::ComponentContext aContext(m_xFactory);
+ Reference< XRowSet > xRowSet(m_xRow,UNO_QUERY);
+
+ (*m_pStream) << '{';
+ (*m_pStream) << aTRRH;
+ for ( sal_Int32 i=1; i <= _nColumnCount; ++i )
+ {
+ (*m_pStream) << ODatabaseImportExport::sNewLine;
+ (*m_pStream) << '{';
+ (*m_pStream) << pHorzChar[i-1];
+
+ if ( bBold ) (*m_pStream) << OOO_STRING_SVTOOLS_RTF_B;
+ if ( bItalic ) (*m_pStream) << OOO_STRING_SVTOOLS_RTF_I;
+ if ( bUnderline ) (*m_pStream) << OOO_STRING_SVTOOLS_RTF_UL;
+ if ( bStrikeout ) (*m_pStream) << OOO_STRING_SVTOOLS_RTF_STRIKE;
+
+ (*m_pStream) << aFS2;
+ (*m_pStream) << ' ';
+
+ try
+ {
+ Reference<XPropertySet> xColumn(m_xRowSetColumns->getByIndex(i-1),UNO_QUERY_THROW);
+ dbtools::FormattedColumnValue aFormatedValue(aContext,xRowSet,xColumn);
+ ::rtl::OUString sValue = aFormatedValue.getFormattedValue();
+ // m_xRow->getString(i);
+ //if (!m_xRow->wasNull())
+ if ( sValue.getLength() )
+ RTFOutFuncs::Out_String(*m_pStream,sValue,m_eDestEnc);
+ }
+ catch (Exception&)
+ {
+ OSL_ENSURE(0,"RTF WRITE!");
+ }
+
+ (*m_pStream) << OOO_STRING_SVTOOLS_RTF_CELL;
+ (*m_pStream) << '}';
+ (*m_pStream) << ODatabaseImportExport::sNewLine;
+ (*m_pStream) << OOO_STRING_SVTOOLS_RTF_PARD << OOO_STRING_SVTOOLS_RTF_INTBL;
+ }
+ (*m_pStream) << OOO_STRING_SVTOOLS_RTF_ROW << ODatabaseImportExport::sNewLine;
+ (*m_pStream) << '}';
+ }
+ ++k;
+}
//-------------------------------------------------------------------
BOOL ORTFImportExport::Read()
{
diff --git a/dbaccess/source/ui/misc/UpdateHelperImpl.hxx b/dbaccess/source/ui/misc/UpdateHelperImpl.hxx
index a0a9e63fc183..5a5633571722 100644
--- a/dbaccess/source/ui/misc/UpdateHelperImpl.hxx
+++ b/dbaccess/source/ui/misc/UpdateHelperImpl.hxx
@@ -60,6 +60,18 @@ namespace dbaui
{
m_xRowUpdate->updateDouble(_nPos, _nValue);
}
+ virtual void updateDate(sal_Int32 _nPos,const ::com::sun::star::util::Date& _nValue)
+ {
+ m_xRowUpdate->updateDate(_nPos, _nValue);
+ }
+ virtual void updateTime(sal_Int32 _nPos,const ::com::sun::star::util::Time& _nValue)
+ {
+ m_xRowUpdate->updateTime(_nPos, _nValue);
+ }
+ virtual void updateTimestamp(sal_Int32 _nPos,const ::com::sun::star::util::DateTime& _nValue)
+ {
+ m_xRowUpdate->updateTimestamp(_nPos, _nValue);
+ }
virtual void updateInt(sal_Int32 _nPos,const sal_Int32& _nValue)
{
m_xRowUpdate->updateInt(_nPos, _nValue);
@@ -100,6 +112,21 @@ namespace dbaui
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OParameterUpdateHelper::updateDouble" );
m_xParameters->setDouble(_nPos, _nValue);
}
+ virtual void updateDate(sal_Int32 _nPos,const ::com::sun::star::util::Date& _nValue)
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OParameterUpdateHelper::updateDouble" );
+ m_xParameters->setDate(_nPos, _nValue);
+ }
+ virtual void updateTime(sal_Int32 _nPos,const ::com::sun::star::util::Time& _nValue)
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OParameterUpdateHelper::updateDouble" );
+ m_xParameters->setTime(_nPos, _nValue);
+ }
+ virtual void updateTimestamp(sal_Int32 _nPos,const ::com::sun::star::util::DateTime& _nValue)
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OParameterUpdateHelper::updateDouble" );
+ m_xParameters->setTimestamp(_nPos, _nValue);
+ }
virtual void updateInt(sal_Int32 _nPos,const sal_Int32& _nValue)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OParameterUpdateHelper::updateInt" );
diff --git a/dbaccess/source/ui/misc/dbumiscres.src b/dbaccess/source/ui/misc/dbumiscres.src
index f58b0b8b23ba..e20e603b2343 100644
--- a/dbaccess/source/ui/misc/dbumiscres.src
+++ b/dbaccess/source/ui/misc/dbumiscres.src
@@ -96,4 +96,8 @@ String STR_NAMED_OBJECT_ALREADY_EXISTS
{
Text [ en-US ] = "The name '$#$' already exists.\nPlease enter another name." ;
};
-
+String RID_STR_EXTENSION_NOT_PRESENT
+{
+ // #i96130# use hard coded name
+ Text [ en-US ] = "The report, \"$file$\", requires the extension Sun Report Builder.";
+};
diff --git a/dbaccess/source/ui/misc/linkeddocuments.cxx b/dbaccess/source/ui/misc/linkeddocuments.cxx
index d1c056b6e4a3..69ec1dcf4975 100644
--- a/dbaccess/source/ui/misc/linkeddocuments.cxx
+++ b/dbaccess/source/ui/misc/linkeddocuments.cxx
@@ -140,7 +140,6 @@
#include <connectivity/dbtools.hxx>
#include <toolkit/helper/vclunohelper.hxx>
#include <com/sun/star/io/WrongFormatException.hpp>
-#include "ExtensionNotPresent.hxx"
#include "com/sun/star/sdb/RowSetVetoException.hpp"
//......................................................................
@@ -455,7 +454,7 @@ namespace dbaui
// more like a hack, insert an empty message
String sText( ModuleRes( RID_STR_EXTENSION_NOT_PRESENT ) );
- sText = sText.GetToken(0,'\n');
+ sText.SearchAndReplaceAscii("$file$",_rLinkName);
aInfo.prepend(sText);
String sMessage = String(ModuleRes(STR_COULDNOTOPEN_LINKEDDOC));
diff --git a/dbaccess/source/ui/relationdesign/relation.src b/dbaccess/source/ui/relationdesign/relation.src
index 391205223886..cb068c43d50c 100644
--- a/dbaccess/source/ui/relationdesign/relation.src
+++ b/dbaccess/source/ui/relationdesign/relation.src
@@ -77,7 +77,7 @@ String STR_QUERY_REL_DELETE_WINDOW
String STR_QUERY_REL_COULD_NOT_CREATE
{
- Text [ en-US ] = "The datbase could not create the relation. May be foreign keys for this kind of table aren't supported.\nPlease check your documentation of the database.";
+ Text [ en-US ] = "The database could not create the relation. May be foreign keys for this kind of table aren't supported.\nPlease check your documentation of the database.";
};
diff --git a/dbaccess/source/ui/tabledesign/FieldDescriptions.cxx b/dbaccess/source/ui/tabledesign/FieldDescriptions.cxx
index 4ece37f2fa51..699a2db8404b 100644
--- a/dbaccess/source/ui/tabledesign/FieldDescriptions.cxx
+++ b/dbaccess/source/ui/tabledesign/FieldDescriptions.cxx
@@ -176,7 +176,11 @@ OFieldDescription::OFieldDescription(const Reference< XPropertySet >& xAffectedC
if(xPropSetInfo->hasPropertyByName(PROPERTY_ISNULLABLE))
SetIsNullable(::comphelper::getINT32(xAffectedCol->getPropertyValue(PROPERTY_ISNULLABLE)));
if(xPropSetInfo->hasPropertyByName(PROPERTY_FORMATKEY))
- SetFormatKey(::comphelper::getINT32(xAffectedCol->getPropertyValue(PROPERTY_FORMATKEY)));
+ {
+ const Any aValue = xAffectedCol->getPropertyValue(PROPERTY_FORMATKEY);
+ if ( aValue.hasValue() )
+ SetFormatKey(::comphelper::getINT32(aValue));
+ }
if(xPropSetInfo->hasPropertyByName(PROPERTY_RELATIVEPOSITION))
m_aRelativePosition = xAffectedCol->getPropertyValue(PROPERTY_RELATIVEPOSITION);
if(xPropSetInfo->hasPropertyByName(PROPERTY_WIDTH))
@@ -184,7 +188,11 @@ OFieldDescription::OFieldDescription(const Reference< XPropertySet >& xAffectedC
if(xPropSetInfo->hasPropertyByName(PROPERTY_HIDDEN))
xAffectedCol->getPropertyValue(PROPERTY_HIDDEN) >>= m_bHidden;
if(xPropSetInfo->hasPropertyByName(PROPERTY_ALIGN))
- SetHorJustify( ::dbaui::mapTextJustify(::comphelper::getINT32(xAffectedCol->getPropertyValue(PROPERTY_ALIGN))));
+ {
+ const Any aValue = xAffectedCol->getPropertyValue(PROPERTY_ALIGN);
+ if ( aValue.hasValue() )
+ SetHorJustify( ::dbaui::mapTextJustify(::comphelper::getINT32(aValue)));
+ }
if(xPropSetInfo->hasPropertyByName(PROPERTY_ISAUTOINCREMENT))
SetAutoIncrement(::cppu::any2bool(xAffectedCol->getPropertyValue(PROPERTY_ISAUTOINCREMENT)));
}
diff --git a/reportdesign/inc/rptui_slotid.hrc b/reportdesign/inc/rptui_slotid.hrc
index 68b3019f2d86..c42eba11ec8f 100644
--- a/reportdesign/inc/rptui_slotid.hrc
+++ b/reportdesign/inc/rptui_slotid.hrc
@@ -209,4 +209,7 @@
#define SID_SECTION_SHRINK_BOTTOM ( SID_RPTUI_START + 165 )
#define SID_SECTION_SHRINK_MENU ( SID_RPTUI_START + 166 )
+#define SID_COLLAPSE_SECTION ( SID_RPTUI_START + 167 )
+#define SID_EXPAND_SECTION ( SID_RPTUI_START + 168 )
+
#endif // _RPTUI_SLOTID_HRC_
diff --git a/reportdesign/source/ui/dlg/AddField.cxx b/reportdesign/source/ui/dlg/AddField.cxx
index 034ff5f9c7b5..6beebfcb30c8 100644
--- a/reportdesign/source/ui/dlg/AddField.cxx
+++ b/reportdesign/source/ui/dlg/AddField.cxx
@@ -116,7 +116,7 @@ uno::Sequence< beans::PropertyValue > OAddFieldWindowListBox::getSelectedFieldDe
DBG_NAME( rpt_OAddFieldWindowListBox );
//------------------------------------------------------------------------------
OAddFieldWindowListBox::OAddFieldWindowListBox( OAddFieldWindow* _pParent )
- :SvTreeListBox( _pParent, WB_BORDER|WB_SORT )
+ :SvTreeListBox( _pParent, WB_TABSTOP|WB_BORDER|WB_SORT )
,m_pTabWin( _pParent )
{
DBG_CTOR( rpt_OAddFieldWindowListBox,NULL);
diff --git a/reportdesign/source/ui/dlg/Navigator.cxx b/reportdesign/source/ui/dlg/Navigator.cxx
index 0ed6d3a9affd..7932c5c04371 100644
--- a/reportdesign/source/ui/dlg/Navigator.cxx
+++ b/reportdesign/source/ui/dlg/Navigator.cxx
@@ -224,7 +224,7 @@ private:
DBG_NAME(rpt_NavigatorTree)
// -----------------------------------------------------------------------------
NavigatorTree::NavigatorTree( Window* pParent,OReportController& _rController )
- :SvTreeListBox( pParent, WB_HASBUTTONS|WB_HASLINES|WB_BORDER|WB_HSCROLL|WB_HASBUTTONSATROOT )
+ :SvTreeListBox( pParent, WB_TABSTOP| WB_HASBUTTONS|WB_HASLINES|WB_BORDER|WB_HSCROLL|WB_HASBUTTONSATROOT )
,comphelper::OSelectionChangeListener(m_aMutex)
,OPropertyChangeListener(m_aMutex)
,m_aTimerTriggered(-1,-1)
@@ -945,6 +945,7 @@ ONavigator::ONavigator( Window* _pParent
//SetOutputSizePixel(aOutSize);
FreeResource();
m_pImpl->m_pNavigatorTree->Show();
+ m_pImpl->m_pNavigatorTree->GrabFocus();
SetSizePixel(Size(STD_WIN_SIZE_X,STD_WIN_SIZE_Y));
Show();
@@ -975,6 +976,13 @@ void ONavigator::Resize()
m_pImpl->m_pNavigatorTree->SetPosSizePixel( aLBPos, aLBSize );
}
// -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
+void ONavigator::GetFocus()
+{
+ Window::GetFocus();
+ if ( m_pImpl->m_pNavigatorTree.get() )
+ m_pImpl->m_pNavigatorTree->GrabFocus();
+}
// =============================================================================
} // rptui
// =============================================================================
diff --git a/reportdesign/source/ui/inc/Navigator.hxx b/reportdesign/source/ui/inc/Navigator.hxx
index 764c53384bee..54dbba4caa88 100644
--- a/reportdesign/source/ui/inc/Navigator.hxx
+++ b/reportdesign/source/ui/inc/Navigator.hxx
@@ -50,6 +50,7 @@ namespace rptui
// window
virtual void Resize();
+ virtual void GetFocus();
};
// =============================================================================
} // namespace rptui
diff --git a/reportdesign/source/ui/inc/ReportController.hxx b/reportdesign/source/ui/inc/ReportController.hxx
index d84da255e9e3..f685723b418c 100644
--- a/reportdesign/source/ui/inc/ReportController.hxx
+++ b/reportdesign/source/ui/inc/ReportController.hxx
@@ -277,6 +277,12 @@ namespace rptui
*/
void markSection(const bool _bNext);
+ /** collapse or expand the currently selected section.
+ *
+ * \param _bCollapse collapse if TRUE otherwise expand
+ */
+ void collapseSection(const bool _bCollapse);
+
/** fills the member that chart is enabled or not
*
*/
diff --git a/reportdesign/source/ui/inc/SectionWindow.hxx b/reportdesign/source/ui/inc/SectionWindow.hxx
index 36eee47f83f3..1e6c71dd6d2d 100644
--- a/reportdesign/source/ui/inc/SectionWindow.hxx
+++ b/reportdesign/source/ui/inc/SectionWindow.hxx
@@ -65,7 +65,6 @@ namespace rptui
OReportSection m_aReportSection;
Splitter m_aSplitter;
OEndMarker m_aEndMarker;
- //Window m_aFill;
::rtl::Reference< comphelper::OPropertyChangeMultiplexer> m_pSectionMulti;
::rtl::Reference< comphelper::OPropertyChangeMultiplexer> m_pGroupMulti;
@@ -94,7 +93,7 @@ namespace rptui
bool setReportSectionTitle(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportDefinition>& _xReport,USHORT _nResId,::std::mem_fun_t< ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection> , OReportHelper> _pGetSection,::std::mem_fun_t<sal_Bool, OReportHelper> _pIsSectionOn);
void ImplInitSettings();
- DECL_LINK(Collapsed,OStartMarker*);
+ DECL_LINK(Collapsed,OColorListener*);
DECL_LINK(StartSplitHdl, Splitter*);
DECL_LINK(SplitHdl, Splitter*);
DECL_LINK(EndSplitHdl, Splitter*);
diff --git a/reportdesign/source/ui/inc/StartMarker.hxx b/reportdesign/source/ui/inc/StartMarker.hxx
index bbe4204eb989..d14abd076fc5 100644
--- a/reportdesign/source/ui/inc/StartMarker.hxx
+++ b/reportdesign/source/ui/inc/StartMarker.hxx
@@ -54,6 +54,7 @@ namespace rptui
sal_Bool m_bShowRuler;
+ void changeImage();
void initDefaultNodeImages();
void setColor();
virtual void ImplInitSettings();
diff --git a/reportdesign/source/ui/report/DesignView.cxx b/reportdesign/source/ui/report/DesignView.cxx
index ce1898df0dde..40264c642d52 100644
--- a/reportdesign/source/ui/report/DesignView.cxx
+++ b/reportdesign/source/ui/report/DesignView.cxx
@@ -691,6 +691,10 @@ sal_Bool ODesignView::handleKeyEvent(const KeyEvent& _rEvent)
{
if ( (m_pPropWin && m_pPropWin->HasChildPathFocus()) )
return sal_False;
+ if ( (m_pAddField && m_pAddField->HasChildPathFocus()) )
+ return sal_False;
+ if ( (m_pReportExplorer && m_pReportExplorer->HasChildPathFocus()) )
+ return sal_False;
return m_aScrollWindow.handleKeyEvent(_rEvent);
}
//------------------------------------------------------------------------
diff --git a/reportdesign/source/ui/report/ReportController.cxx b/reportdesign/source/ui/report/ReportController.cxx
index 9b9b4c1f1ab2..1df7981e21b4 100644
--- a/reportdesign/source/ui/report/ReportController.cxx
+++ b/reportdesign/source/ui/report/ReportController.cxx
@@ -559,6 +559,8 @@ FeatureState OReportController::GetState(sal_uInt16 _nId) const
case SID_RPT_NEW_FUNCTION:
aReturn.bEnabled = isEditable();
break;
+ case SID_COLLAPSE_SECTION:
+ case SID_EXPAND_SECTION:
case SID_NEXT_MARK:
case SID_PREV_MARK:
aReturn.bEnabled = isEditable();
@@ -1171,6 +1173,12 @@ void OReportController::Execute(sal_uInt16 _nId, const Sequence< PropertyValue >
case SID_RPT_NEW_FUNCTION:
createNewFunction(aArgs[0].Value);
break;
+ case SID_COLLAPSE_SECTION:
+ collapseSection(true);
+ break;
+ case SID_EXPAND_SECTION:
+ collapseSection(false);
+ break;
case SID_NEXT_MARK:
markSection(true);
break;
@@ -2107,6 +2115,8 @@ void OReportController::describeSupportedFeatures()
implDescribeSupportedFeature( ".uno:TerminateInplaceActivation", SID_TERMINATE_INPLACEACTIVATION);
implDescribeSupportedFeature( ".uno:SelectAllLabels", SID_SELECT_ALL_LABELS);
implDescribeSupportedFeature( ".uno:SelectAllEdits", SID_SELECT_ALL_EDITS);
+ implDescribeSupportedFeature( ".uno:CollapseSection", SID_COLLAPSE_SECTION);
+ implDescribeSupportedFeature( ".uno:ExpandSection", SID_EXPAND_SECTION);
}
// -----------------------------------------------------------------------------
SfxUndoManager* OReportController::getUndoMgr()
@@ -3967,6 +3977,15 @@ void OReportController::createGroupSection(const bool _bUndo,const bool _bHeader
}
}
// -----------------------------------------------------------------------------
+void OReportController::collapseSection(const bool _bCollapse)
+{
+ ::boost::shared_ptr<OSectionWindow> pSection = m_pMyOwnView->getMarkedSection();
+ if ( pSection )
+ {
+ pSection->setCollapsed(_bCollapse);
+ }
+}
+// -----------------------------------------------------------------------------
void OReportController::markSection(const bool _bNext)
{
::boost::shared_ptr<OSectionWindow> pSection = m_pMyOwnView->getMarkedSection();
diff --git a/reportdesign/source/ui/report/SectionWindow.cxx b/reportdesign/source/ui/report/SectionWindow.cxx
index 020db169cca2..a781a9f654d7 100644
--- a/reportdesign/source/ui/report/SectionWindow.cxx
+++ b/reportdesign/source/ui/report/SectionWindow.cxx
@@ -274,9 +274,10 @@ void OSectionWindow::Resize()
// -----------------------------------------------------------------------------
void OSectionWindow::setCollapsed(sal_Bool _bCollapsed)
{
- m_aReportSection.Show(_bCollapsed);
- m_aEndMarker.Show(_bCollapsed);
- m_aSplitter.Show(_bCollapsed);
+ if ( m_aStartMarker.isCollapsed() != _bCollapsed )
+ {
+ m_aStartMarker.setCollapsed(_bCollapsed);
+ }
}
//-----------------------------------------------------------------------------
void OSectionWindow::showProperties()
@@ -290,17 +291,20 @@ void OSectionWindow::setMarked(sal_Bool _bMark)
m_aEndMarker.setMarked(_bMark);
}
// -----------------------------------------------------------------------------
-IMPL_LINK( OSectionWindow, Collapsed, OStartMarker *, _pMarker )
+IMPL_LINK( OSectionWindow, Collapsed, OColorListener *, _pMarker )
{
if ( _pMarker )
{
- setCollapsed(!_pMarker->isCollapsed());
+ sal_Bool bShow = !_pMarker->isCollapsed();
+ m_aReportSection.Show(bShow);
+ m_aEndMarker.Show(bShow);
+ m_aSplitter.Show(bShow);
+
m_pParent->resize(*this);
Resize();
// TRY
// m_pParent->Invalidate(INVALIDATE_TRANSPARENT | INVALIDATE_NOCHILDREN);
Invalidate();
- // _pMarker->Invalidate();
}
return 0L;
}
diff --git a/reportdesign/source/ui/report/StartMarker.cxx b/reportdesign/source/ui/report/StartMarker.cxx
index b525a42f5dd8..d87f7464a140 100644
--- a/reportdesign/source/ui/report/StartMarker.cxx
+++ b/reportdesign/source/ui/report/StartMarker.cxx
@@ -181,12 +181,7 @@ void OStartMarker::MouseButtonUp( const MouseEvent& rMEvt )
{
m_bCollapsed = !m_bCollapsed;
- Image* pImage = NULL;
- if ( GetDisplayBackground().GetColor().IsDark() )
- pImage = m_bCollapsed ? s_pDefCollapsedHC : s_pDefExpandedHC;
- else
- pImage = m_bCollapsed ? s_pDefCollapsed : s_pDefExpanded;
- m_aImage.SetImage(*pImage);
+ changeImage();
m_aVRuler.Show(!m_bCollapsed && m_bShowRuler);
if ( m_aCollapsedLink.IsSet() )
@@ -195,6 +190,16 @@ void OStartMarker::MouseButtonUp( const MouseEvent& rMEvt )
m_pParent->showProperties();
}
+// -----------------------------------------------------------------------------
+void OStartMarker::changeImage()
+{
+ Image* pImage = NULL;
+ if ( GetDisplayBackground().GetColor().IsDark() )
+ pImage = m_bCollapsed ? s_pDefCollapsedHC : s_pDefExpandedHC;
+ else
+ pImage = m_bCollapsed ? s_pDefCollapsed : s_pDefExpanded;
+ m_aImage.SetImage(*pImage);
+}
// -----------------------------------------------------------------------
void OStartMarker::initDefaultNodeImages()
{
@@ -311,6 +316,7 @@ void OStartMarker::setCollapsed(sal_Bool _bCollapsed)
{
OColorListener::setCollapsed(_bCollapsed);
showRuler(_bCollapsed);
+ changeImage();
}
// -----------------------------------------------------------------------
void OStartMarker::zoom(const Fraction& _aZoom)
diff --git a/reportdesign/uiconfig/dbreport/accelerator/de-DE/default.xml b/reportdesign/uiconfig/dbreport/accelerator/de-DE/default.xml
index 4c64318cb9f1..6aaa305ae7a1 100644
--- a/reportdesign/uiconfig/dbreport/accelerator/de-DE/default.xml
+++ b/reportdesign/uiconfig/dbreport/accelerator/de-DE/default.xml
@@ -12,6 +12,8 @@
<accel:item accel:code="KEY_F" accel:mod1="true" accel:shift="false" xlink:href=".uno:SelectAllEdits"/>
<accel:item accel:code="KEY_Y" accel:mod1="true" xlink:href=".uno:Redo"/>
<accel:item accel:code="KEY_Z" accel:mod1="true" xlink:href=".uno:Undo"/>
+ <accel:item accel:code="KEY_SUBTRACT" xlink:href=".uno:CollapseSection"/>
+ <accel:item accel:code="KEY_ADD" xlink:href=".uno:ExpandSection"/>
<accel:item accel:code="KEY_TAB" accel:mod1="true" xlink:href=".uno:NextMark"/>
<accel:item accel:code="KEY_TAB" accel:mod1="true" accel:shift="true" xlink:href=".uno:PrevMark"/>
</accel:acceleratorlist>
diff --git a/reportdesign/uiconfig/dbreport/accelerator/en-GB/default.xml b/reportdesign/uiconfig/dbreport/accelerator/en-GB/default.xml
index 4c64318cb9f1..6aaa305ae7a1 100644
--- a/reportdesign/uiconfig/dbreport/accelerator/en-GB/default.xml
+++ b/reportdesign/uiconfig/dbreport/accelerator/en-GB/default.xml
@@ -12,6 +12,8 @@
<accel:item accel:code="KEY_F" accel:mod1="true" accel:shift="false" xlink:href=".uno:SelectAllEdits"/>
<accel:item accel:code="KEY_Y" accel:mod1="true" xlink:href=".uno:Redo"/>
<accel:item accel:code="KEY_Z" accel:mod1="true" xlink:href=".uno:Undo"/>
+ <accel:item accel:code="KEY_SUBTRACT" xlink:href=".uno:CollapseSection"/>
+ <accel:item accel:code="KEY_ADD" xlink:href=".uno:ExpandSection"/>
<accel:item accel:code="KEY_TAB" accel:mod1="true" xlink:href=".uno:NextMark"/>
<accel:item accel:code="KEY_TAB" accel:mod1="true" accel:shift="true" xlink:href=".uno:PrevMark"/>
</accel:acceleratorlist>
diff --git a/reportdesign/uiconfig/dbreport/accelerator/en-US/default.xml b/reportdesign/uiconfig/dbreport/accelerator/en-US/default.xml
index 4c64318cb9f1..6aaa305ae7a1 100644
--- a/reportdesign/uiconfig/dbreport/accelerator/en-US/default.xml
+++ b/reportdesign/uiconfig/dbreport/accelerator/en-US/default.xml
@@ -12,6 +12,8 @@
<accel:item accel:code="KEY_F" accel:mod1="true" accel:shift="false" xlink:href=".uno:SelectAllEdits"/>
<accel:item accel:code="KEY_Y" accel:mod1="true" xlink:href=".uno:Redo"/>
<accel:item accel:code="KEY_Z" accel:mod1="true" xlink:href=".uno:Undo"/>
+ <accel:item accel:code="KEY_SUBTRACT" xlink:href=".uno:CollapseSection"/>
+ <accel:item accel:code="KEY_ADD" xlink:href=".uno:ExpandSection"/>
<accel:item accel:code="KEY_TAB" accel:mod1="true" xlink:href=".uno:NextMark"/>
<accel:item accel:code="KEY_TAB" accel:mod1="true" accel:shift="true" xlink:href=".uno:PrevMark"/>
</accel:acceleratorlist>