diff options
author | Noel Grandin <noel@peralex.com> | 2014-08-12 12:11:25 +0200 |
---|---|---|
committer | Noel Grandin <noel@peralex.com> | 2014-08-19 14:57:13 +0200 |
commit | 3a8d3519889a68ddf209ea7c83307bec51cd6da0 (patch) | |
tree | ab67ef1b6f1f65443b7c4d0e086fdcff17f84283 /qadevOOo/runner/util | |
parent | 8b65a61788aa18e97de068bc75fdeecb20a23026 (diff) |
java: remove unused methods
Change-Id: Ibb905e6f3e7d92a0e558f1f6562e5b472cd2717b
Diffstat (limited to 'qadevOOo/runner/util')
-rw-r--r-- | qadevOOo/runner/util/DBTools.java | 215 | ||||
-rw-r--r-- | qadevOOo/runner/util/DrawTools.java | 29 | ||||
-rw-r--r-- | qadevOOo/runner/util/SOfficeFactory.java | 17 | ||||
-rw-r--r-- | qadevOOo/runner/util/UITools.java | 120 | ||||
-rw-r--r-- | qadevOOo/runner/util/XMLTools.java | 67 |
5 files changed, 0 insertions, 448 deletions
diff --git a/qadevOOo/runner/util/DBTools.java b/qadevOOo/runner/util/DBTools.java index 4d41dbc0fe08..f6cd9a865e46 100644 --- a/qadevOOo/runner/util/DBTools.java +++ b/qadevOOo/runner/util/DBTools.java @@ -19,29 +19,18 @@ package util; import com.sun.star.uno.Exception; -import java.io.PrintWriter ; - import com.sun.star.lang.XMultiServiceFactory; import com.sun.star.uno.UnoRuntime; import com.sun.star.beans.PropertyValue; import com.sun.star.beans.XPropertySet; import com.sun.star.sdbc.XConnection ; -import com.sun.star.sdbc.XResultSet ; -import com.sun.star.sdbc.XResultSetUpdate ; -import com.sun.star.sdbc.XStatement ; -import com.sun.star.sdbc.XRowUpdate ; import com.sun.star.util.Date ; import com.sun.star.uno.XNamingService ; import com.sun.star.task.XInteractionHandler ; import com.sun.star.sdb.XCompletedConnection ; -import com.sun.star.io.XInputStream ; -import com.sun.star.io.XTextInputStream ; -import com.sun.star.io.XDataInputStream ; -import com.sun.star.container.XNameAccess ; import com.sun.star.frame.XStorable; import com.sun.star.sdb.XDocumentDataSource; -import com.sun.star.sdbc.XCloseable ; import java.sql.Statement; import java.sql.Connection; import java.sql.DriverManager; @@ -184,50 +173,6 @@ public class DBTools { } /** - * Prints datasource info. - * @param out Stream to which information is printed. - */ - private void printInfo(PrintWriter out) { - out.println("Name = '" + Name + "'") ; - out.println(" URL = '" + URL + "'") ; - out.print(" Info = ") ; - if (Info == null) out.println("null") ; - else { - out.print("{") ; - for (int i = 0; i < Info.length; i++) { - out.print(Info[i].Name + " = '" + Info[i].Value + "'") ; - if (i + 1 < Info.length) out.print("; ") ; - } - out.println("}") ; - } - out.println(" User = '" + User + "'") ; - out.println(" Password = '" + Password + "'") ; - out.println(" IsPasswordRequired = '" + IsPasswordRequired + "'") ; - out.println(" SuppressVersionColumns = '" + SuppressVersionColumns + "'") ; - out.println(" IsReadOnly = '" + IsReadOnly + "'") ; - out.print(" TableFilter = ") ; - if (TableFilter == null) out.println("null") ; - else { - out.print("{") ; - for (int i = 0; i < TableFilter.length; i++) { - out.print("'" + TableFilter[i] + "'") ; - if (i+1 < TableFilter.length) out.print("; "); - } - out.println("}") ; - } - out.print(" TableTypeFilter = ") ; - if (TableTypeFilter == null) out.println("null") ; - else { - out.print("{") ; - for (int i = 0; i < TableTypeFilter.length; i++) { - out.print("'" + TableTypeFilter[i] + "'") ; - if (i+1 < TableTypeFilter.length) out.print("; "); - } - out.println("}") ; - } - } - - /** * Creates new <code>com.sun.star.sdb.DataSource</code> service * instance and copies all fields (which are not null) to * appropriate service properties. @@ -338,166 +283,6 @@ public class DBTools { } /** - * Registers Test data source in the <code>DatabaseContext</code> service. - * This source always has name <code>'APITestDatabase'</code> and it - * is registered in subdirectory <code>TestDB</code> of directory - * <code>docPath</code> which is supposed to be a directory with test - * documents, but can be any other (it must have subdirectory with DBF - * tables). If such data source doesn't exists or exists with - * different URL it is recreated and reregistered. - * @param docPath Path to database <code>TestDB</code> directory. - * @return <code>com.sun.star.sdb.DataSource</code> service - * implementation which represents TestDB. - */ - private Object registerTestDB(String docPath) - throws com.sun.star.uno.Exception { - - String testURL = null ; - if (docPath.endsWith("/") || docPath.endsWith("\\")) - testURL = dirToUrl(docPath + "TestDB") ; - else - testURL = dirToUrl(docPath + "/" + "TestDB") ; - testURL = "sdbc:dbase:" + testURL ; - - String existURL = null ; - - XNameAccess na = UnoRuntime.queryInterface - (XNameAccess.class, dbContext) ; - - Object src = null ; - if (na.hasByName("APITestDatabase")) { - src = dbContext.getRegisteredObject("APITestDatabase") ; - - XPropertySet srcPs = UnoRuntime.queryInterface - (XPropertySet.class, src) ; - - existURL = (String) srcPs.getPropertyValue("URL") ; - } - - if (src == null || !testURL.equals(existURL)) { - // test data source must be reregistered. - DataSourceInfo info = new DataSourceInfo() ; - info.URL = testURL ; - src = info.getDataSourceService() ; - reRegisterDB("APITestDatabase", src) ; - src = dbContext.getRegisteredObject("APITestDatabase") ; - } - - return src ; - } - - - - /** - * Empties the table in the specified source. - * @param con Connection to the DataSource where appropriate - * table exists. - * @param table The name of the table where all rows will be deleted. - * @return Number of rows deleted. - */ - - // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - // Currently doesn't work because of bugs 85509, 85510 - - private int deleteAllRows(XConnection con, String table) - throws com.sun.star.sdbc.SQLException { - - XStatement stat = con.createStatement() ; - - XResultSet set = stat.executeQuery("SELECT * FROM " + table) ; - - XResultSetUpdate updt = UnoRuntime.queryInterface - (XResultSetUpdate.class, set) ; - - int count = 0 ; - set.last() ; - int rowNum = set.getRow() ; - set.first() ; - - for (int i = 0; i < rowNum; i++) { - updt.deleteRow() ; - set.next() ; - count ++ ; - } - - XCloseable xClose = UnoRuntime.queryInterface - (XCloseable.class, set) ; - xClose.close() ; - - return count ; - } - - /** - * Inserts row into test table of the specified connection. - * Test table has some predefined format which includes as much - * field types as possible. For every column type constants - * {@link #TST_STRING TST_STRING}, {@link #TST_INT TST_INT}, etc. - * are declared for column index fast find. - * @param con Connection to data source where test table exists. - * @param table Test table name. - * @param values Values to be inserted into test table. Values of - * this array inserted into appropriate fields depending on their - * types. So <code>String</code> value of the array is inserted - * into the field of <code>CHARACTER</code> type, etc. - * @param streamLength Is optional. It is used only if in values - * list <code>XCharacterInputStream</code> or <code>XBinaryInputStream - * </code> types specified. In this case the parameter specifies - * the length of the stream for inserting. - */ - private void addRowToTestTable(XConnection con, String table, Object[] values, - int streamLength) - throws com.sun.star.sdbc.SQLException { - - XStatement stat = con.createStatement() ; - - XResultSet set = stat.executeQuery("SELECT * FROM " + table) ; - - XResultSetUpdate updt = UnoRuntime.queryInterface - (XResultSetUpdate.class, set) ; - - XRowUpdate rowUpdt = UnoRuntime.queryInterface - (XRowUpdate.class, set) ; - - updt.moveToInsertRow() ; - - for (int i = 0; i < values.length; i++) { - if (values[i] instanceof String) { - rowUpdt.updateString(TST_STRING, (String) values[i]) ; - } else - if (values[i] instanceof Integer) { - rowUpdt.updateInt(TST_INT, ((Integer) values[i]).intValue()) ; - } else - if (values[i] instanceof Double) { - rowUpdt.updateDouble(TST_DOUBLE, ((Double) values[i]).doubleValue()) ; - } else - if (values[i] instanceof Date) { - rowUpdt.updateDate(TST_DATE, (Date) values[i]) ; - } else - if (values[i] instanceof Boolean) { - rowUpdt.updateBoolean(TST_BOOLEAN, ((Boolean) values[i]).booleanValue()) ; - } else - if (values[i] instanceof XTextInputStream) { - rowUpdt.updateCharacterStream(TST_CHARACTER_STREAM, (XInputStream) values[i], - streamLength) ; - } else - if (values[i] instanceof XDataInputStream) { - rowUpdt.updateBinaryStream(TST_BINARY_STREAM, (XInputStream) values[i], - streamLength) ; - } - } - - updt.insertRow() ; - - XCloseable xClose = UnoRuntime.queryInterface - (XCloseable.class, set) ; - xClose.close() ; - } - - - - - - /** * Convert system pathname to SOffice URL string * (for example 'C:\Temp\DBDir\' -> 'file:///C|/Temp/DBDir/'). * (for example '\\server\Temp\DBDir\' -> 'file://server/Temp/DBDir/'). diff --git a/qadevOOo/runner/util/DrawTools.java b/qadevOOo/runner/util/DrawTools.java index 4facd805fd34..43c9e51a2411 100644 --- a/qadevOOo/runner/util/DrawTools.java +++ b/qadevOOo/runner/util/DrawTools.java @@ -28,13 +28,7 @@ import com.sun.star.drawing.XDrawPages; import com.sun.star.drawing.XDrawPagesSupplier; import com.sun.star.drawing.XDrawPage; import com.sun.star.drawing.XShapes; -import com.sun.star.drawing.XShape; - - import util.DesktopTools; -import util.InstCreator; -import util.ShapeDsc; - import com.sun.star.uno.AnyConverter; import com.sun.star.uno.Type; @@ -107,27 +101,4 @@ public class DrawTools { return UnoRuntime.queryInterface(XShapes.class,oDP); } - /** - * creates a XShape - * - * @param oDoc the document - * @param height the height of the shape - * @param width the width of the shape - * @param x the x-position of the shape - * @param y the y-position of the shape - * @param kind the kind of the shape ('Ellipse', 'Line' or 'Rectangle') - * @return the created XShape - */ - - private XShape createShape( XComponent oDoc, int height, int width, int x, - int y, String kind ) { - //possible values for kind are 'Ellipse', 'Line' and 'Rectangle' - - ShapeDsc sDsc = new ShapeDsc( height, width, x, y, kind ); - InstCreator instCreate = new InstCreator( oDoc, sDsc ); - XShape oShape = (XShape)instCreate.getInstance(); - - return oShape; - } - } diff --git a/qadevOOo/runner/util/SOfficeFactory.java b/qadevOOo/runner/util/SOfficeFactory.java index 298b8a18952f..f086a0d27fb2 100644 --- a/qadevOOo/runner/util/SOfficeFactory.java +++ b/qadevOOo/runner/util/SOfficeFactory.java @@ -440,22 +440,5 @@ public class SOfficeFactory { } // finished openDoc - private XComponent openDoc(String kind, String frameName, PropertyValue[] mediaDescriptor) - throws com.sun.star.lang.IllegalArgumentException, - com.sun.star.io.IOException, - com.sun.star.uno.Exception { - - if (frameName == null) { - frameName = "_blank"; - } - // load a blank a doc - XComponent oDoc = oCLoader.loadComponentFromURL( - "private:factory/" + kind, frameName, 40, mediaDescriptor); - DesktopTools.bringWindowToFront(oDoc); - - return oDoc; - - } // finished openDoc - } diff --git a/qadevOOo/runner/util/UITools.java b/qadevOOo/runner/util/UITools.java index e1b8ad592aa5..d57167cc75bc 100644 --- a/qadevOOo/runner/util/UITools.java +++ b/qadevOOo/runner/util/UITools.java @@ -83,12 +83,6 @@ public class UITools { oText.setText(cText); } - private static Object getValue(XInterface xInt) - { - XAccessibleValue oValue = UnoRuntime.queryInterface(XAccessibleValue.class, xInt); - return oValue.getCurrentValue(); - } - private static XAccessible makeRoot(XWindow xWindow) { return AccessibilityTools.getAccessibleObject(xWindow); @@ -157,55 +151,6 @@ public class UITools { /** - * Helper method: gets button via accessibility and 'click' it - * @param buttonName The name of the button in the accessibility tree - * @param toBePressed desired state of the toggle button - * - * @return true if the state of the button could be changed in the desired manner - */ - private boolean clickToggleButton(String buttonName, boolean toBePressed) - { - XAccessibleContext oButton =AccessibilityTools.getAccessibleObjectForRole - (mXRoot, AccessibleRole.TOGGLE_BUTTON, buttonName); - - if (oButton != null){ - boolean isChecked = oButton.getAccessibleStateSet().contains(com.sun.star.accessibility.AccessibleStateType.CHECKED); - if((isChecked && !toBePressed) || (!isChecked && toBePressed)){ - XAccessibleAction oAction = UnoRuntime.queryInterface(XAccessibleAction.class, oButton); - try{ - // "click" the button - oAction.doAccessibleAction(0); - return true; - } catch (com.sun.star.lang.IndexOutOfBoundsException e) { - System.out.println("Could not do accessible action with '" - + buttonName + "'" + e.toString()); - return false; - } - }else - //no need to press togglebar, do nothing - return true; - } else{ - System.out.println("Could not get button '" + buttonName + "'"); - return false; - } - } - - - - - - - - - - - - - - - - - /** * Helper method: returns the entry manes of a List-Box * @param ListBoxName the name of the listbox * @return the listbox entry names @@ -266,71 +211,6 @@ public class UITools { /** - * returns the value of a numeric field - * @param NumericFieldName the name of the numreic field - * @throws java.lang.Exception if something fail - * @return the value of the named numeric filed - */ - private String getNumericFieldValue(String NumericFieldName) - throws java.lang.Exception - { - try{ - XInterface xNumericField =AccessibilityTools.getAccessibleObjectForRole( - mXRoot, AccessibleRole.TEXT, NumericFieldName); - return getString(xNumericField); - - } catch (Exception e) { - throw new Exception("Could get value from NumericField '" - + NumericFieldName + "' : " + e.toString()); - } - } - - private String removeCharactersFromCurrencyString(String stringVal) - throws java.lang.Exception - { - try{ - int beginIndex = 0; - int endIndex = 0; - // find the first numeric character in stringVal - for(int i = 0; i < stringVal.length(); i++){ - int numVal = Character.getNumericValue(stringVal.charAt(i)); - // if ascii is a numeric value - if (numVal != -1){ - beginIndex = i; - break; - } - } - // find the last numeric character in stringVal - for(int i = stringVal.length()-1; i > 0; i--){ - int numVal = Character.getNumericValue(stringVal.charAt(i)); - if (numVal != -1){ - endIndex = i+1; - break; - } - } - String currencyVal = stringVal.substring(beginIndex, endIndex); - - currencyVal = currencyVal.substring(0, currencyVal.length()-3) + - "#" + currencyVal.substring(currencyVal.length()-2); - - currencyVal = currencyVal.replace(",", ""); - currencyVal = currencyVal.replace("\\.", ""); - currencyVal = currencyVal.replace("#", "."); - - return currencyVal; - } catch (Exception e) { - throw new Exception("Could get remove characters from currency string '" - + stringVal + "' : " + e.toString()); - } - - } - - - - - - - /** * set a value to a named check box * @param CheckBoxName the name of the check box * @param Value the value to set diff --git a/qadevOOo/runner/util/XMLTools.java b/qadevOOo/runner/util/XMLTools.java index 508fdfd76ebe..a59f523758ca 100644 --- a/qadevOOo/runner/util/XMLTools.java +++ b/qadevOOo/runner/util/XMLTools.java @@ -25,18 +25,9 @@ import java.util.HashSet; import java.util.Iterator; import com.sun.star.beans.PropertyValue; -import com.sun.star.io.XActiveDataSource; -import com.sun.star.io.XInputStream; -import com.sun.star.io.XOutputStream; -import com.sun.star.lang.XMultiServiceFactory; -import com.sun.star.ucb.XSimpleFileAccess; -import com.sun.star.uno.UnoRuntime; -import com.sun.star.uno.XInterface; -import com.sun.star.xml.sax.InputSource; import com.sun.star.xml.sax.XAttributeList; import com.sun.star.xml.sax.XDocumentHandler; import com.sun.star.xml.sax.XLocator; -import com.sun.star.xml.sax.XParser; public class XMLTools { @@ -749,64 +740,6 @@ public class XMLTools { return props ; } - /** - * Gets the hanlder, which writes all the XML data passed to the - * file specified. - * @param xMSF Soffice <code>ServiceManager</code> factory. - * @param fileURL The file URL (in form file:///<path>) to which - * XML data is written. - * @return SAX handler to which XML data has to be written. - */ - private static XDocumentHandler getFileXMLWriter(XMultiServiceFactory xMSF, String fileURL) - throws com.sun.star.uno.Exception - { - XInterface oFacc = (XInterface)xMSF.createInstance( - "com.sun.star.comp.ucb.SimpleFileAccess"); - XSimpleFileAccess xFacc = UnoRuntime.queryInterface - (XSimpleFileAccess.class, oFacc) ; - - XInterface oWriter = (XInterface)xMSF.createInstance( - "com.sun.star.xml.sax.Writer"); - XActiveDataSource xWriterDS = UnoRuntime.queryInterface(XActiveDataSource.class, oWriter); - XDocumentHandler xDocHandWriter = UnoRuntime.queryInterface - (XDocumentHandler.class, oWriter) ; - - if (xFacc.exists(fileURL)) - xFacc.kill(fileURL); - XOutputStream fOut = xFacc.openFileWrite(fileURL) ; - xWriterDS.setOutputStream(fOut); - - return xDocHandWriter ; - } - - /** - * Parses XML file and passes its data to the SAX handler specified. - * @param xMSF Soffice <code>ServiceManager</code> factory. - * @param fileURL XML file name (in form file:///<path>) to be parsed. - * @param handler SAX handler to which XML data from file will - * be transferred. - */ - private static void parseXMLFile(XMultiServiceFactory xMSF, - String fileURL, XDocumentHandler handler) throws com.sun.star.uno.Exception - { - XInterface oFacc = (XInterface)xMSF.createInstance( - "com.sun.star.comp.ucb.SimpleFileAccess"); - XSimpleFileAccess xFacc = UnoRuntime.queryInterface - (XSimpleFileAccess.class, oFacc) ; - XInputStream oIn = xFacc.openFileRead(fileURL) ; - - XInterface oParser = (XInterface)xMSF.createInstance( - "com.sun.star.xml.sax.Parser"); - XParser xParser = UnoRuntime.queryInterface(XParser.class, oParser); - - xParser.setDocumentHandler(handler) ; - InputSource inSrc = new InputSource() ; - inSrc.aInputStream = oIn ; - xParser.parseStream(inSrc) ; - - oIn.closeInput(); - } - |