From 151a532470b9535fee7927d5895da90c33e1e979 Mon Sep 17 00:00:00 2001 From: Lars Langhans Date: Fri, 18 Jun 2010 10:04:37 +0200 Subject: sb123:#i111449# cleanups in reportdesign qa/complex tests --- reportdesign/prj/build.lst | 3 + reportdesign/qa/complex/RPTCalcTests.odb | Bin 6715 -> 0 bytes reportdesign/qa/complex/RPTWriterTests.odb | Bin 5886 -> 0 bytes reportdesign/qa/complex/ReportDesignerTest.java | 608 ------------------- reportdesign/qa/complex/makefile.mk | 58 -- reportdesign/qa/complex/mysql-connector-exists.pl | 9 - reportdesign/qa/complex/reportdesign/FileURL.java | 62 ++ .../complex/reportdesign/ReportDesignerTest.java | 651 +++++++++++++++++++++ .../qa/complex/reportdesign/TestDocument.java | 41 ++ reportdesign/qa/complex/reportdesign/makefile.mk | 66 +++ .../complex/reportdesign/mysql-connector-exists.pl | 9 + reportdesign/qa/complex/reportdesign/runner.props | 22 + .../reportdesign/test_documents/RPTCalcTests.odb | Bin 0 -> 6715 bytes .../reportdesign/test_documents/RPTWriterTests.odb | Bin 0 -> 5762 bytes reportdesign/qa/complex/runner.props | 22 - 15 files changed, 854 insertions(+), 697 deletions(-) delete mode 100755 reportdesign/qa/complex/RPTCalcTests.odb delete mode 100755 reportdesign/qa/complex/RPTWriterTests.odb delete mode 100755 reportdesign/qa/complex/ReportDesignerTest.java delete mode 100755 reportdesign/qa/complex/makefile.mk delete mode 100644 reportdesign/qa/complex/mysql-connector-exists.pl create mode 100644 reportdesign/qa/complex/reportdesign/FileURL.java create mode 100755 reportdesign/qa/complex/reportdesign/ReportDesignerTest.java create mode 100644 reportdesign/qa/complex/reportdesign/TestDocument.java create mode 100755 reportdesign/qa/complex/reportdesign/makefile.mk create mode 100644 reportdesign/qa/complex/reportdesign/mysql-connector-exists.pl create mode 100755 reportdesign/qa/complex/reportdesign/runner.props create mode 100755 reportdesign/qa/complex/reportdesign/test_documents/RPTCalcTests.odb create mode 100755 reportdesign/qa/complex/reportdesign/test_documents/RPTWriterTests.odb delete mode 100755 reportdesign/qa/complex/runner.props diff --git a/reportdesign/prj/build.lst b/reportdesign/prj/build.lst index 781eb91eccb3..dff79ac79c3d 100644 --- a/reportdesign/prj/build.lst +++ b/reportdesign/prj/build.lst @@ -13,3 +13,6 @@ rd reportdesign\source\ui\inspection nmake rd reportdesign\source\filter\xml nmake - all rd_filter_xml rd_inc NULL rd reportdesign\util nmake - all rd_util rd_api rd_res rd_shared rd_uimisc rd_uidlg rd_uireport rd_uiinspection rd_sdr rd_misc rd_filter_xml NULL +# has problems im m78 +# rd reportdesign\qa\complex\reportdesign nmake - all rd_qa_complex NULL + diff --git a/reportdesign/qa/complex/RPTCalcTests.odb b/reportdesign/qa/complex/RPTCalcTests.odb deleted file mode 100755 index 0e91d633d4e7..000000000000 Binary files a/reportdesign/qa/complex/RPTCalcTests.odb and /dev/null differ diff --git a/reportdesign/qa/complex/RPTWriterTests.odb b/reportdesign/qa/complex/RPTWriterTests.odb deleted file mode 100755 index 86228f457f0b..000000000000 Binary files a/reportdesign/qa/complex/RPTWriterTests.odb and /dev/null differ diff --git a/reportdesign/qa/complex/ReportDesignerTest.java b/reportdesign/qa/complex/ReportDesignerTest.java deleted file mode 100755 index 3bbb9a42fe26..000000000000 --- a/reportdesign/qa/complex/ReportDesignerTest.java +++ /dev/null @@ -1,608 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -package complex; - -import java.io.File; -import java.util.ArrayList; - -import com.sun.star.beans.PropertyValue; -import com.sun.star.beans.XPropertySet; -import com.sun.star.container.XNameAccess; -import com.sun.star.frame.XComponentLoader; -import com.sun.star.frame.XDesktop; -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.XDocumentDataSource; -import com.sun.star.sdb.XOfficeDatabaseDocument; -import com.sun.star.sdb.XReportDocumentsSupplier; -import com.sun.star.sdb.application.XDatabaseDocumentUI; -import com.sun.star.uno.UnoRuntime; -import com.sun.star.uno.XInterface; -import com.sun.star.util.XCloseable; - -// import util.BasicMacroTools; -// import util.DesktopTools; -// import util.dbg; -import complexlib.ComplexTestCase; -import util.utils; -import helper.OfficeProvider; -import helper.URLHelper; -import helper.OfficeWatcher; - -import convwatch.DB; - -// import java.util.Date; -// import java.text.SimpleDateFormat; -// import java.text.ParsePosition; -// import java.sql.Time; -// -// import java.io.BufferedReader; -// import java.io.File; -// import java.io.FileReader; -// import java.io.IOException; -// import java.io.FilenameFilter; -// -// import java.util.Vector; -// -// import helper.AppProvider; -// import java.text.DecimalFormat; -// import util.DynamicClassLoader; -// import java.util.StringTokenizer; - - - - -class PropertySetHelper -{ - XPropertySet m_xPropertySet; - public PropertySetHelper(Object _aObj) - { - m_xPropertySet = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, _aObj); - } - - /** - get a property and don't convert it - @param _sName the string name of the property - @return the object value of the property without any conversion - */ - public Object getPropertyValueAsObject(String _sName) - { - Object aObject = null; - - if (m_xPropertySet != null) - { - try - { - aObject = m_xPropertySet.getPropertyValue(_sName); - } - catch (com.sun.star.beans.UnknownPropertyException e) - { - System.out.println("ERROR: UnknownPropertyException caught. '" + _sName + "'"); - System.out.println("Message: " + e.getMessage()); - } - catch (com.sun.star.lang.WrappedTargetException e) - { - System.out.println("ERROR: WrappedTargetException caught."); - System.out.println("Message: " + e.getMessage()); - } - } - return aObject; - } -} - -class PropertyHelper -{ - /** - Create a PropertyValue[] from a ArrayList - @param _aArrayList - @return a PropertyValue[] - */ - public static PropertyValue[] createPropertyValueArrayFormArrayList(ArrayList _aPropertyList) - { - // copy the whole PropertyValue List to an PropertyValue Array - PropertyValue[] aSaveProperties = null; - - if (_aPropertyList == null) - { - aSaveProperties = new PropertyValue[0]; - } - else - { - if (_aPropertyList.size() > 0) - { - aSaveProperties = new PropertyValue[_aPropertyList.size()]; - for (int i = 0;i<_aPropertyList.size(); i++) - { - aSaveProperties[i] = (PropertyValue) _aPropertyList.get(i); - } - } - else - { - aSaveProperties = new PropertyValue[0]; - } - } - return aSaveProperties; - } -} - -public class ReportDesignerTest extends ComplexTestCase { - - String mTestDocumentPath; - - public String[] getTestMethodNames() - { - return new String[] {"firsttest"}; - } - - private void checkIfOfficeExists(String _sOfficePathWithTrash) - { - String sOfficePath = ""; - int nIndex = _sOfficePathWithTrash.indexOf("soffice.exe"); - if (nIndex > 0) - { - sOfficePath = _sOfficePathWithTrash.substring(0, nIndex + 11); - } - else - { - nIndex = _sOfficePathWithTrash.indexOf("soffice"); - if (nIndex > 0) - { - sOfficePath = _sOfficePathWithTrash.substring(0, nIndex + 7); - } - } - - log.println(sOfficePath); - File sOffice = new File(sOfficePath); - if (! sOffice.exists()) - { - log.println("ERROR: There exists no office installation at given path: '" + sOfficePath + "'"); - System.exit(0); - } - } - - - private static XDesktop m_xDesktop = null; - public static XDesktop getXDesktop() - { - - if (m_xDesktop == null) - { - try - { - XInterface xInterface = (XInterface) m_xXMultiServiceFactory.createInstance( "com.sun.star.frame.Desktop" ); - m_xDesktop = (XDesktop) UnoRuntime.queryInterface(XDesktop.class, xInterface); - } - catch (com.sun.star.uno.Exception e) - { - log.println("ERROR: uno.Exception caught"); - log.println("Message: " + e.getMessage()); - } - } - return m_xDesktop; - } - - private void showElements(XNameAccess _xNameAccess) - { - if (_xNameAccess != null) - { - String[] sElementNames = _xNameAccess.getElementNames(); - for(int i=0;i -# for a copy of the LGPLv3 License. -# -#************************************************************************* - -PRJ=..$/.. - -PRJNAME = reportdesign -PACKAGE = complex -TARGET = rptdesigntest - -# --- Settings ----------------------------------------------------- - -.INCLUDE : settings.mk - -# --- Files -------------------------------------------------------- - -JARFILES = ridl.jar jurt.jar unoil.jar juh.jar OOoRunner.jar - -JAVAFILES = ReportDesignerTest.java - -# --- Targets ------------------------------------------------------ - -.INCLUDE : target.mk - -# JAVADEBUG=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=8502,suspend=y -JAVADEBUG= - -MYSQL_CONNECTOR=$(PWD)$/mysql-connector-java-5.0.6-bin.jar -CLASSPATH!:=$(CLASSPATH)$(PATH_SEPERATOR)$(MYSQL_CONNECTOR) - -run: ALLTAR - $(PERL) mysql-connector-exists.pl $(MYSQL_CONNECTOR) -# @echo $(CLASSPATH) -# @echo $(VCSID) - @java $(JAVADEBUG) -cp $(CLASSPATH) -DVCSID=$(VCSID) -DCWS_WORK_STAMP=$(CWS_WORK_STAMP) -DUPDMINOR=$(UPDMINOR) org.openoffice.Runner -ini runner.props diff --git a/reportdesign/qa/complex/mysql-connector-exists.pl b/reportdesign/qa/complex/mysql-connector-exists.pl deleted file mode 100644 index 6eefe2bb0639..000000000000 --- a/reportdesign/qa/complex/mysql-connector-exists.pl +++ /dev/null @@ -1,9 +0,0 @@ -eval 'exec perl -wS $0 ${1+\"$@\"}' - if 0; - -my $sMySQLConnector = $ARGV[0]; -if (! -e $sMySQLConnector) -{ - exit 1; -} -exit 0; diff --git a/reportdesign/qa/complex/reportdesign/FileURL.java b/reportdesign/qa/complex/reportdesign/FileURL.java new file mode 100644 index 000000000000..9d2cdb89bd0e --- /dev/null +++ b/reportdesign/qa/complex/reportdesign/FileURL.java @@ -0,0 +1,62 @@ +/* + * ************************************************************************ + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + * ************************************************************************ + */ + +package complex.reportdesign; + +import java.io.File; +import java.net.URI; +import java.net.URISyntaxException; + +/** + * + * @author ll93751 + */ +public class FileURL +{ + String m_sFileURL; + + public FileURL(String _sFileURL) + { + m_sFileURL = _sFileURL; + } + public boolean exists() + { + try + { + final URI aURI = new URI(m_sFileURL); + final File aFile = new File(aURI); + return aFile.exists(); + } + catch (URISyntaxException ex) + { + System.out.println("Error: URI is wrong. '" + m_sFileURL + "': " + ex.getMessage()); + } + return false; + } +} diff --git a/reportdesign/qa/complex/reportdesign/ReportDesignerTest.java b/reportdesign/qa/complex/reportdesign/ReportDesignerTest.java new file mode 100755 index 000000000000..d84675a64004 --- /dev/null +++ b/reportdesign/qa/complex/reportdesign/ReportDesignerTest.java @@ -0,0 +1,651 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package complex.reportdesign; + +import java.io.File; +import java.util.ArrayList; + +import com.sun.star.beans.PropertyValue; +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.XNameAccess; +import com.sun.star.frame.XComponentLoader; +import com.sun.star.frame.XDesktop; +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.XDocumentDataSource; +import com.sun.star.sdb.XOfficeDatabaseDocument; +import com.sun.star.sdb.XReportDocumentsSupplier; +import com.sun.star.sdb.application.XDatabaseDocumentUI; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.util.XCloseable; + +// import util.BasicMacroTools; +// import util.DesktopTools; +// import util.dbg; +// import complexlib.ComplexTestCase; +// import util.utils; +import helper.OfficeProvider; +import helper.URLHelper; +// import helper.OfficeWatcher; + +import convwatch.DB; + +// import java.util.Date; +// import java.text.SimpleDateFormat; +// import java.text.ParsePosition; +// import java.sql.Time; +// +// import java.io.BufferedReader; +// import java.io.File; +// import java.io.FileReader; +// import java.io.IOException; +// import java.io.FilenameFilter; +// +// import java.util.Vector; +// +// import helper.AppProvider; +// import java.text.DecimalFormat; +// import util.DynamicClassLoader; +// import java.util.StringTokenizer; + +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.openoffice.test.OfficeConnection; +import static org.junit.Assert.*; + + +class PropertySetHelper +{ + XPropertySet m_xPropertySet; + public PropertySetHelper(Object _aObj) + { + m_xPropertySet = UnoRuntime.queryInterface(XPropertySet.class, _aObj); + } + + /** + get a property and don't convert it + @param _sName the string name of the property + @return the object value of the property without any conversion + */ + public Object getPropertyValueAsObject(String _sName) + { + Object aObject = null; + + if (m_xPropertySet != null) + { + try + { + aObject = m_xPropertySet.getPropertyValue(_sName); + } + catch (com.sun.star.beans.UnknownPropertyException e) + { + System.out.println("ERROR: UnknownPropertyException caught. '" + _sName + "'"); + System.out.println("Message: " + e.getMessage()); + } + catch (com.sun.star.lang.WrappedTargetException e) + { + System.out.println("ERROR: WrappedTargetException caught."); + System.out.println("Message: " + e.getMessage()); + } + } + return aObject; + } +} + +class PropertyHelper +{ + /** + Create a PropertyValue[] from a ArrayList + @param _aArrayList + @return a PropertyValue[] + */ + public static PropertyValue[] createPropertyValueArrayFormArrayList(ArrayList _aPropertyList) + { + // copy the whole PropertyValue List to an PropertyValue Array + PropertyValue[] aSaveProperties = null; + + if (_aPropertyList == null) + { + aSaveProperties = new PropertyValue[0]; + } + else + { + if (_aPropertyList.size() > 0) + { + aSaveProperties = new PropertyValue[_aPropertyList.size()]; + for (int i = 0;i<_aPropertyList.size(); i++) + { + aSaveProperties[i] = (PropertyValue) _aPropertyList.get(i); + } + } + else + { + aSaveProperties = new PropertyValue[0]; + } + } + return aSaveProperties; + } +} + +public class ReportDesignerTest +{ + + String mTestDocumentPath; + +// public String[] getTestMethodNames() +// { +// return new String[] {"firsttest"}; +// } + + @Before public void before() + { + System.out.println("before"); + // String tempdir = System.getProperty("java.io.tmpdir"); + // + int dummy = 0; + // m_xXMultiServiceFactory = getMSF(); + } + + @After public void after() + { + System.out.println("after"); + } + +// private void checkIfOfficeExists(String _sOfficePathWithTrash) +// { +// String sOfficePath = ""; +// int nIndex = _sOfficePathWithTrash.indexOf("soffice.exe"); +// if (nIndex > 0) +// { +// sOfficePath = _sOfficePathWithTrash.substring(0, nIndex + 11); +// } +// else +// { +// nIndex = _sOfficePathWithTrash.indexOf("soffice"); +// if (nIndex > 0) +// { +// sOfficePath = _sOfficePathWithTrash.substring(0, nIndex + 7); +// } +// } +// +// System.out.println(sOfficePath); +// File sOffice = new File(sOfficePath); +// if (! sOffice.exists()) +// { +// System.out.println("ERROR: There exists no office installation at given path: '" + sOfficePath + "'"); +// System.exit(0); +// } +// } + + + private XDesktop m_xDesktop = null; + public XDesktop getXDesktop() + { + + if (m_xDesktop == null) + { + try + { + XInterface xInterface = (XInterface) getMSF().createInstance( "com.sun.star.frame.Desktop" ); + m_xDesktop = UnoRuntime.queryInterface(XDesktop.class, xInterface); + assertNotNull("Can't get XDesktop", m_xDesktop); + } + catch (com.sun.star.uno.Exception e) + { + System.out.println("ERROR: uno.Exception caught"); + System.out.println("Message: " + e.getMessage()); + } + } + return m_xDesktop; + } + + private void showElements(XNameAccess _xNameAccess) + { + if (_xNameAccess != null) + { + String[] sElementNames = _xNameAccess.getElementNames(); + for(int i=0;i aPropertyList = new ArrayList(); + + PropertyValue aActiveConnection = new PropertyValue(); + aActiveConnection.Name = "ActiveConnection"; + aActiveConnection.Value = aActiveConnectionObj; + aPropertyList.add(aActiveConnection); + + loadAndStoreReports(xNameAccess, aPropertyList, _nType); + createDBEntry(_nType); + } + catch(com.sun.star.uno.Exception e) + { + fail("ERROR: Exception caught" + e.getMessage()); + } + + // String mTestDocumentPath = (String) param.get("TestDocumentPath"); + // System.out.println("mTestDocumentPath: '" + mTestDocumentPath + "'"); + // // workaround for issue using deprecated "DOCPTH" prop + // System.setProperty("DOCPTH", mTestDocumentPath); + + // Close the document + closeComponent(xDocComponent); + } + + private String getDocumentPoolName(int _nType) + { + return getFileFormat(_nType); + } + +// ----------------------------------------------------------------------------- + private void createDBEntry(int _nType) + { + // try to connect the database + String sDBConnection = ""; // (String)param.get( convwatch.PropertyName.DB_CONNECTION_STRING ); + System.out.println("DBConnection: " + sDBConnection); + DB.init(sDBConnection); + String sDestinationVersion = m_sCWS_WORK_STAMP; + if (sDestinationVersion.length() == 0) + { + sDestinationVersion = m_sUPDMinor; + } + String sDestinationName = ""; + String sDestinationCreatorType = ""; + String sDocumentPoolDir = getOutputPath(_nType); + String sDocumentPoolName = getDocumentPoolName(_nType); + String sSpecial = ""; + + String sFixRefSubDirectory = "ReportDesign_qa_complex_" + getFileFormat(_nType); +// DB.insertinto_documentcompare(sFixRefSubDirectory, "", "fixref", +// sDestinationVersion, sDestinationName, sDestinationCreatorType, +// sDocumentPoolDir, sDocumentPoolName, m_sMailAddress, +// sSpecial); + // DB.test(); + // System.exit(1); + } + + private void loadAndStoreReports(XNameAccess _xNameAccess, ArrayList _aPropertyList, int _nType) + { + if (_xNameAccess != null) + { + String[] sElementNames = _xNameAccess.getElementNames(); + for(int i=0;i aPropertyList = new ArrayList(); // set some properties for storeAsURL + + PropertyValue aFileFormat = new PropertyValue(); + aFileFormat.Name = "FilterName"; + aFileFormat.Value = getFileFormat(_nType); + aPropertyList.add(aFileFormat); + + PropertyValue aOverwrite = new PropertyValue(); // always overwrite already exist files + aOverwrite.Name = "Overwrite"; + aOverwrite.Value = Boolean.TRUE; + aPropertyList.add(aOverwrite); + + // store the document in an other directory + XStorable aStorable = UnoRuntime.queryInterface(XStorable.class, _xComponent); + if (aStorable != null) + { + System.out.println("store document as URL: '" + sOutputURL + "'"); + try + { + aStorable.storeAsURL(sOutputURL, PropertyHelper.createPropertyValueArrayFormArrayList(aPropertyList)); + } + catch (com.sun.star.io.IOException e) + { + System.out.println("ERROR: Exception caught"); + System.out.println("Can't write document URL: '" + sOutputURL + "'"); + System.out.println("Message: " + e.getMessage()); + } + } + } + + private XComponent loadComponent(String _sName, Object _xComponent, ArrayList _aPropertyList) + { + XComponent xDocComponent = null; + XComponentLoader xComponentLoader = UnoRuntime.queryInterface(XComponentLoader.class, _xComponent); + + try + { + PropertyValue[] aLoadProperties = PropertyHelper.createPropertyValueArrayFormArrayList(_aPropertyList); + System.out.println("Load component: '" + _sName + "'"); + xDocComponent = xComponentLoader.loadComponentFromURL(_sName, "_blank", 0, aLoadProperties); + } + catch (com.sun.star.io.IOException e) + { + System.out.println("ERROR: Exception caught"); + System.out.println("Can't load document '" + _sName + "'"); + System.out.println("Message: " + e.getMessage()); + } + catch (com.sun.star.lang.IllegalArgumentException e) + { + System.out.println("ERROR: Exception caught"); + System.out.println("Illegal Arguments given to loadComponentFromURL."); + System.out.println("Message: " + e.getMessage()); + } + return xDocComponent; + } + + private void closeComponent(XComponent _xDoc) + { + // Close the document + XCloseable xCloseable = UnoRuntime.queryInterface(XCloseable.class, _xDoc); + try + { + xCloseable.close(true); + } + catch (com.sun.star.util.CloseVetoException e) + { + System.out.println("ERROR: CloseVetoException caught"); + System.out.println("CloseVetoException occured Can't close document."); + System.out.println("Message: " + e.getMessage()); + } + } + + + private XMultiServiceFactory getMSF() + { + final XMultiServiceFactory xMSF1 = UnoRuntime.queryInterface(XMultiServiceFactory.class, connection.getComponentContext().getServiceManager()); + return xMSF1; + } + + // setup and close connections + @BeforeClass public static void setUpConnection() throws Exception { + System.out.println("setUpConnection()"); + connection.setUp(); + } + + @AfterClass public static void tearDownConnection() + throws InterruptedException, com.sun.star.uno.Exception + { + System.out.println("tearDownConnection()"); + connection.tearDown(); + } + + private static final OfficeConnection connection = new OfficeConnection(); + +} diff --git a/reportdesign/qa/complex/reportdesign/TestDocument.java b/reportdesign/qa/complex/reportdesign/TestDocument.java new file mode 100644 index 000000000000..a6e294d4d3ec --- /dev/null +++ b/reportdesign/qa/complex/reportdesign/TestDocument.java @@ -0,0 +1,41 @@ +/************************************************************************* +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2010 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* +* for a copy of the LGPLv3 License. +* +************************************************************************/ + +package complex.reportdesign; + +import java.io.File; +import org.openoffice.test.OfficeFileUrl; + +final class TestDocument +{ + public static String getUrl(String name) + { + return OfficeFileUrl.getAbsolute(new File("test_documents", name)); + } + + private TestDocument() {} +} diff --git a/reportdesign/qa/complex/reportdesign/makefile.mk b/reportdesign/qa/complex/reportdesign/makefile.mk new file mode 100755 index 000000000000..68140b184bde --- /dev/null +++ b/reportdesign/qa/complex/reportdesign/makefile.mk @@ -0,0 +1,66 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +.IF "$(OOO_SUBSEQUENT_TESTS)" == "" +nothing .PHONY: + @echo "OOO_SUBSEQUENT_TESTS not set, do nothing." +.ELSE + +PRJ = ../../.. +PRJNAME = reportdesign +TARGET = qa_complex_reportdesign + +.IF "$(OOO_JUNIT_JAR)" != "" +PACKAGE = complex/reportdesign + +# here store only Files which contain a @Test +JAVATESTFILES = \ + ReportDesignerTest.java + +# put here all other files +JAVAFILES = $(JAVATESTFILES) \ + TestDocument.java \ + FileURL.java + +JARFILES = OOoRunner.jar ridl.jar test.jar unoil.jar +EXTRAJARFILES = $(OOO_JUNIT_JAR) + +# subdirectories +# SUBDIRS = helper + +# Sample how to debug +JAVAIFLAGS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=9003,suspend=y + +.END + +.INCLUDE: settings.mk +.INCLUDE: target.mk +.INCLUDE: installationtest.mk + +ALLTAR : javatest + +.END diff --git a/reportdesign/qa/complex/reportdesign/mysql-connector-exists.pl b/reportdesign/qa/complex/reportdesign/mysql-connector-exists.pl new file mode 100644 index 000000000000..6eefe2bb0639 --- /dev/null +++ b/reportdesign/qa/complex/reportdesign/mysql-connector-exists.pl @@ -0,0 +1,9 @@ +eval 'exec perl -wS $0 ${1+\"$@\"}' + if 0; + +my $sMySQLConnector = $ARGV[0]; +if (! -e $sMySQLConnector) +{ + exit 1; +} +exit 0; diff --git a/reportdesign/qa/complex/reportdesign/runner.props b/reportdesign/qa/complex/reportdesign/runner.props new file mode 100755 index 000000000000..d894366ce006 --- /dev/null +++ b/reportdesign/qa/complex/reportdesign/runner.props @@ -0,0 +1,22 @@ +# where to store created documents +wntmsci.DOC_COMPARATOR_OUTPUT_PATH=\\\\so-gfxcmp-lin\\doc-pool\\reporttest +unxlngi.DOC_COMPARATOR_OUTPUT_PATH=/net/so-gfxcmp-lin/export/gfxcmp/document-pool/reporttest + +DB_CONNECTION_STRING=server:jakobus,db:jobs_convwatch,user:admin,passwd:admin + +# Set path to an existing office installation +wntmsci.AppExecutionCommand=C:\\home\\${USERNAME}\\staroffice8\\program\\soffice.exe -norestore -nocrashreport -accept=socket,host=localhost,port=8100;urp; +unxlngi.AppExecutionCommand=/opt/staroffice8/program/soffice -norestore -nocrashreport -accept=socket,host=localhost,port=8100;urp; + +# Set the 'Continue' Property to true, to leave out already done tests. +Continue=true + +TestBase=java_complex +TestJob=-o complex.ReportDesignerTest +DebugIsActive=true +ThreadTimeOut=400000 +SingleTimeOut=300000 + +# don't start office automatically +NoOffice=true + diff --git a/reportdesign/qa/complex/reportdesign/test_documents/RPTCalcTests.odb b/reportdesign/qa/complex/reportdesign/test_documents/RPTCalcTests.odb new file mode 100755 index 000000000000..0e91d633d4e7 Binary files /dev/null and b/reportdesign/qa/complex/reportdesign/test_documents/RPTCalcTests.odb differ diff --git a/reportdesign/qa/complex/reportdesign/test_documents/RPTWriterTests.odb b/reportdesign/qa/complex/reportdesign/test_documents/RPTWriterTests.odb new file mode 100755 index 000000000000..7099b1abf2b5 Binary files /dev/null and b/reportdesign/qa/complex/reportdesign/test_documents/RPTWriterTests.odb differ diff --git a/reportdesign/qa/complex/runner.props b/reportdesign/qa/complex/runner.props deleted file mode 100755 index d894366ce006..000000000000 --- a/reportdesign/qa/complex/runner.props +++ /dev/null @@ -1,22 +0,0 @@ -# where to store created documents -wntmsci.DOC_COMPARATOR_OUTPUT_PATH=\\\\so-gfxcmp-lin\\doc-pool\\reporttest -unxlngi.DOC_COMPARATOR_OUTPUT_PATH=/net/so-gfxcmp-lin/export/gfxcmp/document-pool/reporttest - -DB_CONNECTION_STRING=server:jakobus,db:jobs_convwatch,user:admin,passwd:admin - -# Set path to an existing office installation -wntmsci.AppExecutionCommand=C:\\home\\${USERNAME}\\staroffice8\\program\\soffice.exe -norestore -nocrashreport -accept=socket,host=localhost,port=8100;urp; -unxlngi.AppExecutionCommand=/opt/staroffice8/program/soffice -norestore -nocrashreport -accept=socket,host=localhost,port=8100;urp; - -# Set the 'Continue' Property to true, to leave out already done tests. -Continue=true - -TestBase=java_complex -TestJob=-o complex.ReportDesignerTest -DebugIsActive=true -ThreadTimeOut=400000 -SingleTimeOut=300000 - -# don't start office automatically -NoOffice=true - -- cgit From ab61fd887a083bd8837a82e98dfd60376e0f29c1 Mon Sep 17 00:00:00 2001 From: Lars Langhans Date: Fri, 18 Jun 2010 10:12:37 +0200 Subject: sb123:#i111449# cleanups in reportdesign qa/complex tests --- reportdesign/qa/complex/reportdesign/ReportDesignerTest.java | 1 + 1 file changed, 1 insertion(+) diff --git a/reportdesign/qa/complex/reportdesign/ReportDesignerTest.java b/reportdesign/qa/complex/reportdesign/ReportDesignerTest.java index d84675a64004..346c28569929 100755 --- a/reportdesign/qa/complex/reportdesign/ReportDesignerTest.java +++ b/reportdesign/qa/complex/reportdesign/ReportDesignerTest.java @@ -384,6 +384,7 @@ public class ReportDesignerTest XDatabaseDocumentUI aDBDocUI = UnoRuntime.queryInterface(XDatabaseDocumentUI.class, aController); /* boolean isConnect = */ +// TODO: throws an exception in DEV300m78 aDBDocUI.connect(); // if (isConnect) // { -- cgit From 15642a2f8d17997b3c051a9b0587f523cba83e86 Mon Sep 17 00:00:00 2001 From: Lars Langhans Date: Mon, 21 Jun 2010 11:12:24 +0200 Subject: sb123:#i111449# cleanups in reportdesign qa/complex tests --- reportdesign/prj/build.lst | 2 +- reportdesign/qa/complex/reportdesign/makefile.mk | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/reportdesign/prj/build.lst b/reportdesign/prj/build.lst index dff79ac79c3d..aa73b032fafa 100644 --- a/reportdesign/prj/build.lst +++ b/reportdesign/prj/build.lst @@ -13,6 +13,6 @@ rd reportdesign\source\ui\inspection nmake rd reportdesign\source\filter\xml nmake - all rd_filter_xml rd_inc NULL rd reportdesign\util nmake - all rd_util rd_api rd_res rd_shared rd_uimisc rd_uidlg rd_uireport rd_uiinspection rd_sdr rd_misc rd_filter_xml NULL -# has problems im m78 +# has problems in m78, in m83 also # rd reportdesign\qa\complex\reportdesign nmake - all rd_qa_complex NULL diff --git a/reportdesign/qa/complex/reportdesign/makefile.mk b/reportdesign/qa/complex/reportdesign/makefile.mk index 68140b184bde..261077caed68 100755 --- a/reportdesign/qa/complex/reportdesign/makefile.mk +++ b/reportdesign/qa/complex/reportdesign/makefile.mk @@ -53,7 +53,7 @@ EXTRAJARFILES = $(OOO_JUNIT_JAR) # SUBDIRS = helper # Sample how to debug -JAVAIFLAGS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=9003,suspend=y +# JAVAIFLAGS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=9003,suspend=y .END -- cgit From 3f37bd9ce3a9924f518fdc4e108d1f8074e9532b Mon Sep 17 00:00:00 2001 From: Lars Langhans Date: Mon, 21 Jun 2010 13:55:36 +0200 Subject: sb123:#i111449# cleanups in dbaccess for qa/complex tests --- .../qa/complex/dbaccess/ApplicationController.java | 49 ++-- dbaccess/qa/complex/dbaccess/Beamer.java | 126 +++++----- dbaccess/qa/complex/dbaccess/CRMBasedTestCase.java | 24 +- dbaccess/qa/complex/dbaccess/CopyTableWizard.java | 58 +++-- dbaccess/qa/complex/dbaccess/DataSource.java | 72 +++--- .../qa/complex/dbaccess/DatabaseApplication.java | 11 +- dbaccess/qa/complex/dbaccess/DatabaseDocument.java | 261 ++++++++++----------- dbaccess/qa/complex/dbaccess/Parser.java | 59 +++-- dbaccess/qa/complex/dbaccess/PropertyBag.java | 130 ++++++---- dbaccess/qa/complex/dbaccess/Query.java | 52 ++-- dbaccess/qa/complex/dbaccess/QueryInQuery.java | 72 +++--- dbaccess/qa/complex/dbaccess/RowSet.java | 220 ++++++++--------- .../dbaccess/SingleSelectQueryComposer.java | 136 ++++++----- dbaccess/qa/complex/dbaccess/TestCase.java | 65 +++-- dbaccess/qa/complex/dbaccess/UISettings.java | 58 +++-- dbaccess/qa/complex/dbaccess/makefile.mk | 147 ++++++++---- 16 files changed, 862 insertions(+), 678 deletions(-) mode change 100755 => 100644 dbaccess/qa/complex/dbaccess/CopyTableWizard.java mode change 100755 => 100644 dbaccess/qa/complex/dbaccess/DatabaseApplication.java diff --git a/dbaccess/qa/complex/dbaccess/ApplicationController.java b/dbaccess/qa/complex/dbaccess/ApplicationController.java index 4c964e82dc06..bffc1ce97c4c 100644 --- a/dbaccess/qa/complex/dbaccess/ApplicationController.java +++ b/dbaccess/qa/complex/dbaccess/ApplicationController.java @@ -48,6 +48,17 @@ import helper.URLHelper; import java.io.File; import java.io.IOException; + +// ---------- junit imports ----------------- +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.openoffice.test.OfficeConnection; +import static org.junit.Assert.*; +// ------------------------------------------ + /** complex test case for Base's application UI */ public class ApplicationController extends TestCase @@ -64,13 +75,13 @@ public class ApplicationController extends TestCase // -------------------------------------------------------------------------------------------------------- - public String[] getTestMethodNames() - { - return new String[] - { - "checkSaveAs" - }; - } +// public String[] getTestMethodNames() +// { +// return new String[] +// { +// "checkSaveAs" +// }; +// } // -------------------------------------------------------------------------------------------------------- public String getTestObjectName() @@ -98,16 +109,16 @@ public class ApplicationController extends TestCase // create/load the new database document m_database = (_documentURL == null) - ? new HsqlDatabase(getORB()) - : new HsqlDatabase(getORB(), _documentURL); + ? new HsqlDatabase(getMSF()) + : new HsqlDatabase(getMSF(), _documentURL); m_databaseDocument = m_database.getDatabaseDocument(); // load it into a frame - final Object object = getORB().createInstance("com.sun.star.frame.Desktop"); + final Object object = getMSF().createInstance("com.sun.star.frame.Desktop"); final XComponentLoader xComponentLoader = UnoRuntime.queryInterface(XComponentLoader.class, object); final XComponent loadedComponent = xComponentLoader.loadComponentFromURL(m_database.getDocumentURL(), "_blank", FrameSearchFlag.ALL, new PropertyValue[0]); - assure("too many document instances!", + assertTrue("too many document instances!", UnoRuntime.areSame(loadedComponent, m_databaseDocument)); // get the controller, which provides access to various UI operations @@ -118,21 +129,21 @@ public class ApplicationController extends TestCase } // -------------------------------------------------------------------------------------------------------- - public void before() throws java.lang.Exception + @Before public void before() throws java.lang.Exception { super.before(); impl_switchToDocument(null); } // -------------------------------------------------------------------------------------------------------- - public void after() throws java.lang.Exception + @After public void after() throws java.lang.Exception { impl_closeDocument(); super.after(); } // -------------------------------------------------------------------------------------------------------- - public void checkSaveAs() throws Exception, IOException, java.lang.Exception + @Test 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 @@ -146,7 +157,7 @@ public class ApplicationController extends TestCase // connect m_documentUI.connect(); - assure("could not connect to " + m_database.getDocumentURL(), m_documentUI.isConnected()); + assertTrue("could not connect to " + m_database.getDocumentURL(), m_documentUI.isConnected()); // create a table in the database m_database.createTable(new HsqlTableDescriptor("abc", new HsqlColumnDescriptor[] @@ -159,18 +170,18 @@ public class ApplicationController extends TestCase // load the old document, and verify there is *no* table therein impl_switchToDocument(oldDocumentURL); m_documentUI.connect(); - assure("could not connect to " + m_database.getDocumentURL(), m_documentUI.isConnected()); + assertTrue("could not connect to " + m_database.getDocumentURL(), m_documentUI.isConnected()); XTablesSupplier suppTables = UnoRuntime.queryInterface( XTablesSupplier.class, m_documentUI.getActiveConnection() ); XNameAccess tables = suppTables.getTables(); - assure("the table was created in the wrong database", !tables.hasByName("abc")); + assertTrue("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); m_documentUI.connect(); - assure("could not connect to " + m_database.getDocumentURL(), m_documentUI.isConnected()); + assertTrue("could not connect to " + m_database.getDocumentURL(), m_documentUI.isConnected()); suppTables = UnoRuntime.queryInterface( XTablesSupplier.class, m_documentUI.getActiveConnection() ); tables = suppTables.getTables(); - assure("the newly created table has not been written", tables.hasByName("abc")); + assertTrue("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 index 909bf39d1707..2b77e21b9d60 100644 --- a/dbaccess/qa/complex/dbaccess/Beamer.java +++ b/dbaccess/qa/complex/dbaccess/Beamer.java @@ -28,10 +28,8 @@ 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; @@ -39,34 +37,30 @@ 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; + + +// ---------- junit imports ----------------- +import org.junit.After; +// import org.junit.AfterClass; +import org.junit.Before; +// import org.junit.BeforeClass; +import org.junit.Test; +// import org.openoffice.test.OfficeConnection; +import static org.junit.Assert.*; +// ------------------------------------------ + /** complex test case for Base's application UI */ -public class Beamer extends complexlib.ComplexTestCase +public class Beamer extends TestCase { private XModel docModel; @@ -76,43 +70,43 @@ public class Beamer extends complexlib.ComplexTestCase 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; - } +// // -------------------------------------------------------------------------------------------------------- +// 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[] getTestMethodNames() +// { +// return new String[] +// { +// "testBeamer" +// }; +// } - // -------------------------------------------------------------------------------------------------------- - public String getTestObjectName() - { - return getClass().getName(); - } +// // -------------------------------------------------------------------------------------------------------- +// public String getTestObjectName() +// { +// return getClass().getName(); +// } // -------------------------------------------------------------------------------------------------------- - protected final XMultiServiceFactory getORB() - { - return (XMultiServiceFactory) param.getMSF(); - } +// protected final XMultiServiceFactory getORB() +// { +// return (XMultiServiceFactory) param.getMSF(); +// } // -------------------------------------------------------------------------------------------------------- private void impl_closeDocument() @@ -120,40 +114,40 @@ public class Beamer extends complexlib.ComplexTestCase } // -------------------------------------------------------------------------------------------------------- - public void before() throws Exception, java.lang.Exception + @Before 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 Object object = getMSF().createInstance("com.sun.star.frame.Desktop"); + final 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); + docModel = UnoRuntime.queryInterface(XModel.class, loadedComponent); } // -------------------------------------------------------------------------------------------------------- - public void after() + @After public void after() { } // -------------------------------------------------------------------------------------------------------- - public void testBeamer() throws Exception, IOException, java.lang.Exception + @Test 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); + final XDispatchProvider dispatchP = 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); + Object instance = getMSF().createInstance("com.sun.star.util.URLTransformer"); + XURLTransformer atrans = 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); + assertNotNull(dispatch); dispatch.dispatch(command, new PropertyValue[0]); final PropertyValue[] props = new PropertyValue[] @@ -164,8 +158,8 @@ public class Beamer extends complexlib.ComplexTestCase }; 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")); + assertNotNull(beamer); + final XEnumerationAccess evtBc = UnoRuntime.queryInterface(XEnumerationAccess.class, getMSF().createInstance("com.sun.star.frame.GlobalEventBroadcaster")); XEnumeration enumeration = evtBc.createEnumeration(); int count = -1; while (enumeration.hasMoreElements()) @@ -173,9 +167,9 @@ public class Beamer extends complexlib.ComplexTestCase enumeration.nextElement(); ++count; } - final XSelectionSupplier selSup = (XSelectionSupplier)UnoRuntime.queryInterface(XSelectionSupplier.class, beamer.getController()); + final XSelectionSupplier selSup = 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); + final com.sun.star.util.XCloseable close = UnoRuntime.queryInterface(com.sun.star.util.XCloseable.class, frame); close.close(false); enumeration = evtBc.createEnumeration(); @@ -186,6 +180,6 @@ public class Beamer extends complexlib.ComplexTestCase ++count2; } - assure("count1 = " + count + " count2 = " + count2, count == count2); + assertTrue("count1 = " + count + " count2 = " + count2, count == count2); } } diff --git a/dbaccess/qa/complex/dbaccess/CRMBasedTestCase.java b/dbaccess/qa/complex/dbaccess/CRMBasedTestCase.java index 3bba8fa45001..ff89c755a90f 100644 --- a/dbaccess/qa/complex/dbaccess/CRMBasedTestCase.java +++ b/dbaccess/qa/complex/dbaccess/CRMBasedTestCase.java @@ -26,13 +26,21 @@ ************************************************************************/ package complex.dbaccess; -import com.sun.star.lang.XMultiServiceFactory; import com.sun.star.sdb.XSingleSelectQueryComposer; -import com.sun.star.uno.UnoRuntime; import connectivity.tools.CRMDatabase; import java.util.logging.Level; import java.util.logging.Logger; +// ---------- junit imports ----------------- +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.openoffice.test.OfficeConnection; +import static org.junit.Assert.*; +// ------------------------------------------ + public abstract class CRMBasedTestCase extends TestCase { protected CRMDatabase m_database; @@ -42,30 +50,30 @@ public abstract class CRMBasedTestCase extends TestCase { try { - m_database = new CRMDatabase( getORB(), false ); + m_database = new CRMDatabase( getMSF(), false ); } catch ( Exception e ) { e.printStackTrace( System.err ); - assure( "caught an exception (" + e.getMessage() + ") while creating the test case", false ); + fail( "caught an exception (" + e.getMessage() + ") while creating the test case"); } } // -------------------------------------------------------------------------------------------------------- - @Override - public void before() + @Before public void before() { createTestCase(); } // -------------------------------------------------------------------------------------------------------- - @Override - public void after() + @After public void after() { try { if ( m_database != null ) + { m_database.saveAndClose(); + } } catch ( Exception ex ) { diff --git a/dbaccess/qa/complex/dbaccess/CopyTableWizard.java b/dbaccess/qa/complex/dbaccess/CopyTableWizard.java old mode 100755 new mode 100644 index 7c3db7f6020d..89fc56253ed0 --- a/dbaccess/qa/complex/dbaccess/CopyTableWizard.java +++ b/dbaccess/qa/complex/dbaccess/CopyTableWizard.java @@ -46,6 +46,16 @@ import connectivity.tools.DbaseDatabase; import java.io.IOException; import util.UITools; +// ---------- junit imports ----------------- +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.openoffice.test.OfficeConnection; +import static org.junit.Assert.*; +// ------------------------------------------ + /** complex test case for Base's application UI */ public class CopyTableWizard extends CRMBasedTestCase @@ -60,42 +70,40 @@ public class CopyTableWizard extends CRMBasedTestCase } // -------------------------------------------------------------------------------------------------------- - public String[] getTestMethodNames() - { - return new String[] - { - "copyTable", "copyTableDbase" - }; - } +// public String[] getTestMethodNames() +// { +// return new String[] +// { +// "copyTable", "copyTableDbase" +// }; +// } // -------------------------------------------------------------------------------------------------------- - @Override - public String getTestObjectName() - { - return getClass().getName(); - } +// @Override +// public String getTestObjectName() +// { +// return getClass().getName(); +// } // -------------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------------- - @Override - public void after() + @After public void after() { dest.store(); super.after(); } - @Override - public void before() + @Before public void before() { try { createTestCase(); source = new DatabaseApplication(this.m_database.getDatabase()); - dest = new DatabaseApplication(new DbaseDatabase(getORB())); + dest = new DatabaseApplication(new DbaseDatabase(getMSF())); } catch (java.lang.Exception ex) { - assure(false); + fail(""); } } // -------------------------------------------------------------------------------------------------------- @@ -123,7 +131,7 @@ public class CopyTableWizard extends CRMBasedTestCase Object toolKit = null; try { - toolKit = getORB().createInstance("com.sun.star.awt.Toolkit"); + toolKit = getMSF().createInstance("com.sun.star.awt.Toolkit"); } catch (com.sun.star.uno.Exception e) { @@ -135,21 +143,21 @@ public class CopyTableWizard extends CRMBasedTestCase return (XWindow) UnoRuntime.queryInterface(XWindow.class, atw); } - public void copyTable() throws Exception, IOException, java.lang.Exception + @Test public void copyTable() throws Exception, IOException, java.lang.Exception { copyTable(source,source); } - public void copyTableDbase() throws Exception, IOException, java.lang.Exception + @Test 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 + private 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 XTablesSupplier suppTables = UnoRuntime.queryInterface(XTablesSupplier.class, sourceConnection); final XNameAccess tables = suppTables.getTables(); final String[] names = tables.getElementNames(); @@ -161,7 +169,7 @@ public class CopyTableWizard extends CRMBasedTestCase public void assure(final String message) { - assure(message, false); + fail(message); } private void copyTable(final String tableName, final XConnection sourceConnection, final XConnection destConnection) throws Exception, IOException, java.lang.Exception @@ -194,7 +202,7 @@ public class CopyTableWizard extends CRMBasedTestCase try { final XWindow dialog = getActiveWindow(); - final UITools uiTools = new UITools(getORB(), dialog); + final UITools uiTools = new UITools(getMSF(), dialog); final XAccessible root = uiTools.getRoot(); final XAccessibleContext accContext = root.getAccessibleContext(); final int count = accContext.getAccessibleChildCount(); diff --git a/dbaccess/qa/complex/dbaccess/DataSource.java b/dbaccess/qa/complex/dbaccess/DataSource.java index f74d5af8d8f0..ce1e6db28e99 100644 --- a/dbaccess/qa/complex/dbaccess/DataSource.java +++ b/dbaccess/qa/complex/dbaccess/DataSource.java @@ -30,32 +30,43 @@ 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 complexlib.ComplexTestCase; import connectivity.tools.CRMDatabase; import connectivity.tools.HsqlDatabase; -import java.util.logging.Level; -import java.util.logging.Logger; +//import java.util.logging.Level; +//import java.util.logging.Logger; -public class DataSource extends ComplexTestCase +// ---------- junit imports ----------------- +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.openoffice.test.OfficeConnection; +import static org.junit.Assert.*; +// ------------------------------------------ + + +public class DataSource extends TestCase { HsqlDatabase m_database; connectivity.tools.DataSource m_dataSource; // -------------------------------------------------------------------------------------------------------- - public String[] getTestMethodNames() - { - return new String[] - { - "testRegistrationName" - }; - } - - // -------------------------------------------------------------------------------------------------------- - public String getTestObjectName() - { - return "DataSource"; - } +// public String[] getTestMethodNames() +// { +// return new String[] +// { +// "testRegistrationName" +// }; +// } +// +// // -------------------------------------------------------------------------------------------------------- +// public String getTestObjectName() +// { +// return "DataSource"; +// } // -------------------------------------------------------------------------------------------------------- private void createTestCase() @@ -64,47 +75,48 @@ public class DataSource extends ComplexTestCase { if (m_database == null) { - final CRMDatabase database = new CRMDatabase( getFactory(), false ); + final CRMDatabase database = new CRMDatabase( getMSF(), false ); m_database = database.getDatabase(); m_dataSource = m_database.getDataSource(); } } catch (Exception e) { - failed("could not create the test case, error message:\n" + e.getMessage()); + fail("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()); + fail("could not create the test case, error message:\n" + e.getMessage()); } } // -------------------------------------------------------------------------------------------------------- - private XMultiServiceFactory getFactory() - { - return (XMultiServiceFactory) param.getMSF(); - } +// private XMultiServiceFactory getFactory() +// { +// return (XMultiServiceFactory) param.getMSF(); +// } // -------------------------------------------------------------------------------------------------------- - public void testRegistrationName() + @Test public void testRegistrationName() { try { createTestCase(); // 1. check the existing "Bibliography" data source whether it has the proper name String dataSourceName = "Bibliography"; - final 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(getMSF(), dataSourceName); + assertEquals("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"; final XNamingService dataSourceRegistrations = (XNamingService) UnoRuntime.queryInterface( - XNamingService.class, getFactory().createInstance("com.sun.star.sdb.DatabaseContext")); + XNamingService.class, getMSF().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()); + assertEquals("registration name of a newly registered data source is wrong", dataSourceName, m_dataSource.getName()); } catch (Exception ex) { - Logger.getLogger(DataSource.class.getName()).log(Level.SEVERE, null, ex); + // Logger.getLogger(DataSource.class.getName()).log(Level.SEVERE, null, ex); + fail(); } } } diff --git a/dbaccess/qa/complex/dbaccess/DatabaseApplication.java b/dbaccess/qa/complex/dbaccess/DatabaseApplication.java old mode 100755 new mode 100644 index d6bfa804eafa..0941bd318d47 --- a/dbaccess/qa/complex/dbaccess/DatabaseApplication.java +++ b/dbaccess/qa/complex/dbaccess/DatabaseApplication.java @@ -56,14 +56,12 @@ public class DatabaseApplication // 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 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()); + final XModel docModel = UnoRuntime.queryInterface(XModel.class, loadedComponent); + documentUI = UnoRuntime.queryInterface(XDatabaseDocumentUI.class, docModel.getCurrentController()); documentUI.connect(); } @@ -87,8 +85,7 @@ public class DatabaseApplication // store the doc in a new location try { - final XStorable storeDoc = (XStorable) UnoRuntime.queryInterface(XStorable.class, - databaseDocument); + final XStorable storeDoc = UnoRuntime.queryInterface(XStorable.class, databaseDocument); if (storeDoc != null) { storeDoc.store(); diff --git a/dbaccess/qa/complex/dbaccess/DatabaseDocument.java b/dbaccess/qa/complex/dbaccess/DatabaseDocument.java index 02fb820f3fd4..757ae2de22d5 100644 --- a/dbaccess/qa/complex/dbaccess/DatabaseDocument.java +++ b/dbaccess/qa/complex/dbaccess/DatabaseDocument.java @@ -33,7 +33,7 @@ import com.sun.star.lang.XEventListener; import com.sun.star.lang.XMultiServiceFactory; import com.sun.star.script.XStorageBasedLibraryContainer; import com.sun.star.task.XInteractionRequest; -import com.sun.star.uno.Exception; + import com.sun.star.uno.Type; import com.sun.star.uno.UnoRuntime; import com.sun.star.frame.XStorable; @@ -45,7 +45,6 @@ import com.sun.star.document.XDocumentEventBroadcaster; import com.sun.star.document.XDocumentEventListener; import com.sun.star.document.XEmbeddedScripts; import com.sun.star.document.XEventsSupplier; -import com.sun.star.frame.DoubleInitializationException; import com.sun.star.lang.XComponent; import com.sun.star.frame.XComponentLoader; import com.sun.star.frame.XDispatch; @@ -56,13 +55,12 @@ import com.sun.star.frame.XModel; import com.sun.star.frame.XModel2; import com.sun.star.frame.XTitle; import com.sun.star.lang.EventObject; -import com.sun.star.lang.NotInitializedException; import com.sun.star.lang.XServiceInfo; import com.sun.star.lang.XSingleComponentFactory; import com.sun.star.lang.XTypeProvider; import com.sun.star.script.provider.XScriptProviderSupplier; import com.sun.star.sdb.XDocumentDataSource; -import com.sun.star.sdbc.XDataSource; + import com.sun.star.sdb.XFormDocumentsSupplier; import com.sun.star.sdb.XOfficeDatabaseDocument; import com.sun.star.sdb.XReportDocumentsSupplier; @@ -83,6 +81,16 @@ import java.util.ArrayList; import java.util.logging.Level; import java.util.logging.Logger; +// ---------- junit imports ----------------- +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.openoffice.test.OfficeConnection; +import static org.junit.Assert.*; +// ------------------------------------------ + public class DatabaseDocument extends TestCase implements com.sun.star.document.XDocumentEventListener { @@ -145,12 +153,12 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document. private final ArrayList m_eventListeners = new ArrayList(); - public Object createInstanceWithContext(XComponentContext _context) throws Exception + public Object createInstanceWithContext(XComponentContext _context) throws com.sun.star.uno.Exception { return new CallbackComponent(); } - public Object createInstanceWithArgumentsAndContext(Object[] arg0, XComponentContext _context) throws Exception + public Object createInstanceWithArgumentsAndContext(Object[] arg0, XComponentContext _context) throws com.sun.star.uno.Exception { return createInstanceWithContext(_context); } @@ -209,8 +217,7 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document. { try { - m_defaultHandler = (XInteractionHandler) UnoRuntime.queryInterface(XInteractionHandler.class, - _factory.createInstance("com.sun.star.task.InteractionHandler")); + m_defaultHandler = UnoRuntime.queryInterface(XInteractionHandler.class, _factory.createInstance("com.sun.star.task.InteractionHandler")); } catch (Exception ex) { @@ -227,14 +234,13 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document. return; } - assureEquals("interaction handleer called in wrong state", STATE_LOADING_DOC, m_loadDocState); + assertEquals("interaction handleer called in wrong state", STATE_LOADING_DOC, m_loadDocState); // auto-approve final XInteractionContinuation continuations[] = _request.getContinuations(); for (int i = 0; i < continuations.length; ++i) { - final XInteractionApprove approve = (XInteractionApprove) UnoRuntime.queryInterface(XInteractionApprove.class, - continuations[i]); + final XInteractionApprove approve = UnoRuntime.queryInterface(XInteractionApprove.class, continuations[i]); if (approve != null) { approve.select(); @@ -247,25 +253,25 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document. // ======================================================================================================== // -------------------------------------------------------------------------------------------------------- - public String[] getTestMethodNames() - { - return new String[] - { - "testLoadable", - "testDocumentRevenants", - "testDocumentEvents", - "testGlobalEvents" - }; - } +// public String[] getTestMethodNames() +// { +// return new String[] +// { +// "testLoadable", +// "testDocumentRevenants", +// "testDocumentEvents", +// "testGlobalEvents" +// }; +// } +// +// // -------------------------------------------------------------------------------------------------------- +// public String getTestObjectName() +// { +// return "DatabaseDocument"; +// } // -------------------------------------------------------------------------------------------------------- - public String getTestObjectName() - { - return "DatabaseDocument"; - } - - // -------------------------------------------------------------------------------------------------------- - public void before() throws java.lang.Exception + @Before public void before() throws java.lang.Exception { super.before(); @@ -274,26 +280,24 @@ 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 - final XSet globalFactory = (XSet) UnoRuntime.queryInterface( - XSet.class, getORB()); + final XSet globalFactory = UnoRuntime.queryInterface(XSet.class, getMSF()); m_callbackFactory = new CallbackComponentFactory(); globalFactory.insert(m_callbackFactory); // register ourself as listener at the global event broadcaster - final XDocumentEventBroadcaster broadcaster = (XDocumentEventBroadcaster) UnoRuntime.queryInterface( - XDocumentEventBroadcaster.class, getORB().createInstance("com.sun.star.frame.GlobalEventBroadcaster")); + final XDocumentEventBroadcaster broadcaster = UnoRuntime.queryInterface(XDocumentEventBroadcaster.class, getMSF().createInstance("com.sun.star.frame.GlobalEventBroadcaster")); broadcaster.addDocumentEventListener(this); } catch (Exception e) { - log.println("could not create the test case, error message:\n" + e.getMessage()); + System.out.println("could not create the test case, error message:\n" + e.getMessage()); e.printStackTrace(System.err); - failed("failed to create the test case"); + fail("failed to create the test case"); } } // -------------------------------------------------------------------------------------------------------- - public void after() throws java.lang.Exception + @After public void after() throws java.lang.Exception { try { @@ -302,15 +306,14 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document. m_callbackFactory.dispose(); // revoke ourself as listener at the global event broadcaster - final XDocumentEventBroadcaster broadcaster = (XDocumentEventBroadcaster) UnoRuntime.queryInterface( - XDocumentEventBroadcaster.class, getORB().createInstance("com.sun.star.frame.GlobalEventBroadcaster")); + final XDocumentEventBroadcaster broadcaster = UnoRuntime.queryInterface(XDocumentEventBroadcaster.class, getMSF().createInstance("com.sun.star.frame.GlobalEventBroadcaster")); broadcaster.removeDocumentEventListener(this); } catch (Exception e) { - log.println("could not create the test case, error message:\n" + e.getMessage()); + System.out.println("could not create the test case, error message:\n" + e.getMessage()); e.printStackTrace(System.err); - failed("failed to close the test case"); + fail("failed to close the test case"); } super.after(); @@ -348,16 +351,15 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document. for (int i = 0; i < unsupportedMethods.length; ++i) { - assureException( _document, unsupportedMethods[i].unoInterfaceClass, - unsupportedMethods[i].methodName, new Object[]{}, _isInitialized ? null : NotInitializedException.class ); +// assureException( _document, unsupportedMethods[i].unoInterfaceClass, +// unsupportedMethods[i].methodName, new Object[]{}, _isInitialized ? null : NotInitializedException.class ); } } // -------------------------------------------------------------------------------------------------------- private XModel impl_createDocument() throws Exception { - final XModel databaseDoc = (XModel) UnoRuntime.queryInterface(XModel.class, - getORB().createInstance("com.sun.star.sdb.OfficeDatabaseDocument")); + final XModel databaseDoc = UnoRuntime.queryInterface(XModel.class, getMSF().createInstance("com.sun.star.sdb.OfficeDatabaseDocument")); // should not be initialized here - we did neither initNew nor load nor storeAsURL it impl_checkDocumentInitState(databaseDoc, false); @@ -368,17 +370,15 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document. // -------------------------------------------------------------------------------------------------------- private void impl_closeDocument(XModel _databaseDoc) throws CloseVetoException, IOException, Exception { - final XCloseable closeDoc = (XCloseable) UnoRuntime.queryInterface(XCloseable.class, - _databaseDoc); + final XCloseable closeDoc = UnoRuntime.queryInterface(XCloseable.class, _databaseDoc); closeDoc.close(true); } // -------------------------------------------------------------------------------------------------------- private XModel impl_createEmptyEmbeddedHSQLDocument() throws Exception, IOException { - final XModel databaseDoc = (XModel) UnoRuntime.queryInterface(XModel.class, - getORB().createInstance("com.sun.star.sdb.OfficeDatabaseDocument")); - final XStorable storeDoc = (XStorable) UnoRuntime.queryInterface(XStorable.class, databaseDoc); + final XModel databaseDoc = UnoRuntime.queryInterface(XModel.class, getMSF().createInstance("com.sun.star.sdb.OfficeDatabaseDocument")); + final XStorable storeDoc = UnoRuntime.queryInterface(XStorable.class, databaseDoc); // verify the document rejects API calls which require it to be initialized impl_checkDocumentInitState(databaseDoc, false); @@ -388,15 +388,13 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document. 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); + assertEquals("location is expected to be empty here", "", location); + assertEquals("URL is expected to be empty here", "", url); + assertEquals("Args are expected to be empty here", 0, args.length); // and, you should be able to set properties at the data source - final XOfficeDatabaseDocument dataSourceAccess = (XOfficeDatabaseDocument) UnoRuntime.queryInterface( - XOfficeDatabaseDocument.class, databaseDoc); - final XPropertySet dsProperties = (XPropertySet) UnoRuntime.queryInterface( - XPropertySet.class, dataSourceAccess.getDataSource()); + final XOfficeDatabaseDocument dataSourceAccess = UnoRuntime.queryInterface(XOfficeDatabaseDocument.class, databaseDoc); + final XPropertySet dsProperties = UnoRuntime.queryInterface(XPropertySet.class, dataSourceAccess.getDataSource()); dsProperties.setPropertyValue("URL", "sdbc:embedded:hsqldb"); final String documentURL = createTempFileURL(); @@ -404,7 +402,7 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document. // now that the document is stored, ... // ... its URL should be correct - assureEquals("wrong URL after storing the document", documentURL, databaseDoc.getURL()); + assertEquals("wrong URL after storing the document", documentURL, databaseDoc.getURL()); // ... it should be initialized impl_checkDocumentInitState(databaseDoc, true); @@ -412,7 +410,7 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document. } // -------------------------------------------------------------------------------------------------------- - public void testLoadable() throws Exception, IOException + @Test public void testLoadable() throws Exception, IOException { XModel databaseDoc = impl_createEmptyEmbeddedHSQLDocument(); String documentURL = databaseDoc.getURL(); @@ -426,40 +424,39 @@ 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")); + databaseDoc = UnoRuntime.queryInterface(XModel.class, getMSF().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); + XLoadable loadDoc = 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()); + assertEquals("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], - DoubleInitializationException.class ); - assureException( databaseDoc, XLoadable.class, "load", new Object[] { new PropertyValue[0] }, - DoubleInitializationException.class ); +// assureException( databaseDoc, XLoadable.class, "initNew", new Object[0], +// DoubleInitializationException.class ); +// assureException( databaseDoc, XLoadable.class, "load", new Object[] { new PropertyValue[0] }, +// DoubleInitializationException.class ); // .................................................................... // 3. XLoadable::initNew impl_closeDocument(databaseDoc); databaseDoc = impl_createDocument(); - loadDoc = (XLoadable) UnoRuntime.queryInterface(XLoadable.class, databaseDoc); + loadDoc = UnoRuntime.queryInterface(XLoadable.class, databaseDoc); loadDoc.initNew(); - assureEquals("wrong URL after initializing the document", "", databaseDoc.getURL()); + assertEquals("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], - DoubleInitializationException.class ); - assureException( databaseDoc, XLoadable.class, "load", new Object[] { new PropertyValue[0] }, - DoubleInitializationException.class ); +// assureException( databaseDoc, XLoadable.class, "initNew", new Object[0], +// DoubleInitializationException.class ); +// assureException( databaseDoc, XLoadable.class, "load", new Object[] { new PropertyValue[0] }, +// DoubleInitializationException.class ); } // -------------------------------------------------------------------------------------------------------- @@ -478,7 +475,9 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document. for ( int i=0; i<_args.length; ++i ) { if ( _args[i].Name.equals( "TestCase_Marker" ) && _args[i].Value.equals( "Yes" ) ) + { return true; + } } return false; } @@ -499,28 +498,25 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document. { 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) + new PropertyValue("InteractionHandler", 0, new MacroExecutionApprove(getMSF()), PropertyState.DIRECT_VALUE) }; } // -------------------------------------------------------------------------------------------------------- private int impl_setMacroSecurityLevel(int _level) throws Exception { - final XMultiServiceFactory configProvider = (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, - getORB().createInstance("com.sun.star.configuration.ConfigurationProvider")); + final XMultiServiceFactory configProvider = UnoRuntime.queryInterface(XMultiServiceFactory.class, getMSF().createInstance("com.sun.star.configuration.ConfigurationProvider")); final PropertyValue[] args = new PropertyValue[] { new PropertyValue("nodepath", 0, "/org.openoffice.Office.Common/Security/Scripting", PropertyState.DIRECT_VALUE) }; - final XPropertySet securitySettings = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, - configProvider.createInstanceWithArguments("com.sun.star.configuration.ConfigurationUpdateAccess", args)); + final XPropertySet securitySettings = 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)); - final XChangesBatch committer = (XChangesBatch) UnoRuntime.queryInterface(XChangesBatch.class, - securitySettings); + final XChangesBatch committer = UnoRuntime.queryInterface(XChangesBatch.class, securitySettings); committer.commitChanges(); return oldValue; @@ -529,10 +525,8 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document. // -------------------------------------------------------------------------------------------------------- private XModel impl_loadDocument( final String _documentURL, final PropertyValue[] _loadArgs ) throws Exception { - final XComponentLoader loader = (XComponentLoader) UnoRuntime.queryInterface( XComponentLoader.class, - getORB().createInstance("com.sun.star.frame.Desktop") ); - return (XModel) UnoRuntime.queryInterface( XModel.class, - loader.loadComponentFromURL( _documentURL, _BLANK, 0, _loadArgs ) ); + final XComponentLoader loader = UnoRuntime.queryInterface(XComponentLoader.class, getMSF().createInstance("com.sun.star.frame.Desktop")); + return UnoRuntime.queryInterface(XModel.class, loader.loadComponentFromURL(_documentURL, _BLANK, 0, _loadArgs)); } // -------------------------------------------------------------------------------------------------------- @@ -540,8 +534,7 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document. { // store the document final String documentURL = FileHelper.getOOoCompatibleFileURL( _document.getURL() ); - final XStorable storeDoc = (XStorable) UnoRuntime.queryInterface( XStorable.class, - _document ); + final XStorable storeDoc = UnoRuntime.queryInterface(XStorable.class, _document); storeDoc.store(); } @@ -553,8 +546,7 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document. XModel databaseDoc = impl_createEmptyEmbeddedHSQLDocument(); // create Basic library/module therein - final XEmbeddedScripts embeddedScripts = (XEmbeddedScripts) UnoRuntime.queryInterface(XEmbeddedScripts.class, - databaseDoc); + final XEmbeddedScripts embeddedScripts = UnoRuntime.queryInterface(XEmbeddedScripts.class, databaseDoc); final XStorageBasedLibraryContainer basicLibs = embeddedScripts.getBasicLibraries(); final XNameContainer newLib = basicLibs.createLibrary( _libName ); newLib.insertByName( _moduleName, _code ); @@ -579,7 +571,7 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document. * This method here tests some of those aspects of a document which should survive the death of one * instance and re-creation as a revenant. */ - public void testDocumentRevenants() throws Exception, IOException + @Test public void testDocumentRevenants() throws Exception, IOException { // create an empty document XModel databaseDoc = impl_createDocWithMacro( "Lib", "Module", @@ -592,42 +584,38 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document. // at this stage, the marker should not yet be present in the doc's args, else some of the below // tests become meaningless - assure( "A newly created doc should not have the test case marker", !impl_hasMarker( databaseDoc.getArgs() ) ); + assertTrue( "A newly created doc should not have the test case marker", !impl_hasMarker( databaseDoc.getArgs() ) ); // obtain the DataSource associated with the document. Keeping this alive // ensures that the "impl data" of the document is kept alive, too, so when closing // and re-opening it, this "impl data" must be re-used. - XDocumentDataSource dataSource = (XDocumentDataSource)UnoRuntime.queryInterface( XDocumentDataSource.class, - ((XOfficeDatabaseDocument)UnoRuntime.queryInterface( - XOfficeDatabaseDocument.class, databaseDoc )).getDataSource() ); + XDocumentDataSource dataSource = UnoRuntime.queryInterface(XDocumentDataSource.class, (UnoRuntime.queryInterface(XOfficeDatabaseDocument.class, databaseDoc)).getDataSource()); // close and reload the doc impl_closeDocument(databaseDoc); databaseDoc = impl_loadDocument( documentURL, impl_getMarkerLoadArgs() ); // since we just put the marker into the load-call, it should be present at the doc - assure( "The test case marker got lost.", impl_hasMarker( databaseDoc.getArgs() ) ); + assertTrue( "The test case marker got lost.", impl_hasMarker( databaseDoc.getArgs() ) ); // The basic library should have survived - final XEmbeddedScripts embeddedScripts = (XEmbeddedScripts) UnoRuntime.queryInterface(XEmbeddedScripts.class, - databaseDoc); + final XEmbeddedScripts embeddedScripts = UnoRuntime.queryInterface(XEmbeddedScripts.class, databaseDoc); final XStorageBasedLibraryContainer basicLibs = embeddedScripts.getBasicLibraries(); - assure( "Baisc lib did not survive reloading a closed document", basicLibs.hasByName( "Lib" ) ); - final XNameContainer lib = (XNameContainer)UnoRuntime.queryInterface( - XNameContainer.class, basicLibs.getByName( "Lib" ) ); - assure( "Basic module did not survive reloading a closed document", lib.hasByName( "Module" ) ); + assertTrue( "Baisc lib did not survive reloading a closed document", basicLibs.hasByName( "Lib" ) ); + final XNameContainer lib = UnoRuntime.queryInterface(XNameContainer.class, basicLibs.getByName("Lib")); + assertTrue( "Basic module did not survive reloading a closed document", lib.hasByName( "Module" ) ); // now closing the doc, and obtaining it from the data source, should preserve the marker we put into the load // args impl_closeDocument( databaseDoc ); - databaseDoc = (XModel)UnoRuntime.queryInterface( XModel.class, dataSource.getDatabaseDocument() ); - assure( "The test case marker did not survive re-retrieval of the doc from the data source.", + databaseDoc = UnoRuntime.queryInterface(XModel.class, dataSource.getDatabaseDocument()); + assertTrue( "The test case marker did not survive re-retrieval of the doc from the data source.", impl_hasMarker( databaseDoc.getArgs() ) ); // on the other hand, closing and regurlarly re-loading the doc *without* the marker should indeed // lose it impl_closeDocument( databaseDoc ); databaseDoc = impl_loadDocument( documentURL, impl_getDefaultLoadArgs() ); - assure( "Reloading the document kept the old args, instead of the newly supplied ones.", + assertTrue( "Reloading the document kept the old args, instead of the newly supplied ones.", !impl_hasMarker( databaseDoc.getArgs() ) ); // clean up @@ -635,7 +623,7 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document. } // -------------------------------------------------------------------------------------------------------- - public void testDocumentEvents() throws Exception, IOException + @Test public void testDocumentEvents() throws Exception, IOException { // create an empty document final String libName = "EventHandlers"; @@ -660,8 +648,7 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document. // bind the macro to the OnLoad event final String macroURI = "vnd.sun.star.script:" + libName + "." + moduleName + ".OnLoad?language=Basic&location=document"; - final XEventsSupplier eventsSupplier = (XEventsSupplier) UnoRuntime.queryInterface(XEventsSupplier.class, - databaseDoc); + final XEventsSupplier eventsSupplier = UnoRuntime.queryInterface(XEventsSupplier.class, databaseDoc); eventsSupplier.getEvents().replaceByName("OnLoad", new PropertyValue[] { new PropertyValue("EventType", 0, "Script", PropertyState.DIRECT_VALUE), @@ -694,7 +681,7 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document. "OnLoad" }, context); - assureEquals("our provided interaction handler was not called", STATE_ON_LOAD_RECEIVED, m_loadDocState); + assertEquals("our provided interaction handler was not called", STATE_ON_LOAD_RECEIVED, m_loadDocState); // restore macro security level impl_setMacroSecurityLevel(oldSecurityLevel); @@ -704,11 +691,10 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document. } // -------------------------------------------------------------------------------------------------------- - public void testGlobalEvents() throws Exception, IOException + @Test public void testGlobalEvents() throws Exception, IOException { XModel databaseDoc = impl_createEmptyEmbeddedHSQLDocument(); - final XStorable storeDoc = (XStorable) UnoRuntime.queryInterface(XStorable.class, - databaseDoc); + final XStorable storeDoc = UnoRuntime.queryInterface(XStorable.class, databaseDoc); String context, newURL; @@ -717,7 +703,7 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document. context = "store"; impl_startObservingEvents(context); storeDoc.store(); - assureEquals("store is not expected to change the document URL", databaseDoc.getURL(), oldURL); + assertEquals("store is not expected to change the document URL", databaseDoc.getURL(), oldURL); impl_stopObservingEvents(m_globalEvents, new String[] { "OnSave", "OnSaveDone" @@ -727,7 +713,7 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document. context = "storeToURL"; impl_startObservingEvents(context); storeDoc.storeToURL(createTempFileURL(), new PropertyValue[0]); - assureEquals("storetoURL is not expected to change the document URL", databaseDoc.getURL(), oldURL); + assertEquals("storetoURL is not expected to change the document URL", databaseDoc.getURL(), oldURL); impl_stopObservingEvents(m_globalEvents, new String[] { "OnSaveTo", "OnSaveToDone" @@ -738,19 +724,18 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document. context = "storeAsURL"; impl_startObservingEvents(context); storeDoc.storeAsURL(newURL, new PropertyValue[0]); - assureEquals("storeAsURL is expected to change the document URL", databaseDoc.getURL(), newURL); + assertEquals("storeAsURL is expected to change the document URL", databaseDoc.getURL(), newURL); impl_stopObservingEvents(m_globalEvents, new String[] { "OnSaveAs", "OnSaveAsDone" }, context); // XModifiable.setModified - final XModifiable modifyDoc = (XModifiable) UnoRuntime.queryInterface(XModifiable.class, - databaseDoc); + final XModifiable modifyDoc = UnoRuntime.queryInterface(XModifiable.class, databaseDoc); context = "setModified"; impl_startObservingEvents(context); modifyDoc.setModified(true); - assureEquals("setModified didn't work", modifyDoc.isModified(), true); + assertEquals("setModified didn't work", modifyDoc.isModified(), true); impl_stopObservingEvents(m_globalEvents, new String[] { "OnModifyChanged" @@ -760,7 +745,7 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document. context = "store (2)"; impl_startObservingEvents(context); storeDoc.store(); - assureEquals("'store' should implicitly reset the modified flag", modifyDoc.isModified(), false); + assertEquals("'store' should implicitly reset the modified flag", modifyDoc.isModified(), false); impl_stopObservingEvents(m_globalEvents, new String[] { "OnSave", "OnSaveDone", "OnModifyChanged" @@ -768,12 +753,10 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document. // XComponentLoader.loadComponentFromURL newURL = copyToTempFile(databaseDoc.getURL()); - final XComponentLoader loader = (XComponentLoader) UnoRuntime.queryInterface(XComponentLoader.class, - getORB().createInstance("com.sun.star.frame.Desktop")); + final XComponentLoader loader = UnoRuntime.queryInterface(XComponentLoader.class, getMSF().createInstance("com.sun.star.frame.Desktop")); context = "loadComponentFromURL"; impl_startObservingEvents(context); - databaseDoc = (XModel) UnoRuntime.queryInterface(XModel.class, - loader.loadComponentFromURL(newURL, _BLANK, 0, impl_getDefaultLoadArgs())); + databaseDoc = UnoRuntime.queryInterface(XModel.class, loader.loadComponentFromURL(newURL, _BLANK, 0, impl_getDefaultLoadArgs())); impl_stopObservingEvents(m_globalEvents, new String[] { @@ -781,8 +764,7 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document. }, context); // closing a document by API - final XCloseable closeDoc = (XCloseable) UnoRuntime.queryInterface(XCloseable.class, - databaseDoc); + final XCloseable closeDoc = UnoRuntime.queryInterface(XCloseable.class, databaseDoc); context = "close (API)"; impl_startObservingEvents(context); closeDoc.close(true); @@ -795,13 +777,11 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document. // 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())); + databaseDoc = 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 XDispatchProvider dispatchProvider = UnoRuntime.queryInterface(XDispatchProvider.class, databaseDoc.getCurrentController().getFrame()); final URL url = impl_getURL(".uno:CloseDoc"); final XDispatch dispatcher = dispatchProvider.queryDispatch(url, "", 0); impl_startObservingEvents(context); @@ -814,8 +794,7 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document. // creating a new document databaseDoc = impl_createDocument(); - final XLoadable loadDoc = (XLoadable) UnoRuntime.queryInterface(XLoadable.class, - databaseDoc); + final XLoadable loadDoc = UnoRuntime.queryInterface(XLoadable.class, databaseDoc); context = "initNew"; impl_startObservingEvents(context); loadDoc.initNew(); @@ -832,13 +811,11 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document. 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())); + databaseDoc = UnoRuntime.queryInterface(XModel.class, loader.loadComponentFromURL(newURL, _BLANK, 0, impl_getDefaultLoadArgs())); final int previousOnLoadEventPos = impl_waitForEvent(m_globalEvents, "OnLoad", 5000); // ... and another document ... final String otherURL = copyToTempFile(databaseDoc.getURL()); - final XModel otherDoc = (XModel) UnoRuntime.queryInterface(XModel.class, - loader.loadComponentFromURL(otherURL, _BLANK, 0, impl_getDefaultLoadArgs())); + final XModel otherDoc = UnoRuntime.queryInterface(XModel.class, loader.loadComponentFromURL(otherURL, _BLANK, 0, impl_getDefaultLoadArgs())); impl_raise(otherDoc); impl_waitForEvent(m_globalEvents, "OnLoad", 5000, previousOnLoadEventPos + 1); @@ -864,8 +841,7 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document. new URL() }; url[0].Complete = _completeURL; - final XURLTransformer urlTransformer = (XURLTransformer) UnoRuntime.queryInterface(XURLTransformer.class, - getORB().createInstance("com.sun.star.util.URLTransformer")); + final XURLTransformer urlTransformer = UnoRuntime.queryInterface(XURLTransformer.class, getMSF().createInstance("com.sun.star.util.URLTransformer")); urlTransformer.parseStrict(url); return url[0]; } @@ -874,15 +850,14 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document. private void impl_raise(XModel _document) { final XFrame frame = _document.getCurrentController().getFrame(); - final XTopWindow topWindow = (XTopWindow) UnoRuntime.queryInterface(XTopWindow.class, - frame.getContainerWindow()); + final XTopWindow topWindow = UnoRuntime.queryInterface(XTopWindow.class, frame.getContainerWindow()); topWindow.toFront(); } // -------------------------------------------------------------------------------------------------------- private void impl_startObservingEvents(String _context) { - log.println(" " + _context + " {"); + System.out.println(" " + _context + " {"); synchronized (m_documentEvents) { m_documentEvents.clear(); @@ -923,19 +898,19 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document. actualEventCount = _actualEvents.size(); } - assureEquals("wrong event count for '" + _context + "'", + assertEquals("wrong event count for '" + _context + "'", _expectedEvents.length, _actualEvents.size()); for (int i = 0; i < _expectedEvents.length; ++i) { - assureEquals("wrong event at positon " + (i + 1) + " for '" + _context + "'", + assertEquals("wrong event at positon " + (i + 1) + " for '" + _context + "'", _expectedEvents[i], _actualEvents.get(i)); } } } finally { - log.println(" }"); + System.out.println(" }"); } } @@ -975,7 +950,7 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document. } } - failed("expected event '" + _expectedEvent + "' did not arrive after " + _maxMilliseconds + " milliseconds"); + fail("expected event '" + _expectedEvent + "' did not arrive after " + _maxMilliseconds + " milliseconds"); return -1; } @@ -994,7 +969,7 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document. if ((_Event.EventName.equals("OnLoad")) && (m_loadDocState != STATE_NOT_STARTED)) { - assureEquals("OnLoad event must come *after* invocation of the interaction handler / user!", + assertEquals("OnLoad event must come *after* invocation of the interaction handler / user!", m_loadDocState, STATE_MACRO_EXEC_APPROVED); m_loadDocState = STATE_ON_LOAD_RECEIVED; } @@ -1005,7 +980,7 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document. m_documentEvents.notifyAll(); } - log.println(" document event: " + _Event.EventName); + System.out.println(" document event: " + _Event.EventName); } // -------------------------------------------------------------------------------------------------------- @@ -1023,7 +998,7 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document. m_globalEvents.notifyAll(); } - log.println(" global event: " + _Event.EventName); + System.out.println(" global event: " + _Event.EventName); } // -------------------------------------------------------------------------------------------------------- diff --git a/dbaccess/qa/complex/dbaccess/Parser.java b/dbaccess/qa/complex/dbaccess/Parser.java index 2b1b9342edcb..3b6b0b92e3ed 100644 --- a/dbaccess/qa/complex/dbaccess/Parser.java +++ b/dbaccess/qa/complex/dbaccess/Parser.java @@ -35,23 +35,34 @@ import com.sun.star.sdbc.SQLException; import com.sun.star.uno.Exception; import com.sun.star.uno.UnoRuntime; + +// ---------- junit imports ----------------- +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.openoffice.test.OfficeConnection; +import static org.junit.Assert.*; +// ------------------------------------------ + public class Parser extends CRMBasedTestCase { // -------------------------------------------------------------------------------------------------------- - public String[] getTestMethodNames() - { - return new String[] { - "checkJoinSyntax", - "checkParameterTypes", - "checkWhere", - }; - } +// public String[] getTestMethodNames() +// { +// return new String[] { +// "checkJoinSyntax", +// "checkParameterTypes", +// "checkWhere", +// }; +// } // -------------------------------------------------------------------------------------------------------- - public String getTestObjectName() - { - return "Parser"; - } +// public String getTestObjectName() +// { +// return "Parser"; +// } // -------------------------------------------------------------------------------------------------------- protected void createTestCase() @@ -64,11 +75,11 @@ public class Parser extends CRMBasedTestCase catch ( Exception e ) { e.printStackTrace( System.err ); - assure( "caught an exception (" + e.getMessage() + ") while creating the test case", false ); + fail( "caught an exception (" + e.getMessage() + ") while creating the test case"); } } - public void checkWhere() throws Exception + @Test public void checkWhere() throws Exception { final XSingleSelectQueryComposer composer = createQueryComposer(); final String SELECT = "SELECT \"products\".\"Name\" FROM \"products\" WHERE "; @@ -107,7 +118,7 @@ public class Parser extends CRMBasedTestCase // -------------------------------------------------------------------------------------------------------- /** verifies that aliases for inner queries work as expected */ - public void checkJoinSyntax() throws Exception + @Test public void checkJoinSyntax() throws Exception { final XSingleSelectQueryComposer composer = createQueryComposer(); @@ -144,7 +155,7 @@ public class Parser extends CRMBasedTestCase { caughtExpected = true; } - assure( "pre-condition not met: parser should except on unparseable statements, else the complete" + + assertTrue( "pre-condition not met: parser should except on unparseable statements, else the complete" + "test is bogus!", caughtExpected ); } @@ -154,30 +165,28 @@ public class Parser extends CRMBasedTestCase final XSingleSelectQueryComposer composer = createQueryComposer(); composer.setQuery( _statement ); - assureEquals( "checkParameterTypes: internal error", _expectedParameterNames.length, _expectedParameterTypes.length ); + assertEquals( "checkParameterTypes: internal error", _expectedParameterNames.length, _expectedParameterTypes.length ); - final XParametersSupplier paramSupp = (XParametersSupplier)UnoRuntime.queryInterface( - XParametersSupplier.class, composer ); + final XParametersSupplier paramSupp = UnoRuntime.queryInterface(XParametersSupplier.class, composer); final XIndexAccess parameters = paramSupp.getParameters(); - assureEquals( "(ctx: " + _context + ") unexpected parameter count", _expectedParameterNames.length, parameters.getCount() ); + assertEquals( "(ctx: " + _context + ") unexpected parameter count", _expectedParameterNames.length, parameters.getCount() ); for ( int i=0; i 4"); final XIndexAccess orderColumns = m_composer.getOrderColumns(); - assure("Order columns doesn't exist: \"Address\"", + assertTrue("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\"", + assertTrue("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", + final XColumnsSupplier xSelectColumns = UnoRuntime.queryInterface(XColumnsSupplier.class, m_composer); + assertTrue("no select columns, or wrong number of select columns", xSelectColumns != null && xSelectColumns.getColumns() != null && xSelectColumns.getColumns().getElementNames().length == 6); // structured filter @@ -196,41 +206,40 @@ public class SingleSelectQueryComposer extends CRMBasedTestCase final PropertyValue[][] aStructuredFilter = m_composer.getStructuredFilter(); m_composer.setFilter(""); m_composer.setStructuredFilter(aStructuredFilter); - assure("Structured Filter not identical", m_composer.getFilter().equals(COMPLEXFILTER)); + assertTrue("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)); + assertTrue("Structured Having Clause not identical", m_composer.getHavingClause().equals(COMPLEXFILTER)); } catch (Exception e) { - assure("Exception caught: " + e, false); + fail("Exception caught: " + e); } } /** test various sub query related features ("queries in queries") */ - public void testSubQueries() throws Exception + @Test public void testSubQueries() throws Exception { m_composer.setQuery("SELECT * from \"" + INNERPRODUCTSQUERY + "\""); - final XTablesSupplier suppTables = (XTablesSupplier) UnoRuntime.queryInterface( - XTablesSupplier.class, m_composer); + final XTablesSupplier suppTables = UnoRuntime.queryInterface(XTablesSupplier.class, m_composer); final XNameAccess tables = suppTables.getTables(); - assure("a simple SELECT * FROM could not be parsed", + assertTrue("a simple SELECT * FROM could not be parsed", tables != null && tables.hasByName(INNERPRODUCTSQUERY)); 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 + "\"", + assertTrue("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 */ - public void testParameters() + @Test public void testParameters() { try { @@ -241,8 +250,7 @@ public class SingleSelectQueryComposer extends CRMBasedTestCase 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()); - final XParametersSupplier suppParams = (XParametersSupplier) UnoRuntime.queryInterface( - XParametersSupplier.class, m_composer); + final XParametersSupplier suppParams = UnoRuntime.queryInterface(XParametersSupplier.class, m_composer); final XIndexAccess parameters = suppParams.getParameters(); final String expectedParamNames[] = @@ -252,26 +260,25 @@ public class SingleSelectQueryComposer extends CRMBasedTestCase }; final int paramCount = parameters.getCount(); - assure("composer did find wrong number of parameters in the nested queries.", + assertTrue("composer did find wrong number of parameters in the nested queries.", paramCount == expectedParamNames.length); for (int i = 0; i < paramCount; ++i) { - final XPropertySet parameter = (XPropertySet) UnoRuntime.queryInterface( - XPropertySet.class, parameters.getByIndex(i)); + final XPropertySet parameter = 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 + ")", + assertTrue("wrong parameter name at position " + (i + 1) + " (expected: " + expectedParamNames[i] + ", found: " + paramName + ")", paramName.equals(expectedParamNames[i])); } } catch (Exception e) { - assure("caught an exception: " + e, false); + fail("caught an exception: " + e); } } - public void testConditionByColumn() + @Test public void testConditionByColumn() { try { @@ -282,23 +289,22 @@ public class SingleSelectQueryComposer extends CRMBasedTestCase 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)); + final XPropertyContainer filter = UnoRuntime.queryInterface(XPropertyContainer.class, getMSF().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); + final XPropertySet column = UnoRuntime.queryInterface(XPropertySet.class, filter); m_composer.appendFilterByColumn(column, true,SQLFilterOperator.LIKE); - assure("At least one row should exist",m_database.getConnection().createStatement().executeQuery(m_composer.getQuery()).next()); + assertTrue("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); + fail("caught an exception: " + e); } } @@ -311,18 +317,18 @@ public class SingleSelectQueryComposer extends CRMBasedTestCase catch (Exception e) { // this is an error: the query is expected to be parseable - assure("caught an exception: " + e, false); + fail("caught an exception: " + e); } final PropertyValue[][] disjunctiveNormalForm = m_composer.getStructuredFilter(); - assureEquals("DNF: wrong number of rows", _expectedDNF.length, disjunctiveNormalForm.length); + assertEquals("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); + assertEquals("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, + assertEquals("DNF: wrong content in column " + j + ", row " + i, _expectedDNF[i][j].Name, disjunctiveNormalForm[i][j].Name); } } @@ -331,7 +337,7 @@ public class SingleSelectQueryComposer extends CRMBasedTestCase /** tests the disjunctive normal form functionality, aka the structured filter, * of the composer */ - public void testDisjunctiveNormalForm() + @Test public void testDisjunctiveNormalForm() { // a simple case: WHERE clause simply is a combination of predicates knitted with AND String query = diff --git a/dbaccess/qa/complex/dbaccess/TestCase.java b/dbaccess/qa/complex/dbaccess/TestCase.java index b8dae3f6f350..ba899a114205 100644 --- a/dbaccess/qa/complex/dbaccess/TestCase.java +++ b/dbaccess/qa/complex/dbaccess/TestCase.java @@ -31,7 +31,7 @@ import com.sun.star.beans.XPropertySet; import com.sun.star.frame.XComponentLoader; import com.sun.star.frame.XModel; import com.sun.star.lang.XMultiServiceFactory; -import com.sun.star.uno.Exception; +// import com.sun.star.uno.Exception; import com.sun.star.uno.UnoRuntime; import com.sun.star.uno.XComponentContext; import helper.FileTools; @@ -40,13 +40,24 @@ import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; -public abstract class TestCase extends complexlib.ComplexTestCase +// ---------- junit imports ----------------- +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.openoffice.test.OfficeConnection; +import static org.junit.Assert.*; +// ------------------------------------------ + + +public abstract class TestCase { // -------------------------------------------------------------------------------------------------------- - protected final XMultiServiceFactory getORB() - { - return (XMultiServiceFactory)param.getMSF(); - } +// protected final XMultiServiceFactory getORB() +// { +// return (XMultiServiceFactory)param.getMSF(); +// } // -------------------------------------------------------------------------------------------------------- protected final XComponentContext getComponentContext() @@ -54,13 +65,13 @@ public abstract class TestCase extends complexlib.ComplexTestCase XComponentContext context = null; try { - final XPropertySet orbProps = UnoRuntime.queryInterface( XPropertySet.class, getORB() ); + final XPropertySet orbProps = UnoRuntime.queryInterface( XPropertySet.class, getMSF() ); context = UnoRuntime.queryInterface( XComponentContext.class, orbProps.getPropertyValue( "DefaultContext" ) ); } catch ( Exception ex ) { - failed( "could not retrieve the ComponentContext" ); + fail( "could not retrieve the ComponentContext" ); } return context; } @@ -83,9 +94,11 @@ public abstract class TestCase extends complexlib.ComplexTestCase */ protected final String createTempFileURL() throws IOException { - final File documentFile = java.io.File.createTempFile( getTestObjectName(), ".odb" ).getAbsoluteFile(); + final File documentFile = java.io.File.createTempFile( "dbaccess_test", ".odb" ).getAbsoluteFile(); if ( documentFile.exists() ) + { documentFile.delete(); + } return FileHelper.getOOoCompatibleFileURL( documentFile.toURI().toURL().toString() ); } @@ -111,16 +124,40 @@ public abstract class TestCase extends complexlib.ComplexTestCase protected final XModel loadDocument( final String _docURL ) throws Exception { final XComponentLoader loader = UnoRuntime.queryInterface( XComponentLoader.class, - getORB().createInstance( "com.sun.star.frame.Desktop" ) ); + getMSF().createInstance( "com.sun.star.frame.Desktop" ) ); return UnoRuntime.queryInterface( XModel.class, loader.loadComponentFromURL( _docURL, "_blank", 0, new PropertyValue[] {} ) ); } // -------------------------------------------------------------------------------------------------------- - protected void assureException( Object _object, Class _unoInterfaceClass, String _methodName, Object[] _methodArgs, - Class _expectedExceptionClass ) +// protected void assureException( Object _object, Class _unoInterfaceClass, String _methodName, Object[] _methodArgs, +// Class _expectedExceptionClass ) +// { +// assureException( UnoRuntime.queryInterface( _unoInterfaceClass, _object ), _methodName, +// _methodArgs, _expectedExceptionClass ); +// } + + + + protected XMultiServiceFactory getMSF() + { + final XMultiServiceFactory xMSF1 = UnoRuntime.queryInterface(XMultiServiceFactory.class, connection.getComponentContext().getServiceManager()); + return xMSF1; + } + + // setup and close connections + @BeforeClass public static void setUpConnection() throws Exception { + System.out.println("setUpConnection()"); + connection.setUp(); + } + + @AfterClass public static void tearDownConnection() + throws InterruptedException, com.sun.star.uno.Exception { - assureException( UnoRuntime.queryInterface( _unoInterfaceClass, _object ), _methodName, - _methodArgs, _expectedExceptionClass ); + System.out.println("tearDownConnection()"); + connection.tearDown(); } + + private static final OfficeConnection connection = new OfficeConnection(); + } diff --git a/dbaccess/qa/complex/dbaccess/UISettings.java b/dbaccess/qa/complex/dbaccess/UISettings.java index fc772b158f5f..8733f000f644 100644 --- a/dbaccess/qa/complex/dbaccess/UISettings.java +++ b/dbaccess/qa/complex/dbaccess/UISettings.java @@ -32,37 +32,45 @@ import com.sun.star.beans.XPropertySet; import com.sun.star.container.XNameAccess; import com.sun.star.form.runtime.XFormController; import com.sun.star.frame.XController; -import com.sun.star.frame.XModel; import com.sun.star.sdb.application.DatabaseObject; -import com.sun.star.sdb.application.XDatabaseDocumentUI; import com.sun.star.uno.UnoRuntime; import com.sun.star.util.XCloseable; import connectivity.tools.CRMDatabase; +// ---------- junit imports ----------------- +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.openoffice.test.OfficeConnection; +import static org.junit.Assert.*; +// ------------------------------------------ + public class UISettings extends TestCase { // -------------------------------------------------------------------------------------------------------- - public String[] getTestMethodNames() - { - return new String[] { - "checkTableFormattingPersistence", - "checkTransparentQueryColumnSettings" - }; - } - - // -------------------------------------------------------------------------------------------------------- - public String getTestObjectName() - { - return "UISettings"; - } +// public String[] getTestMethodNames() +// { +// return new String[] { +// "checkTableFormattingPersistence", +// "checkTransparentQueryColumnSettings" +// }; +// } +// +// // -------------------------------------------------------------------------------------------------------- +// public String getTestObjectName() +// { +// return "UISettings"; +// } // -------------------------------------------------------------------------------------------------------- /** verifies that aliases for inner queries work as expected */ - public void checkTableFormattingPersistence() throws java.lang.Exception + @Test public void checkTableFormattingPersistence() throws java.lang.Exception { // create, load, and connect a DB doc - CRMDatabase database = new CRMDatabase( getORB(), true ); + CRMDatabase database = new CRMDatabase( getMSF(), true ); // display a table XFormController tableViewController = UnoRuntime.queryInterface( XFormController.class, @@ -89,7 +97,7 @@ public class UISettings extends TestCase // stay alive, and subsequent requests to load the doc will just reuse it, without really loading it. docURL = copyToTempFile( docURL ); loadDocument( docURL ); - database = new CRMDatabase( getORB(), docURL ); + database = new CRMDatabase( getMSF(), docURL ); // display the table, again tableViewController = UnoRuntime.queryInterface( XFormController.class, @@ -98,9 +106,9 @@ public class UISettings extends TestCase tableViewController.getCurrentControl().getModel() ); // verify the properties - assureEquals( "wrong font name", "Andale Sans UI", (String)tableControlModel.getPropertyValue( "FontName" ) ); - assureEquals( "wrong font height", (float)20, ((Float)tableControlModel.getPropertyValue( "FontHeight" )).floatValue() ); - assureEquals( "wrong font slant", FontSlant.ITALIC, (FontSlant)tableControlModel.getPropertyValue( "FontSlant" ) ); + assertEquals( "wrong font name", "Andale Sans UI", (String)tableControlModel.getPropertyValue( "FontName" ) ); + assertEquals( "wrong font height", (float)20, ((Float)tableControlModel.getPropertyValue( "FontHeight" )).floatValue() ); + assertEquals( "wrong font slant", FontSlant.ITALIC, (FontSlant)tableControlModel.getPropertyValue( "FontSlant" ) ); // close the doc database.saveAndClose(); @@ -111,10 +119,10 @@ public class UISettings extends TestCase * settings * @throws java.lang.Exception */ - public void checkTransparentQueryColumnSettings() throws java.lang.Exception + @Test public void checkTransparentQueryColumnSettings() throws java.lang.Exception { // create, load, and connect a DB doc - CRMDatabase database = new CRMDatabase( getORB(), true ); + CRMDatabase database = new CRMDatabase( getMSF(), true ); // display a table XController tableView = database.loadSubComponent( DatabaseObject.TABLE, "customers" ); @@ -125,7 +133,7 @@ public class UISettings extends TestCase // change the formatting of a table column XPropertySet idColumn = UnoRuntime.queryInterface( XPropertySet.class, tableControlModel.getByName( "ID" ) ); - assure( "precondition not met: column already centered", + assertTrue( "precondition not met: column already centered", ((Short)idColumn.getPropertyValue( "Align" )).shortValue() != TextAlign.CENTER ); idColumn.setPropertyValue( "Align", TextAlign.CENTER ); @@ -143,7 +151,7 @@ public class UISettings extends TestCase queryViewController.getCurrentControl().getModel() ); idColumn = UnoRuntime.queryInterface( XPropertySet.class, tableControlModel.getByName( "ID" ) ); - assure( "table column alignment was not propagated to the query column", + assertTrue( "table column alignment was not propagated to the query column", ((Short)idColumn.getPropertyValue( "Align" )).shortValue() == TextAlign.CENTER ); // save close the database document diff --git a/dbaccess/qa/complex/dbaccess/makefile.mk b/dbaccess/qa/complex/dbaccess/makefile.mk index 56a24c0292fc..ef5c9183ce60 100755 --- a/dbaccess/qa/complex/dbaccess/makefile.mk +++ b/dbaccess/qa/complex/dbaccess/makefile.mk @@ -25,54 +25,113 @@ # #************************************************************************* -PRJ = ..$/..$/.. -TARGET = DbaComplexTests -PRJNAME = $(TARGET) -PACKAGE = complex$/dbaccess - -# --- Settings ----------------------------------------------------- -.INCLUDE: settings.mk - -.IF "$(SOLAR_JAVA)" == "" -all: - @echo "Java not available. Build skipped" - -.INCLUDE : target.mk +.IF "$(OOO_SUBSEQUENT_TESTS)" == "" +nothing .PHONY: + @echo "OOO_SUBSEQUENT_TESTS not set, do nothing." .ELSE -#----- compile .java files ----------------------------------------- - -JARFILES = ridl.jar unoil.jar jurt.jar juh.jar java_uno.jar OOoRunner.jar ConnectivityTools.jar -JAVAFILES := $(shell @$(FIND) ./*.java) -JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class) - -#----- make a jar from compiled files ------------------------------ - -MAXLINELENGTH = 100000 - -JARCLASSDIRS = $(PACKAGE) -JARTARGET = $(TARGET).jar -JARCOMPRESS = TRUE - -RUNNER_ARGS = -cp "$(CLASSPATH)$(PATH_SEPERATOR)$(SOLARBINDIR)$/OOoRunner.jar" org.openoffice.Runner -TestBase java_complex +PRJ = ../../.. +PRJNAME = dbaccess +TARGET = qa_complex_dbaccess + +.IF "$(OOO_JUNIT_JAR)" != "" +PACKAGE = complex/dbaccess + +# here store only Files which contain a @Test +JAVATESTFILES = \ + ApplicationController.java \ + Beamer.java \ + CRMBasedTestCase.java \ + CopyTableWizard.java \ + DataSource.java \ + DatabaseDocument.java \ + Parser.java \ + PropertyBag.java \ + Query.java \ + QueryInQuery.java \ + RowSet.java \ + SingleSelectQueryComposer.java \ + UISettings.java \ + TestCase.java + +# put here all other files +JAVAFILES = $(JAVATESTFILES) \ + CopyTableInterActionHandler.java \ + DatabaseApplication.java \ + FileHelper.java \ + RowSetEventListener.java + + +JARFILES = OOoRunner.jar ridl.jar test.jar unoil.jar ConnectivityTools.jar +EXTRAJARFILES = $(OOO_JUNIT_JAR) + +# subdirectories +# SUBDIRS = helper + +# Sample how to debug +# JAVAIFLAGS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=9003,suspend=y + +.END -RUNNER_CALL = $(AUGMENT_LIBRARY_PATH) java - -# --- Targets ------------------------------------------------------ - -.IF "$(depend)" == "" -ALL : ALLTAR -.ELSE -ALL: ALLDEP -.ENDIF - -.INCLUDE : target.mk +.INCLUDE: settings.mk +.INCLUDE: target.mk +.INCLUDE: installationtest.mk +ALLTAR : javatest -run: $(CLASSDIR)$/$(JARTARGET) - +$(RUNNER_CALL) $(RUNNER_ARGS) -sce dbaccess.sce +.END -run_%: $(CLASSDIR)$/$(JARTARGET) - +$(RUNNER_CALL) $(RUNNER_ARGS) -o complex.dbaccess.$(@:s/run_//) -.ENDIF # "$(SOLAR_JAVA)" == "" +# +# +# PRJ = ..$/..$/.. +# TARGET = DbaComplexTests +# PRJNAME = $(TARGET) +# PACKAGE = complex$/dbaccess +# +# # --- Settings ----------------------------------------------------- +# .INCLUDE: settings.mk +# +# .IF "$(SOLAR_JAVA)" == "" +# all: +# @echo "Java not available. Build skipped" +# +# .INCLUDE : target.mk +# .ELSE +# +# #----- compile .java files ----------------------------------------- +# +# JARFILES = ridl.jar unoil.jar jurt.jar juh.jar java_uno.jar OOoRunner.jar ConnectivityTools.jar +# JAVAFILES := $(shell @$(FIND) ./*.java) +# JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class) +# +# #----- make a jar from compiled files ------------------------------ +# +# MAXLINELENGTH = 100000 +# +# JARCLASSDIRS = $(PACKAGE) +# JARTARGET = $(TARGET).jar +# JARCOMPRESS = TRUE +# +# RUNNER_ARGS = -cp "$(CLASSPATH)$(PATH_SEPERATOR)$(SOLARBINDIR)$/OOoRunner.jar" org.openoffice.Runner -TestBase java_complex +# +# RUNNER_CALL = $(AUGMENT_LIBRARY_PATH) java +# +# # --- Targets ------------------------------------------------------ +# +# .IF "$(depend)" == "" +# ALL : ALLTAR +# .ELSE +# ALL: ALLDEP +# .ENDIF +# +# .INCLUDE : target.mk +# +# +# run: $(CLASSDIR)$/$(JARTARGET) +# +$(RUNNER_CALL) $(RUNNER_ARGS) -sce dbaccess.sce +# +# run_%: $(CLASSDIR)$/$(JARTARGET) +# +$(RUNNER_CALL) $(RUNNER_ARGS) -o complex.dbaccess.$(@:s/run_//) +# +# .ENDIF # "$(SOLAR_JAVA)" == "" -- cgit From 8000ebd780252e05906e17b3255c78473e12c5e0 Mon Sep 17 00:00:00 2001 From: Lars Langhans Date: Mon, 21 Jun 2010 13:57:04 +0200 Subject: sb123:#i111449# cleanups in dbaccess for qa/complex tests --- dbaccess/prj/build.lst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/dbaccess/prj/build.lst b/dbaccess/prj/build.lst index f8b0502574e0..a69a7b1c0c85 100644 --- a/dbaccess/prj/build.lst +++ b/dbaccess/prj/build.lst @@ -29,3 +29,6 @@ ba dbaccess\util nmake - all ba_util ba_uiimglst ba dbaccess\win32\source\odbcconfig nmake - w ba_odbcconfig ba_inc NULL ba dbaccess\qa\complex\dbaccess nmake - all ba_complex_tests NULL ba dbaccess\qa\unoapi nmake - all ba_q_unoapi NULL + +# complex tests doesn't work +# ba dbaccess\qa\complex\dbaccess nmake - all ba_qa_complex NULL -- cgit From d1e2b3804ca92d0e28e672a600f7a7b1d66f6d75 Mon Sep 17 00:00:00 2001 From: Lars Langhans Date: Tue, 29 Jun 2010 13:43:23 +0200 Subject: sb123:#i111449# makefile cleanups for qa/complex tests --- dbaccess/qa/complex/dbaccess/makefile.mk | 1 - reportdesign/qa/complex/reportdesign/makefile.mk | 1 - 2 files changed, 2 deletions(-) diff --git a/dbaccess/qa/complex/dbaccess/makefile.mk b/dbaccess/qa/complex/dbaccess/makefile.mk index ef5c9183ce60..c0d78d55d687 100755 --- a/dbaccess/qa/complex/dbaccess/makefile.mk +++ b/dbaccess/qa/complex/dbaccess/makefile.mk @@ -27,7 +27,6 @@ .IF "$(OOO_SUBSEQUENT_TESTS)" == "" nothing .PHONY: - @echo "OOO_SUBSEQUENT_TESTS not set, do nothing." .ELSE PRJ = ../../.. diff --git a/reportdesign/qa/complex/reportdesign/makefile.mk b/reportdesign/qa/complex/reportdesign/makefile.mk index 261077caed68..49de6d4b1e57 100755 --- a/reportdesign/qa/complex/reportdesign/makefile.mk +++ b/reportdesign/qa/complex/reportdesign/makefile.mk @@ -27,7 +27,6 @@ .IF "$(OOO_SUBSEQUENT_TESTS)" == "" nothing .PHONY: - @echo "OOO_SUBSEQUENT_TESTS not set, do nothing." .ELSE PRJ = ../../.. -- cgit From 45f206d9cda0fcba57560de7ac5cfb309677f652 Mon Sep 17 00:00:00 2001 From: Lars Langhans Date: Thu, 8 Jul 2010 15:26:59 +0200 Subject: sb123:#i111449# make clear buildable. --- dbaccess/prj/build.lst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dbaccess/prj/build.lst b/dbaccess/prj/build.lst index a69a7b1c0c85..a6bbb58d8c57 100644 --- a/dbaccess/prj/build.lst +++ b/dbaccess/prj/build.lst @@ -27,8 +27,8 @@ ba dbaccess\source\ui\uno nmake - all ba_uiuno ba_inc NULL ba dbaccess\source\ui\imagelists nmake - all ba_uiimglst ba_inc NULL ba dbaccess\util nmake - all ba_util ba_uiimglst ba_capi ba_cdaccess ba_cmisc ba_crecovery ba_shared ba_uibrowser ba_uiapp ba_uicontrol ba_uidlg ba_uimisc ba_uiquery ba_uitabledesign ba_uirelationdesign ba_uiuno ba_conntools ba_misctools ba_miscres ba_ext_adabasui NULL ba dbaccess\win32\source\odbcconfig nmake - w ba_odbcconfig ba_inc NULL -ba dbaccess\qa\complex\dbaccess nmake - all ba_complex_tests NULL ba dbaccess\qa\unoapi nmake - all ba_q_unoapi NULL # complex tests doesn't work -# ba dbaccess\qa\complex\dbaccess nmake - all ba_qa_complex NULL +# ba dbaccess\qa\complex\dbaccess nmake - all ba_qa_complex NULL + -- cgit From 077f9fea1f7faccb083f933bd60caaae65c6be32 Mon Sep 17 00:00:00 2001 From: Lars Langhans Date: Mon, 23 Aug 2010 10:38:44 +0200 Subject: sb123:#i111449# remove all subdirs in complex tests --- dbaccess/qa/complex/dbaccess/makefile.mk | 3 --- reportdesign/qa/complex/reportdesign/makefile.mk | 3 --- 2 files changed, 6 deletions(-) diff --git a/dbaccess/qa/complex/dbaccess/makefile.mk b/dbaccess/qa/complex/dbaccess/makefile.mk index c0d78d55d687..4a3e0426fe1d 100755 --- a/dbaccess/qa/complex/dbaccess/makefile.mk +++ b/dbaccess/qa/complex/dbaccess/makefile.mk @@ -64,9 +64,6 @@ JAVAFILES = $(JAVATESTFILES) \ JARFILES = OOoRunner.jar ridl.jar test.jar unoil.jar ConnectivityTools.jar EXTRAJARFILES = $(OOO_JUNIT_JAR) -# subdirectories -# SUBDIRS = helper - # Sample how to debug # JAVAIFLAGS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=9003,suspend=y diff --git a/reportdesign/qa/complex/reportdesign/makefile.mk b/reportdesign/qa/complex/reportdesign/makefile.mk index 49de6d4b1e57..4174eb02ce3a 100755 --- a/reportdesign/qa/complex/reportdesign/makefile.mk +++ b/reportdesign/qa/complex/reportdesign/makefile.mk @@ -48,9 +48,6 @@ JAVAFILES = $(JAVATESTFILES) \ JARFILES = OOoRunner.jar ridl.jar test.jar unoil.jar EXTRAJARFILES = $(OOO_JUNIT_JAR) -# subdirectories -# SUBDIRS = helper - # Sample how to debug # JAVAIFLAGS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=9003,suspend=y -- cgit From 39f7e8187da53962b481629dd4065709aa4c5991 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Mon, 20 Sep 2010 23:42:56 +0200 Subject: dba33j: #i114627# do not let the SubComponentManager manage reports executed for data display --- dbaccess/source/ui/app/AppController.cxx | 19 ++++++++++++++----- dbaccess/source/ui/app/AppControllerGen.cxx | 3 ++- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/dbaccess/source/ui/app/AppController.cxx b/dbaccess/source/ui/app/AppController.cxx index 9d659c26e707..595d9b412851 100644 --- a/dbaccess/source/ui/app/AppController.cxx +++ b/dbaccess/source/ui/app/AppController.cxx @@ -1789,7 +1789,7 @@ bool OApplicationController::onEntryDoubleClick( SvTreeListBox& _rTree ) } catch(const Exception&) { - OSL_ENSURE(0,"Could not open element!"); + DBG_UNHANDLED_EXCEPTION(); } } return false; // not handled @@ -1842,12 +1842,20 @@ Reference< XComponent > OApplicationController::openElementWithArguments( const getContainer()->showPreview(NULL); } + bool isStandaloneDocument = false; switch ( _eType ) { case E_REPORT: + if ( _eOpenMode != E_OPEN_DESIGN ) + { + // reports which are opened in a mode other than design are no sub components of our application + // component, but standalone documents. + isStandaloneDocument = true; + } + // NO break! case E_FORM: { - if ( !m_pSubComponentManager->activateSubFrame( _sName, _eType, _eOpenMode, xRet ) ) + if ( isStandaloneDocument || !m_pSubComponentManager->activateSubFrame( _sName, _eType, _eOpenMode, xRet ) ) { ::std::auto_ptr< OLinkedDocumentsAccess > aHelper = getDocumentsAccess( _eType ); if ( !aHelper->isConnected() ) @@ -1856,7 +1864,8 @@ Reference< XComponent > OApplicationController::openElementWithArguments( const Reference< XComponent > xDefinition; xRet = aHelper->open( _sName, xDefinition, _eOpenMode, _rAdditionalArguments ); - onDocumentOpened( _sName, _eType, _eOpenMode, xRet, xDefinition ); + if ( !isStandaloneDocument ) + onDocumentOpened( _sName, _eType, _eOpenMode, xRet, xDefinition ); } } break; @@ -2781,9 +2790,9 @@ void OApplicationController::containerFound( const Reference< XContainer >& _xCo _xContainer->addContainerListener(this); } } - catch(Exception) + catch(const Exception&) { - OSL_ENSURE(0,"Could not listener on the container!"); + DBG_UNHANDLED_EXCEPTION(); } } // ----------------------------------------------------------------------------- diff --git a/dbaccess/source/ui/app/AppControllerGen.cxx b/dbaccess/source/ui/app/AppControllerGen.cxx index 435c6ff25fef..9965f00dbd21 100644 --- a/dbaccess/source/ui/app/AppControllerGen.cxx +++ b/dbaccess/source/ui/app/AppControllerGen.cxx @@ -676,7 +676,8 @@ void OApplicationController::onDocumentOpened( const ::rtl::OUString& _rName, co try { - m_pSubComponentManager->onSubComponentOpened( _rName, _nType, _eMode, _rxDefinition.is() ? _rxDefinition : _xDocument ); + OSL_ENSURE( _xDocument.is(), "OApplicationController::onDocumentOpened: is there any *valid* scenario where this fails?" ); + m_pSubComponentManager->onSubComponentOpened( _rName, _nType, _eMode, _xDocument.is() ? _xDocument : _rxDefinition ); if ( _rxDefinition.is() ) { -- cgit From c212d898215c5d5b935dd76cd6f37b5896c04ce6 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Wed, 22 Sep 2010 11:08:30 +0200 Subject: dba33j: i114026: findTableColumnsMatching_throw: take the update-table's name as parameter, to catch the cases where the name is an alias --- dbaccess/source/core/api/KeySet.cxx | 70 ++++++++++++-------- dbaccess/source/core/api/KeySet.hxx | 7 +- dbaccess/source/core/api/OptimisticSet.cxx | 2 +- dbaccess/source/core/api/RowSetCache.cxx | 103 +++++++++-------------------- 4 files changed, 79 insertions(+), 103 deletions(-) diff --git a/dbaccess/source/core/api/KeySet.cxx b/dbaccess/source/core/api/KeySet.cxx index 6ee7a2b8ea4c..5de2c497c031 100644 --- a/dbaccess/source/core/api/KeySet.cxx +++ b/dbaccess/source/core/api/KeySet.cxx @@ -197,9 +197,10 @@ void OKeySet::initColumns() m_pParameterNames.reset( new SelectColumnsMetaData(bCase) ); m_pForeignColumnNames.reset( new SelectColumnsMetaData(bCase) ); } -void OKeySet::findTableColumnsMatching_throw(const Any& i_aTable - ,const Reference& i_xMeta - ,const Reference& i_xQueryColumns) +void OKeySet::findTableColumnsMatching_throw( const Any& i_aTable, + const ::rtl::OUString& i_rUpdateTableName, + const Reference& i_xMeta, + const Reference& i_xQueryColumns) { // first ask the database itself for the best columns which can be used Sequence< ::rtl::OUString> aBestColumnNames; @@ -220,37 +221,48 @@ void OKeySet::findTableColumnsMatching_throw(const Any& i_aTable xPara->getPropertyValue(PROPERTY_REALNAME) >>= aParameterColumns[i]; } - if ( m_sUpdateTableName.getLength() ) + ::rtl::OUString sUpdateTableName( i_rUpdateTableName ); + if ( sUpdateTableName.getLength() == 0 ) { - ::dbaccess::getColumnPositions(i_xQueryColumns,aBestColumnNames,m_sUpdateTableName,(*m_pKeyColumnNames),true); - ::dbaccess::getColumnPositions(i_xQueryColumns,xTblColumns->getElementNames(),m_sUpdateTableName,(*m_pColumnNames),true); - ::dbaccess::getColumnPositions(i_xQueryColumns,aParameterColumns,m_sUpdateTableName,(*m_pParameterNames),true); + OSL_ENSURE( false, "OKeySet::findTableColumnsMatching_throw: This is a fallback only - it won't work when the table has an alias name." ); + // If i_aTable originates from a query composer, and is a table which appears with an alias in the SELECT statement, + // then the below code will not produce correct results. + // For instance, imagine a "SELECT alias.col FROM table AS alias". Now i_aTable would be the table named + // "table", so our sUpdateTableName would be "table" as well - not the information about the "alias" is + // already lost here. + // now getColumnPositions would travers the columns, and check which of them belong to the table denoted + // by sUpdateTableName. Since the latter is "table", but the columns only know that they belong to a table + // named "alias", there will be no matching - so getColumnPositions wouldn't find anything. + + ::rtl::OUString sCatalog, sSchema, sTable; + Reference xTableProp( i_aTable, UNO_QUERY_THROW ); + xTableProp->getPropertyValue( PROPERTY_CATALOGNAME )>>= sCatalog; + xTableProp->getPropertyValue( PROPERTY_SCHEMANAME ) >>= sSchema; + xTableProp->getPropertyValue( PROPERTY_NAME ) >>= sTable; + sUpdateTableName = dbtools::composeTableName( i_xMeta, sCatalog, sSchema, sTable, sal_False, ::dbtools::eInDataManipulation ); } - else + + ::dbaccess::getColumnPositions(i_xQueryColumns,aBestColumnNames,sUpdateTableName,(*m_pKeyColumnNames),true); + ::dbaccess::getColumnPositions(i_xQueryColumns,xTblColumns->getElementNames(),sUpdateTableName,(*m_pColumnNames),true); + ::dbaccess::getColumnPositions(i_xQueryColumns,aParameterColumns,sUpdateTableName,(*m_pParameterNames),true); + + if ( m_pKeyColumnNames->empty() ) { - ::rtl::OUString sCatalog,sSchema,sTable; - Reference xTableProp(i_aTable,UNO_QUERY); - Any aCatalog = xTableProp->getPropertyValue(PROPERTY_CATALOGNAME); - aCatalog >>= sCatalog; - xTableProp->getPropertyValue(PROPERTY_SCHEMANAME) >>= sSchema; - xTableProp->getPropertyValue(PROPERTY_NAME) >>= sTable; - const ::rtl::OUString sComposedUpdateTableName = dbtools::composeTableName( i_xMeta, sCatalog, sSchema, sTable, sal_False, ::dbtools::eInDataManipulation ); - ::dbaccess::getColumnPositions(i_xQueryColumns,aBestColumnNames,sComposedUpdateTableName,(*m_pKeyColumnNames),true); - ::dbaccess::getColumnPositions(i_xQueryColumns,xTblColumns->getElementNames(),sComposedUpdateTableName,(*m_pColumnNames),true); - ::dbaccess::getColumnPositions(i_xQueryColumns,aParameterColumns,sComposedUpdateTableName,(*m_pParameterNames),true); + ::dbtools::throwGenericSQLException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Could not find any key column." ) ), *this ); } - SelectColumnsMetaData::const_iterator aPosIter = m_pKeyColumnNames->begin(); - SelectColumnsMetaData::const_iterator aPosEnd = m_pKeyColumnNames->end(); - for(;aPosIter != aPosEnd;++aPosIter) + for ( SelectColumnsMetaData::const_iterator keyColumn = m_pKeyColumnNames->begin(); + keyColumn != m_pKeyColumnNames->end(); + ++keyColumn + ) { - if ( xTblColumns->hasByName(aPosIter->second.sRealName) ) - { - Reference xProp(xTblColumns->getByName(aPosIter->second.sRealName),UNO_QUERY); - sal_Bool bAuto = sal_False; - if( (xProp->getPropertyValue(PROPERTY_ISAUTOINCREMENT) >>= bAuto) && bAuto) - m_aAutoColumns.push_back(aPosIter->first); - } + if ( !xTblColumns->hasByName( keyColumn->second.sRealName ) ) + continue; + + Reference xProp( xTblColumns->getByName( keyColumn->second.sRealName ), UNO_QUERY ); + sal_Bool bAuto = sal_False; + if ( ( xProp->getPropertyValue( PROPERTY_ISAUTOINCREMENT ) >>= bAuto ) && bAuto ) + m_aAutoColumns.push_back( keyColumn->first ); } } ::rtl::OUStringBuffer OKeySet::createKeyFilter() @@ -286,7 +298,7 @@ void OKeySet::construct(const Reference< XResultSet>& _xDriverSet,const ::rtl::O Reference xMeta = m_xConnection->getMetaData(); Reference xQueryColSup(m_xComposer,UNO_QUERY); const Reference xQueryColumns = xQueryColSup->getColumns(); - findTableColumnsMatching_throw(makeAny(m_xTable),xMeta,xQueryColumns); + findTableColumnsMatching_throw(makeAny(m_xTable),m_sUpdateTableName,xMeta,xQueryColumns); // the first row is empty because it's now easier for us to distinguish when we are beforefirst or first // without extra varaible to be set diff --git a/dbaccess/source/core/api/KeySet.hxx b/dbaccess/source/core/api/KeySet.hxx index 212ec237699e..1266c271040a 100644 --- a/dbaccess/source/core/api/KeySet.hxx +++ b/dbaccess/source/core/api/KeySet.hxx @@ -142,9 +142,10 @@ namespace dbaccess void impl_convertValue_throw(const ORowSetRow& _rInsertRow,const SelectColumnDescription& i_aMetaData); void initColumns(); - void findTableColumnsMatching_throw( const ::com::sun::star::uno::Any& i_aTable - ,const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData>& i_xMeta - ,const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess>& i_xQueryColumns); + void findTableColumnsMatching_throw( const ::com::sun::star::uno::Any& i_aTable, + const ::rtl::OUString& i_rUpdateTableName, + const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData>& i_xMeta, + const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess>& i_xQueryColumns); ::rtl::OUStringBuffer createKeyFilter(); void tryRefetch(const ORowSetRow& _rInsertRow,bool bRefetch); void executeUpdate(const ORowSetRow& _rInsertRow ,const ORowSetRow& _rOrginalRow,const ::rtl::OUString& i_sSQL,const ::rtl::OUString& i_sTableName,const ::std::vector& _aIndexColumnPositions = ::std::vector()); diff --git a/dbaccess/source/core/api/OptimisticSet.cxx b/dbaccess/source/core/api/OptimisticSet.cxx index 2a9ac96ce82b..99bbc17f1f0f 100644 --- a/dbaccess/source/core/api/OptimisticSet.cxx +++ b/dbaccess/source/core/api/OptimisticSet.cxx @@ -133,7 +133,7 @@ void OptimisticSet::construct(const Reference< XResultSet>& _xDriverSet,const :: const ::rtl::OUString* pTableNameEnd = pTableNameIter + aTableNames.getLength(); for( ; pTableNameIter != pTableNameEnd ; ++pTableNameIter) { - findTableColumnsMatching_throw(xTables->getByName(*pTableNameIter),xMeta,xQueryColumns); + findTableColumnsMatching_throw(xTables->getByName(*pTableNameIter),*pTableNameIter,xMeta,xQueryColumns); } // the first row is empty because it's now easier for us to distinguish when we are beforefirst or first diff --git a/dbaccess/source/core/api/RowSetCache.cxx b/dbaccess/source/core/api/RowSetCache.cxx index 92e29ac784ba..be9984938e01 100644 --- a/dbaccess/source/core/api/RowSetCache.cxx +++ b/dbaccess/source/core/api/RowSetCache.cxx @@ -28,84 +28,44 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_dbaccess.hxx" -#ifndef _COMPHELPER_SEQSTREAM_HXX -#include -#endif -#ifndef _COMPHELPER_UNO3_HXX_ -#include -#endif -#ifndef _COMPHELPER_EXTRACT_HXX_ -#include -#endif -#ifndef _COM_SUN_STAR_SDBCX_XKEYSSUPPLIER_HPP_ -#include -#endif -#ifndef _COM_SUN_STAR_SDBCX_XTABLESSUPPLIER_HPP_ -#include -#endif -#ifndef _COM_SUN_STAR_SDBCX_KEYTYPE_HPP_ -#include -#endif -#ifndef _COM_SUN_STAR_SDBC_RESULTSETCONCURRENCY_HPP_ -#include -#endif -#ifndef _COM_SUN_STAR_SDBC_COLUMNVALUE_HPP_ -#include -#endif -#ifndef _COM_SUN_STAR_SDBCX_XCOLUMNSSUPPLIER_HPP_ -#include -#endif -#ifndef _COM_SUN_STAR_SDBCX_PRIVILEGE_HPP_ -#include -#endif -#ifndef _DBACORE_DATACOLUMN_HXX_ -#include "CRowSetDataColumn.hxx" -#endif -#ifndef DBACCESS_CORE_API_CROWSETCOLUMN_HXX + +#include "BookmarkSet.hxx" #include "CRowSetColumn.hxx" -#endif -#ifndef DBACCESS_CORE_API_ROWSETBASE_HXX +#include "CRowSetDataColumn.hxx" +#include "KeySet.hxx" +#include "OptimisticSet.hxx" #include "RowSetBase.hxx" -#endif +#include "RowSetCache.hxx" +#include "StaticSet.hxx" +#include "WrappedResultSet.hxx" +#include "core_resource.hrc" +#include "core_resource.hxx" +#include "dbastrings.hrc" + +/** === begin UNO includes === **/ +#include +#include +#include +#include +#include +#include +#include +#include +/** === end UNO includes === **/ + +#include +#include +#include +#include #include -#include -#include #include #include -#ifndef _COMPHELPER_PROPERTY_HXX_ -#include -#endif -#ifndef _COM_SUN_STAR_SDBCX_COMPAREBOOKMARK_HPP_ -#include -#endif -#ifndef _TOOLS_DEBUG_HXX +#include +#include #include -#endif +#include #include -#ifndef DBACCESS_CORE_API_ROWSETCACHE_HXX -#include "RowSetCache.hxx" -#endif -#ifndef _DBA_CORE_RESOURCE_HXX_ -#include "core_resource.hxx" -#endif -#ifndef _DBA_CORE_RESOURCE_HRC_ -#include "core_resource.hrc" -#endif -#ifndef DBACCESS_CORE_API_BOOKMARKSET_HXX -#include "BookmarkSet.hxx" -#endif -#ifndef DBACCESS_CORE_API_STATICSET_HXX -#include "StaticSet.hxx" -#endif -#ifndef DBACCESS_CORE_API_KEYSET_HXX -#include "KeySet.hxx" -#endif -#ifndef DBACCESS_SHARED_DBASTRINGS_HRC -#include "dbastrings.hrc" -#endif -#include "WrappedResultSet.hxx" -#include "OptimisticSet.hxx" using namespace dbaccess; using namespace dbtools; @@ -228,7 +188,10 @@ ORowSetCache::ORowSetCache(const Reference< XResultSet >& _xRs, } catch(const Exception&) { + DBG_UNHANDLED_EXCEPTION(); } + m_pCacheSet = NULL; + m_xCacheSet.clear(); } else { -- cgit From 467abe4b7b87482e0ebd2fd9dc9f34080f25c7ea Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Mon, 20 Sep 2010 22:53:54 +0200 Subject: dba33j: #i114438# --- dbaccess/source/core/inc/DatabaseDataProvider.hxx | 2 +- dbaccess/source/core/misc/DatabaseDataProvider.cxx | 295 +++++++++++++-------- reportdesign/source/core/sdr/RptObject.cxx | 20 +- .../source/filter/xml/xmlExportDocumentHandler.cxx | 4 +- .../source/filter/xml/xmlImportDocumentHandler.cxx | 38 ++- .../source/filter/xml/xmlImportDocumentHandler.hxx | 1 + .../source/ui/inspection/DataProviderHandler.cxx | 21 +- 7 files changed, 219 insertions(+), 162 deletions(-) diff --git a/dbaccess/source/core/inc/DatabaseDataProvider.hxx b/dbaccess/source/core/inc/DatabaseDataProvider.hxx index e75c980e2a93..5d7a4a4e368e 100644 --- a/dbaccess/source/core/inc/DatabaseDataProvider.hxx +++ b/dbaccess/source/core/inc/DatabaseDataProvider.hxx @@ -223,7 +223,7 @@ private: void impl_fillRowSet_throw(); void impl_executeRowSet_throw(::osl::ResettableMutexGuard& _rClearForNotifies); bool impl_fillParameters_nothrow( ::osl::ResettableMutexGuard& _rClearForNotifies); - void impl_fillInternalDataProvider_throw(sal_Bool _bHasCategories,const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::rtl::OUString > >& i_aColumnNames); + void impl_fillInternalDataProvider_throw(sal_Bool _bHasCategories,const ::com::sun::star::uno::Sequence< ::rtl::OUString >& i_aColumnNames); void impl_invalidateParameter_nothrow(); ::com::sun::star::uno::Any impl_getNumberFormatKey_nothrow(const ::rtl::OUString & _sRangeRepresentation) const; diff --git a/dbaccess/source/core/misc/DatabaseDataProvider.cxx b/dbaccess/source/core/misc/DatabaseDataProvider.cxx index 802e052297f9..bb41b5062ff8 100644 --- a/dbaccess/source/core/misc/DatabaseDataProvider.cxx +++ b/dbaccess/source/core/misc/DatabaseDataProvider.cxx @@ -31,10 +31,12 @@ #include "dbastrings.hrc" #include "cppuhelper/implbase1.hxx" #include +#include #include #include #include #include +#include #include #include @@ -205,22 +207,24 @@ uno::Reference< chart2::data::XDataSource > SAL_CALL DatabaseDataProvider::creat osl::ResettableMutexGuard aClearForNotifies(m_aMutex); if ( createDataSourcePossible(_aArguments) ) { - sal_Bool bHasCategories = sal_True; - uno::Sequence< uno::Sequence< ::rtl::OUString > > aColumnNames; - const beans::PropertyValue* pArgIter = _aArguments.getConstArray(); - const beans::PropertyValue* pArgEnd = pArgIter + _aArguments.getLength(); - for(;pArgIter != pArgEnd;++pArgIter) + try { - if ( pArgIter->Name.equalsAscii("HasCategories") ) - { - pArgIter->Value >>= bHasCategories; - - } - else if ( pArgIter->Name.equalsAscii("ComplexColumnDescriptions") ) - { - pArgIter->Value >>= aColumnNames; - } + uno::Reference< chart::XChartDataArray> xChartData( m_xInternal, uno::UNO_QUERY_THROW ); + xChartData->setData( uno::Sequence< uno::Sequence< double > >() ); + xChartData->setColumnDescriptions( uno::Sequence< ::rtl::OUString >() ); + if ( m_xInternal->hasDataByRangeRepresentation( ::rtl::OUString::valueOf( sal_Int32(0) ) ) ) + m_xInternal->deleteSequence(0); + } + catch( const uno::Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); } + + ::comphelper::NamedValueCollection aArgs( _aArguments ); + const sal_Bool bHasCategories = aArgs.getOrDefault( "HasCategories", sal_True ); + uno::Sequence< ::rtl::OUString > aColumnNames = + aArgs.getOrDefault( "ColumnDescriptions", uno::Sequence< ::rtl::OUString >() ); + bool bRet = false; if ( m_Command.getLength() != 0 && m_xActiveConnection.is() ) { @@ -254,41 +258,36 @@ uno::Reference< chart2::data::XDataSource > SAL_CALL DatabaseDataProvider::creat uno::Sequence< beans::PropertyValue > SAL_CALL DatabaseDataProvider::detectArguments(const uno::Reference< chart2::data::XDataSource > & _xDataSource) throw (uno::RuntimeException) { - uno::Sequence< beans::PropertyValue > aArguments( 4 ); - aArguments[0] = beans::PropertyValue( - ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CellRangeRepresentation")), -1, uno::Any(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("all")) ), - beans::PropertyState_DIRECT_VALUE ); - aArguments[1] = beans::PropertyValue( - ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DataRowSource")), -1, uno::makeAny( chart::ChartDataRowSource_COLUMNS ), - beans::PropertyState_DIRECT_VALUE ); + ::comphelper::NamedValueCollection aArguments; + aArguments.put( "CellRangeRepresentation", uno::Any( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "all" ) ) ) ); + aArguments.put( "DataRowSource", uno::makeAny( chart::ChartDataRowSource_COLUMNS ) ); // internal data always contains labels and categories - aArguments[2] = beans::PropertyValue( - ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FirstCellAsLabel")), -1, uno::makeAny( true ), beans::PropertyState_DIRECT_VALUE ); + aArguments.put( "FirstCellAsLabel", uno::makeAny( sal_True ) ); + sal_Bool bHasCategories = sal_False; if( _xDataSource.is()) { - uno::Sequence< uno::Reference< chart2::data::XLabeledDataSequence > > aSequences(_xDataSource->getDataSequences()); - const sal_Int32 nCount( aSequences.getLength()); - for( sal_Int32 nIdx=0; nIdx xSeqProp( aSequences[nIdx]->getValues(), uno::UNO_QUERY ); - ::rtl::OUString aRole; - if( xSeqProp.is() && - (xSeqProp->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Role"))) >>= aRole) && - aRole.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("categories")) ) - { - bHasCategories = sal_True; - break; - } - } - } + uno::Sequence< uno::Reference< chart2::data::XLabeledDataSequence > > aSequences(_xDataSource->getDataSequences()); + const sal_Int32 nCount( aSequences.getLength()); + for( sal_Int32 nIdx=0; nIdx xSeqProp( aSequences[nIdx]->getValues(), uno::UNO_QUERY ); + ::rtl::OUString aRole; + if ( xSeqProp.is() + && ( xSeqProp->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Role" ) ) ) >>= aRole ) + && aRole.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "categories" ) ) + ) + { + bHasCategories = sal_True; + break; + } + } + } } - - aArguments[3] = beans::PropertyValue( - ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("HasCategories")), -1, uno::makeAny( bHasCategories ), beans::PropertyState_DIRECT_VALUE ); - return aArguments; + aArguments.put( "HasCategories", uno::makeAny( bHasCategories ) ); + return aArguments.getPropertyValues(); } // ----------------------------------------------------------------------------- @@ -649,66 +648,136 @@ void DatabaseDataProvider::impl_executeRowSet_throw(::osl::ResettableMutexGuard& if ( impl_fillParameters_nothrow(_rClearForNotifies) ) m_xRowSet->execute(); } + // ----------------------------------------------------------------------------- -void DatabaseDataProvider::impl_fillInternalDataProvider_throw(sal_Bool _bHasCategories,const uno::Sequence< uno::Sequence< ::rtl::OUString > >& i_aColumnNames) +namespace { - // clear the data before fill the new one - uno::Reference< chart::XChartDataArray> xChartData(m_xInternal,uno::UNO_QUERY); - if ( xChartData.is() ) + struct ColumnDescription { - xChartData->setData(uno::Sequence< uno::Sequence >()); - xChartData->setColumnDescriptions(uno::Sequence< ::rtl::OUString >()); - if ( m_xInternal->hasDataByRangeRepresentation(::rtl::OUString::valueOf(sal_Int32(0))) ) - m_xInternal->deleteSequence(0); - } + ::rtl::OUString sName; + sal_Int32 nResultSetPosition; + sal_Int32 nDataType; + + ColumnDescription() + :sName() + ,nResultSetPosition( 0 ) + ,nDataType( sdbc::DataType::VARCHAR ) + { + } + explicit ColumnDescription( const ::rtl::OUString& i_rName ) + :sName( i_rName ) + ,nResultSetPosition( 0 ) + ,nDataType( sdbc::DataType::VARCHAR ) + { + } + }; - uno::Reference< sdbcx::XColumnsSupplier> xColSup(m_xRowSet,uno::UNO_QUERY_THROW); - uno::Reference< container::XNameAccess > xColumns = xColSup->getColumns(); - uno::Sequence< ::rtl::OUString > aColumns; + struct CreateColumnDescription : public ::std::unary_function< ::rtl::OUString, ColumnDescription > + { + ColumnDescription operator()( const ::rtl::OUString& i_rName ) + { + return ColumnDescription( i_rName ); + } + }; + + struct SelectColumnName : public ::std::unary_function< ColumnDescription, ::rtl::OUString > + { + const ::rtl::OUString& operator()( const ColumnDescription& i_rColumn ) + { + return i_rColumn.sName; + } + }; +} + +// ----------------------------------------------------------------------------- +void DatabaseDataProvider::impl_fillInternalDataProvider_throw(sal_Bool _bHasCategories,const uno::Sequence< ::rtl::OUString >& i_aColumnNames) +{ + // clear the data before fill the new one + uno::Reference< sdbcx::XColumnsSupplier > xColSup(m_xRowSet,uno::UNO_QUERY_THROW); + uno::Reference< container::XNameAccess > xColumns( xColSup->getColumns(), uno::UNO_SET_THROW ); + const uno::Sequence< ::rtl::OUString > aRowSetColumnNames( xColumns->getElementNames() ); + + typedef ::std::vector< ColumnDescription > ColumnDescriptions; + ColumnDescriptions aColumns; + bool bFirstColumnIsCategory = _bHasCategories; if ( i_aColumnNames.getLength() ) { - aColumns.realloc(1); - aColumns[0] = xColumns->getElementNames()[0]; - for(sal_Int32 i = 0 ; i < i_aColumnNames.getLength();++i) + // some normalizations ... + uno::Sequence< ::rtl::OUString > aImposedColumnNames( i_aColumnNames ); + + // strangely, there exist documents where the ColumnDescriptions end with a number of empty strings. /me + // thinks they're generated when you have a chart based on a result set with n columns, but remove some + // of those columns from the chart - it looks like a bug in the report XML export to me. + // So, get rid of the "trailing" empty columns + sal_Int32 nLastNonEmptyColName = aImposedColumnNames.getLength() - 1; + for ( ; nLastNonEmptyColName >= 0; --nLastNonEmptyColName ) { - if ( i_aColumnNames[i].getLength() ) + if ( aImposedColumnNames[ nLastNonEmptyColName ].getLength() != 0 ) + break; + } + aImposedColumnNames.realloc( nLastNonEmptyColName + 1 ); + + // second, for X-Y-charts the ColumnDescriptions exported by chart miss the name of the first (non-category) + // column. This, this results in a ColumnDescriptions array like <"", "col2", "col3">, where you'd expect + // <"col1", "col2", "col3">. + // Fix this with some heuristics: + if ( ( aImposedColumnNames.getLength() > 0 ) && ( aImposedColumnNames[0].getLength() == 0 ) ) + { + const sal_Int32 nAssumedRowSetColumnIndex = _bHasCategories ? 1 : 0; + if ( nAssumedRowSetColumnIndex < aRowSetColumnNames.getLength() ) + aImposedColumnNames[0] = aRowSetColumnNames[ nAssumedRowSetColumnIndex ]; + } + + const sal_Int32 nCount = aImposedColumnNames.getLength(); + for ( sal_Int32 i = 0 ; i < nCount; ++i ) + { + const ::rtl::OUString sColumnName( aImposedColumnNames[i] ); + if ( !xColumns->hasByName( sColumnName ) ) + continue; + + if ( _bHasCategories && aColumns.empty() ) { - sal_Int32 nCount = aColumns.getLength(); - aColumns.realloc(nCount+1); - aColumns[nCount] = i_aColumnNames[i][0]; + if ( aRowSetColumnNames.getLength() ) + aColumns.push_back( ColumnDescription( aRowSetColumnNames[0] ) ); + else + aColumns.push_back( ColumnDescription( sColumnName ) ); + bFirstColumnIsCategory = true; } + aColumns.push_back( ColumnDescription( sColumnName ) ); } } - else + if ( aColumns.empty() ) { - aColumns = xColumns->getElementNames(); + aColumns.resize( aRowSetColumnNames.getLength() ); + ::std::transform( + aRowSetColumnNames.getConstArray(), + aRowSetColumnNames.getConstArray() + aRowSetColumnNames.getLength(), + aColumns.begin(), + CreateColumnDescription() + ); } + // fill the data - uno::Reference< sdbc::XResultSet> xRes(m_xRowSet,uno::UNO_QUERY_THROW); - uno::Reference< sdbc::XRow> xRow(m_xRowSet,uno::UNO_QUERY_THROW); - uno::Reference< sdbc::XResultSetMetaData> xResultSetMetaData = uno::Reference< sdbc::XResultSetMetaDataSupplier>(m_xRowSet,uno::UNO_QUERY)->getMetaData(); - uno::Reference< sdbc::XColumnLocate> xColumnLocate(m_xRowSet,uno::UNO_QUERY_THROW); - - ::std::vector aColumnTypes; - uno::Sequence< uno::Any > aLabelArgs(1); - const sal_Int32 nCount = aColumns.getLength(); - if ( nCount ) - aColumnTypes.push_back(xResultSetMetaData->getColumnType(1)); - - ::std::vector< sal_Int32 > aColumnPositions; - const ::rtl::OUString* pIter = aColumns.getConstArray(); - const ::rtl::OUString* pEnd = pIter + aColumns.getLength(); - for(sal_Int32 k = 0;pIter != pEnd;++pIter,++k) + uno::Reference< sdbc::XResultSet> xRes( m_xRowSet, uno::UNO_QUERY_THROW ); + uno::Reference< sdbc::XRow> xRow( m_xRowSet,uno::UNO_QUERY_THROW ); + uno::Reference< sdbc::XResultSetMetaDataSupplier > xSuppMeta( m_xRowSet,uno::UNO_QUERY_THROW ); + uno::Reference< sdbc::XResultSetMetaData > xResultSetMetaData( xSuppMeta->getMetaData(), uno::UNO_SET_THROW ); + uno::Reference< sdbc::XColumnLocate > xColumnLocate( m_xRowSet, uno::UNO_QUERY_THROW ); + + for ( ColumnDescriptions::iterator col = aColumns.begin(); + col != aColumns.end(); + ++col + ) { - aColumnPositions.push_back(xColumnLocate->findColumn(*pIter)); - uno::Reference< beans::XPropertySet> xColumn(xColumns->getByName(*pIter),uno::UNO_QUERY); - sal_Int32 nType = sdbc::DataType::VARCHAR; - if ( xColumn.is() ) - { - m_aNumberFormats.insert( ::std::map< ::rtl::OUString,uno::Any>::value_type(::rtl::OUString::valueOf(k),xColumn->getPropertyValue(PROPERTY_NUMBERFORMAT))); - xColumn->getPropertyValue(PROPERTY_TYPE) >>= nType; - } - aColumnTypes.push_back(nType); + col->nResultSetPosition = xColumnLocate->findColumn( col->sName ); + + const uno::Reference< beans::XPropertySet > xColumn( xColumns->getByName( col->sName ), uno::UNO_QUERY_THROW ); + const uno::Any aNumberFormat( xColumn->getPropertyValue( PROPERTY_NUMBERFORMAT ) ); + OSL_VERIFY( xColumn->getPropertyValue( PROPERTY_TYPE ) >>= col->nDataType ); + + const sal_Int32 columnIndex = col - aColumns.begin(); + const ::rtl::OUString sRangeName = ::rtl::OUString::valueOf( columnIndex ); + m_aNumberFormats.insert( ::std::map< ::rtl::OUString, uno::Any >::value_type( sRangeName, aNumberFormat ) ); } ::std::vector< ::rtl::OUString > aRowLabels; @@ -719,31 +788,31 @@ void DatabaseDataProvider::impl_fillInternalDataProvider_throw(sal_Bool _bHasCat { ++nRowCount; - aValue.fill(1,aColumnTypes[0],xRow); - aRowLabels.push_back(aValue.getString()); + aValue.fill( aColumns[0].nResultSetPosition, aColumns[0].nDataType, xRow ); + aRowLabels.push_back( aValue.getString() ); + ::std::vector< double > aRow; - ::std::vector< sal_Int32 >::iterator aColumnPosIter = aColumnPositions.begin(); - ::std::vector< sal_Int32 >::iterator aColumnPosEnd = aColumnPositions.end(); - sal_Int32 i = 0; - if ( _bHasCategories ) + for ( ColumnDescriptions::const_iterator col = aColumns.begin(); + col != aColumns.end(); + ++col + ) { - ++aColumnPosIter; - ++i; - } - for (; aColumnPosIter != aColumnPosEnd; ++aColumnPosIter,++i) - { - aValue.fill(*aColumnPosIter,aColumnTypes[i],xRow); + if ( bFirstColumnIsCategory && ( col == aColumns.begin() ) ) + continue; + + aValue.fill( col->nResultSetPosition, col->nDataType, xRow ); if ( aValue.isNull() ) { double nValue; ::rtl::math::setNan( &nValue ); - aRow.push_back(nValue); + aRow.push_back( nValue ); } else - aRow.push_back(aValue.getDouble()); + aRow.push_back( aValue.getDouble() ); } - aDataValues.push_back(aRow); - } // while( xRes->next() && (!m_RowLimit || nRowCount < m_RowLimit) ) + + aDataValues.push_back( aRow ); + } // insert default data when no rows exist if ( !nRowCount ) @@ -759,19 +828,29 @@ void DatabaseDataProvider::impl_fillInternalDataProvider_throw(sal_Bool _bHasCat aRowLabels.push_back(::rtl::OUString::valueOf(h+1)); ::std::vector< double > aRow; const sal_Int32 nSize = sizeof(fDefaultData)/sizeof(fDefaultData[0]); - for (sal_Int32 j = 0; j < (nCount-1); ++j,++k) + for (size_t j = 0; j < (aColumns.size()-1); ++j,++k) { if ( k >= nSize ) k = 0; aRow.push_back(fDefaultData[k]); - } // for (sal_Int32 j = 0,k = 0; j < (nCount-1); ++j,++k) + } // for (sal_Int32 j = 0,k = 0; j < (aColumns.size()-1); ++j,++k) aDataValues.push_back(aRow); } } // if ( !nRowCount ) uno::Reference< chart::XChartDataArray> xData(m_xInternal,uno::UNO_QUERY); xData->setRowDescriptions(uno::Sequence< ::rtl::OUString >(&(*aRowLabels.begin()),aRowLabels.size())); - xData->setColumnDescriptions(uno::Sequence< ::rtl::OUString >(aColumns.getArray()+ (_bHasCategories ? 1 : 0),aColumns.getLength() - (_bHasCategories ? 1 : 0) )); + + const size_t nOffset = bFirstColumnIsCategory ? 1 : 0; + uno::Sequence< ::rtl::OUString > aColumnDescriptions( aColumns.size() - nOffset ); + ::std::transform( + aColumns.begin() + nOffset, + aColumns.end(), + aColumnDescriptions.getArray(), + SelectColumnName() + ); + xData->setColumnDescriptions( aColumnDescriptions ); + uno::Sequence< uno::Sequence< double > > aData(aDataValues.size()); uno::Sequence< double >* pDataIter = aData.getArray(); uno::Sequence< double >* pDataEnd = pDataIter + aData.getLength(); diff --git a/reportdesign/source/core/sdr/RptObject.cxx b/reportdesign/source/core/sdr/RptObject.cxx index 2299fff10f98..7d1cdbc6db30 100644 --- a/reportdesign/source/core/sdr/RptObject.cxx +++ b/reportdesign/source/core/sdr/RptObject.cxx @@ -1221,20 +1221,12 @@ void OOle2Obj::initializeChart( const uno::Reference< frame::XModel>& _xModel) OReportModel* pRptModel = static_cast(GetModel()); pRptModel->GetUndoEnv().AddElement(lcl_getDataProvider(xObj)); - uno::Sequence< beans::PropertyValue > aArgs( 4 ); - aArgs[0] = beans::PropertyValue( - ::rtl::OUString::createFromAscii("CellRangeRepresentation"), -1, - uno::makeAny( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("all")) ), beans::PropertyState_DIRECT_VALUE ); - aArgs[1] = beans::PropertyValue( - ::rtl::OUString::createFromAscii("HasCategories"), -1, - uno::makeAny( sal_True ), beans::PropertyState_DIRECT_VALUE ); - aArgs[2] = beans::PropertyValue( - ::rtl::OUString::createFromAscii("FirstCellAsLabel"), -1, - uno::makeAny( sal_True ), beans::PropertyState_DIRECT_VALUE ); - aArgs[3] = beans::PropertyValue( - ::rtl::OUString::createFromAscii("DataRowSource"), -1, - uno::makeAny( chart::ChartDataRowSource_COLUMNS ), beans::PropertyState_DIRECT_VALUE ); - xReceiver->setArguments( aArgs ); + ::comphelper::NamedValueCollection aArgs; + aArgs.put( "CellRangeRepresentation", uno::makeAny( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "all" ) ) ) ); + aArgs.put( "HasCategories", uno::makeAny( sal_True ) ); + aArgs.put( "FirstCellAsLabel", uno::makeAny( sal_True ) ); + aArgs.put( "DataRowSource", uno::makeAny( chart::ChartDataRowSource_COLUMNS ) ); + xReceiver->setArguments( aArgs.getPropertyValues() ); if( xChartModel.is() ) xChartModel->unlockControllers(); diff --git a/reportdesign/source/filter/xml/xmlExportDocumentHandler.cxx b/reportdesign/source/filter/xml/xmlExportDocumentHandler.cxx index d3a557c3ff6b..be664b5694e1 100644 --- a/reportdesign/source/filter/xml/xmlExportDocumentHandler.cxx +++ b/reportdesign/source/filter/xml/xmlExportDocumentHandler.cxx @@ -349,14 +349,14 @@ void SAL_CALL ExportDocumentHandler::initialize( const uno::Sequence< uno::Any > if ( xDataProvider.is() ) { m_aColumns.realloc(1); - uno::Sequence< uno::Sequence< ::rtl::OUString > > aColumnNames = xDataProvider->getComplexColumnDescriptions(); + uno::Sequence< ::rtl::OUString > aColumnNames = xDataProvider->getColumnDescriptions(); for(sal_Int32 i = 0 ; i < aColumnNames.getLength();++i) { if ( aColumnNames[i].getLength() ) { sal_Int32 nCount = m_aColumns.getLength(); m_aColumns.realloc(nCount+1); - m_aColumns[nCount] = aColumnNames[i][0]; + m_aColumns[nCount] = aColumnNames[i]; } } } diff --git a/reportdesign/source/filter/xml/xmlImportDocumentHandler.cxx b/reportdesign/source/filter/xml/xmlImportDocumentHandler.cxx index c92eecc1084d..c0ae9152e146 100644 --- a/reportdesign/source/filter/xml/xmlImportDocumentHandler.cxx +++ b/reportdesign/source/filter/xml/xmlImportDocumentHandler.cxx @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -56,8 +57,9 @@ using namespace ::xmloff::token; ::rtl::OUString lcl_createAttribute(const xmloff::token::XMLTokenEnum& _eNamespace,const xmloff::token::XMLTokenEnum& _eAttribute); -ImportDocumentHandler::ImportDocumentHandler(uno::Reference< uno::XComponentContext > const & context) : - m_xContext(context) +ImportDocumentHandler::ImportDocumentHandler(uno::Reference< uno::XComponentContext > const & context) + :m_xContext(context) + ,m_bImportedChart( false ) { } // ----------------------------------------------------------------------------- @@ -121,35 +123,24 @@ void SAL_CALL ImportDocumentHandler::endDocument() throw (uno::RuntimeException, { m_xDelegatee->endDocument(); uno::Reference< chart2::data::XDataReceiver > xReceiver(m_xModel,uno::UNO_QUERY_THROW); - if ( xReceiver.is() ) + if ( xReceiver.is() && m_bImportedChart ) { // this fills the chart again - uno::Sequence< beans::PropertyValue > aArgs( 4 ); - aArgs[0] = beans::PropertyValue( - ::rtl::OUString::createFromAscii("CellRangeRepresentation"), -1, - uno::makeAny( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("all")) ), beans::PropertyState_DIRECT_VALUE ); - aArgs[1] = beans::PropertyValue( - ::rtl::OUString::createFromAscii("HasCategories"), -1, - uno::makeAny( sal_True ), beans::PropertyState_DIRECT_VALUE ); - aArgs[2] = beans::PropertyValue( - ::rtl::OUString::createFromAscii("FirstCellAsLabel"), -1, - uno::makeAny( sal_True ), beans::PropertyState_DIRECT_VALUE ); - aArgs[3] = beans::PropertyValue( - ::rtl::OUString::createFromAscii("DataRowSource"), -1, - uno::makeAny( chart::ChartDataRowSource_COLUMNS ), beans::PropertyState_DIRECT_VALUE ); + ::comphelper::NamedValueCollection aArgs; + aArgs.put( "CellRangeRepresentation", ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("all")) ); + aArgs.put( "HasCategories", uno::makeAny( sal_True ) ); + aArgs.put( "FirstCellAsLabel", uno::makeAny( sal_True ) ); + aArgs.put( "DataRowSource", uno::makeAny( chart::ChartDataRowSource_COLUMNS ) ); uno::Reference< chart::XComplexDescriptionAccess > xDataProvider(m_xModel->getDataProvider(),uno::UNO_QUERY); if ( xDataProvider.is() ) { - aArgs.realloc(5); - uno::Sequence< uno::Sequence< ::rtl::OUString > > aColumnNames = xDataProvider->getComplexColumnDescriptions(); - aArgs[4] = beans::PropertyValue( - ::rtl::OUString::createFromAscii("ComplexColumnDescriptions"), -1, - uno::makeAny( aColumnNames ), beans::PropertyState_DIRECT_VALUE ); + const uno::Sequence< ::rtl::OUString > aColumnNames = xDataProvider->getColumnDescriptions(); + aArgs.put( "ColumnDescriptions", uno::makeAny( aColumnNames ) ); } - xReceiver->attachDataProvider(m_xDatabaseDataProvider.get()); - xReceiver->setArguments( aArgs ); + xReceiver->attachDataProvider( m_xDatabaseDataProvider.get() ); + xReceiver->setArguments( aArgs.getPropertyValues() ); } } @@ -204,6 +195,7 @@ void SAL_CALL ImportDocumentHandler::startElement(const ::rtl::OUString & _sName } m_xDelegatee->startElement(lcl_createAttribute(XML_NP_OFFICE,XML_CHART),NULL); bExport = false; + m_bImportedChart = true; } else if ( _sName.equalsAscii("rpt:master-detail-field") ) { diff --git a/reportdesign/source/filter/xml/xmlImportDocumentHandler.hxx b/reportdesign/source/filter/xml/xmlImportDocumentHandler.hxx index 3f0fdebfc111..579a1b79b231 100644 --- a/reportdesign/source/filter/xml/xmlImportDocumentHandler.hxx +++ b/reportdesign/source/filter/xml/xmlImportDocumentHandler.hxx @@ -85,6 +85,7 @@ private: virtual ~ImportDocumentHandler(); ::osl::Mutex m_aMutex; + bool m_bImportedChart; ::std::vector< ::rtl::OUString> m_aMasterFields; ::std::vector< ::rtl::OUString> m_aDetailFields; ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > m_aArguments; diff --git a/reportdesign/source/ui/inspection/DataProviderHandler.cxx b/reportdesign/source/ui/inspection/DataProviderHandler.cxx index 57e293994741..d62a9443d490 100644 --- a/reportdesign/source/ui/inspection/DataProviderHandler.cxx +++ b/reportdesign/source/ui/inspection/DataProviderHandler.cxx @@ -27,6 +27,7 @@ #include "precompiled_reportdesign.hxx" #include "DataProviderHandler.hxx" #include +#include #include #include #include @@ -469,21 +470,13 @@ void SAL_CALL DataProviderHandler::actuatingPropertyChanged(const ::rtl::OUStrin sal_Bool bModified = xReport->isModified(); // this fills the chart again - uno::Sequence< beans::PropertyValue > aArgs( 4 ); - aArgs[0] = beans::PropertyValue( - ::rtl::OUString::createFromAscii("CellRangeRepresentation"), -1, - uno::makeAny( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("all")) ), beans::PropertyState_DIRECT_VALUE ); - aArgs[1] = beans::PropertyValue( - ::rtl::OUString::createFromAscii("HasCategories"), -1, - uno::makeAny( sal_True ), beans::PropertyState_DIRECT_VALUE ); - aArgs[2] = beans::PropertyValue( - ::rtl::OUString::createFromAscii("FirstCellAsLabel"), -1, - uno::makeAny( sal_True ), beans::PropertyState_DIRECT_VALUE ); - aArgs[3] = beans::PropertyValue( - ::rtl::OUString::createFromAscii("DataRowSource"), -1, - uno::makeAny( chart::ChartDataRowSource_COLUMNS ), beans::PropertyState_DIRECT_VALUE ); + ::comphelper::NamedValueCollection aArgs; + aArgs.put( "CellRangeRepresentation", uno::makeAny( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "all" ) ) ) ); + aArgs.put( "HasCategories", uno::makeAny( sal_True ) ); + aArgs.put( "FirstCellAsLabel", uno::makeAny( sal_True ) ); + aArgs.put( "DataRowSource", uno::makeAny( chart::ChartDataRowSource_COLUMNS ) ); uno::Reference< chart2::data::XDataReceiver > xReceiver(m_xChartModel,uno::UNO_QUERY_THROW); - xReceiver->setArguments( aArgs ); + xReceiver->setArguments( aArgs.getPropertyValues() ); if ( !bModified ) xReport->setModified(sal_False); } // if ( NewValue != OldValue ) -- cgit From 5e8e3f41a72bf7be444b501a97481443fce5a23c Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Wed, 22 Sep 2010 16:19:51 +0200 Subject: dba33j: GCC WaE --- dbaccess/source/core/misc/DatabaseDataProvider.cxx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dbaccess/source/core/misc/DatabaseDataProvider.cxx b/dbaccess/source/core/misc/DatabaseDataProvider.cxx index bb41b5062ff8..ab0ccc737a11 100644 --- a/dbaccess/source/core/misc/DatabaseDataProvider.cxx +++ b/dbaccess/source/core/misc/DatabaseDataProvider.cxx @@ -244,10 +244,10 @@ uno::Reference< chart2::data::XDataSource > SAL_CALL DatabaseDataProvider::creat uno::Reference< lang::XInitialization> xIni(m_xInternal,uno::UNO_QUERY); if ( xIni.is() ) { - uno::Sequence< uno::Any > aArgs(1); + uno::Sequence< uno::Any > aInitArgs(1); beans::NamedValue aParam(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CreateDefaultData")),uno::makeAny(sal_True)); - aArgs[0] <<= aParam; - xIni->initialize(aArgs); + aInitArgs[0] <<= aParam; + xIni->initialize(aInitArgs); } } -- cgit From e5ab3e1c6d76f36d9d1fe44f5c48981fc9e73942 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Wed, 22 Sep 2010 17:26:17 +0200 Subject: dba33j: unxmacxi.pro: WaE --- reportdesign/source/filter/xml/xmlImportDocumentHandler.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/reportdesign/source/filter/xml/xmlImportDocumentHandler.cxx b/reportdesign/source/filter/xml/xmlImportDocumentHandler.cxx index c0ae9152e146..92ee79509dea 100644 --- a/reportdesign/source/filter/xml/xmlImportDocumentHandler.cxx +++ b/reportdesign/source/filter/xml/xmlImportDocumentHandler.cxx @@ -58,8 +58,8 @@ using namespace ::xmloff::token; ::rtl::OUString lcl_createAttribute(const xmloff::token::XMLTokenEnum& _eNamespace,const xmloff::token::XMLTokenEnum& _eAttribute); ImportDocumentHandler::ImportDocumentHandler(uno::Reference< uno::XComponentContext > const & context) - :m_xContext(context) - ,m_bImportedChart( false ) + :m_bImportedChart( false ) + ,m_xContext(context) { } // ----------------------------------------------------------------------------- -- cgit