diff options
Diffstat (limited to 'qadevOOo/runner/graphical/OpenOfficeDatabaseReportExtractor.java')
-rw-r--r-- | qadevOOo/runner/graphical/OpenOfficeDatabaseReportExtractor.java | 180 |
1 files changed, 48 insertions, 132 deletions
diff --git a/qadevOOo/runner/graphical/OpenOfficeDatabaseReportExtractor.java b/qadevOOo/runner/graphical/OpenOfficeDatabaseReportExtractor.java index a325ba5aaf0d..a0592d5ce143 100644 --- a/qadevOOo/runner/graphical/OpenOfficeDatabaseReportExtractor.java +++ b/qadevOOo/runner/graphical/OpenOfficeDatabaseReportExtractor.java @@ -64,7 +64,7 @@ class PropertySetHelper XPropertySet m_xPropertySet; public PropertySetHelper(Object _aObj) { - m_xPropertySet = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, _aObj); + m_xPropertySet = UnoRuntime.queryInterface(XPropertySet.class, _aObj); } /** @@ -115,12 +115,12 @@ public class OpenOfficeDatabaseReportExtractor extends Assurance try { XInterface xInterface = (XInterface) getMultiServiceFactory().createInstance( "com.sun.star.frame.Desktop" ); - m_xDesktop = (XDesktop) UnoRuntime.queryInterface(XDesktop.class, xInterface); + m_xDesktop = UnoRuntime.queryInterface(XDesktop.class, xInterface); } catch (com.sun.star.uno.Exception e) { - GlobalLogWriter.get().println("ERROR: uno.Exception caught"); - GlobalLogWriter.get().println("Message: " + e.getMessage()); + GlobalLogWriter.println("ERROR: uno.Exception caught"); + GlobalLogWriter.println("Message: " + e.getMessage()); } } return m_xDesktop; @@ -149,7 +149,7 @@ public class OpenOfficeDatabaseReportExtractor extends Assurance { if (m_xMultiServiceFactory == null) { - m_xMultiServiceFactory = (XMultiServiceFactory)m_aParameterHelper.getMultiServiceFactory(); + m_xMultiServiceFactory = m_aParameterHelper.getMultiServiceFactory(); } return m_xMultiServiceFactory; } @@ -192,95 +192,11 @@ public class OpenOfficeDatabaseReportExtractor extends Assurance /** * This is the main test Function of current ReportDesignerTest + * @param _sDocument + * @return */ -// public void load(String _sDocumentName) -// { -// // convwatch.GlobalLogWriter.set(log); -// -// // GlobalLogWriter.get().println("Set office watcher"); -// // OfficeWatcher aWatcher = (OfficeWatcher)m_aParameterHelper.getTestParameters().get("Watcher"); -// // GlobalLogWriter.get().setWatcher(aWatcher); -// -// try -// { -// -// // -------------------- preconditions, try to find an office -------------------- -// -//// String sAppExecutionCommand = (String) m_aParameterHelper.getTestParameters().get("AppExecutionCommand"); -//// GlobalLogWriter.get().println("sAppExecutionCommand='" + sAppExecutionCommand + "'"); -//// -//// String sUser = System.getProperty("user.name"); -//// GlobalLogWriter.get().println("user.name='" + sUser + "'"); -//// -//// // String sVCSID = System.getProperty("VCSID"); -//// // GlobalLogWriter.get().println("VCSID='" + sVCSID + "'"); -//// // m_sMailAddress = sVCSID + "@openoffice.org"; -//// m_sMailAddress = System.getProperty("MailAddress"); -//// GlobalLogWriter.get().println("Assumed mail address: " + m_sMailAddress); -//// -//// m_sParentDistinct = System.getProperty("ParentDistinct"); -//// -//// m_sSourceVersion = System.getProperty("SourceVersion"); -//// m_sSourceName = System.getProperty("SourceName"); -//// m_sDestinationVersion = System.getProperty("DestinationVersion"); -//// m_sDestinationName = System.getProperty("DestinationName"); -//// // createDBEntry(); -//// // GlobalLogWriter.get().println("Current CWS: " + m_sCWS_WORK_STAMP); -//// // GlobalLogWriter.get().println("Current MWS: " + m_sUPDMinor); -//// -//// if (m_sSourceVersion == null) -//// { -//// System.out.println("Error, Sourceversion is null."); -//// System.exit(1); -//// } -//// -//// sAppExecutionCommand = sAppExecutionCommand.replaceAll( "\\$\\{USERNAME\\}", sUser); -//// GlobalLogWriter.get().println("sAppExecutionCommand='" + sAppExecutionCommand + "'"); -// -// // an other way to replace strings -// // sAppExecutionCommand = utils.replaceAll13(sAppExecutionCommand, "${USERNAME}", sUser); -// -// // checkIfOfficeExists(sAppExecutionCommand); -// // param.put("AppExecutionCommand", new String(sAppExecutionCommand)); -// -// // System.exit(1); -// -// // --------------------------- Start the given Office --------------------------- -// -// // startOffice(); -// -// // ------------------------------ Start a test run ------------------------------ -// -// // String sCurrentDirectory = System.getProperty("user.dir"); -// // GlobalLogWriter.get().println("Current Dir: " + sCurrentDirectory); -//// String sDocument = (String) m_aParameterHelper.getTestParameters().get(convwatch.PropertyName.DOC_COMPARATOR_INPUT_PATH); -//// sDocument = helper.StringHelper.removeQuoteIfExists( sDocument ); -// startTestForFile(_sDocumentName); -// // if (sDocument.toLowerCase().indexOf("writer") >= 0) -// // { -// // startTestForFile(sDocument, WRITER); -// // } -// // else if (sDocument.toLowerCase().indexOf("calc") >= 0) -// // { -// // startTestForFile(sDocument, CALC); -// // } -// // else -// // { -// // assure("Can't identify the document no 'writer' nor 'calc' in it's name given.", false); -// // } -// } -// catch (AssureException e) -// { -// // stopOffice(); -// // throw new AssureException(e.getMessage()); -// } -// -// // ------------------------------ Office shutdown ------------------------------ -// // stopOffice(); -// } -// ----------------------------------------------------------------------------- - public ArrayList load(String _sDocument /*, int _nType*/) + public ArrayList<String> load(String _sDocument /*, int _nType*/) { // We need to copy the database file to a place where we have write access, NEVER use the docpool for this String sOutputPath = m_aParameterHelper.getOutputPath(); @@ -295,9 +211,9 @@ public class OpenOfficeDatabaseReportExtractor extends Assurance assure("There exists no file: " + sDestinationFile, FileHelper.exists(sDestinationFile)); String sFileURL = URLHelper.getFileURLFromSystemPath(sDestinationFile); - GlobalLogWriter.get().println("File URL: " + sFileURL); + GlobalLogWriter.println("File URL: " + sFileURL); - ArrayList aPropertyList = new ArrayList(); + ArrayList<PropertyValue> aPropertyList = new ArrayList<PropertyValue>(); // FYI: it is not allowed to open the document read only // PropertyValue aReadOnly = new PropertyValue(); // always overwrite already exist files @@ -307,7 +223,7 @@ public class OpenOfficeDatabaseReportExtractor extends Assurance XComponent xDocComponent = loadComponent(sFileURL, getXDesktop(), aPropertyList); - GlobalLogWriter.get().println("Load done"); + GlobalLogWriter.println("Load done"); // context = createUnoService("com.sun.star.sdb.DatabaseContext") // oDataBase = context.getByName("hh") // oDBDoc = oDataBase.DatabaseDocument @@ -318,35 +234,35 @@ public class OpenOfficeDatabaseReportExtractor extends Assurance // reportContainer = oDBDoc.getReportDocuments() // report = reportContainer.loadComponentFromURL("Report40","",0,args) - ArrayList aList = null; + ArrayList<String> aList = null; try { // XInterface x = (XInterface)getMultiServiceFactory().createInstance("com.sun.star.sdb.DatabaseContext"); // assure("can't create instance of com.sun.star.sdb.DatabaseContext", x != null); -// GlobalLogWriter.get().println("createInstance com.sun.star.sdb.DatabaseContext done"); +// GlobalLogWriter.println("createInstance com.sun.star.sdb.DatabaseContext done"); // XNameAccess xNameAccess = (XNameAccess) UnoRuntime.queryInterface(XNameAccess.class, x); // showElements(xNameAccess); // Object aObj = xNameAccess.getByName(sFileURL); -// GlobalLogWriter.get().println("1"); +// GlobalLogWriter.println("1"); // PropertySetHelper aHelper = new PropertySetHelper(aObj); // XDocumentDataSource xDataSource = (XDocumentDataSource)UnoRuntime.queryInterface(XDocumentDataSource.class, aObj); // Object aDatabaseDocument = aHelper.getPropertyValueAsObject("DatabaseDocument"); // XOfficeDatabaseDocument xOfficeDBDoc = xDataSource.getDatabaseDocument(); - XOfficeDatabaseDocument xOfficeDBDoc = (XOfficeDatabaseDocument)UnoRuntime.queryInterface(XOfficeDatabaseDocument.class, xDocComponent); + XOfficeDatabaseDocument xOfficeDBDoc = UnoRuntime.queryInterface(XOfficeDatabaseDocument.class, xDocComponent); // XOfficeDatabaseDocument xOfficeDBDoc = (XOfficeDatabaseDocument)UnoRuntime.queryInterface(XOfficeDatabaseDocument.class, xDataSource); assure("can't access DatabaseDocument", xOfficeDBDoc != null); -// GlobalLogWriter.get().println("2"); +// GlobalLogWriter.println("2"); - XModel xDBSource = (XModel)UnoRuntime.queryInterface(XModel.class, xOfficeDBDoc); + XModel xDBSource = UnoRuntime.queryInterface(XModel.class, xOfficeDBDoc); Object aController = xDBSource.getCurrentController(); assure("Controller of xOfficeDatabaseDocument is empty!", aController != null); -// GlobalLogWriter.get().println("3"); +// GlobalLogWriter.println("3"); - XDatabaseDocumentUI aDBDocUI = (XDatabaseDocumentUI)UnoRuntime.queryInterface(XDatabaseDocumentUI.class, aController); + XDatabaseDocumentUI aDBDocUI = UnoRuntime.queryInterface(XDatabaseDocumentUI.class, aController); aDBDocUI.connect(); boolean isConnect = aDBDocUI.isConnected(); if (isConnect) @@ -360,19 +276,19 @@ public class OpenOfficeDatabaseReportExtractor extends Assurance // aHelper = new PropertySetHelper(aController); - XReportDocumentsSupplier xSupplier = (XReportDocumentsSupplier)UnoRuntime.queryInterface(XReportDocumentsSupplier.class, xOfficeDBDoc); + XReportDocumentsSupplier xSupplier = UnoRuntime.queryInterface(XReportDocumentsSupplier.class, xOfficeDBDoc); XNameAccess xNameAccess = xSupplier.getReportDocuments(); assure("xOfficeDatabaseDocument returns no Report Document", xNameAccess != null); -// GlobalLogWriter.get().println("5"); +// GlobalLogWriter.println("5"); showElements(xNameAccess); // Object aActiveConnectionObj = aHelper.getPropertyValueAsObject("ActiveConnection"); Object aActiveConnectionObj = aDBDocUI.getActiveConnection(); assure("ActiveConnection is empty", aActiveConnectionObj != null); -// GlobalLogWriter.get().println("5"); +// GlobalLogWriter.println("5"); - ArrayList aPropertyList2 = new ArrayList(); + ArrayList<PropertyValue> aPropertyList2 = new ArrayList<PropertyValue>(); PropertyValue aActiveConnection = new PropertyValue(); aActiveConnection.Name = "ActiveConnection"; @@ -384,8 +300,8 @@ public class OpenOfficeDatabaseReportExtractor extends Assurance } catch(Exception/*com.sun.star.uno.Exception*/ e) { - GlobalLogWriter.get().println("ERROR: Exception caught"); - GlobalLogWriter.get().println("Message: " + e.getMessage()); + GlobalLogWriter.println("ERROR: Exception caught"); + GlobalLogWriter.println("Message: " + e.getMessage()); } // String mTestDocumentPath = (String) param.get("TestDocumentPath"); @@ -413,7 +329,7 @@ public class OpenOfficeDatabaseReportExtractor extends Assurance String sDBConnection = (String)m_aParameterHelper.getTestParameters().get( convwatch.PropertyName.DB_CONNECTION_STRING ); if (sDBConnection != null && sDBConnection.length() > 0) { - GlobalLogWriter.get().println("DBConnection: " + sDBConnection); + GlobalLogWriter.println("DBConnection: " + sDBConnection); // TODO: DB // DB.init(sDBConnection); @@ -447,9 +363,9 @@ public class OpenOfficeDatabaseReportExtractor extends Assurance } } - private ArrayList loadAndStoreReports(XNameAccess _xNameAccess, ArrayList _aPropertyList /*, int _nType*/ ) + private ArrayList<String> loadAndStoreReports(XNameAccess _xNameAccess, ArrayList<PropertyValue> _aPropertyList /*, int _nType*/ ) { - ArrayList aList = new ArrayList(); + ArrayList<String> aList = new ArrayList<String>(); if (_xNameAccess != null) { String[] sElementNames = _xNameAccess.getElementNames(); @@ -473,7 +389,7 @@ public class OpenOfficeDatabaseReportExtractor extends Assurance private String getFormatExtension(Object _xComponent /* int _nType*/ ) { String sExtension; - XServiceInfo xServiceInfo = (XServiceInfo) UnoRuntime.queryInterface( XServiceInfo.class, _xComponent ); + XServiceInfo xServiceInfo = UnoRuntime.queryInterface( XServiceInfo.class, _xComponent ); if ( xServiceInfo.supportsService( "com.sun.star.sheet.SpreadsheetDocument" ) ) { // calc @@ -567,7 +483,7 @@ public class OpenOfficeDatabaseReportExtractor extends Assurance String sOutputURL = URLHelper.getFileURLFromSystemPath(sOutputPath); - ArrayList aPropertyList = new ArrayList(); // set some properties for storeAsURL + ArrayList<PropertyValue> aPropertyList = new ArrayList<PropertyValue>(); // set some properties for storeAsURL // PropertyValue aFileFormat = new PropertyValue(); // aFileFormat.Name = "FilterName"; @@ -580,19 +496,19 @@ public class OpenOfficeDatabaseReportExtractor extends Assurance aPropertyList.add(aOverwrite); // store the document in an other directory - XStorable aStorable = (XStorable) UnoRuntime.queryInterface( XStorable.class, _xComponent); + XStorable aStorable = UnoRuntime.queryInterface( XStorable.class, _xComponent); if (aStorable != null) { - GlobalLogWriter.get().println("store document as URL: '" + sOutputURL + "'"); + GlobalLogWriter.println("store document as URL: '" + sOutputURL + "'"); try { aStorable.storeAsURL(sOutputURL, PropertyHelper.createPropertyValueArrayFormArrayList(aPropertyList)); } catch (com.sun.star.io.IOException e) { - GlobalLogWriter.get().println("ERROR: Exception caught"); - GlobalLogWriter.get().println("Can't write document URL: '" + sOutputURL + "'"); - GlobalLogWriter.get().println("Message: " + e.getMessage()); + GlobalLogWriter.println("ERROR: Exception caught"); + GlobalLogWriter.println("Can't write document URL: '" + sOutputURL + "'"); + GlobalLogWriter.println("Message: " + e.getMessage()); } } return sBackPathName; @@ -601,26 +517,26 @@ public class OpenOfficeDatabaseReportExtractor extends Assurance private XComponent loadComponent(String _sName, Object _xComponent, ArrayList _aPropertyList) { XComponent xDocComponent = null; - XComponentLoader xComponentLoader = (XComponentLoader) UnoRuntime.queryInterface( XComponentLoader.class, _xComponent ); + XComponentLoader xComponentLoader = UnoRuntime.queryInterface( XComponentLoader.class, _xComponent ); try { PropertyValue[] aLoadProperties = PropertyHelper.createPropertyValueArrayFormArrayList(_aPropertyList); - GlobalLogWriter.get().println("Load component: '" + _sName + "'"); + GlobalLogWriter.println("Load component: '" + _sName + "'"); xDocComponent = xComponentLoader.loadComponentFromURL(_sName, "_blank", FrameSearchFlag.ALL, aLoadProperties); - GlobalLogWriter.get().println("Load component: '" + _sName + "' done"); + GlobalLogWriter.println("Load component: '" + _sName + "' done"); } catch (com.sun.star.io.IOException e) { - GlobalLogWriter.get().println("ERROR: Exception caught"); - GlobalLogWriter.get().println("Can't load document '" + _sName + "'"); - GlobalLogWriter.get().println("Message: " + e.getMessage()); + GlobalLogWriter.println("ERROR: Exception caught"); + GlobalLogWriter.println("Can't load document '" + _sName + "'"); + GlobalLogWriter.println("Message: " + e.getMessage()); } catch (com.sun.star.lang.IllegalArgumentException e) { - GlobalLogWriter.get().println("ERROR: Exception caught"); - GlobalLogWriter.get().println("Illegal Arguments given to loadComponentFromURL."); - GlobalLogWriter.get().println("Message: " + e.getMessage()); + GlobalLogWriter.println("ERROR: Exception caught"); + GlobalLogWriter.println("Illegal Arguments given to loadComponentFromURL."); + GlobalLogWriter.println("Message: " + e.getMessage()); } return xDocComponent; } @@ -628,16 +544,16 @@ public class OpenOfficeDatabaseReportExtractor extends Assurance private void closeComponent(XComponent _xDoc) { // Close the document - XCloseable xCloseable = (XCloseable) UnoRuntime.queryInterface(XCloseable.class, _xDoc); + XCloseable xCloseable = UnoRuntime.queryInterface(XCloseable.class, _xDoc); try { xCloseable.close(true); } catch (com.sun.star.util.CloseVetoException e) { - GlobalLogWriter.get().println("ERROR: CloseVetoException caught"); - GlobalLogWriter.get().println("CloseVetoException occured Can't close document."); - GlobalLogWriter.get().println("Message: " + e.getMessage()); + GlobalLogWriter.println("ERROR: CloseVetoException caught"); + GlobalLogWriter.println("CloseVetoException occured Can't close document."); + GlobalLogWriter.println("Message: " + e.getMessage()); } } |