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 | |
parent | 8b65a61788aa18e97de068bc75fdeecb20a23026 (diff) |
java: remove unused methods
Change-Id: Ibb905e6f3e7d92a0e558f1f6562e5b472cd2717b
Diffstat (limited to 'qadevOOo')
-rw-r--r-- | qadevOOo/runner/complexlib/Assurance.java | 63 | ||||
-rw-r--r-- | qadevOOo/runner/convwatch/IniFile.java | 33 | ||||
-rw-r--r-- | qadevOOo/runner/convwatch/PRNCompare.java | 109 | ||||
-rw-r--r-- | qadevOOo/runner/graphical/MSOfficePostscriptCreator.java | 209 | ||||
-rw-r--r-- | qadevOOo/runner/graphical/OpenOfficePostscriptCreator.java | 232 | ||||
-rw-r--r-- | qadevOOo/runner/helper/ConfigHelper.java | 37 | ||||
-rw-r--r-- | qadevOOo/runner/helper/ProcessHandler.java | 26 | ||||
-rw-r--r-- | qadevOOo/runner/helper/StringHelper.java | 10 | ||||
-rw-r--r-- | qadevOOo/runner/helper/URLHelper.java | 52 | ||||
-rw-r--r-- | qadevOOo/runner/lib/Parameters.java | 3 | ||||
-rw-r--r-- | qadevOOo/runner/org/openoffice/Runner.java | 14 | ||||
-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 |
16 files changed, 0 insertions, 1236 deletions
diff --git a/qadevOOo/runner/complexlib/Assurance.java b/qadevOOo/runner/complexlib/Assurance.java index 575ec0793f69..3c12ca7156ff 100644 --- a/qadevOOo/runner/complexlib/Assurance.java +++ b/qadevOOo/runner/complexlib/Assurance.java @@ -18,9 +18,6 @@ package complexlib; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; - /** * I have removed the assure(...) functions from ComplexTestCase due to the fact now I can * use the functions every where and don't need to be a ComplexTestCase any longer. @@ -122,66 +119,6 @@ public class Assurance - /** invokes a given method on a given object, and assures a certain exception is caught - * @param _message is the message to print when the check fails - * @param _object is the object to invoke the method on - * @param _methodName is the name of the method to invoke - * @param _methodArgs are the arguments to pass to the method. - * @param _argClasses are the classes to assume for the arguments of the methods - * @param _expectedExceptionClass is the class of the exception to be caught. If this is null, - * it means that <em>no</em> exception must be throw by invoking the method. - */ - private void assureException( final String _message, final Object _object, final String _methodName, - final Class<?>[] _argClasses, final Object[] _methodArgs, final Class<?> _expectedExceptionClass ) - { - Class<?> objectClass = _object.getClass(); - - boolean noExceptionAllowed = ( _expectedExceptionClass == null ); - - boolean caughtExpected = noExceptionAllowed; - try - { - Method method = objectClass.getMethod( _methodName, _argClasses ); - method.invoke(_object, _methodArgs ); - } - catch ( InvocationTargetException e ) - { - caughtExpected = noExceptionAllowed - ? false - : ( e.getTargetException().getClass().equals( _expectedExceptionClass ) ); - } - catch( Exception e ) - { - caughtExpected = false; - } - - assure( _message, caughtExpected ); - } - - /** invokes a given method on a given object, and assures a certain exception is caught - * @param _message is the message to print when the check fails - * @param _object is the object to invoke the method on - * @param _methodName is the name of the method to invoke - * @param _methodArgs are the arguments to pass to the method. Those implicitly define - * the classes of the arguments of the method which is called. - * @param _expectedExceptionClass is the class of the exception to be caught. If this is null, - * it means that <em>no</em> exception must be throw by invoking the method. - */ - private void assureException( final String _message, final Object _object, final String _methodName, - final Object[] _methodArgs, final Class<?> _expectedExceptionClass ) - { - Class<?>[] argClasses = new Class[ _methodArgs.length ]; - for ( int i=0; i<_methodArgs.length; ++i ) - argClasses[i] = _methodArgs[i].getClass(); - assureException( _message, _object, _methodName, argClasses, _methodArgs, _expectedExceptionClass ); - } - - - - - - - /** * Mark the currently executed method as failed. * with the given message. diff --git a/qadevOOo/runner/convwatch/IniFile.java b/qadevOOo/runner/convwatch/IniFile.java index 1e7795d4abd5..eaa511afa47d 100644 --- a/qadevOOo/runner/convwatch/IniFile.java +++ b/qadevOOo/runner/convwatch/IniFile.java @@ -198,39 +198,6 @@ class IniFile return -1; } - // i must be the index in the list, where the well known section starts - private int findLastKnownKeyIndex(int _nSectionIndex, String _sKey) - { - _sKey = toLowerIfNeed(_sKey); - int i = _nSectionIndex + 1; - for (int j=i; j<m_aList.size();j++) - { - String sLine = getItem(j).trim(); - - if (isRemark(sLine)) - { - continue; - } - - if (sLine.startsWith("[")) - { - // found end. - return j; - } - - int nEqual = sLine.indexOf("="); - if (nEqual >= 0) - { - String sKey = toLowerIfNeed(sLine.substring(0, nEqual).trim()); - if (sKey.equals(_sKey)) - { - return j; - } - } - } - return i; - } - private String getValue(int _nIndex) { String sLine = getItem(_nIndex).trim(); diff --git a/qadevOOo/runner/convwatch/PRNCompare.java b/qadevOOo/runner/convwatch/PRNCompare.java index dc9b9eb2344f..501ec30ebe17 100644 --- a/qadevOOo/runner/convwatch/PRNCompare.java +++ b/qadevOOo/runner/convwatch/PRNCompare.java @@ -315,115 +315,6 @@ public class PRNCompare } - private StatusHelper[] createDiffs(String[] _aRefList, String[] _aPSList, int _nMaxDiffs, TriState _tUseBorderMove) - { - if (_nMaxDiffs < 1) - { - _nMaxDiffs = 1; - } - - // count, from which file (jpegs) exist more, take the less one - // more are not compareable - - // take the min of both - int nMin = Math.min(_aRefList.length, _aPSList.length); - nMin = Math.min(nMin, _nMaxDiffs); - - StatusHelper[] aList = new StatusHelper[nMin]; - -// TODO: if both document do not have same page count, produce an error - - int nStatusIndex = 0; - for (int i=1;i<=nMin;i++) - { - String sOldGfx = _aRefList[i]; - String sNewGfx = _aPSList[i]; - - - String sDiffGfx = compareJPEGs(sOldGfx, sNewGfx ); - StatusHelper aStatus = new StatusHelper(sOldGfx, sNewGfx, sDiffGfx); - - if (sDiffGfx.length() > 0) - { - int nResult = identify(sDiffGfx); - if (nResult == 1) - { - aStatus.nDiffStatus = StatusHelper.DIFF_NO_DIFFERENCES; - } - else - { - try - { - int nPercent = estimateGfx(sOldGfx, sNewGfx, sDiffGfx); - - aStatus.nDiffStatus = StatusHelper.DIFF_DIFFERENCES_FOUND; - aStatus.nPercent = nPercent; - - if (nPercent > 75 && - ((_tUseBorderMove == TriState.TRUE ) || - ((_tUseBorderMove == TriState.UNSET) && - m_sDocumentType.indexOf("MS PowerPoint") > 0))) - { - _tUseBorderMove = TriState.TRUE; -// TODO: problem is here, that we have to create some new names. - - String sBasename1 = FileHelper.getBasename(sOldGfx); - String sNameNoSuffix1 = FileHelper.getNameNoSuffix(sBasename1); - String sBasename2 = FileHelper.getBasename(sNewGfx); - String sNameNoSuffix2 = FileHelper.getNameNoSuffix(sBasename2); - - String sTmpDir = util.utils.getUsersTempDir(); - String fs = System.getProperty("file.separator"); - - String sOld_BM_Gfx = sTmpDir + fs + sNameNoSuffix1 + "-BM-" + StringHelper.createValueString(i, 4) + ".jpg"; - String sNew_BM_Gfx = sTmpDir + fs + sNameNoSuffix2 + "-BM-" + StringHelper.createValueString(i, 4) + ".jpg"; - try - { - BorderRemover a = new BorderRemover(); - a.createNewImageWithoutBorder(sOldGfx, sOld_BM_Gfx); - a.createNewImageWithoutBorder(sNewGfx, sNew_BM_Gfx); - - String sDiff_BM_Gfx = compareJPEGs( sOld_BM_Gfx, sNew_BM_Gfx ); - - aStatus.setFilesForBorderMove(sOld_BM_Gfx, sNew_BM_Gfx, sDiff_BM_Gfx); - - if (sDiff_BM_Gfx.length() > 0) - { - nResult = identify(sDiff_BM_Gfx); - if (nResult == 1) - { - aStatus.nDiffStatus = StatusHelper.DIFF_AFTER_MOVE_DONE_NO_PROBLEMS; - aStatus.nPercent2 = 0; - } - else - { - nPercent = estimateGfx(sOld_BM_Gfx, sNew_BM_Gfx, sDiff_BM_Gfx); - aStatus.nDiffStatus = StatusHelper.DIFF_AFTER_MOVE_DONE_DIFFERENCES_FOUND; - aStatus.nPercent2 = nPercent; - } - } - else - { - } - } - catch(java.io.IOException e) - { - GlobalLogWriter.get().println("Exception caught. At border remove: " + e.getMessage()); - } - } - } - catch (java.io.IOException e) - { - GlobalLogWriter.get().println(e.getMessage()); - } - } - - } - aList[nStatusIndex ++] = aStatus; - } - return aList; - } - public static String compareJPEGs(String _sOldGfx, String _sNewGfx) { String sBasename1 = FileHelper.getBasename(_sOldGfx); diff --git a/qadevOOo/runner/graphical/MSOfficePostscriptCreator.java b/qadevOOo/runner/graphical/MSOfficePostscriptCreator.java index 8d9e8c9ecd4a..1d3081af6794 100644 --- a/qadevOOo/runner/graphical/MSOfficePostscriptCreator.java +++ b/qadevOOo/runner/graphical/MSOfficePostscriptCreator.java @@ -24,10 +24,6 @@ import java.io.RandomAccessFile; import helper.ProcessHandler; import java.util.ArrayList; import helper.OSHelper; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import org.w3c.dom.Document; -import org.w3c.dom.Node; /** * This object gives all functionallity to print msoffice documents. @@ -416,87 +412,6 @@ public class MSOfficePostscriptCreator implements IOffice return aList; } - private ArrayList<String> createWordStoreHelper() throws java.io.IOException - { - // create a program in tmp file - String sTmpPath = util.utils.getUsersTempDir(); - String ls = System.getProperty("line.separator"); - - String sSaveViaWord = "saveViaWord.pl"; - - ArrayList<String> aList = searchLocalFile(sSaveViaWord); - if (aList.isEmpty() == false) - { - return aList; - } - - String sName = FileHelper.appendPath(sTmpPath, sSaveViaWord); - if (FileHelper.isDebugEnabled()) - { - GlobalLogWriter.println("No local found, create a perl script: " + sName); - } - - File aFile = new File(sName); - FileWriter out = new FileWriter(aFile); - - out.write( "eval 'exec perl -wS $0 ${1+\"$@\"}' " + ls ); - out.write( " if 0; " + ls ); - out.write( "use strict; " + ls ); - out.write( " " + ls ); - out.write( "if ( $^O ne \"MSWin32\") " + ls ); - out.write( "{ " + ls ); - out.write( " print 'Windows only.\\n'; " + ls ); - out.write( " print_usage(); " + ls ); - out.write( " exit(1); " + ls ); - out.write( "} " + ls ); - out.write( " " + ls ); - out.write( "use Win32::OLE; " + ls ); - out.write( "use Win32::OLE::Const 'Microsoft Word'; " + ls ); - out.write( " " + ls ); - out.write( "# ------ usage ------ " + ls ); - out.write( "sub print_usage() " + ls ); - out.write( "{ " + ls ); - out.write( " print STDERR \"Usage: storeViaWord.pl <Word file> <output filer> <output file> \\n\" " + ls ); - out.write( "} " + ls ); - out.write( " " + ls ); - out.write( " " + ls ); - out.write( "if ($#ARGV != 2) " + ls ); - out.write( "{ " + ls ); - out.write( " print 'Too less arguments.\\n'; " + ls ); - out.write( " print_usage(); " + ls ); - out.write( " exit(1); " + ls ); - out.write( "} " + ls ); - out.write( " " + ls ); - out.write( " " + ls ); - out.write( "my $Word = Win32::OLE->new('Word.Application'); " + ls ); - out.write( "# $Word->{'Visible'} = 1; # if you want to see what's going on " + ls ); - out.write( "my $Book = $Word->Documents->Open($ARGV[0]) " + ls ); - out.write( " || die('Unable to open document ', Win32::OLE->LastError()); " + ls ); - out.write( "# my $oldActivePrinte = $Word->{ActivePrinter} ; " + ls ); - out.write( "# $Word->{ActivePrinter} = $ARGV[1]; " + ls ); - out.write( "# $Word->ActiveDocument->PrintOut({ " + ls ); - out.write( "# Background => 0, " + ls ); - out.write( "# Append => 0, " + ls ); - out.write( "# Range => wdPrintAllDocument, " + ls ); - out.write( "# Item => wdPrintDocumentContent, " + ls ); - out.write( "# Copies => 1, " + ls ); - out.write( "# PageType => wdPrintAllPages, " + ls ); - out.write( "# PrintToFile => 1, " + ls ); - out.write( "# OutputFileName => $ARGV[2] " + ls ); - out.write( "# }); " + ls ); - out.write( "# $Word->{ActivePrinter} = $oldActivePrinte; " + ls ); - out.write( "$Book->savaAs($ARGV[2], $ARGV[1]); " + ls ); - out.write( "# ActiveDocument.Close(SaveChanges:=WdSaveOptions.wdDoNotSaveChanges)" + ls ); - out.write( "$Book->Close({SaveChanges => 0}); " + ls ); - out.write( "$Word->Quit(); " + ls ); - out.close(); - - aList.add(getPerlExe()); - aList.add(sName); - return aList; - } - - private ArrayList<String> createExcelPrintHelper() throws java.io.IOException { // create a program in tmp file @@ -595,95 +510,6 @@ public class MSOfficePostscriptCreator implements IOffice return aList; } - private ArrayList<String> createExcelStoreHelper() throws java.io.IOException - { - // create a program in tmp file - String sTmpPath = util.utils.getUsersTempDir(); - String ls = System.getProperty("line.separator"); - - String sSaveViaExcel = "saveViaExcel.pl"; - - ArrayList<String> aList = searchLocalFile(sSaveViaExcel); - if (aList.isEmpty() == false) - { - return aList; - } - String sName = FileHelper.appendPath(sTmpPath, sSaveViaExcel); - if (FileHelper.isDebugEnabled()) - { - GlobalLogWriter.println("No local found, create a script: " + sName); - } - - File aFile = new File(sName); - FileWriter out = new FileWriter(aFile); - - out.write( "eval 'exec perl -wS $0 ${1+\"$@\"}' " + ls ); - out.write( " if 0; " + ls ); - out.write( "use strict; " + ls ); - out.write( "# This script is automatically created. " + ls ); - out.write( " " + ls ); - out.write( "use Win32::OLE qw(in with); " + ls ); - out.write( "use Win32::OLE::Const 'Microsoft Excel'; " + ls ); - out.write( " " + ls ); - out.write( "# ------ usage ------ " + ls ); - out.write( "sub print_usage() " + ls ); - out.write( "{ " + ls ); - out.write( " print STDERR \"Usage: savaViaExcel.pl <Excel file> <filefilter> <output file> .\\n " + ls ); - out.write( " execl_print.pl c:\\book1.xls Apple LaserWriter II NT v47.0 c:\\output\\book1.ps \\n\"; " + ls ); - out.write( "} " + ls ); - out.write( " " + ls ); - out.write( " " + ls ); - out.write( " " + ls ); - out.write( "$Win32::OLE::Warn = 3; # die on errors... " + ls ); - out.write( " " + ls ); - out.write( " " + ls ); - out.write( "if ($#ARGV != 2) " + ls ); - out.write( "{ " + ls ); - out.write( " print \"Too less arguments.\\n\"; " + ls ); - out.write( " print_usage(); " + ls ); - out.write( " exit(1); " + ls ); - out.write( "} " + ls ); - out.write( " " + ls ); - out.write( "my $Excel = Win32::OLE->GetActiveObject('Excel.Application') " + ls ); - out.write( " || Win32::OLE->new('Excel.Application', 'Quit'); # get already active Excel " + ls ); - out.write( " # application or open new " + ls ); - out.write( "my $sFilterParameter = $ARGV[1]; " + ls ); - out.write( "my $sFilterName = xlHTML; " + ls ); - out.write( "if ($sFilterParameter eq 'xlXMLSpreadsheet') " + ls ); - out.write( "{ " + ls ); - out.write( " $sFilterName = xlXMLSpreadsheet; " + ls ); - out.write( "} " + ls ); - out.write( "elsif ($sFilterParameter eq 'xlHTML') " + ls ); - out.write( "{ " + ls ); - out.write( " $sFilterName = xlHTML; " + ls ); - out.write( "} " + ls ); - out.write( "else " + ls ); - out.write( "{ " + ls ); - out.write( " my $undefined; " + ls); - out.write( " $sFilterName = $undefined; " + ls ); - out.write( "} " + ls ); - out.write( " " + ls ); - out.write( "my $Book = $Excel->Workbooks->Open( $ARGV[0] ); " + ls ); - out.write( "$Excel->{DisplayAlerts} = 0; " + ls ); - out.write( "$Book->saveAs($ARGV[2], " + ls ); - out.write( " $sFilterName, " + ls ); - out.write( " '', " + ls ); - out.write( " '', " + ls ); - out.write( " 0, " + ls ); - out.write( " 0, " + ls ); - out.write( " xlNoChange, " + ls ); - out.write( " xlLocalSessionChanges, " + ls ); - out.write( " 1); " + ls ); - out.write( "# Close worksheets without store changes" + ls ); - out.write( "# $Book->Close({SaveChanges => 0}); " + ls ); - out.write( "$Excel->Quit(); " + ls ); - out.close(); - - aList.add(getPerlExe()); - aList.add(sName); - return aList; - } - private ArrayList<String> createPowerPointPrintHelper() throws java.io.IOException { // create a program in tmp file @@ -855,39 +681,4 @@ public class MSOfficePostscriptCreator implements IOffice return sOfficeType; } - private static String getXMLDocumentFormat(String _sInputFile) - { - String sType = "word"; // default - try - { - // ---- Parse XML file ---- - DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); - DocumentBuilder builder = factory.newDocumentBuilder(); - Document document = builder.parse( new File (_sInputFile) ); - Node rootNode = document.getDocumentElement(); - - // ---- Get list of nodes to given tag ---- - // document. - String sRootNodeName = rootNode.getNodeName(); - if (sRootNodeName.equals("w:wordDocument")) - { - sType = "word"; - } - else if (sRootNodeName.equals("WorkBook")) - { - sType = "excel"; - } - // there exists no powerpoint xml representation in MSOffice 2003 - else - { - GlobalLogWriter.println("Error: unknown root node: '" + sRootNodeName + "' please check the document. Try to use Word as default."); - sType = "word"; // default - } - } - catch (java.lang.Exception e) - { - } - return sType; - } - } diff --git a/qadevOOo/runner/graphical/OpenOfficePostscriptCreator.java b/qadevOOo/runner/graphical/OpenOfficePostscriptCreator.java index 9b224b82120f..f63c623975d0 100644 --- a/qadevOOo/runner/graphical/OpenOfficePostscriptCreator.java +++ b/qadevOOo/runner/graphical/OpenOfficePostscriptCreator.java @@ -26,8 +26,6 @@ import java.util.ArrayList; import com.sun.star.uno.UnoRuntime; import com.sun.star.lang.XMultiServiceFactory; -import com.sun.star.document.XTypeDetection; -import com.sun.star.container.XNameAccess; import com.sun.star.frame.XDesktop; import com.sun.star.beans.XPropertySet; import com.sun.star.beans.PropertyValue; @@ -584,236 +582,6 @@ public class OpenOfficePostscriptCreator implements IOffice - private String getInternalFilterName(String _sFilterName, XMultiServiceFactory _xMSF) - { - if (_sFilterName.length() == 0) - { - return null; - } - - if (_xMSF == null) - { - GlobalLogWriter.println("MultiServiceFactory not set."); - return null; - } - Object aObj = null; - try - { - aObj = _xMSF.createInstance("com.sun.star.document.FilterFactory"); - } - catch(com.sun.star.uno.Exception e) - { - GlobalLogWriter.println("Can't get com.sun.star.document.FilterFactory."); - return null; - } - if (aObj != null) - { - XNameAccess aNameAccess = UnoRuntime.queryInterface(XNameAccess.class, aObj); - if (aNameAccess != null) - { - - if (! aNameAccess.hasByName(_sFilterName)) - { - GlobalLogWriter.println("FilterFactory.hasByName() says there exist no '" + _sFilterName + "'" ); - return null; - } - - Object[] aElements = null; - try - { - aElements = (Object[]) aNameAccess.getByName(_sFilterName); - if (aElements != null) - { - String sInternalFilterName = null; - for (int i=0;i<aElements.length; i++) - { - PropertyValue aPropertyValue = (PropertyValue)aElements[i]; - if (aPropertyValue.Name.equals("Type")) - { - String sValue = (String)aPropertyValue.Value; - sInternalFilterName = sValue; - } - } - return sInternalFilterName; - } - else - { - GlobalLogWriter.println("There are no elements for FilterName '" + _sFilterName + "'"); - return null; - } - } - catch (com.sun.star.container.NoSuchElementException e) - { - GlobalLogWriter.println("NoSuchElementException caught. " + e.getMessage()); - } - catch (com.sun.star.lang.WrappedTargetException e) - { - GlobalLogWriter.println("WrappedTargetException caught. " + e.getMessage()); - } - } - } - return null; - } - - - - private String getServiceNameFromFilterName(String _sFilterName, XMultiServiceFactory _xMSF) - { - if (_sFilterName.length() == 0) - { - return null; - } - - if (_xMSF == null) - { - GlobalLogWriter.println("MultiServiceFactory not set."); - return null; - } - Object aObj = null; - try - { - aObj = _xMSF.createInstance("com.sun.star.document.FilterFactory"); - } - catch(com.sun.star.uno.Exception e) - { - GlobalLogWriter.println("Can't get com.sun.star.document.FilterFactory."); - return null; - } - if (aObj != null) - { - XNameAccess aNameAccess = UnoRuntime.queryInterface(XNameAccess.class, aObj); - if (aNameAccess != null) - { - if (! aNameAccess.hasByName(_sFilterName)) - { - GlobalLogWriter.println("FilterFactory.hasByName() says there exist no '" + _sFilterName + "'" ); - return null; - } - - Object[] aElements = null; - try - { - aElements = (Object[]) aNameAccess.getByName(_sFilterName); - if (aElements != null) - { - String sServiceName = null; - for (int i=0;i<aElements.length; i++) - { - PropertyValue aPropertyValue = (PropertyValue)aElements[i]; - if (aPropertyValue.Name.equals("DocumentService")) - { - String sValue = (String)aPropertyValue.Value; - sServiceName = sValue; - break; - } - } - return sServiceName; - } - else - { - GlobalLogWriter.println("There are no elements for FilterName '" + _sFilterName + "'"); - return null; - } - } - catch (com.sun.star.container.NoSuchElementException e) - { - GlobalLogWriter.println("NoSuchElementException caught. " + e.getMessage()); - } - catch (com.sun.star.lang.WrappedTargetException e) - { - GlobalLogWriter.println("WrappedTargetException caught. " + e.getMessage()); - } - } - } - return null; - } - - - private static String getFileExtension(String _sInternalFilterName, XMultiServiceFactory _xMSF) - { - if (_sInternalFilterName.length() == 0) - { - return null; - } - - if (_xMSF == null) - { - GlobalLogWriter.println("MultiServiceFactory not set."); - return null; - } - XTypeDetection aTypeDetection = null; - try - { - Object oObj = _xMSF.createInstance("com.sun.star.document.TypeDetection"); - aTypeDetection = UnoRuntime.queryInterface(XTypeDetection.class, oObj); - } - catch(com.sun.star.uno.Exception e) - { - GlobalLogWriter.println("Can't get com.sun.star.document.TypeDetection."); - return null; - } - if (aTypeDetection != null) - { - XNameAccess aNameAccess = UnoRuntime.queryInterface(XNameAccess.class, aTypeDetection); - if (aNameAccess != null) - { - - if (! aNameAccess.hasByName(_sInternalFilterName)) - { - GlobalLogWriter.println("TypeDetection.hasByName() says there exist no '" + _sInternalFilterName + "'" ); - return null; - } - - Object[] aElements = null; - String[] aExtensions; - try - { - aElements = (Object[]) aNameAccess.getByName(_sInternalFilterName); - if (aElements != null) - { - String sExtension = null; - for (int i=0;i<aElements.length; i++) - { - PropertyValue aPropertyValue = (PropertyValue)aElements[i]; - if (aPropertyValue.Name.equals("Extensions")) - { - aExtensions = (String[])aPropertyValue.Value; - GlobalLogWriter.println(" Possible extensions are: " + String.valueOf(aExtensions.length)); - if (aExtensions.length > 0) - { - for (int j=0;j<aExtensions.length;j++) - { - GlobalLogWriter.println(" " + aExtensions[j]); - } - sExtension = aExtensions[0]; - GlobalLogWriter.println(""); - } - } - } - return sExtension; - } - else - { - GlobalLogWriter.println("There are no elements for FilterName '" + _sInternalFilterName + "'"); - return null; - } - } - catch (com.sun.star.container.NoSuchElementException e) - { - GlobalLogWriter.println("NoSuchElementException caught. " + e.getMessage()); - } - catch (com.sun.star.lang.WrappedTargetException e) - { - GlobalLogWriter.println("WrappedTargetException caught. " + e.getMessage()); - } -} - } - return null; - } - - - - private OfficeProvider m_aProvider = null; private void startOffice() { diff --git a/qadevOOo/runner/helper/ConfigHelper.java b/qadevOOo/runner/helper/ConfigHelper.java index f6029bc0e8a0..da873a59b97c 100644 --- a/qadevOOo/runner/helper/ConfigHelper.java +++ b/qadevOOo/runner/helper/ConfigHelper.java @@ -125,43 +125,6 @@ public class ConfigHelper } - private Object readRelativeKey(String sRelPath, - String sKey ) - throws com.sun.star.container.NoSuchElementException - { - try - { - XPropertySet xPath = UnoRuntime.queryInterface( - XPropertySet.class, - m_xConfig.getByHierarchicalName(sRelPath)); - return xPath.getPropertyValue(sKey); - } - catch(com.sun.star.uno.Exception ex) - { - throw new com.sun.star.container.NoSuchElementException(ex.getMessage()); - } - } - - - private void writeRelativeKey(String sRelPath, - String sKey , - Object aValue ) - throws com.sun.star.container.NoSuchElementException - { - try - { - XPropertySet xPath = UnoRuntime.queryInterface( - XPropertySet.class, - m_xConfig.getByHierarchicalName(sRelPath)); - xPath.setPropertyValue(sKey, aValue); - } - catch(com.sun.star.uno.Exception ex) - { - throw new com.sun.star.container.NoSuchElementException(ex.getMessage()); - } - } - - /** * Updates the configuration.<p> * This must be called after you have changed the configuration diff --git a/qadevOOo/runner/helper/ProcessHandler.java b/qadevOOo/runner/helper/ProcessHandler.java index 012a38fd0a47..85accac84cd8 100644 --- a/qadevOOo/runner/helper/ProcessHandler.java +++ b/qadevOOo/runner/helper/ProcessHandler.java @@ -765,20 +765,6 @@ public class ProcessHandler return exitValue; } - /** Causes the thread to sleep some time. - */ - private static void shortWait(long milliseconds) - { - try - { - Thread.sleep(milliseconds); - } - catch (InterruptedException e) - { - System.out.println("While waiting :" + e); - } - } - private void dbg(String message) { if (debug) @@ -813,18 +799,6 @@ public class ProcessHandler { return m_bInterrupt; } - /** - * Marks the thread to hold on, next time - * STUPID: The thread must poll this flag itself. - * - * Reason: interrupt() seems not to work as expected. - */ - private synchronized void holdOn() - { - m_bInterrupt = true; - interrupt(); - } - @Override public void run() { diff --git a/qadevOOo/runner/helper/StringHelper.java b/qadevOOo/runner/helper/StringHelper.java index 6308a0a2eacb..7c4943c05ee9 100644 --- a/qadevOOo/runner/helper/StringHelper.java +++ b/qadevOOo/runner/helper/StringHelper.java @@ -21,16 +21,6 @@ package helper; public class StringHelper { - private static String doubleQuote(String _sStr) - { - return "\"" + _sStr + "\""; - } - - private static String singleQuote(String _sStr) - { - return "'" + _sStr + "'"; - } - /** * removes quotes if both exists at start and at end */ diff --git a/qadevOOo/runner/helper/URLHelper.java b/qadevOOo/runner/helper/URLHelper.java index 9b5fc651f97f..60bebf87ee0e 100644 --- a/qadevOOo/runner/helper/URLHelper.java +++ b/qadevOOo/runner/helper/URLHelper.java @@ -98,58 +98,6 @@ public class URLHelper /** - * Does the same as getFileURLFromSystemPath() before ... but uses - * the given protocol string (e.g."http://") instead of "file:///". - * - * @param aSystemPath - * represent the file in system notation - * - * @param aBasePath - * define the base path of the aSystemPath value, - * which must be replaced with the value of "sServerPath". - * - * @param sServerURL - * Will be used to replace sBasePath. - * - * @example - * System Path = "d:\test\file.txt" - * Base Path = "d:\test" - * Server Path = "http://alaska:8000" - * => "http://alaska:8000/file.txt" - * - * @return [String] - * an url which represent the given system path - * and uses the given protocol - */ - private static String getURLWithProtocolFromSystemPath( File aSystemPath, File aBasePath, String sServerURL ) - { - String sFileURL = URLHelper.getFileURLFromSystemPath(aSystemPath); - String sBaseURL = URLHelper.getFileURLFromSystemPath(aBasePath ); - - // cut last '/'! - if (sBaseURL.lastIndexOf('/')==(sBaseURL.length()-1)) - sBaseURL = sBaseURL.substring(0,sBaseURL.length()-1); - - // cut last '/'! - if (sServerURL.lastIndexOf('/')==(sServerURL.length()-1)) - sServerURL = sServerURL.substring(0,sServerURL.length()-1); - - int index = sFileURL.indexOf(sBaseURL); - String sURL = sFileURL.substring(0,index) + sServerURL + - sFileURL.substring(index+sBaseURL.length()); - return sURL; - } - - - - - - - - - - - /** * Return a name list of all available files of a directory. * We filter pure sub directories names. All other files * are returned as full qualified URL strings. So they can be diff --git a/qadevOOo/runner/lib/Parameters.java b/qadevOOo/runner/lib/Parameters.java index 5b64378257ce..e66ea5027643 100644 --- a/qadevOOo/runner/lib/Parameters.java +++ b/qadevOOo/runner/lib/Parameters.java @@ -145,9 +145,6 @@ public class Parameters implements XPropertySet { private Map<String,Object> toMap() { return new HashMap<String,Object>(parameters) { - public String get(String obj) { - return Parameters.this.get(obj); - } }; } diff --git a/qadevOOo/runner/org/openoffice/Runner.java b/qadevOOo/runner/org/openoffice/Runner.java index c1c78503194b..33071aa4e7b4 100644 --- a/qadevOOo/runner/org/openoffice/Runner.java +++ b/qadevOOo/runner/org/openoffice/Runner.java @@ -37,20 +37,6 @@ import base.TestBase; public class Runner { - /** - * @return the time, which is done until last startTime() - */ - private static long meanTime(long _nCurrentTimer) - { - if (_nCurrentTimer == 0) - { - System.out.println("Forgotten to initialise a start timer?"); - return 0; - } - long nMeanTime = System.currentTimeMillis(); - return nMeanTime - _nCurrentTimer; - } - private static String beautifyTime(long _nTime) { long sec = (_nTime / 1000) % 60; 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(); - } - |