summaryrefslogtreecommitdiff
path: root/qadevOOo/runner/graphical
diff options
context:
space:
mode:
Diffstat (limited to 'qadevOOo/runner/graphical')
-rw-r--r--qadevOOo/runner/graphical/BuildID.java226
-rw-r--r--qadevOOo/runner/graphical/DateHelper.java58
-rw-r--r--qadevOOo/runner/graphical/DirectoryHelper.java160
-rw-r--r--qadevOOo/runner/graphical/EnhancedComplexTestCase.java519
-rw-r--r--qadevOOo/runner/graphical/FileHelper.java767
-rw-r--r--qadevOOo/runner/graphical/GlobalLogWriter.java72
-rw-r--r--qadevOOo/runner/graphical/GraphicalComparator.java31
-rw-r--r--qadevOOo/runner/graphical/HTMLResult.java212
-rw-r--r--qadevOOo/runner/graphical/IDocument.java46
-rw-r--r--qadevOOo/runner/graphical/IOffice.java63
-rw-r--r--qadevOOo/runner/graphical/ImageHelper.java120
-rw-r--r--qadevOOo/runner/graphical/IniFile.java693
-rw-r--r--qadevOOo/runner/graphical/JPEGComparator.java816
-rw-r--r--qadevOOo/runner/graphical/JPEGCreator.java475
-rw-r--r--qadevOOo/runner/graphical/JPEGEvaluator.java163
-rw-r--r--qadevOOo/runner/graphical/MSOfficePostscriptCreator.java1004
-rw-r--r--qadevOOo/runner/graphical/Office.java170
-rw-r--r--qadevOOo/runner/graphical/OfficeException.java45
-rw-r--r--qadevOOo/runner/graphical/OpenOfficeDatabaseReportExtractor.java560
-rw-r--r--qadevOOo/runner/graphical/OpenOfficePostscriptCreator.java1427
-rw-r--r--qadevOOo/runner/graphical/ParameterHelper.java433
-rw-r--r--qadevOOo/runner/graphical/PerformanceContainer.java271
-rw-r--r--qadevOOo/runner/graphical/PixelCounter.java247
-rw-r--r--qadevOOo/runner/graphical/PostscriptCreator.java137
-rw-r--r--qadevOOo/runner/graphical/PropertyName.java73
-rw-r--r--qadevOOo/runner/graphical/TimeHelper.java91
-rw-r--r--qadevOOo/runner/graphical/Tolerance.java23
-rw-r--r--qadevOOo/runner/graphical/WrongEnvironmentException.java42
-rw-r--r--qadevOOo/runner/graphical/WrongSuffixException.java42
-rw-r--r--qadevOOo/runner/graphical/makefile.mk76
30 files changed, 9062 insertions, 0 deletions
diff --git a/qadevOOo/runner/graphical/BuildID.java b/qadevOOo/runner/graphical/BuildID.java
new file mode 100644
index 000000000000..cf9188d84a47
--- /dev/null
+++ b/qadevOOo/runner/graphical/BuildID.java
@@ -0,0 +1,226 @@
+/*************************************************************************
+ *
+ * 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
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package graphical;
+
+import java.io.File;
+import helper.OSHelper;
+
+public class BuildID
+{
+ private static String getOfficePath(String _sApp)
+ {
+ String sOfficePath = "";
+ // TODO: StringHelper.removeQuote?
+ if (_sApp.startsWith("\""))
+ {
+ int nIdx = _sApp.indexOf("\"", 1);
+ if (nIdx != -1)
+ {
+ // leave double qoute out.
+ sOfficePath = _sApp.substring(1, nIdx);
+ }
+ }
+ else
+ {
+ // check if _sApp ends with the office executable, if not
+ if (! (_sApp.endsWith("soffice.exe") || _sApp.endsWith("soffice")))
+ {
+ // check if a space exist, so we get all until space
+ int nIdx = _sApp.indexOf(" ", 1);
+ if (nIdx == -1)
+ {
+ sOfficePath = _sApp;
+ }
+ else
+ {
+ sOfficePath = _sApp.substring(0, nIdx);
+ }
+ }
+ else
+ {
+ sOfficePath = _sApp;
+ }
+ }
+ // GlobalLogWriter.get().println("Office path: " + sOfficePath);
+ return sOfficePath;
+ }
+
+ public static String getBuildID(String _sApp)
+ {
+ final String sOfficePath = getOfficePath(_sApp);
+ final String sBuildID = getBuildID(sOfficePath, "buildid");
+ return sBuildID;
+ }
+
+ private static String getBuildID(String _sOfficePath, String _sIniSection)
+ {
+ File aSOfficeFile = new File(_sOfficePath);
+ String sBuildID = "";
+ if (aSOfficeFile.exists())
+ {
+ String sOfficePath = FileHelper.getPath(_sOfficePath);
+ // ok. System.out.println("directory: " + sOfficePath);
+ sBuildID = getBuildIDFromBootstrap(sOfficePath, _sIniSection);
+ if (sBuildID.length() == 0)
+ {
+ sBuildID = getBuildIDFromVersion(sOfficePath, _sIniSection);
+ }
+ }
+ else
+ {
+ GlobalLogWriter.println("soffice executable not found.");
+ }
+
+// int dummy = 0;
+ return sBuildID;
+ }
+
+ private static String getBuildIDFromBootstrap(String _sOfficePath, String _sIniSection)
+ {
+ String sBuildID = "";
+ String sOfficePath;
+ if (OSHelper.isWindows())
+ {
+ sOfficePath = FileHelper.appendPath(_sOfficePath, "bootstrap.ini");
+ }
+ else
+ {
+ sOfficePath = FileHelper.appendPath(_sOfficePath, "bootstraprc");
+ }
+ IniFile aIniFile = new IniFile(sOfficePath);
+ if (aIniFile.is())
+ {
+ sBuildID = aIniFile.getValue("Bootstrap", /*"buildid"*/ _sIniSection);
+ }
+ else
+ {
+ GlobalLogWriter.println("Property Build, can't open file '" + sOfficePath + "', please check.");
+ }
+ return sBuildID;
+ }
+
+ private static String getBuildIDFromVersion(String _sOfficePath, String _sIniSection)
+ {
+ // String fs = System.getProperty("file.separator");
+ String sBuildID = "";
+ String sOfficePath;
+ if (OSHelper.isWindows())
+ {
+ sOfficePath = FileHelper.appendPath(_sOfficePath, "version.ini");
+ }
+ else
+ {
+ sOfficePath = FileHelper.appendPath(_sOfficePath, "versionrc");
+ }
+ IniFile aIniFile = new IniFile(sOfficePath);
+ if (aIniFile.is())
+ {
+ sBuildID = aIniFile.getValue("Version", /*"buildid"*/ _sIniSection);
+ }
+ else
+ {
+ GlobalLogWriter.println("Property Build, can't open file '" + sOfficePath + "', please check.");
+ }
+ return sBuildID;
+ }
+
+// public static void main(String[] args)
+// {
+// String sApp;
+// sApp = "/opt/staroffice8_m116/program/soffice -headless -accept=socket,host=localhost,port=8100;urp;";
+// String sBuildID;
+// sBuildID = getBuildID(sApp);
+// System.out.println("BuildID is: " + sBuildID);
+//
+// Date aDate = new Date();
+// long nStart = aDate.getTime();
+// System.out.println("Time:" + nStart);
+// // LLA: Just some more tests for getBuildID
+// // sApp = "/opt/staroffice8_net/program/soffice";
+// // sBuildID = getBuildID(sApp);
+// // System.out.println("BuildID is: " + sBuildID);
+// //
+// // sApp = "\"/opt/staroffice8_net/program/soffice\" test blah";
+// // sBuildID = getBuildID(sApp);
+// //
+// // System.out.println("BuildID is: " + sBuildID);
+// System.exit(1);
+// }
+
+ public static String getMaster(String _sOfficePath)
+ {
+ final String sOfficePath = getOfficePath(_sOfficePath);
+ final String sMaster = getBuildID(sOfficePath, "ProductSource");
+ return sMaster;
+ }
+
+ public static String getMinor(String _sOfficePath)
+ {
+ final String sOfficePath = getOfficePath(_sOfficePath);
+ final String sMinor = "m" + getBuildID(sOfficePath, "ProductMinor");
+ return sMinor;
+ }
+
+ public static String getCWSName(String _sOfficePath)
+ {
+ final String sOfficePath = getOfficePath(_sOfficePath);
+ final String sBuildID = getBuildID(sOfficePath, "buildid");
+ String sCWSName = "MWS";
+ int nIdx = sBuildID.indexOf("[CWS:");
+ if (nIdx > 0)
+ {
+ int nIdx2 = sBuildID.indexOf("]", nIdx);
+ sCWSName = sBuildID.substring(nIdx + 5, nIdx2);
+ }
+ return sCWSName;
+ }
+
+// public static void main(String[] args)
+// {
+// String sApp;
+// sApp = "D:/staroffice9_m63/Sun/StarOffice 9/program/soffice.exe";
+// String sBuildID;
+// sBuildID = getBuildID(sApp);
+// System.out.println("BuildID is: " + sBuildID);
+//
+// String sMaster;
+// sMaster = getMaster(sApp);
+// System.out.println("Master is: " + sMaster);
+//
+// String sMinor;
+// sMinor = getMinor(sApp);
+// System.out.println("Minor is: " + sMinor);
+//
+// String sCWSName;
+// sCWSName = getCWSName(sApp);
+// System.out.println("CWSName is: " + sCWSName);
+//
+// System.exit(1);
+// }
+
+}
diff --git a/qadevOOo/runner/graphical/DateHelper.java b/qadevOOo/runner/graphical/DateHelper.java
new file mode 100644
index 000000000000..07a5c5844099
--- /dev/null
+++ b/qadevOOo/runner/graphical/DateHelper.java
@@ -0,0 +1,58 @@
+/*************************************************************************
+ *
+ * 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
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package graphical;
+
+import java.text.SimpleDateFormat;
+import java.util.GregorianCalendar;
+import java.text.FieldPosition;
+import java.util.Locale;
+
+public class DateHelper
+{
+ public static String getDateTimeForFilename()
+ {
+ return getDateString("yyyyMMdd-HHmmss");
+ }
+
+ public static String getDateTimeForHumanreadableLog()
+ {
+ return getDateString("[yyyy/MM/dd HH:mm:ss]");
+ }
+
+ public static String getDateString(String _sFormat)
+ {
+ GregorianCalendar aCalendar = new GregorianCalendar();
+ StringBuffer aBuf = new StringBuffer();
+
+ Locale aLocale = new Locale("en","US");
+ SimpleDateFormat aFormat = new SimpleDateFormat(_sFormat, aLocale);
+ aBuf = aFormat.format(aCalendar.getTime(), aBuf, new FieldPosition(0) );
+ // DebugHelper.writeInfo("Date: " + aBuf.toString());
+ return aBuf.toString();
+ }
+}
diff --git a/qadevOOo/runner/graphical/DirectoryHelper.java b/qadevOOo/runner/graphical/DirectoryHelper.java
new file mode 100644
index 000000000000..46930d19425f
--- /dev/null
+++ b/qadevOOo/runner/graphical/DirectoryHelper.java
@@ -0,0 +1,160 @@
+/*************************************************************************
+ *
+ * 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
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package graphical;
+
+import java.io.File;
+import java.io.FileFilter;
+import java.util.ArrayList;
+
+/**
+ * Helper for directory access
+ *
+ * @author lla@openoffice.org
+ */
+public class DirectoryHelper
+{
+ ArrayList<String> m_aFileList = new ArrayList<String>();
+ boolean m_bRecursiveIsAllowed = true;
+
+ void setRecursiveIsAllowed(boolean _bValue)
+ {
+ m_bRecursiveIsAllowed = _bValue;
+ }
+
+ /**
+ * Traverse over a given directory, and filter with a given FileFilter
+ * object and gives back the deep directory as a Object[] list, which
+ * contain a String object for every directory entry.
+ *
+ * <B>Example</B>
+ * List directory /bin, filter out all files which ends with '.prn'
+ *
+ * FileFilter aFileFilter = new FileFilter()
+ * {
+ * public boolean accept( File pathname )
+ * {
+ * if (pathname.getName().endsWith(".prn"))
+ * {
+ * return false;
+ * }
+ * return true;
+ * }
+ * };
+ *
+ * Object[] aList = DirectoryHelper.traverse("/bin", aFileFilter);
+ * for (int i=0;i<aList.length;i++)
+ * {
+ * String aEntry = (String)aList[i];
+ * System.out.println(aEntry);
+ * }
+ *
+ * @param _sDirectory
+ * @param _aFileFilter
+ * @param _bRecursiveIsAllowed
+ * @return list of directories
+ */
+ public static Object[] traverse( String _sDirectory, FileFilter _aFileFilter, boolean _bRecursiveIsAllowed )
+ {
+ DirectoryHelper a = new DirectoryHelper();
+ a.setRecursiveIsAllowed(_bRecursiveIsAllowed);
+ a.traverse_impl(_sDirectory, _aFileFilter);
+ return a.m_aFileList.toArray();
+ }
+
+ public static Object[] traverse( String _sDirectory, boolean _bRecursiveIsAllowed )
+ {
+ DirectoryHelper a = new DirectoryHelper();
+ a.setRecursiveIsAllowed(_bRecursiveIsAllowed);
+ a.traverse_impl(_sDirectory, null);
+ return a.m_aFileList.toArray();
+ }
+
+ void traverse_impl( String afileDirectory, FileFilter _aFileFilter )
+ {
+ File fileDirectory = new File(afileDirectory);
+ // Testing, if the file is a directory, and if so, it throws an exception
+ if ( !fileDirectory.isDirectory() )
+ {
+ throw new IllegalArgumentException( "not a directory: " + fileDirectory.getName() );
+ }
+
+ // Getting all files and directories in the current directory
+ File[] aDirEntries;
+ if (_aFileFilter != null)
+ {
+ aDirEntries = fileDirectory.listFiles(_aFileFilter);
+ }
+ else
+ {
+ aDirEntries = fileDirectory.listFiles();
+ }
+
+ // Iterating for each file and directory
+ for ( int i = 0; i < aDirEntries.length; ++i )
+ {
+ if ( aDirEntries[ i ].isDirectory() )
+ {
+ if (m_bRecursiveIsAllowed == true)
+ {
+ // Recursive call for the new directory
+ traverse_impl( aDirEntries[ i ].getAbsolutePath(), _aFileFilter );
+ }
+ }
+ else
+ {
+ // adding file to List
+ try
+ {
+ // Composing the URL by replacing all backslashs
+ // String stringUrl = "file:///" + aFileEntries[ i ].getAbsolutePath().replace( '\\', '/' );
+ String aStr = aDirEntries[ i ].getAbsolutePath();
+ m_aFileList.add(aStr);
+ }
+ catch( Exception exception )
+ {
+ exception.printStackTrace();
+ break;
+ }
+ }
+ }
+ }
+
+ // tests
+ // public static void main(String[] args)
+ // {
+ // String sDirectory = "/misc/convwatch/gfxcmp/data/doc-pool/demo";
+ // Object[] aDirectoryList = DirectoryHelper.traverse( sDirectory, false );
+ //
+ // for (int i=0;i<aDirectoryList.length;i++)
+ // {
+ // String sEntry = (String)aDirectoryList[i];
+ // System.out.println(sEntry);
+ // }
+ // }
+}
+
diff --git a/qadevOOo/runner/graphical/EnhancedComplexTestCase.java b/qadevOOo/runner/graphical/EnhancedComplexTestCase.java
new file mode 100644
index 000000000000..c3ec2b3e8336
--- /dev/null
+++ b/qadevOOo/runner/graphical/EnhancedComplexTestCase.java
@@ -0,0 +1,519 @@
+/*
+ * ************************************************************************
+ *
+ * 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
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ * ***********************************************************************
+ */
+
+package graphical;
+
+import complexlib.ComplexTestCase;
+import java.io.File;
+import java.io.FileFilter;
+import java.util.ArrayList;
+
+/**
+ *
+ * @author ll93751
+ */
+abstract public class EnhancedComplexTestCase extends ComplexTestCase implements IDocument
+{
+
+
+private void callEntry(String _sEntry, ParameterHelper _aParam)
+{
+ // log.println("- next file is: ------------------------------");
+ log.println("File: " + _sEntry);
+ // TODO: check if 'sEntry' is a guilty document.
+ File aFile = new File(_aParam.getInputPath());
+ String sPath = _aParam.getInputPath();
+ // problem here, isFile() checks also if the file exists, but a not existing file is not really a directory
+ // therefore we check if the given file a path (isDirectory()) if not it must be a file
+ if (aFile.isDirectory())
+ {
+ }
+ else
+ {
+ // special case, if a file is given in inputpath
+ sPath = FileHelper.getPath(_aParam.getInputPath());
+ }
+ String sNewSubDir = FileHelper.removeFirstDirectorysAndBasenameFrom(_sEntry, sPath);
+
+// String sNewReferencePath = _aParam.getReferencePath();
+ String sNewOutputPath = _aParam.getOutputPath();
+ // String sNewDiffPath = m_sDiffPath;
+
+ // if there exist a subdirectory, add it to all result path
+ if (sNewSubDir.length() > 0)
+ {
+// if (sNewReferencePath != null)
+// {
+// sNewReferencePath = FileHelper.appendPath(sNewReferencePath, sNewSubDir);
+// }
+
+ sNewOutputPath = FileHelper.appendPath(sNewOutputPath, sNewSubDir);
+ // if (sNewDiffPath != null)
+ // {
+ // sNewDiffPath = FileHelper.appendPath(sNewDiffPath, sNewSubDir);
+ // }
+ }
+ // log.println("sEntry: " + _sEntry + " " /* + sNewReferencePath + " " */ + sNewOutputPath);
+ log.println("Outputpath: " + sNewOutputPath);
+
+
+ // call interface with parameters
+ try
+ {
+ checkOneFile(_sEntry, sNewOutputPath, _aParam);
+ }
+ catch (OfficeException e)
+ {
+ // TODO: unhandled yet.
+ GlobalLogWriter.println("Warning: caught OfficeException " + e.getMessage());
+ assure("Exception caught: " + e.getMessage(), false);
+ }
+
+}
+
+/**
+ * Run through all documents found in Inputpath.
+ * Call the IDocument interface function call(...);
+ * @param _aParam
+ */
+ public void foreachDocumentinInputPath(ParameterHelper _aParam)
+ {
+ // TODO: auslagern in eine function, die ein Interface annimmt.
+ File aInputPath = new File(_aParam.getInputPath());
+ if (aInputPath.isDirectory())
+ {
+ // check a whole directory
+ // a whole directory
+ FileFilter aFileFilter = FileHelper.getFileFilter();
+ traverseDirectory(aFileFilter, _aParam);
+ }
+ else
+ {
+ callEntry(_aParam.getInputPath(), _aParam);
+ }
+ }
+
+ private void traverseDirectory(FileFilter _aFileFilter, ParameterHelper _aParam)
+ {
+ Object[] aList = DirectoryHelper.traverse(_aParam.getInputPath(), _aFileFilter, _aParam.isIncludeSubDirectories());
+ if (aList.length == 0)
+ {
+ log.println("Nothing to do, there are no document files found.");
+ }
+ else
+ {
+ for (int i=0;i<aList.length;i++)
+ {
+ String sEntry = (String)aList[i];
+ callEntry(sEntry, _aParam);
+ }
+ }
+ }
+/**
+ * Run through a given index.ini or run through a given directory,
+ * find all postscript or pdf files.
+ * Call the IDocument interface function call(...);
+ * @param _aParam
+ */
+ public void foreachPSorPDFinInputPath(ParameterHelper _aParam)
+ {
+ // TODO: auslagern in eine function, die ein Interface annimmt.
+ String sInputPath = _aParam.getInputPath();
+ File aInputPath = new File(sInputPath);
+// if (!aInputPath.exists())
+// {
+// GlobalLogWriter.println("Error, InputPath or File in InputPath doesn't exists. Please check: '" + sInputPath + "'");
+// assure("Error, InputPath or File in InputPath doesn't exists. Please check: '" + sInputPath + "'", false);
+// }
+ if (aInputPath.isDirectory())
+ {
+ // check a whole directory
+ // a whole directory
+ FileFilter aFileFilter = FileHelper.getFileFilterPSorPDF();
+ traverseDirectory(aFileFilter, _aParam);
+ }
+ else
+ {
+ // the inputpath contains a file
+ if (sInputPath.toLowerCase().endsWith(".ini"))
+ {
+ IniFile aIniFile = new IniFile(_aParam.getInputPath());
+ while (aIniFile.hasMoreElements())
+ {
+ String sKey = (String)aIniFile.nextElement();
+ String sPath = FileHelper.getPath(_aParam.getInputPath());
+ String sEntry = FileHelper.appendPath(sPath, sKey);
+ File aFile = new File(sEntry);
+ assure("File '" + sEntry + "' doesn't exists.", aFile.exists(), true);
+ if (aFile.exists())
+ {
+ callEntry(sEntry, _aParam);
+ }
+ }
+ }
+ else
+ {
+ // call for a single pdf/ps file
+ if (sInputPath.toLowerCase().endsWith(".ps") ||
+ sInputPath.toLowerCase().endsWith(".pdf") ||
+ sInputPath.toLowerCase().endsWith(".prn"))
+ {
+ callEntry(sInputPath, _aParam);
+ }
+ else
+ {
+ String sInputPathWithPDF = sInputPath + ".pdf";
+ File aInputPathWithPDF = new File(sInputPathWithPDF);
+
+ if (aInputPathWithPDF.exists() &&
+ _aParam.getReferenceType().toLowerCase().equals("pdf"))
+ {
+ // create PDF only if a pdf file exists and creatortype is set to PDF
+ callEntry(sInputPathWithPDF, _aParam);
+ }
+ else
+ {
+ String sInputPathWithPS = sInputPath + ".ps";
+
+ File aInputPathWithPS = new File(sInputPathWithPS);
+ if (aInputPathWithPS.exists())
+ {
+ callEntry(sInputPathWithPS, _aParam);
+ }
+ else
+ {
+ String sPath = FileHelper.getPath(sInputPath);
+ String sBasename = FileHelper.getBasename(sInputPath);
+
+ // there exist an index file, therefore we assume the given
+ // file is already converted to postscript or pdf
+ runThroughEveryReportInIndex(sPath, sBasename, _aParam);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ private void runThroughEveryReportInIndex(String _sPath, String _sBasename, ParameterHelper _aParam)
+ {
+ String sIndexFile = FileHelper.appendPath(_sPath, "index.ini");
+ File aIndexFile = new File(sIndexFile);
+ if (aIndexFile.exists())
+ {
+ IniFile aIniFile = new IniFile(sIndexFile);
+
+ if (aIniFile.hasSection(_sBasename))
+ {
+ // special case for odb files
+ int nFileCount = aIniFile.getIntValue(_sBasename, "reportcount", 0);
+ ArrayList<String> aList = new ArrayList<String>();
+ for (int i=0;i<nFileCount;i++)
+ {
+ String sValue = aIniFile.getValue(_sBasename, "report" + i);
+
+ String sPSorPDFName = getPSorPDFNameFromIniFile(aIniFile, sValue);
+ if (sPSorPDFName.length() > 0)
+ {
+ String sEntry = FileHelper.appendPath(_sPath, sPSorPDFName);
+ aList.add(sEntry);
+ }
+ }
+ aIniFile.close();
+
+ int nOkStatus = 0;
+ String sStatusRunThrough = "";
+ String sStatusInfo = "";
+ // get the bad status and store it into the
+ for (int i=0;i<aList.size();i++)
+ {
+ String sEntry = aList.get(i);
+ callEntry(sEntry, _aParam);
+
+ // we want to know the current status of the run through
+ // if the status is greater (more bad) then the current,
+ // we will remember this. Only the very bad status will
+ // seen.
+ int nCurrentOkStatus = _aParam.getTestParameters().getInt("current_ok_status");
+ if (nCurrentOkStatus > nOkStatus)
+ {
+ sStatusRunThrough = (String)_aParam.getTestParameters().get("current_state");
+ sStatusInfo = (String)_aParam.getTestParameters().get("current_info");
+ nOkStatus = nCurrentOkStatus;
+ }
+ }
+ if (nOkStatus > 0)
+ {
+ _aParam.getTestParameters().put("last_state", sStatusRunThrough);
+ _aParam.getTestParameters().put("last_info", sStatusInfo);
+ }
+ }
+ else
+ {
+ // runThroughOneFileInIndex();
+ String sPSorPDFName = getPSorPDFNameFromIniFile(aIniFile, _sBasename);
+
+ aIniFile.close();
+
+ if (sPSorPDFName.length() > 0)
+ {
+ String sEntry = FileHelper.appendPath(_sPath, sPSorPDFName);
+ callEntry(sEntry, _aParam);
+ }
+ }
+ }
+ else
+ {
+ assure("File '" + sIndexFile + "' doesn't exists.", aIndexFile.exists(), true);
+ }
+ }
+
+ private String getPSorPDFNameFromIniFile(IniFile _aIniFile, String _sName)
+ {
+ boolean bHasPostscriptOrPDF = false;
+ String sPSBasename = _sName + ".ps";
+ if (_aIniFile.hasSection(sPSBasename)) // checks for Postscript
+ {
+ bHasPostscriptOrPDF = true;
+ }
+ else
+ {
+ sPSBasename = _sName + ".pdf"; // checks for PDF
+ if (_aIniFile.hasSection(sPSBasename))
+ {
+ bHasPostscriptOrPDF = true;
+ }
+ }
+ if (bHasPostscriptOrPDF)
+ {
+ return sPSBasename;
+ }
+ return "";
+ }
+
+ public void runThroughOneFileInIndex(String _sPath, String _sBasename, ParameterHelper _aParam)
+ {
+
+ }
+/**
+ * Run through a given index.ini or run through a given directory,
+ * find all postscript or pdf files.
+ * Call the IDocument interface function call(...);
+ * @param _aParam
+ */
+ public void foreachJPEGcompareWithJPEG(ParameterHelper _aParam)
+ {
+ // TODO: auslagern in eine function, die ein Interface annimmt.
+ String sInputPath = _aParam.getInputPath();
+ File aInputPath = new File(sInputPath);
+// if (!aInputPath.exists())
+// {
+// GlobalLogWriter.println("Error, InputPath or File in InputPath doesn't exists. Please check: '" + sInputPath + "'");
+// assure("Error, InputPath or File in InputPath doesn't exists. Please check: '" + sInputPath + "'", false);
+// }
+ if (aInputPath.isDirectory())
+ {
+ // check a whole directory
+ // a whole directory
+ FileFilter aFileFilter = FileHelper.getFileFilterJPEG();
+ traverseDirectory(aFileFilter, _aParam);
+ }
+ else
+ {
+ // the inputpath contains a file
+ if (sInputPath.toLowerCase().endsWith(".ini"))
+ {
+ IniFile aIniFile = new IniFile(_aParam.getInputPath());
+ while (aIniFile.hasMoreElements())
+ {
+ String sSection = (String)aIniFile.nextElement();
+// TODO: not supported yet.
+ // callEveryPictureInIniFile(aIniFile, sSection, _aParam);
+ }
+ }
+ else
+ {
+ // call for a single jpeg file
+ try
+ {
+ String sOutputFilename = _aParam.getOutputPath();
+ if (sInputPath.toLowerCase().endsWith(".jpg") ||
+ sInputPath.toLowerCase().endsWith(".jpeg") )
+ {
+ checkOneFile(sInputPath, sOutputFilename, _aParam);
+ }
+ else
+ {
+ // check if there exists a ini file
+ String sPath = FileHelper.getPath(sInputPath);
+ String sBasename = FileHelper.getBasename(sInputPath);
+
+ runThroughEveryReportInIndex(sPath, sBasename, _aParam);
+
+ String sStatusRunThrough = (String)_aParam.getTestParameters().get("last_state");
+ String sStatusInfo = (String)_aParam.getTestParameters().get("last_info");
+
+ if (sStatusRunThrough != null &&
+ sStatusInfo != null )
+ {
+ // store the bad status in the <Name>.odb.ps.ini file
+ String sOutputPath = _aParam.getOutputPath();
+ String sBasenameIni = FileHelper.appendPath(sOutputPath, sBasename + ".ps.ini");
+ IniFile aBasenameIni = new IniFile(sBasenameIni);
+ aBasenameIni.insertValue("global", "state", sStatusRunThrough);
+ aBasenameIni.insertValue("global", "info", sStatusInfo);
+ aBasenameIni.close();
+ }
+
+ }
+ }
+ catch (OfficeException e)
+ {
+ // TODO: unhandled yet.
+ GlobalLogWriter.println("Warning: caught OfficeException " + e.getMessage());
+ }
+ // callEntry(sInputPath, _aParam);
+ }
+ }
+ }
+
+
+/**
+ * Run through a given index.ini or run through a given directory,
+ * find all ini files.
+ * Call the IDocument interface function call(...);
+ * @param _aParam
+ */
+ public void foreachResultCreateHTML(ParameterHelper _aParam)
+ {
+ // TODO: auslagern in eine function, die ein Interface annimmt.
+ String sInputPath = _aParam.getInputPath();
+ File aInputPath = new File(sInputPath);
+// if (!aInputPath.exists())
+// {
+// GlobalLogWriter.println("Error, InputPath or File in InputPath doesn't exists. Please check: '" + sInputPath + "'");
+// assure("Error, InputPath or File in InputPath doesn't exists. Please check: '" + sInputPath + "'", false);
+// }
+
+ // call for a single ini file
+ if (sInputPath.toLowerCase().endsWith(".ini") )
+ {
+ callEntry(sInputPath, _aParam);
+ }
+ else
+ {
+ // check if there exists an ini file
+ String sPath = FileHelper.getPath(sInputPath);
+ String sBasename = FileHelper.getBasename(sInputPath);
+
+ runThroughEveryReportInIndex(sPath, sBasename, _aParam);
+
+ // Create a HTML page which shows locally to all files in .odb
+ if (sInputPath.toLowerCase().endsWith(".odb"))
+ {
+ String sIndexFile = FileHelper.appendPath(sPath, "index.ini");
+ File aIndexFile = new File(sIndexFile);
+ if (aIndexFile.exists())
+ {
+ IniFile aIniFile = new IniFile(sIndexFile);
+
+ if (aIniFile.hasSection(sBasename))
+ {
+ // special case for odb files
+ int nFileCount = aIniFile.getIntValue(sBasename, "reportcount", 0);
+ ArrayList<String> aList = new ArrayList<String>();
+ for (int i=0;i<nFileCount;i++)
+ {
+ String sValue = aIniFile.getValue(sBasename, "report" + i);
+
+ String sPSorPDFName = getPSorPDFNameFromIniFile(aIniFile, sValue);
+ if (sPSorPDFName.length() > 0)
+ {
+ aList.add(sPSorPDFName);
+ }
+ }
+ if (aList.size() > 0)
+ {
+ // HTML output for the odb file, shows only all other documents.
+ HTMLResult aOutputter = new HTMLResult(sPath, sBasename + ".ps.html" );
+ aOutputter.header("content of DB file: " + sBasename);
+ aOutputter.indexSection(sBasename);
+
+ for (int i=0;i<aList.size();i++)
+ {
+ String sPSFile = aList.get(i);
+
+ // TODO: this information has to come out of the ini files
+ String sStatusRunThrough = "";
+ String sStatusMessage = "";
+
+ String sHTMLFile = sPSFile + ".html";
+ aOutputter.indexLine(sHTMLFile, sPSFile, sStatusRunThrough, sStatusMessage);
+ }
+ aOutputter.close();
+
+// String sHTMLFile = FileHelper.appendPath(sPath, sBasename + ".ps.html");
+// try
+// {
+//
+// FileOutputStream out2 = new FileOutputStream(sHTMLFile);
+// PrintStream out = new PrintStream(out2);
+//
+// out.println("<HTML>");
+// out.println("<BODY>");
+// for (int i=0;i<aList.size();i++)
+// {
+// // <A href="link">blah</A>
+// String sPSFile = (String)aList.get(i);
+// out.print("<A href=\"");
+// out.print(sPSFile + ".html");
+// out.print("\">");
+// out.print(sPSFile);
+// out.println("</A>");
+// out.println("<BR>");
+// }
+// out.println("</BODY></HTML>");
+// out.close();
+// out2.close();
+// }
+// catch (java.io.IOException e)
+// {
+//
+// }
+ }
+ }
+ aIniFile.close();
+ }
+
+ }
+ }
+ }
+
+
+}
diff --git a/qadevOOo/runner/graphical/FileHelper.java b/qadevOOo/runner/graphical/FileHelper.java
new file mode 100644
index 000000000000..892f652567c1
--- /dev/null
+++ b/qadevOOo/runner/graphical/FileHelper.java
@@ -0,0 +1,767 @@
+/*************************************************************************
+ *
+ * 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
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package graphical;
+
+import java.io.File;
+import java.io.FileFilter;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.StringTokenizer;
+import helper.OSHelper;
+
+import java.io.PrintStream;
+import javax.swing.JOptionPane;
+
+public class FileHelper
+{
+ public FileHelper()
+ {
+ // fs = System.getProperty("file.separator");
+
+
+ String sOSName = System.getProperty("os.name");
+ String sOSArch = System.getProperty("os.arch");
+ String sOSVersion = System.getProperty("os.version");
+
+ GlobalLogWriter.println(sOSName);
+ GlobalLogWriter.println(sOSArch);
+ GlobalLogWriter.println(sOSVersion);
+
+ }
+
+ public static void MessageBox(String _sStr)
+ {
+ String sVersion = System.getProperty("java.version");
+ String sOSName = System.getProperty("os.name");
+ JOptionPane.showMessageDialog( null, _sStr, sVersion + " " + sOSName + " Hello World Debugger", JOptionPane.INFORMATION_MESSAGE );
+ }
+
+ public static boolean exists(String _sFile)
+ {
+ if (_sFile == null)
+ {
+ return false;
+ }
+
+ File aFile = new File(_sFile);
+ if (aFile.exists())
+ {
+ return true;
+ }
+ // This is just nice for DEBUG behaviour
+ // due to the fact this is absolutly context dependency no one should use it.
+ // else
+ // {
+ // System.out.println("FileHelper:exists() tell this path doesn't exists. Check it. path is:" );
+ // System.out.println( _sFile );
+ // System.out.println( aFile.getAbsolutePath() );
+ // MessageBox("Der JavaProzess wartet auf eine interaktion ihrerseits.");
+ //
+ // File aFile2 = new File(_sFile);
+ // if (aFile2.exists())
+ // {
+ // System.out.println("Thanks, file exists." );
+ // return true;
+ // }
+ // }
+ return false;
+ }
+
+ public static boolean isDir(String _sDir)
+ {
+ if (_sDir == null)
+ {
+ return false;
+ }
+ try
+ {
+ File aFile = new File(_sDir);
+ if (aFile.exists() && aFile.isDirectory())
+ {
+ return true;
+ }
+ }
+ catch (NullPointerException e)
+ {
+ GlobalLogWriter.println("Exception caught. FileHelper.isDir('" + _sDir + "')");
+ e.printStackTrace();
+ }
+ return false;
+ }
+
+ public static String getBasename(String _sFilename)
+ {
+ if (_sFilename == null)
+ {
+ return "";
+ }
+ // String fs = System.getProperty("file.separator");
+
+ int nIdx = _sFilename.lastIndexOf("\\");
+ if (nIdx == -1)
+ {
+ nIdx = _sFilename.lastIndexOf("/");
+ }
+ if (nIdx > 0)
+ {
+ return _sFilename.substring(nIdx + 1);
+ }
+ return _sFilename;
+ }
+
+ public static String getNameNoSuffix(String _sFilename)
+ {
+ if (_sFilename == null)
+ {
+ return "";
+ }
+ int nIdx = _sFilename.lastIndexOf(".");
+ if (nIdx > 0)
+ {
+ return _sFilename.substring(0, nIdx);
+ }
+ return _sFilename;
+ }
+
+ public static String getSuffix(String _sFilename)
+ {
+ if (_sFilename == null)
+ {
+ return "";
+ }
+ int nIdx = _sFilename.lastIndexOf(".");
+ if (nIdx > 0)
+ {
+ return _sFilename.substring(nIdx );
+ }
+ return "";
+ }
+
+ public static String getPath(String _sFilename)
+ {
+ if (_sFilename == null)
+ {
+ return "";
+ }
+ // String fs = System.getProperty("file.separator");
+
+ int nIdx = _sFilename.lastIndexOf("\\");
+ if (nIdx == -1)
+ {
+ nIdx = _sFilename.lastIndexOf("/");
+ }
+ if (nIdx > 0)
+ {
+ return _sFilename.substring(0, nIdx);
+ }
+ return "";
+ }
+
+/*
+ static ArrayList files = new ArrayList();
+ public static Object[] traverse( String afileDirectory )
+ {
+
+ File fileDirectory = new File(afileDirectory);
+ // Testing, if the file is a directory, and if so, it throws an exception
+ if ( !fileDirectory.isDirectory() )
+ {
+ throw new IllegalArgumentException( "not a directory: " + fileDirectory.getName() );
+ }
+
+ // Getting all files and directories in the current directory
+ File[] entries = fileDirectory.listFiles();
+
+ // Iterating for each file and directory
+ for ( int i = 0; i < entries.length; ++i )
+ {
+ // adding file to List
+ try
+ {
+ // Composing the URL by replacing all backslashs
+ String stringUrl = "file:///"
+ + entries[ i ].getAbsolutePath().replace( '\\', '/' );
+ files.add(stringUrl);
+ }
+ catch( Exception exception )
+ {
+ exception.printStackTrace();
+ }
+ }
+ return files.toArray();
+ }
+*/
+
+ // makeDirectories("", "/tmp/a/b");
+ // creates all directories /tmp/a/b
+ //
+ public static void makeDirectories(String first, String path)
+ {
+ makeDirectories(first, path, "0777");
+ }
+
+ public static void makeDirectories(String first, String path, String _sMode)
+ {
+ String fs = System.getProperty("file.separator");
+ if (path.startsWith(fs + fs)) // starts with UNC Path
+ {
+ int n = path.indexOf(fs, 2);
+ n = path.indexOf(fs, n + 1);
+ first = path.substring(0, n);
+ path = path.substring(n + 1);
+ }
+
+ String already_done = null;
+ StringTokenizer path_tokenizer = new StringTokenizer(path,fs,false);
+ already_done = first;
+ while (path_tokenizer.hasMoreTokens())
+ {
+ String part = path_tokenizer.nextToken();
+ File new_dir = new File(already_done + File.separatorChar + part);
+ already_done = new_dir.toString();
+ // System.out.println(already_done);
+ //create the directory
+ new_dir.mkdirs();
+ if (OSHelper.isUnix() &&
+ _sMode.length() > 0)
+ {
+ try
+ {
+ chmod(new_dir, _sMode);
+ }
+ catch (java.io.IOException e)
+ {
+ GlobalLogWriter.println("Exception caught. FileHelper.makeDirectories('" + new_dir.getAbsolutePath() + "')");
+ }
+ }
+ }
+ // return;
+ }
+
+ public static void chmod(File file, String mode) throws java.io.IOException
+ {
+ Runtime.getRuntime().exec
+ (new String[]
+ {"chmod", mode, file.getAbsolutePath()});
+ }
+
+ public static String removeFirstDirectorysAndBasenameFrom(String _sName, String _sRemovePath)
+ {
+ // pre: _sName: /a/b/c/d/e/f.g _sRemovePath /a/b/c
+ // result: d/e
+ String fs = System.getProperty("file.separator");
+
+ String sBasename = FileHelper.getBasename(_sName);
+ String sSubDirs = "";
+ if (_sName.startsWith(_sRemovePath))
+ {
+ // if _sName starts with _sRemovePath
+ int nRemovePathIndex = _sRemovePath.length();
+ if (! _sRemovePath.endsWith(fs))
+ {
+ // add 1 if we not ends with file separator
+ nRemovePathIndex ++;
+ }
+ int nBasenameIndex = _sName.length() - sBasename.length() - 1;
+ if (nRemovePathIndex < nBasenameIndex)
+ {
+ sSubDirs = _sName.substring(nRemovePathIndex, nBasenameIndex);
+ }
+ }
+ else
+ {
+ // special case, the _sRemovePath is not part of _sName
+ sSubDirs = FileHelper.getPath(_sName);
+ if (sSubDirs.startsWith(fs))
+ {
+ // remove leading file separator
+ sSubDirs = sSubDirs.substring(1);
+ }
+ }
+
+ return sSubDirs;
+ }
+
+ public static void test_removeFirstDirectorysAndBasenameFrom()
+ {
+ String a = removeFirstDirectorysAndBasenameFrom("/a/b/c/d/e/f.g", "/a/b/c");
+ // assure("", a.equals("d/e"));
+ String b = removeFirstDirectorysAndBasenameFrom("/a/b/c/d/e/f.g", "/a/b/c/");
+ // assure("", b.equals("d/e"));
+ String c = removeFirstDirectorysAndBasenameFrom("/a/b/c/d/e/f.g", "/b/c");
+ // assure("", c.equals("a/b/c/d/e"));
+ }
+
+
+ public static String getSystemPathFromFileURL( String _sFileURL )
+ {
+ String sSystemFile = null;
+
+ if(_sFileURL.startsWith("file:///"))
+ {
+ if (OSHelper.isWindows())
+ {
+ sSystemFile = _sFileURL.substring(8);
+ }
+ else
+ {
+ sSystemFile = _sFileURL.substring(7);
+ }
+ }
+ else if (_sFileURL.startsWith("file://"))
+ {
+ sSystemFile = _sFileURL.substring(5);
+ }
+ String fs = System.getProperty("file.separator");
+ if (! fs.equals("/"))
+ {
+ sSystemFile = sSystemFile.replace ('/', fs.toCharArray ()[0]);
+ }
+// FEATURE FOR UNC NEED!!!
+ return sSystemFile;
+ }
+
+ private static boolean m_bDebugTextShown = false;
+ public static boolean isDebugEnabled()
+ {
+ boolean bDebug = false;
+ String sTmpPath = util.utils.getUsersTempDir();
+ //util.utils.getUsersTempDir();
+ String fs = System.getProperty("file.separator");
+ String sName = sTmpPath + fs + "DOC_COMPARATOR_DEBUG";
+ File aFile = new File(sName);
+ if (aFile.exists())
+ {
+ if (m_bDebugTextShown == false)
+ {
+ GlobalLogWriter.println("Found file: " + sName);
+ GlobalLogWriter.println("Activate debug mode.");
+ GlobalLogWriter.println("If debug mode is no longer necessary, remove the above file.");
+ m_bDebugTextShown = true;
+ }
+ bDebug = true;
+ }
+ return bDebug;
+ }
+
+ private static void copyStream(InputStream _aIn, OutputStream _aOut) throws java.io.IOException
+ {
+ byte[] aBuffer = new byte[0xFFFF];
+ for (int len; (len = _aIn.read(aBuffer)) != -1; )
+ {
+ _aOut.write(aBuffer, 0, len);
+ }
+ }
+
+ public static void copy(String _sSource, String _sDestination)
+ {
+ FileInputStream aFIS = null;
+ FileOutputStream aFOS = null;
+
+ try
+ {
+ aFIS = new FileInputStream(_sSource);
+ aFOS = new FileOutputStream(_sDestination);
+ copyStream(aFIS, aFOS);
+ }
+ catch (java.io.IOException e)
+ {
+ System.out.println("Error: caught Exception: " + e.getMessage());
+ }
+ finally
+ {
+ if (aFIS != null)
+ {
+ try
+ {
+ aFIS.close();
+ }
+ catch (java.io.IOException e)
+ {
+ System.out.println("Error: caught Exception: " + e.getMessage());
+ }
+ }
+ if (aFOS != null)
+ {
+ try
+ {
+ aFOS.close();
+ }
+ catch (java.io.IOException e)
+ {
+ System.out.println("Error: caught Exception: " + e.getMessage());
+ }
+ }
+ }
+
+// try
+// {
+// File inputFile = new File(_sSource);
+// File outputFile = new File(_sDestination);
+//
+// java.io.FileReader in = new java.io.FileReader(inputFile);
+// java.io.FileWriter out = new java.io.FileWriter(outputFile);
+// int c;
+//
+// while ((c = in.read()) != -1)
+// {
+// out.write(c);
+// }
+//
+// in.close();
+// out.close();
+// }
+// catch (java.io.IOException e)
+// {
+// GlobalLogWriter.get().println("Exception caught. FileHelper.copy('" + _sSource + ", " + _sDestination + "')");
+// GlobalLogWriter.get().println("Message: " + e.getMessage());
+// }
+ }
+
+
+ /**
+ * Within the directory run through, it's possible to say which file extension types should not
+ * consider like '*.prn' because it's not a document.
+ *
+ * @return a FileFilter function
+ */
+ public static FileFilter getFileFilter()
+ {
+ FileFilter aFileFilter = new FileFilter()
+ {
+ public boolean accept( File pathname )
+ {
+ // leave out files which started by '~$' these are Microsoft Office temp files
+ if (pathname.getName().startsWith("~$"))
+ {
+ return false;
+ }
+ // leave out files starts with '.~lock.' these are OpenOffice.org lock files
+ if (pathname.getName().startsWith(".~lock."))
+ {
+ return false;
+ }
+ // leave out files ends with '#' these could be temp files
+ if (pathname.getName().endsWith("#"))
+ {
+ return false;
+ }
+ if (pathname.getName().endsWith(".prn"))
+ {
+ return false;
+ }
+ if (pathname.getName().endsWith(".ps"))
+ {
+ return false;
+ }
+ // This type of document no one would like to load.
+ if (pathname.getName().endsWith(".zip"))
+ {
+ return false;
+ }
+ // just a hack
+ if (pathname.getName().endsWith("_"))
+ {
+ return false;
+ }
+ return true;
+ }
+ };
+ return aFileFilter;
+ }
+ /**
+ * Within the directory run through, it's possible to say which file extension types should not
+ * consider like '*.prn' because it's not a document.
+ *
+ * @return a FileFilter function
+ */
+ public static FileFilter getFileFilterPSorPDF()
+ {
+ FileFilter aFileFilter = new FileFilter()
+ {
+ public boolean accept( File pathname )
+ {
+ if (pathname.getName().endsWith(".ps"))
+ {
+ return true;
+ }
+ if (pathname.getName().endsWith(".pdf"))
+ {
+ return true;
+ }
+ return false;
+ }
+ };
+ return aFileFilter;
+ }
+ /**
+ * Within the directory run through, it's possible to say which file extension types should not
+ * consider like '*.prn' because it's not a document.
+ *
+ * @return a FileFilter function
+ */
+ public static FileFilter getFileFilterJPEG()
+ {
+ FileFilter aFileFilter = new FileFilter()
+ {
+ public boolean accept( File pathname )
+ {
+ if (pathname.getName().toLowerCase().endsWith(".jpg"))
+ {
+ return true;
+ }
+ if (pathname.getName().toLowerCase().endsWith(".jpeg"))
+ {
+ return true;
+ }
+ return false;
+ }
+ };
+ return aFileFilter;
+ }
+ /**
+ * Within the directory run through, it's possible to say which file extension types should not
+ * consider like '*.ini' because it's not a document.
+ *
+ * @return a FileFilter function
+ */
+ public static FileFilter getFileFilterINI()
+ {
+ FileFilter aFileFilter = new FileFilter()
+ {
+ public boolean accept( File pathname )
+ {
+ String sPathname = pathname.getName().toLowerCase();
+ if (sPathname.endsWith("index.ini"))
+ {
+ // don't consider the index.ini file
+ return false;
+ }
+ if (sPathname.endsWith(".ini"))
+ {
+ return true;
+ }
+ return false;
+ }
+ };
+ return aFileFilter;
+ }
+
+ public static String appendPath(String _sPath, String _sRelativePathToAdd)
+ {
+ String sNewPath = _sPath;
+ String fs = System.getProperty("file.separator");
+ if (_sPath.startsWith("file:"))
+ {
+ fs = "/"; // we use a file URL so only '/' is allowed.
+ }
+ if (! (sNewPath.endsWith("/") || sNewPath.endsWith("\\") ) )
+ {
+ sNewPath += fs;
+ }
+ sNewPath += _sRelativePathToAdd;
+ return sNewPath;
+ }
+
+ // -----------------------------------------------------------------------------
+ public static void createInfoFile(String _sFile, ParameterHelper _aGTA)
+ {
+ createInfoFile(_sFile, _aGTA, "");
+ }
+
+ public static void createInfoFile(String _sFile, ParameterHelper _aGTA, String _sSpecial)
+ {
+ String sFilename;
+ if (_sFile.startsWith("file://"))
+ {
+ sFilename = FileHelper.getSystemPathFromFileURL(_sFile);
+ GlobalLogWriter.println("CreateInfoFile: '" + sFilename + "'" );
+ }
+ else
+ {
+ sFilename = _sFile;
+ }
+ String sFileDir = FileHelper.getPath(sFilename);
+ String sBasename = FileHelper.getBasename(sFilename);
+ String sNameNoSuffix = FileHelper.getNameNoSuffix(sBasename);
+
+ String sIniFile = FileHelper.appendPath(sFileDir, sBasename + ".ini");
+ IniFile aIniFile = new IniFile(sIniFile);
+
+ // OLD INFO FILE
+
+ // String fs = System.getProperty("file.separator");
+ String ls = System.getProperty("line.separator");
+ String sInfoFilename = FileHelper.appendPath(sFileDir, sNameNoSuffix + ".info");
+ File aInfoFile = new File(sInfoFilename);
+
+ String sBuildID = "";
+
+ try
+ {
+ FileOutputStream out2 = new FileOutputStream(aInfoFile.toString());
+ PrintStream out = new PrintStream(out2);
+
+ out.println("# automatically created file by graphical compare");
+ if (_aGTA != null)
+ {
+ if (_sSpecial != null && _sSpecial.equals("msoffice"))
+ {
+ out.println("# buildid from wordloadfile");
+ sBuildID = _aGTA.getPerformance().getMSOfficeVersion();
+ out.println("buildid=" + sBuildID);
+ }
+ else
+ {
+ out.println("# buildid is read out of the bootstrap file");
+ sBuildID = _aGTA.getBuildID();
+ out.println("buildid=" + sBuildID);
+ }
+ aIniFile.insertValue("global", "buildid", sBuildID);
+
+ // if (_sSpecial != null && _sSpecial.length() > 0)
+ // {
+ // out.write("special=" + _sSpecial + ls);
+ // }
+ out.println();
+ out.println("# resolution given in DPI");
+ out.println("resolution=" + _aGTA.getResolutionInDPI());
+ aIniFile.insertValue("global", "resolution", _aGTA.getResolutionInDPI());
+ }
+ else
+ {
+ out.println("buildid=" + _sSpecial);
+ aIniFile.insertValue("global", "buildid", _sSpecial);
+ }
+
+ // long nTime = stopTimer();
+ // if (nTime != 0)
+ // {
+ // out.write("# time is given in milli seconds" + ls);
+ // out.write("time=" + nTime + ls);
+ // }
+
+ out.println();
+ out.println("# Values out of System.getProperty(...)");
+ out.println("os.name=" + System.getProperty("os.name"));
+ out.println("os.arch=" + System.getProperty("os.arch"));
+ out.println("os.version=" + System.getProperty("os.version"));
+
+ aIniFile.insertValue("global", "os.name", System.getProperty("os.name"));
+ aIniFile.insertValue("global", "os.arch", System.getProperty("os.arch"));
+ aIniFile.insertValue("global", "os.version", System.getProperty("os.version"));
+
+ if (_aGTA != null)
+ {
+ out.println();
+ out.println("# Performance output, values are given in milli sec.");
+ _aGTA.getPerformance().print(out);
+ _aGTA.getPerformance().print(aIniFile, "global");
+ }
+
+ out.flush();
+ out.close();
+ out2.close();
+ }
+ catch (java.io.IOException e)
+ {
+ GlobalLogWriter.println("can't create Info file.");
+ e.printStackTrace();
+ }
+ aIniFile.close();
+
+// String sExtension = FileHelper.getSuffix(_aGTA.getInputFile());
+// if (sExtension.startsWith("."))
+// {
+// sExtension = sExtension.substring(1);
+// }
+//
+// DB.writeToDB(_aGTA.getInputFile(),
+// sNameNoSuffix,
+// sExtension,
+// sBuildID,
+// _aGTA.getReferenceType(),
+// _aGTA.getResolutionInDPI()
+// );
+ }
+
+ public static void addBasenameToFile(String _sIndexFilename, String _sBasename, String _sCreator, String _sType, String _sSource)
+ {
+ // String sOutputDir = FileHelper.getPath(_sOutputFilename);
+ String sPath;
+ if (_sIndexFilename.startsWith("file:"))
+ {
+ sPath = FileHelper.getSystemPathFromFileURL(_sIndexFilename);
+ }
+ else
+ {
+ sPath = _sIndexFilename;
+ }
+ String sIndexFilename = sPath; // FileHelper.appendPath(sPath, _sFilename);
+ IniFile aIniFile = new IniFile(sIndexFilename);
+ aIniFile.insertValue(_sBasename, "creator", _sCreator);
+ aIniFile.insertValue(_sBasename, "type", _sType);
+ aIniFile.insertValue(_sBasename, "source", _sSource);
+ aIniFile.close();
+// File aFile = new File(sIndexFilename);
+// try
+// {
+// RandomAccessFile aRandomAccess = new RandomAccessFile(aFile, "rw");
+// // String sBasename = FileHelper.getBasename(_sOutputFilename);
+// aRandomAccess.seek(aRandomAccess.length()); // jump to the end.
+//// TODO: seems to be wrong, there exist no writeLine() with 'return' ending?
+// aRandomAccess.writeUTF(_sBasename);
+// aRandomAccess.close();
+// }
+// catch (java.io.FileNotFoundException e)
+// {
+// }
+// catch (java.io.IOException e)
+// {
+// }
+ }
+
+ public static void addBasenameToPostscript(String _sOutputFilename)
+ {
+ String sIndexFilename = FileHelper.appendPath(_sOutputFilename, "postscript.ini");
+ // String sPath = FileHelper.getPath(sIndexFilename);
+ String sBasename = FileHelper.getBasename(_sOutputFilename);
+ addBasenameToFile(sIndexFilename, sBasename, "", "", "");
+ }
+ public static void addBasenameToIndex(String _sOutputFilename, String _sBasename, String _sCreator, String _sType, String _sSource)
+ {
+ String sIndexFilename = FileHelper.appendPath(_sOutputFilename, "index.ini");
+ // String sPath = FileHelper.getPath(sIndexFilename);
+ // String sBasename = FileHelper.getBasename(_sOutputFilename);
+ addBasenameToFile(sIndexFilename, _sBasename, _sCreator, _sType, _sSource);
+ }
+
+}
+
diff --git a/qadevOOo/runner/graphical/GlobalLogWriter.java b/qadevOOo/runner/graphical/GlobalLogWriter.java
new file mode 100644
index 000000000000..478d3323abda
--- /dev/null
+++ b/qadevOOo/runner/graphical/GlobalLogWriter.java
@@ -0,0 +1,72 @@
+/*************************************************************************
+ *
+ * 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
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package graphical;
+
+import share.LogWriter;
+import stats.SimpleLogWriter;
+
+public class GlobalLogWriter
+{
+ private static LogWriter m_aGlobalLogWriter = null;
+
+ /**
+ * This is just a helper to get clearer code.
+ * use this GlobalLogWriter.println(...)
+ * @param _sMsg
+ */
+ protected static synchronized void println(String _sMsg)
+ {
+ get().println(_sMsg);
+ }
+
+ /**
+ * @deprecated use GlobalLogWriter.println(...) direct
+ * @return
+ */
+ protected static synchronized LogWriter get()
+ {
+ if (m_aGlobalLogWriter == null)
+ {
+ SimpleLogWriter aLog = new SimpleLogWriter();
+ m_aGlobalLogWriter = aLog;
+ }
+ return m_aGlobalLogWriter;
+ }
+
+// public static synchronized void initialize()
+// {
+// get().initialize(null, true);
+// }
+
+ protected static synchronized void set(LogWriter _aLog)
+ {
+ m_aGlobalLogWriter = _aLog;
+ }
+
+}
+
diff --git a/qadevOOo/runner/graphical/GraphicalComparator.java b/qadevOOo/runner/graphical/GraphicalComparator.java
new file mode 100644
index 000000000000..c10bbff8b49e
--- /dev/null
+++ b/qadevOOo/runner/graphical/GraphicalComparator.java
@@ -0,0 +1,31 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package graphical;
+
+// import graphical.EnhancedComplexTestCase;
+
+/**
+ *
+ * @author ll93751
+ */
+public class GraphicalComparator extends EnhancedComplexTestCase
+{
+
+ // @Override
+ public String[] getTestMethodNames() {
+ return new String[]{"check"};
+ }
+
+ public void check()
+ {
+ }
+
+ public void checkOneFile(String _sDocument, String _sResult, ParameterHelper _aParams) throws OfficeException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+}
+
diff --git a/qadevOOo/runner/graphical/HTMLResult.java b/qadevOOo/runner/graphical/HTMLResult.java
new file mode 100644
index 000000000000..af2a31a308ea
--- /dev/null
+++ b/qadevOOo/runner/graphical/HTMLResult.java
@@ -0,0 +1,212 @@
+/*
+ ************************************************************************
+ *
+ * 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
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package graphical;
+
+import java.io.File;
+import java.io.FileWriter;
+// import util.utils;
+// import helper.OSHelper;
+
+public class HTMLResult
+{
+ private FileWriter m_aOut;
+ // private String m_sFilename;
+ // private String m_sNamePrefix; // the HTML files used a suffix to build it's right name
+
+ /**
+ * ls is the current line separator (carridge return)
+ */
+ private String ls;
+
+ public HTMLResult( String _sOutputPath, String _sHTMLFilename )
+ {
+ FileHelper.makeDirectories("", _sOutputPath);
+ // HTMLResult a = new HTMLResult();
+ String sFilename = FileHelper.appendPath(_sOutputPath, _sHTMLFilename);
+
+ try
+ {
+ File outputFile = new File(sFilename);
+ m_aOut = new FileWriter(outputFile.toString());
+ ls = System.getProperty("line.separator");
+ }
+ catch (java.io.IOException e)
+ {
+ e.printStackTrace();
+ GlobalLogWriter.println("ERROR: Can't create HTML Outputter");
+ // return null;
+ }
+ // m_sFilename = sFilename;
+ // a.m_sNamePrefix = _sNamePrefix;
+ // return a;
+ }
+
+ // public String getFilename() {return m_sFilename;}
+
+ private void writeln(String _sStr)
+ {
+ try
+ {
+ m_aOut.write( _sStr );
+ m_aOut.write ( ls );
+ }
+ catch (java.io.IOException e)
+ {
+ }
+ }
+ private void flush()
+ {
+ try
+ {
+ m_aOut.flush();
+ }
+ catch (java.io.IOException e)
+ {
+ }
+ }
+
+
+ /**
+ * create the HTML header
+ * @param _sTitle
+ */
+ public void header(String _sTitle)
+ {
+ writeln( "<HTML>");
+ writeln( "<HEAD>" );
+ writeln( "<TITLE>" + _sTitle + "</TITLE>");
+ writeln( "<LINK rel=\"stylesheet\" type=\"text/css\" href=\"/gfxcmp_ui/xmloff.css\" media=\"screen\" />");
+ writeln( "<LINK rel=\"stylesheet\" type=\"text/css\" href=\"/gfxcmp_ui/style.css\" media=\"screen\" />");
+ writeln( "</HEAD>");
+ writeln( "<BODY bgcolor=white>");
+ flush();
+ }
+
+ final static String TEST_TABLETITLE = "Document";
+ final static String VISUAL_STATUS_TABLETITLE = "Visual status";
+ final static String VISUAL_STATUS_MESSAGE_TABLETITLE = "Message";
+ final static String FIRSTGFX_TABLETITLE = "Original print file as jpeg";
+
+ public void indexSection(String _sOfficeInfo)
+ {
+ writeln( "<H2>Results for " + _sOfficeInfo + "</H2>");
+ writeln( "<P>This result was created at: " + DateHelper.getDateTimeForHumanreadableLog());
+ writeln( "<P>Legend:<BR>");
+ writeln( stronghtml(FIRSTGFX_TABLETITLE) + " contains the output printed via 'ghostscript' as a jpeg picture.<BR>");
+
+ writeln( "<TABLE class=\"infotable\">");
+ writeln( "<TR>");
+ writeln( tableHeaderCell(TEST_TABLETITLE));
+ writeln( tableHeaderCell(""));
+ writeln( tableHeaderCell(VISUAL_STATUS_TABLETITLE));
+ writeln( tableHeaderCell(VISUAL_STATUS_MESSAGE_TABLETITLE));
+ writeln( "</TR>");
+ flush();
+ }
+/**
+ * Returns the given _sHREF & _sPathInfo as a HTML String
+ * <A HREF="_sHREF">_sPathInfo</A>
+ * @param _sHREF
+ * @param _sPathInfo
+ * @return
+ */
+ private String getHREF(String _sHREF, String _sPathInfo)
+ {
+ StringBuffer a = new StringBuffer();
+ a.append("<A HREF=\"");
+ a.append(_sHREF);
+ a.append("\">");
+ a.append(_sPathInfo);
+ a.append("</A>");
+ return a.toString();
+ }
+
+ /**
+ * Returns the given _sValue as a HTML Table cell with _sValue as content
+ * @param _sValue
+ * @return
+ */
+ private String tableDataCell(String _sValue)
+ {
+ StringBuffer a = new StringBuffer();
+ a.append("<TD>");
+ a.append(_sValue);
+ a.append("</TD>");
+ return a.toString();
+ }
+
+ /**
+ * Returns the given _sValue as a HTML Table header cell with _sValue as content
+ * @param _sValue
+ * @return
+ */
+ private String tableHeaderCell(String _sValue)
+ {
+ StringBuffer a = new StringBuffer();
+ a.append("<TH>");
+ a.append(_sValue);
+ a.append("</TH>");
+ return a.toString();
+ }
+
+ public void indexLine(String _sHTMLFile, String _sHTMLName, String _sStatusRunThrough, String _sStatusMessage)
+ {
+ writeln( "<TR>");
+ writeln(tableDataCell( getHREF(_sHTMLFile, _sHTMLName) ) );
+ writeln(tableDataCell( "" ) );
+ writeln( tableDataCell(_sStatusRunThrough) );
+ writeln( tableDataCell(_sStatusMessage) );
+ writeln( "</TR>");
+ flush();
+ }
+
+ public void close()
+ {
+ writeln( "</TABLE>");
+ writeln( "</BODY></HTML>");
+ try
+ {
+ m_aOut.close();
+ }
+ catch (java.io.IOException e)
+ {
+ }
+ }
+
+// -----------------------------------------------------------------------------
+ private String stronghtml(String _sValue)
+ {
+ StringBuffer a = new StringBuffer();
+ a.append("<STRONG>");
+ a.append(_sValue);
+ a.append("</STRONG>");
+ return a.toString();
+ }
+
+}
diff --git a/qadevOOo/runner/graphical/IDocument.java b/qadevOOo/runner/graphical/IDocument.java
new file mode 100644
index 000000000000..e23ddd4b91a1
--- /dev/null
+++ b/qadevOOo/runner/graphical/IDocument.java
@@ -0,0 +1,46 @@
+/*
+ * ************************************************************************
+ *
+ * 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
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ * ***********************************************************************
+ */
+
+package graphical;
+
+/**
+ *
+ * @author ll93751
+ */
+public interface IDocument
+{
+ /**
+ * Call this for each document
+ * @param _sDocument
+ * @param _sResult
+ * @param _aParams
+ * @throws OfficeException
+ */
+ public void checkOneFile(String _sDocument, String _sResult, ParameterHelper _aParams) throws OfficeException;
+}
diff --git a/qadevOOo/runner/graphical/IOffice.java b/qadevOOo/runner/graphical/IOffice.java
new file mode 100644
index 000000000000..ec1dc3b7371f
--- /dev/null
+++ b/qadevOOo/runner/graphical/IOffice.java
@@ -0,0 +1,63 @@
+/*
+ * ************************************************************************
+ *
+ * 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
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ * ***********************************************************************
+ */
+
+package graphical;
+
+/**
+ *
+ * @author ll93751
+ */
+public interface IOffice
+{
+ /**
+ * start an Office, if need
+ * @throws graphical.OfficeException
+ */
+ public void start() throws OfficeException;
+
+ /**
+ * Load a document by it's Name
+ * @param Name
+ * @throws graphical.OfficeException
+ */
+ public void load(String Name) throws OfficeException;
+
+ /**
+ * Create a postscript file in the DOC_COMPARATOR_OUTPUT_DIR directory from a loaded document
+ * @throws graphical.OfficeException
+ */
+ public void storeAsPostscript() throws OfficeException;
+
+
+ /**
+ * Close the background office
+ * @throws graphical.OfficeException
+ */
+ public void close() throws OfficeException;
+}
diff --git a/qadevOOo/runner/graphical/ImageHelper.java b/qadevOOo/runner/graphical/ImageHelper.java
new file mode 100644
index 000000000000..e016e08f0df1
--- /dev/null
+++ b/qadevOOo/runner/graphical/ImageHelper.java
@@ -0,0 +1,120 @@
+/*************************************************************************
+ *
+ * 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
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package graphical;
+
+import java.awt.Image;
+import java.awt.image.PixelGrabber;
+import java.awt.image.ImageObserver;
+import java.io.File;
+//import javax.imageio.ImageIO;
+import java.lang.reflect.Method;
+
+class ImageHelper
+{
+ Image m_aImage;
+ int[] m_aPixels;
+ int m_w = 0;
+ int m_h = 0;
+ boolean m_bGrabbed = false;
+
+ private ImageHelper(Image _aImage)
+ {
+ m_aImage = _aImage;
+
+ // grab all (consume much memory)
+ m_w = getWidth();
+ m_h = getHeight();
+ int x = 0;
+ int y = 0;
+ m_aPixels = new int[m_w * m_h];
+ PixelGrabber pg = new PixelGrabber(m_aImage, x, y, m_w, m_h, m_aPixels, 0, m_w);
+ try
+ {
+ pg.grabPixels();
+ }
+ catch (InterruptedException e)
+ {
+ System.err.println("interrupted waiting for pixels!");
+ return;
+ }
+ if ((pg.getStatus() & ImageObserver.ABORT) != 0)
+ {
+ System.err.println("image fetch aborted or errored");
+ return;
+ }
+ m_bGrabbed = true;
+ }
+ public int getWidth() {return m_aImage.getWidth(null);}
+ public int getHeight() {return m_aImage.getHeight(null);}
+ // direct access to a pixel
+ public int getPixel(final int x, final int y)
+ {
+ return m_aPixels[y * m_w + x];
+ }
+
+ // Write down the current image to a file.
+ // public void storeImage(String _sFilename)
+ // {
+ // }
+
+ public static ImageHelper createImageHelper(String _sFilename)
+ throws java.io.IOException
+ {
+ Image aImage = null;
+ File aFile = new File(_sFilename);
+ Exception ex = null;
+ try {
+ Class imageIOClass = Class.forName("javax.imageio.ImageIO");
+ Method readMethod = imageIOClass.getDeclaredMethod("read", new Class[]{java.io.File.class});
+ Object retValue = readMethod.invoke(imageIOClass, new Object[]{aFile});
+ aImage = (Image)retValue;
+ }
+ catch(java.lang.ClassNotFoundException e) {
+ ex = e;
+ }
+ catch(java.lang.NoSuchMethodException e) {
+ ex = e;
+ }
+ catch(java.lang.IllegalAccessException e) {
+ ex = e;
+ }
+ catch(java.lang.reflect.InvocationTargetException e) {
+ ex = e;
+ }
+
+ if (ex != null) {
+ // get Java version:
+ String javaVersion = System.getProperty("java.version");
+ throw new java.io.IOException(
+ "Cannot construct object with current Java version " +
+ javaVersion + ": " + ex.getMessage());
+ }
+// aImage = ImageIO.read(aFile);
+ return new ImageHelper(aImage);
+ }
+}
diff --git a/qadevOOo/runner/graphical/IniFile.java b/qadevOOo/runner/graphical/IniFile.java
new file mode 100644
index 000000000000..bd54a66b65fd
--- /dev/null
+++ b/qadevOOo/runner/graphical/IniFile.java
@@ -0,0 +1,693 @@
+/*************************************************************************
+ *
+ * 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
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package graphical;
+
+// import java.io.BufferedReader;
+import java.io.File;
+import java.io.RandomAccessFile;
+import java.util.ArrayList;
+import java.util.Enumeration;
+
+/**
+ Helper class to give a simple API to read/write windows like ini files
+*/
+/* public */ // is only need, if we need this class outside package convwatch
+public class IniFile implements Enumeration
+{
+
+ /**
+ * internal representation of the ini file content.
+ * Problem, if ini file changed why other write something difference, we don't realise this.
+ */
+ private String m_sFilename;
+ private ArrayList<String> m_aList;
+ boolean m_bListContainUnsavedChanges = false;
+ private int m_aEnumerationPos = 0;
+
+ /**
+ open a ini file by it's name
+ @param _sFilename string a filename, if the file doesn't exist, a new empty ini file will create.
+ write back to disk only if there are really changes.
+ */
+ public IniFile(String _sFilename)
+ {
+ m_sFilename = _sFilename;
+ m_aList = loadLines();
+ m_aEnumerationPos = findNextSection(0);
+// if (_sFilename.endsWith(".odb.ps.ini"))
+// {
+// int dummy = 0;
+// }
+ }
+
+ public void insertFirstComment(String[] _aList)
+ {
+ if (m_aList.size() == 0)
+ {
+ // can only insert if there is nothing else already in the ini file
+ for (int i = 0; i < _aList.length; i++)
+ {
+ m_aList.add(_aList[i]);
+ }
+ }
+ }
+
+ private ArrayList<String> loadLines()
+ {
+ File aFile = new File(m_sFilename);
+ ArrayList<String> aLines = new ArrayList<String>();
+ if (!aFile.exists())
+ {
+ // GlobalLogWriter.println("couldn't find file '" + m_sFilename + "', will be created.");
+ // DebugHelper.exception(BasicErrorCode.SbERR_FILE_NOT_FOUND, "");
+ // m_bListContainUnsavedChanges = false;
+ return aLines;
+ }
+ RandomAccessFile aReader = null;
+ // BufferedReader aReader;
+ try
+ {
+ aReader = new RandomAccessFile(aFile, "r");
+ String aLine = "";
+ while (aLine != null)
+ {
+ aLine = aReader.readLine();
+ if (aLine != null && aLine.length() > 0)
+ {
+ aLines.add(aLine);
+ }
+ }
+ }
+ catch (java.io.FileNotFoundException fne)
+ {
+ GlobalLogWriter.println("couldn't open file " + m_sFilename);
+ GlobalLogWriter.println("Message: " + fne.getMessage());
+ // DebugHelper.exception(BasicErrorCode.SbERR_FILE_NOT_FOUND, "");
+ }
+ catch (java.io.IOException ie)
+ {
+ GlobalLogWriter.println("Exception occurs while reading from file " + m_sFilename);
+ GlobalLogWriter.println("Message: " + ie.getMessage());
+ // DebugHelper.exception(BasicErrorCode.SbERR_INTERNAL_ERROR, ie.getMessage());
+ }
+ try
+ {
+ aReader.close();
+ }
+ catch (java.io.IOException ie)
+ {
+ GlobalLogWriter.println("Couldn't close file " + m_sFilename);
+ GlobalLogWriter.println("Message: " + ie.getMessage());
+ // DebugHelper.exception(BasicErrorCode.SbERR_INTERNAL_ERROR, ie.getMessage());
+ }
+ return aLines;
+ }
+
+ /**
+ * @return true, if the ini file contain some readable data
+ */
+ public boolean is()
+ {
+ return m_aList.size() > 1 ? true : false;
+ }
+
+ /**
+ * Check if a given Section and Key exists in the ini file
+ * @param _sSectionName
+ * @param _sKey
+ * @return true if the given Section, Key exists, now you can get the value
+ */
+ public boolean hasValue(String _sSectionName, String _sKey)
+ {
+ int n = findKey(_sSectionName, _sKey);
+ if (n > 0)
+ {
+ return true;
+ }
+ return false;
+ }
+ // -----------------------------------------------------------------------------
+
+ private boolean isRemark(String _sLine)
+ {
+ if (((_sLine.length() < 2)) ||
+ (_sLine.startsWith("#")) ||
+ (_sLine.startsWith(";")))
+ {
+ return true;
+ }
+ return false;
+ }
+
+ private String getItem(int i)
+ {
+ return m_aList.get(i);
+ }
+
+ private String buildSectionName(String _sSectionName)
+ {
+ String sFindSection = "[" + _sSectionName + "]";
+ return sFindSection;
+ }
+
+ private String sectionToString(String _sSectionName)
+ {
+ String sKeyName = _sSectionName;
+ if (sKeyName.startsWith("[") &&
+ sKeyName.endsWith("]"))
+ {
+ sKeyName = sKeyName.substring(1, sKeyName.length() - 1);
+ }
+ return sKeyName;
+ }
+
+ private String toLowerIfNeed(String _sName)
+ {
+ return _sName.toLowerCase();
+ }
+
+ // return the number where this section starts
+ private int findSection(String _sSection)
+ {
+ String sFindSection = toLowerIfNeed(buildSectionName(_sSection));
+ // ----------- find _sSection ---------------
+ int i;
+ for (i = 0; i < m_aList.size(); i++)
+ {
+ String sLine = toLowerIfNeed(getItem(i).trim());
+ if (isRemark(sLine))
+ {
+ continue;
+ }
+ if (sFindSection.equals("[]"))
+ {
+ // special case, empty Section.
+ return i - 1;
+ }
+ if (sLine.startsWith(sFindSection))
+ {
+ return i;
+ }
+ }
+ return -1;
+ }
+
+ /**
+ * Checks if a given section exists in the ini file
+ * @param _sSection
+ * @return true if the given _sSection was found
+ */
+ public boolean hasSection(String _sSection)
+ {
+ int i = findSection(_sSection);
+ if (i == -1)
+ {
+ return false;
+ }
+ return true;
+ }
+
+ // return the line number, where the key is found.
+ private int findKey(String _sSection, String _sKey)
+ {
+ int i = findSection(_sSection);
+ if (i == -1)
+ {
+ // Section not found, therefore the value can't exist
+ return -1;
+ }
+ return findKeyFromKnownSection(i, _sKey);
+ }
+
+ // i must be the index in the list, where the well known section starts
+ private int findKeyFromKnownSection(int _nSectionIndex, String _sKey)
+ {
+ _sKey = toLowerIfNeed(_sKey);
+ for (int j = _nSectionIndex + 1; j < m_aList.size(); j++)
+ {
+ String sLine = getItem(j).trim();
+
+ if (isRemark(sLine))
+ {
+ continue;
+ }
+ if (sLine.startsWith("[") /* && sLine.endsWith("]") */)
+ {
+ // TODO: due to the fact we would like to insert an empty line before new sections
+ // TODO: we should check if we are in an empty line and if, go back one line.
+
+ // found end.
+ break;
+ }
+
+ int nEqual = sLine.indexOf("=");
+ if (nEqual >= 0)
+ {
+ String sKey = toLowerIfNeed(sLine.substring(0, nEqual).trim());
+ if (sKey.equals(_sKey))
+ {
+ return j;
+ }
+ }
+ }
+ 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("[") /* && sLine.endsWith("]") */)
+ {
+ // 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();
+ if (isRemark(sLine))
+ {
+ return "";
+ }
+ int nEqual = sLine.indexOf("=");
+ if (nEqual >= 0)
+ {
+ String sKey = sLine.substring(0, nEqual).trim();
+ String sValue = sLine.substring(nEqual + 1).trim();
+ return sValue;
+ }
+ return "";
+ }
+
+ /**
+ @param _sSection string
+ @param _sKey string
+ @return the value found in the inifile which is given by the section and key parameter
+ */
+ // private int m_nCurrentPosition;
+ // private String m_sOldKey;
+ public String getValue(String _sSection, String _sKey)
+ {
+ String sValue = "";
+ int m_nCurrentPosition = findKey(_sSection, _sKey);
+ if (m_nCurrentPosition == -1)
+ {
+ // Section not found, therefore the value can't exist
+ return "";
+ }
+
+ // m_sOldKey = _sKey;
+ sValue = getValue(m_nCurrentPosition);
+
+ return sValue;
+ }
+
+// private String getNextValue()
+// {
+// if (m_nCurrentPosition >= 0)
+// {
+// ++m_nCurrentPosition;
+// String sValue = getValue(m_nCurrentPosition);
+// return sValue;
+// }
+// return "";
+// }
+ /**
+ * Returns the value at Section, Key converted to an integer
+ * Check with hasValue(Section, Key) to check before you get into trouble.
+ * @param _sSection
+ * @param _sKey
+ * @param _nDefault if there is a problem, key not found... this value will return
+ * @return
+ */
+ public int getIntValue(String _sSection, String _sKey, int _nDefault)
+ {
+ String sValue = getValue(_sSection, _sKey);
+ int nValue = _nDefault;
+ if (sValue.length() > 0)
+ {
+ try
+ {
+ nValue = Integer.valueOf(sValue).intValue();
+ }
+ catch (java.lang.NumberFormatException e)
+ {
+ GlobalLogWriter.println("IniFile.getIntValue(): Caught a number format exception, return the default value.");
+ }
+ }
+ return nValue;
+ }
+
+ public void close()
+ {
+ store();
+ }
+
+ /**
+ write back the ini file to the disk, only if there exist changes
+ * @deprecated use close() instead!
+ */
+
+ // TODO: make private
+ public void store()
+ {
+ if (m_bListContainUnsavedChanges == false)
+ {
+ // nothing has changed, so no need to store
+ return;
+ }
+
+ File aFile = new File(m_sFilename);
+ if (aFile.exists())
+ {
+ // System.out.println("couldn't find file " + m_sFilename);
+ // TODO: little bit unsafe here, first rename, after write is complete, delete the old.
+ aFile.delete();
+ if (aFile.exists())
+ {
+ GlobalLogWriter.println("Couldn't delete the file " + m_sFilename);
+ return;
+ // DebugHelper.exception(BasicErrorCode.SbERR_INTERNAL_ERROR, "Couldn't delete the file " + m_sFilename);
+ }
+ }
+ // if (! aFile.canWrite())
+ // {
+ // System.out.println("Couldn't write to file " + m_sFilename);
+ // DebugHelper.exception(BasicErrorCode.SbERR_INTERNAL_ERROR, "");
+ // }
+ try
+ {
+ RandomAccessFile aWriter = new RandomAccessFile(aFile, "rw");
+ for (int i = 0; i < m_aList.size(); i++)
+ {
+ String sLine = getItem(i);
+ if (sLine.startsWith("["))
+ {
+ // write an extra empty line before next section.
+ aWriter.writeByte((int) '\n');
+ }
+ aWriter.writeBytes(sLine);
+ aWriter.writeByte((int) '\n');
+ }
+ aWriter.close();
+ }
+ catch (java.io.FileNotFoundException fne)
+ {
+ GlobalLogWriter.println("couldn't open file for writing " + m_sFilename);
+ GlobalLogWriter.println("Message: " + fne.getMessage());
+ // DebugHelper.exception(BasicErrorCode.SbERR_FILE_NOT_FOUND, "");
+ }
+ catch (java.io.IOException ie)
+ {
+ GlobalLogWriter.println("Exception occurs while writing to file " + m_sFilename);
+ GlobalLogWriter.println("Message: " + ie.getMessage());
+ // DebugHelper.exception(BasicErrorCode.SbERR_INTERNAL_ERROR, ie.getMessage());
+ }
+ }
+
+ public void insertValue(String _sSection, String _sKey, int _nValue)
+ {
+ insertValue(_sSection, _sKey, String.valueOf(_nValue));
+ }
+
+ public void insertValue(String _sSection, String _sKey, long _nValue)
+ {
+ insertValue(_sSection, _sKey, String.valueOf(_nValue));
+ }
+
+ /**
+ insert a value
+ there are 3 cases
+ 1. section doesn't exist, goto end and insert a new section, insert a new key value pair
+ 2. section exist but key not, search section, search key, if key is -1 get last known key position and insert new key value pair there
+ 3. section exist and key exist, remove the old key and insert the key value pair at the same position
+ * @param _sSection
+ * @param _sKey
+ * @param _sValue
+ */
+ public void insertValue(String _sSection, String _sKey, String _sValue)
+ {
+ int i = findSection(_sSection);
+ if (i == -1)
+ {
+ // case 1: section doesn't exist
+ String sFindSection = buildSectionName(_sSection);
+
+ // TODO: before create a new Section, insert a empty line
+ m_aList.add(sFindSection);
+ if (_sKey.length() > 0)
+ {
+ String sKeyValuePair = _sKey + "=" + _sValue;
+ m_aList.add(sKeyValuePair);
+ }
+ m_bListContainUnsavedChanges = true;
+ return;
+ }
+ int j = findKeyFromKnownSection(i, _sKey);
+ if (j == -1)
+ {
+ // case 2: section exist, but not the key
+ j = findLastKnownKeyIndex(i, _sKey);
+ if (_sKey.length() > 0)
+ {
+ String sKeyValuePair = _sKey + "=" + _sValue;
+ m_aList.add(j, sKeyValuePair);
+ m_bListContainUnsavedChanges = true;
+ }
+ return;
+ }
+ else
+ {
+ // case 3: section exist, and also the key
+ String sKeyValuePair = _sKey + "=" + _sValue;
+ m_aList.set(j, sKeyValuePair);
+ m_bListContainUnsavedChanges = true;
+ }
+ }
+ // -----------------------------------------------------------------------------
+ // String replaceEvaluatedValue(String _sSection, String _sValue)
+ // {
+ // String sValue = _sValue;
+ // int nIndex = 0;
+ // while (( nIndex = sValue.indexOf("$(", nIndex)) >= 0)
+ // {
+ // int nNextIndex = sValue.indexOf(")", nIndex);
+ // if (nNextIndex >= 0)
+ // {
+ // String sKey = sValue.substring(nIndex + 2, nNextIndex);
+ // String sNewValue = getValue(_sSection, sKey);
+ // if (sNewValue != null && sNewValue.length() > 0)
+ // {
+ // String sRegexpKey = "\\$\\(" + sKey + "\\)";
+ // sValue = sValue.replaceAll(sRegexpKey, sNewValue);
+ // }
+ // nIndex = nNextIndex;
+ // }
+ // else
+ // {
+ // nIndex += 2;
+ // }
+ // }
+ // return sValue;
+ // }
+ // -----------------------------------------------------------------------------
+
+ // public String getLocalEvaluatedValue(String _sSection, String _sKey)
+ // {
+ // String sValue = getValue(_sSection, _sKey);
+ // sValue = replaceEvaluatedValue(_sSection, sValue);
+ // return sValue;
+ // }
+
+ // -----------------------------------------------------------------------------
+
+ // this is a special behaviour.
+ // public String getGlobalLocalEvaluatedValue(String _sSection, String _sKey)
+ // {
+ // String sGlobalValue = getKey("global", _sKey);
+ // String sLocalValue = getKey(_sSection, _sKey);
+ // if (sLocalValue.length() == 0)
+ // {
+ // sGlobalValue = replaceEvaluatedKey(_sSection, sGlobalValue);
+ // sGlobalValue = replaceEvaluatedKey("global", sGlobalValue);
+ // return sGlobalValue;
+ // }
+ // sLocalValue = replaceEvaluatedKey(_sSection, sLocalValue);
+ // sLocalValue = replaceEvaluatedKey("global", sLocalValue);
+ //
+ // return sLocalValue;
+ // }
+ public void removeSection(String _sSectionToRemove)
+ {
+ // first, search for the name
+ int i = findSection(_sSectionToRemove);
+ if (i == -1)
+ {
+ // Section to remove not found, do nothing.
+ return;
+ }
+ // second, find the next section
+ int j = findNextSection(i + 1);
+ if (j == -1)
+ {
+ // if we are at the end, use size() as second section
+ j = m_aList.size();
+ }
+ // remove all between first and second section
+ for (int k = i; k < j; k++)
+ {
+ m_aList.remove(i);
+ }
+ // mark the list as changed
+ m_bListContainUnsavedChanges = true;
+ }
+
+ /**
+ * some tests for this class
+ */
+// public static void main(String[] args)
+// {
+// String sTempFile = System.getProperty("java.io.tmpdir");
+// sTempFile += "inifile";
+//
+//
+// IniFile aIniFile = new IniFile(sTempFile);
+// String sValue = aIniFile.getValue("Section", "Key");
+// // insert a new value to a already exist section
+// aIniFile.insertValue("Section", "Key2", "a new value in a existing section");
+// // replace a value
+// aIniFile.insertValue("Section", "Key", "replaced value");
+// // create a new value
+// aIniFile.insertValue("New Section", "Key", "a new key value pair");
+// aIniFile.insertValue("New Section", "Key2", "a new second key value pair");
+//
+// String sValue2 = aIniFile.getValue("Section2", "Key");
+//
+// aIniFile.removeSection("Section");
+// aIniFile.removeSection("New Section");
+//
+// aIniFile.close();
+// }
+
+ /**
+ * Enumeration Interface
+ * @return true, if there are more Key values
+ */
+ public boolean hasMoreElements()
+ {
+ if (m_aEnumerationPos >= 0 &&
+ m_aEnumerationPos < m_aList.size())
+ {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Find the next line, which starts with '['
+ * @param i start position
+ * @return the line where '[' found or -1
+ */
+ private int findNextSection(int i)
+ {
+ if (i >= 0)
+ {
+ while (i < m_aList.size())
+ {
+ String sLine = m_aList.get(i);
+ if (sLine.startsWith("["))
+ {
+ return i;
+ }
+ i++;
+ }
+ }
+ return -1;
+ }
+
+ /**
+ * Enumeration Interface
+ * @return a key without the enveloped '[' ']'
+ */
+ public Object nextElement()
+ {
+ int nLineWithSection = findNextSection(m_aEnumerationPos);
+ if (nLineWithSection != -1)
+ {
+ String sSection = m_aList.get(nLineWithSection);
+ m_aEnumerationPos = findNextSection(nLineWithSection + 1);
+ sSection = sectionToString(sSection);
+ return sSection;
+ }
+ else
+ {
+ m_aEnumerationPos = m_aList.size();
+ }
+ return null;
+ }
+
+ /**
+ * Helper to count the occurence of Sections
+ * @return returns the count of '^['.*']$' Elements
+ */
+ public int getElementCount()
+ {
+ int nCount = 0;
+ int nPosition = 0;
+ while ((nPosition = findNextSection(nPosition)) != -1)
+ {
+ nCount++;
+ nPosition++;
+ }
+ return nCount;
+ }
+}
+
diff --git a/qadevOOo/runner/graphical/JPEGComparator.java b/qadevOOo/runner/graphical/JPEGComparator.java
new file mode 100644
index 000000000000..a643b2b333c3
--- /dev/null
+++ b/qadevOOo/runner/graphical/JPEGComparator.java
@@ -0,0 +1,816 @@
+/*
+ * ************************************************************************
+ *
+ * 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
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ * ***********************************************************************
+ */
+package graphical;
+
+import helper.OSHelper;
+import helper.ProcessHandler;
+import java.io.File;
+import java.io.IOException;
+
+/**
+ * Helper class to interpret a jpg filename
+ */
+class NameDPIPage
+{
+
+ String Name;
+ int DPI;
+ int Page;
+
+ private NameDPIPage(String _sName, int _nDPI, int _nPage)
+ {
+ Name = _sName;
+ DPI = _nDPI;
+ Page = _nPage;
+ }
+
+ public static NameDPIPage interpret(String _sFilename)
+ {
+ String sBasename = FileHelper.getBasename(_sFilename); // if exist a path, remove it
+ String sNameNoSuffix = FileHelper.getNameNoSuffix(sBasename); // remove extension (.jpg)
+
+ // check if there exist a 'DPI_' at specific position
+ String sDPICheck = sNameNoSuffix.substring(sNameNoSuffix.length() - 8, sNameNoSuffix.length() - 4);
+ String sName;
+ int nDPI = -1;
+ int nPage = -1;
+ if (sDPICheck.equals("DPI_"))
+ {
+ // seems to be a generated filename by us.
+ int nDPIStart = sNameNoSuffix.lastIndexOf("_", sNameNoSuffix.length() - 8);
+ sName = sNameNoSuffix.substring(0, nDPIStart);
+ if (nDPIStart > 0)
+ {
+ String sDPI = sNameNoSuffix.substring(nDPIStart + 1, sNameNoSuffix.length() - 8);
+ try
+ {
+ nDPI = Integer.valueOf(sDPI).intValue();
+ }
+ catch (java.lang.NumberFormatException e)
+ {
+ GlobalLogWriter.println("DPI: Number format exception");
+ }
+ String sPage = sNameNoSuffix.substring(sNameNoSuffix.length() - 4);
+ try
+ {
+ nPage = Integer.valueOf(sPage).intValue();
+ }
+ catch (java.lang.NumberFormatException e)
+ {
+ GlobalLogWriter.println("Page: Number format exception");
+ }
+ }
+ }
+ else
+ {
+ sName = sNameNoSuffix;
+ }
+
+ return new NameDPIPage(sName, nDPI, nPage);
+ }
+}
+
+class CountNotXXXPixelsFromImage extends Thread
+{
+
+ private String m_sFilename;
+ protected int m_nValue;
+
+ CountNotXXXPixelsFromImage(String _sFilename)
+ {
+ m_sFilename = _sFilename;
+ }
+
+ public int getValue()
+ {
+ return m_nValue;
+ }
+
+ protected void setValue(int _nValue)
+ {
+ m_nValue = _nValue;
+ }
+
+ protected String getFilename()
+ {
+ return m_sFilename;
+ }
+}
+
+class CountNotWhitePixelsFromImage extends CountNotXXXPixelsFromImage
+{
+
+ CountNotWhitePixelsFromImage(String _sFilename)
+ {
+ super(_sFilename);
+ }
+
+ public void run()
+ {
+ try
+ {
+ final int nNotWhiteCount = PixelCounter.countNotWhitePixelsFromImage(getFilename());
+ setValue(nNotWhiteCount);
+ }
+ catch (java.io.IOException e)
+ {
+ m_nValue = -1;
+ }
+ }
+}
+
+class CountNotBlackPixelsFromImage extends CountNotXXXPixelsFromImage
+{
+
+ CountNotBlackPixelsFromImage(String _sFilename)
+ {
+ super(_sFilename);
+ }
+
+ public void run()
+ {
+ try
+ {
+ final int nNotBlackCount = PixelCounter.countNotBlackPixelsFromImage(getFilename());
+ setValue(nNotBlackCount);
+ }
+ catch (java.io.IOException e)
+ {
+ m_nValue = -1;
+ }
+ }
+}
+
+/**
+ *
+ * @author ll93751
+ */
+public class JPEGComparator extends EnhancedComplexTestCase
+{
+ // @Override
+
+ public String[] getTestMethodNames()
+ {
+ return new String[]{"CompareJPEGvsJPEG"};
+ }
+ private Tolerance m_aTolerance;
+
+ /**
+ * test function.
+ */
+ public void CompareJPEGvsJPEG()
+ {
+ GlobalLogWriter.set(log);
+ ParameterHelper aParam = new ParameterHelper(param);
+
+ // run through all documents found in Inputpath
+ foreachJPEGcompareWithJPEG(aParam);
+ }
+
+ public void checkOneFile(String _sDocumentName, String _sResult, ParameterHelper _aParams) throws OfficeException
+ {
+ // private void callEveryPictureInIniFile(IniFile _aIniFile, String _sSectionName, ParameterHelper _aParam)
+ // {
+ String sPath = FileHelper.getPath(_sDocumentName);
+ String sSectionName = FileHelper.getBasename(_sDocumentName);
+
+ // take the build id out of the ini file in the reference file and put it into the current parameter helper
+ String sIniFileForRefBuildID = FileHelper.appendPath(sPath, sSectionName + ".ini");
+ IniFile aIniFileForRefBuildID = new IniFile(sIniFileForRefBuildID);
+ String sRefBuildID = aIniFileForRefBuildID.getValue("global", "buildid");
+ aIniFileForRefBuildID.close();
+
+ _aParams.getTestParameters().put("RefBuildId", sRefBuildID);
+
+ String sIniFile = FileHelper.appendPath(sPath, "index.ini");
+ IniFile aIniFile = new IniFile(sIniFile);
+ if (aIniFile.hasValue(sSectionName, "pages"))
+ {
+ // only which has 'pages' has also pictures
+ int nPages = aIniFile.getIntValue(sSectionName, "pages", 0);
+ String sJPEGSchema = aIniFile.getValue(sSectionName, "jpegschema");
+ int nTolerance = aIniFile.getIntValue(sSectionName, "tolerance", 0);
+ m_aTolerance = new Tolerance(nTolerance);
+ for (int i = 1; i <= nPages; i++)
+ {
+ String sJPEGFilename = JPEGCreator.getFilenameForJPEGSchema(sJPEGSchema, i);
+ // String sPath = FileHelper.getPath(_aParam.getInputPath());
+ String sJPEGPath = FileHelper.getPath(sJPEGFilename);
+ if (!sPath.equals(sJPEGPath))
+ {
+ GlobalLogWriter.println("Path where to find the index and where to file the JPEG pictures are not the same.");
+
+ }
+ // String sEntry = FileHelper.appendPath(sPath, sSection);
+ File aFile = new File(sJPEGFilename);
+ assure("File '" + sJPEGFilename + "' doesn't exists.", aFile.exists(), true);
+ if (aFile.exists())
+ {
+ GlobalLogWriter.println("Page: " + i);
+ checkOnePicture(sJPEGFilename, _sResult, _aParams);
+ }
+ }
+ }
+ else
+ {
+ GlobalLogWriter.println("The document '" + sSectionName + "' seems to have no picture representation.");
+ }
+
+ String sResultIniFile = FileHelper.appendPath(_sResult, sSectionName);
+ evaluateResult(sResultIniFile, _aParams);
+ }
+
+ private void evaluateResult(String _sDocument, ParameterHelper _aParams)
+ {
+ String sResultIniFile = _sDocument + ".ini";
+ File aFile = new File(sResultIniFile);
+ assure("Result file doesn't exists " + sResultIniFile, aFile.exists());
+
+ int good = 0;
+ int bad = 0;
+ int ugly = 0;
+ int ok_status = 1; // 1=ok 2=bad 3=ugly
+
+ IniFile aResultIniFile = new IniFile(sResultIniFile);
+ int nPages = aResultIniFile.getIntValue("global", "pages", 0);
+ for (int i = 0; i < nPages; i++)
+ {
+ String sCurrentPage = "page" + String.valueOf(i + 1);
+ int nPercent = aResultIniFile.getIntValue(sCurrentPage, "percent", -1);
+ if (nPercent == 0)
+ {
+ good++;
+ }
+ else if (nPercent <= 5)
+ {
+ bad++;
+ ok_status = 2;
+ }
+ else
+ {
+ ugly++;
+ ok_status = 3;
+ }
+ }
+
+ assure("Error: document doesn't contains pages", nPages > 0);
+
+// TODO: this information has to come out of the ini files
+ String sStatusRunThrough = "PASSED, ";
+ String sPassed = "OK";
+
+ String sStatusMessage = "From " + nPages + " page(s) are: ";
+ String sGood = "";
+ String sBad = "";
+ String sUgly = "";
+
+ if (good > 0)
+ {
+ sGood = " good:=" + good;
+ sStatusMessage += sGood;
+ }
+ if (bad > 0)
+ {
+ sBad = " bad:=" + bad;
+ sStatusMessage += sBad;
+ }
+ if (ugly > 0)
+ {
+ sUgly = " ugly:=" + ugly;
+ sStatusMessage += sUgly;
+ }
+
+ // Failure matrix
+ // 0 1
+ // ugly OK FAILED
+ // bad OK
+ // good OK
+
+ if (ugly > 0)
+ {
+ sPassed = "FAILED";
+ }
+ else
+ {
+ if (bad > 0)
+ {
+ sPassed = "NEED A LOOK";
+ }
+ else
+ {
+ sPassed = "OK";
+ }
+ }
+ sStatusRunThrough += sPassed;
+ aResultIniFile.insertValue("global", "state", sStatusRunThrough);
+ aResultIniFile.insertValue("global", "info", sStatusMessage);
+ aResultIniFile.close();
+
+ _aParams.getTestParameters().put("current_state", sStatusRunThrough);
+ _aParams.getTestParameters().put("current_info", sStatusMessage);
+ _aParams.getTestParameters().put("current_ok_status", ok_status);
+
+ // if we have a ugly page, we must return this as a FAILED STATUS in Log file!
+ assure("There exist pages marked as ugly.", ugly == 0);
+ }
+
+ private void checkOnePicture(String _sDocumentName, String _sResult, ParameterHelper _aParams)
+ {
+ GlobalLogWriter.println("JPEG: Compare difference between '" + _sDocumentName + "' and '" + _sResult + "'");
+ File aResultFile = new File(_sResult);
+ if (aResultFile.isDirectory())
+ {
+ // result is just a directory, so we search for the basename of the source and take this.
+ String sBasename = FileHelper.getBasename(_sDocumentName);
+ String sResultFilename = FileHelper.appendPath(_sResult, sBasename);
+ aResultFile = new File(sResultFilename);
+ if (aResultFile.exists())
+ {
+ // Original and Result exists
+ String sInputPath = _aParams.getInputPath();
+ if (sInputPath.toLowerCase().endsWith("index.ini"))
+ {
+ // special case
+ // we want to get the buildid from the info file.
+ }
+
+ compareJPEG(_sDocumentName, sResultFilename, _aParams);
+
+ }
+ else
+ {
+ String sResultFilenamePDF = util.utils.replaceAll13(sResultFilename, ".ps_", ".pdf_");
+ File aResultPDFFile = new File(sResultFilenamePDF);
+ if (aResultPDFFile.exists())
+ {
+ // Original and Result exists
+ String sInputPath = _aParams.getInputPath();
+ if (sInputPath.toLowerCase().endsWith("index.ini"))
+ {
+ // special case
+ // we want to get the buildid from the info file.
+ }
+
+ compareJPEG(_sDocumentName, sResultFilenamePDF, _aParams);
+ }
+ else
+ {
+ GlobalLogWriter.println("Warning: Result JPEG doesn't exists '" + sResultFilename + "'");
+ }
+ }
+ }
+ else
+ {
+ // result is also a file
+ if (aResultFile.exists())
+ {
+ compareJPEG(_sDocumentName, _sResult, _aParams);
+ }
+ else
+ {
+ GlobalLogWriter.println("Warning: Result JPEG doesn't exists '" + _sResult + "'");
+ }
+ }
+ }
+
+ /**
+ * compare 2 JPEGs, it is a need, that both _sDocumentName and _sResultFilename exist.
+ * @param _sDocumentName
+ * @param _sResult
+ * @param _aParams
+ * @return 0=no difference !=0 both files differ
+ */
+ private void compareJPEG(String _sDocumentName, String _sResult, ParameterHelper _aParams)
+ {
+ NameDPIPage aNameDPIPage = NameDPIPage.interpret(_sDocumentName);
+
+ String sSourceBasename = FileHelper.getBasename(_sDocumentName);
+ String sSourcePath = FileHelper.getPath(_sDocumentName);
+ String sDestinationBasename = FileHelper.getBasename(_sResult);
+ String sDestinationPath = FileHelper.getPath(_sResult);
+
+ if (!sSourcePath.equals(sDestinationPath))
+ {
+ // we want to have all in one Directory, Original, Reference and the Difference result.
+ // copy the original file to the reference path
+ String sNewSourceBasename = "Original_" + sSourceBasename;
+ // String sSource = FileHelper.appendPath(sSourcePath, sSourceBasename);
+ String sSource = _sDocumentName;
+ String sDestination = FileHelper.appendPath(sDestinationPath, sNewSourceBasename);
+ FileHelper.copy(sSource, sDestination);
+ sSourceBasename = sNewSourceBasename;
+ //
+ JPEGCreator.convertToNearSameFileWithWidth340(sDestination);
+ }
+ String sDifferenceBasename = "Difference_between_" + FileHelper.getNameNoSuffix(sSourceBasename) + "_and_" + FileHelper.getNameNoSuffix(sDestinationBasename) + ".jpg";
+ // String sDifferencePath = sDestinationPath;
+
+ String sSource = FileHelper.appendPath(sDestinationPath, sSourceBasename);
+ String sDestination = FileHelper.appendPath(sDestinationPath, sDestinationBasename);
+ String sDifference = FileHelper.appendPath(sDestinationPath, sDifferenceBasename);
+ int nErr = compareJPEG(sSource, sDestination, sDifference);
+ if (nErr == 0 && FileHelper.exists(sDifference))
+ {
+ // check the difference, returns the count of different colors
+ // this means, 1=only one color, no differences found.
+ int nResult = identify(sDifference);
+ int nPercentColorDiffer = 0;
+
+ String sResult = "YES";
+
+ if (m_aTolerance != null)
+ {
+ final int nAcceptedTolerance = m_aTolerance.getAccept();
+ if (nResult <= nAcceptedTolerance)
+ {
+ nResult = 1;
+ sResult = "IN TOLERANCE";
+ GlobalLogWriter.println("The differences are in tolerance.");
+
+ }
+ }
+ if (nResult != 1)
+ {
+ sResult = "NO";
+ try
+ {
+ nPercentColorDiffer = estimateGfx(sSource, sDestination, sDifference);
+ }
+ catch (java.io.IOException e)
+ {
+ GlobalLogWriter.println("Can't estimate the different colors. " + e.getMessage());
+ }
+ }
+
+ // store the result in a result.ini file
+ String sResultFile = FileHelper.appendPath(sDestinationPath, aNameDPIPage.Name + ".ini");
+ int nPage = aNameDPIPage.Page;
+ if (nPage < 0)
+ {
+ nPage = 0;
+ }
+ IniFile aResultIni = new IniFile(sResultFile);
+
+ String[] aComment =
+ {
+ "; This file is automatically created by a graphical.JPEGComparator run",
+ "; ",
+ "; If you see this file in a browser you may have forgotten to set the follows in the property file",
+ "; " + PropertyName.DOC_COMPARATOR_HTML_OUTPUT_PREFIX + "=http://<computer>/gfxcmp_ui/cw.php?inifile=",
+ "; Please check the documentation if you got confused.",
+ "; ",
+ "; "
+ };
+ aResultIni.insertFirstComment(aComment);
+
+ // write down the global flags
+ int nMaxPage = Math.max(nPage, aResultIni.getIntValue("global", "pages", 0));
+ aResultIni.insertValue("global", "pages", nMaxPage);
+
+ // INIoutput.writeValue("buildid", _sBuildID);
+ // INIoutput.writeValue("refbuildid", _sRefBuildID);
+ String sRefBuildId = (String) _aParams.getTestParameters().get("RefBuildId");
+ if (sRefBuildId == null)
+ {
+ sRefBuildId = "";
+ }
+ aResultIni.insertValue("global", "refbuildid", sRefBuildId);
+
+ aResultIni.insertValue("global", "diffdiff", "no");
+ aResultIni.insertValue("global", "basename", aNameDPIPage.Name);
+ aResultIni.insertValue("global", "dpi", aNameDPIPage.DPI);
+
+ // write down flags for each page
+ String sSection = "page" + String.valueOf(nPage);
+
+ aResultIni.insertValue(sSection, "oldgfx", sSource);
+ aResultIni.insertValue(sSection, "newgfx", sDestination);
+ aResultIni.insertValue(sSection, "diffgfx", sDifference);
+ aResultIni.insertValue(sSection, "percent", nPercentColorDiffer);
+ aResultIni.insertValue(sSection, "BM", "false");
+ aResultIni.insertValue(sSection, "result", sResult);
+
+ aResultIni.close();
+ }
+ }
+
+// // This creates a status for exact on document
+// static boolean createINIStatus(StatusHelper[] aList, String _sFilenamePrefix, String _sOutputPath, String _sAbsoluteInputFile, String _sBuildID, String _sRefBuildID)
+// {
+// // Status
+// String fs = System.getProperty("file.separator");
+// String sBasename = FileHelper.getBasename(_sAbsoluteInputFile);
+// String sNameNoSuffix = FileHelper.getNameNoSuffix(sBasename);
+//// String sHTMLFile = _sFilenamePrefix + sNameNoSuffix + ".html";
+//// HTMLOutputter HTMLoutput = HTMLOutputter.create(_sOutputPath, sHTMLFile, "", "");
+//// HTMLoutput.header(sNameNoSuffix);
+//// TODO: version info was fine
+//// HTMLoutput.checkSection(sBasename);
+// // Status end
+//
+// String sINIFile = _sFilenamePrefix + sNameNoSuffix + ".ini";
+// INIOutputter INIoutput = INIOutputter.create(_sOutputPath, sINIFile, "", "");
+// INIoutput.createHeader();
+//// TODO: version info was fine
+//
+// INIoutput.writeSection("global");
+// INIoutput.writeValue("pages", String.valueOf(aList.length));
+// INIoutput.writeValue("buildid", _sBuildID);
+// INIoutput.writeValue("refbuildid", _sRefBuildID);
+// INIoutput.writeValue("diffdiff", "no");
+// INIoutput.writeValue("basename", sBasename);
+//
+// boolean bResultIsOk = true; // result over all pages
+// for (int i=0;i<aList.length; i++)
+// {
+// INIoutput.writeSection("page" + String.valueOf(i + 1)); // list start at point 0, but this is page 1 and so on... current_page = (i + 1)
+// aList[i].printStatus();
+//
+// boolean bCurrentResult = true; // result over exact one page
+//
+// int nCurrentDiffStatus = aList[i].nDiffStatus;
+//
+// // check if the status is in a defined range
+// if (nCurrentDiffStatus == StatusHelper.DIFF_NO_DIFFERENCES)
+// {
+// // ok.
+// }
+// else if (nCurrentDiffStatus == StatusHelper.DIFF_DIFFERENCES_FOUND && aList[i].nPercent < 5)
+// {
+// // ok.
+// }
+// else if (nCurrentDiffStatus == StatusHelper.DIFF_AFTER_MOVE_DONE_NO_PROBLEMS)
+// {
+// // ok.
+// }
+// else if (nCurrentDiffStatus == StatusHelper.DIFF_AFTER_MOVE_DONE_DIFFERENCES_FOUND && aList[i].nPercent2 < 5)
+// {
+// // ok.
+// }
+// else
+// {
+// // failed.
+// bCurrentResult = false; // logic: nDiff==0 = true if there is no difference
+// }
+//
+// // Status
+//// HTMLoutput.checkLine(aList[i], bCurrentResult);
+// INIoutput.checkLine(aList[i], bCurrentResult);
+// bResultIsOk &= bCurrentResult;
+// }
+// // Status
+//// HTMLoutput.close();
+// INIoutput.close();
+// return bResultIsOk;
+// }
+ /**
+ * count how much pixel differ and between Old or New and the Difference graphics
+ *
+ * First, count the old graphics, then the new graphics due to the fact both should be equal
+ * it should be legal to take result from old or new. We take the graphics with less values.
+ *
+ * Second, count the difference graphics, now take the percent algorithm and
+ * build a percent value, which contain the number of different pixels as a percent value
+ *
+ * Interpretation:
+ * 0% there is no difference
+ *
+ * &lt;100% Take a look into the difference graphics, maybe the difference graphics shows
+ * text like outlined or the text is little bit move left, right up or down.
+ *
+ * &gt;>100% Yes it's possible that there is a difference more then 100%, maybe a font problem
+ * between old and new graphics. The font of the new graphics is little bit bigger,
+ * so the pixel count between old graphics and new graphics is twice the more.
+ *
+ * @param _sOldGfx path & name to the jpeg file (1)
+ * @param _sNewGfx path & name to the other jpeg file (2)
+ * @param _sDiffGfx path & name to the new difference file which shows the difference between (1) and (2)
+ * @return the count of different pixels
+ * @throws java.io.IOException if file access is not possible
+ */
+ public static int estimateGfx(String _sOldGfx, String _sNewGfx, String _sDiffGfx)
+ throws java.io.IOException
+ {
+ TimeHelper a = new TimeHelper();
+ a.start();
+ // Count Pixels
+ final int nNotWhiteCount_OldGraphic = PixelCounter.countNotWhitePixelsFromImage(_sOldGfx);
+ final int nNotWhiteCount_NewGraphic = PixelCounter.countNotWhitePixelsFromImage(_sNewGfx);
+ final int nNotBlackCount_DiffGraphic = PixelCounter.countNotBlackPixelsFromImage(_sDiffGfx);
+
+ // Count Pixels in different threads
+// CountNotWhitePixelsFromImage t1 = new CountNotWhitePixelsFromImage(_sOldGfx);
+// CountNotWhitePixelsFromImage t2 = new CountNotWhitePixelsFromImage(_sNewGfx);
+// CountNotBlackPixelsFromImage t3 = new CountNotBlackPixelsFromImage(_sDiffGfx);
+// t1.start();
+// t2.start();
+// t3.start();
+// try
+// {
+// t1.join();
+// }
+// catch (InterruptedException ex)
+// {
+// GlobalLogWriter.get().println("Thread 1 failed: " + ex.getMessage());
+// }
+// try
+// {
+// t2.join();
+// }
+// catch (InterruptedException ex)
+// {
+// GlobalLogWriter.get().println("Thread 2 failed: " + ex.getMessage());
+// }
+// try
+// {
+// t3.join();
+// }
+// catch (InterruptedException ex)
+// {
+// GlobalLogWriter.get().println("Thread 3 failed: " + ex.getMessage());
+// }
+// final int nNotWhiteCount_OldGraphic = t1.getValue();
+// final int nNotWhiteCount_NewGraphic = t2.getValue();
+// final int nNotBlackCount_DiffGraphic = t3.getValue();
+
+ a.stop();
+ GlobalLogWriter.println("Thread Time is: " + a.getTime());
+
+ int nMinNotWhiteCount = Math.min(nNotWhiteCount_NewGraphic, nNotWhiteCount_OldGraphic);
+
+ // check if not zero
+ if (nMinNotWhiteCount == 0)
+ {
+ nMinNotWhiteCount = Math.max(nNotWhiteCount_NewGraphic, nNotWhiteCount_OldGraphic);
+ if (nMinNotWhiteCount == 0)
+ {
+ nMinNotWhiteCount = 1;
+ }
+ }
+
+ int nPercent = Math.abs(nNotBlackCount_DiffGraphic * 100 / nMinNotWhiteCount);
+ GlobalLogWriter.println("Graphics check, pixel based:" + String.valueOf(nPercent) + "% pixel differ ");
+ return nPercent;
+ }
+
+ private static int compareJPEG(String _sOldGfx, String _sNewGfx, String _sDiffGfx)
+ {
+ String sComposite = "composite";
+ if (OSHelper.isWindows())
+ {
+ sComposite = "composite.exe";
+ String sIMPath = (String) param.get("imagemagick.path");
+ if (sIMPath != null)
+ {
+ sComposite = FileHelper.appendPath(sIMPath, sComposite);
+ }
+ }
+
+ // String sCommand = sComposite + " -compose difference " +
+ // StringHelper.doubleQuoteIfNeed(_sOldGfx) + " " +
+ // StringHelper.doubleQuoteIfNeed(_sNewGfx) + " " +
+ // StringHelper.doubleQuoteIfNeed(_sDiffGfx);
+
+ String[] sCommandArray =
+ {
+ sComposite,
+ "-compose",
+ "difference",
+ _sOldGfx,
+ _sNewGfx,
+ _sDiffGfx
+ };
+
+ ProcessHandler aHandler = new ProcessHandler(sCommandArray);
+ boolean bBackValue = aHandler.executeSynchronously();
+ int nExitCode = aHandler.getExitCode();
+ if (nExitCode != 0)
+ {
+ GlobalLogWriter.println("'" + sComposite + "' return with ");
+ String sBack = aHandler.getOutputText();
+ GlobalLogWriter.println("'" + sBack + "'");
+ }
+ else
+ {
+ // creates an extra smaller difference picture
+ File aDiffFile = new File(_sDiffGfx);
+ if (aDiffFile.exists())
+ {
+ JPEGCreator.convertToNearSameFileWithWidth340(_sDiffGfx);
+ }
+ }
+ return nExitCode;
+ }
+
+ /**
+ * wrapper for ImageMagick identify,
+ * function checks how many different colors a picture contains.
+ * if it's only one color (nResult==1), like background color, there is no difference.
+ */
+ int identify(String _sDiffGfx)
+ {
+ int nResult = 0;
+ // would like to know what the meaning of %k is for ImageMagick's 'identify'
+ String sIM_Format = "%k";
+ // if (OSHelper.isWindows())
+ // {
+ // sIM_Format = "%%k";
+ // }
+
+ String sIdentify = "identify";
+ if (OSHelper.isWindows())
+ {
+ sIdentify = "identify.exe";
+ String sIMPath = (String) param.get("imagemagick.path");
+ if (sIMPath != null)
+ {
+ sIdentify = FileHelper.appendPath(sIMPath, sIdentify);
+ }
+ }
+
+ // String sCommand = sIdentify + " " + sIM_Format + " " + StringHelper.doubleQuoteIfNeed(_sDiffGfx);
+
+ String[] sCommandArray =
+ {
+ sIdentify,
+ "-format",
+ sIM_Format,
+ _sDiffGfx
+ };
+ ProcessHandler aHandler = new ProcessHandler(sCommandArray);
+ boolean bBackValue = aHandler.executeSynchronously();
+ int nExitCode = aHandler.getExitCode();
+
+ String sBack = aHandler.getOutputText();
+ GlobalLogWriter.println("'" + sBack + "'");
+
+ // try to interpret the result, which we get as a String
+ try
+ {
+ int nIdx = sBack.indexOf("\n");
+ if (nIdx > 0)
+ {
+ sBack = sBack.substring(0, nIdx);
+ }
+
+ nResult = Integer.valueOf(sBack).intValue();
+ }
+ catch (java.lang.NumberFormatException e)
+ {
+ GlobalLogWriter.println("identify(): Number format exception");
+ nResult = 0;
+ }
+ return nResult;
+ }
+// public static void main(String [] _args)
+// {
+//// give an index.ini file, ok
+//// give a directory, where exist jpeg files ok
+//// inputpath (given file) doesn't exists
+//// give a jpeg file.
+//
+// String args[] = {
+// "-TimeOut", "3600000",
+// "-tb", "java_complex",
+// "-o", "graphical.JPEGComparator",
+// "-DOC_COMPARATOR_INPUT_PATH", "C:\\CWS\\temp\\output\\index.ini",
+// "-DOC_COMPARATOR_OUTPUT_PATH", "C:\\CWS\\temp\\output2",
+//// "-DOC_COMPARATOR_INPUT_PATH", "C:\\CWS\\temp\\output\\GroupReport.odt.pdf_180DPI_0001.jpg",
+//// "-DOC_COMPARATOR_OUTPUT_PATH", "C:\\CWS\\temp\\output2\\Report1.odt.pdf_180DPI_0001.jpg",
+// "-DOC_COMPARATOR_HTML_OUTPUT_PREFIX", "http://so-gfxcmp-lin.germany.sun.com/gfxcmp_ui/cw.php?inifile=",
+//// "-DOC_COMPARATOR_REFERENCE_CREATOR_TYPE", "PDF", /* default: "OOo" */
+//// "-DOC_COMPARATOR_REFERENCE_CREATOR_TYPE", "msoffice", /* default: "OOo" */
+//// "-OFFICE_VIEWABLE", "false",
+//// "-AppExecutionCommand", "\"C:/Programme/sun/staroffice 9/program/soffice.exe\" -norestore -nocrashreport -accept=pipe,name=ll93751;urp;",
+// "-NoOffice"
+// };
+//
+// org.openoffice.Runner.main(args);
+// }
+}
diff --git a/qadevOOo/runner/graphical/JPEGCreator.java b/qadevOOo/runner/graphical/JPEGCreator.java
new file mode 100644
index 000000000000..a4336229e448
--- /dev/null
+++ b/qadevOOo/runner/graphical/JPEGCreator.java
@@ -0,0 +1,475 @@
+/*
+ * ************************************************************************
+ *
+ * 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
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ * ***********************************************************************
+ */
+
+package graphical;
+
+import helper.OSHelper;
+import helper.ProcessHandler;
+import helper.StringHelper;
+import java.io.File;
+
+/**
+ *
+ * @author ll93751
+ */
+public class JPEGCreator extends EnhancedComplexTestCase
+{
+ // @Override
+ public String[] getTestMethodNames()
+ {
+ return new String[]{"PostscriptOrPDFToJPEG"};
+ }
+
+ /**
+ * test function.
+ */
+ public void PostscriptOrPDFToJPEG()
+ {
+ GlobalLogWriter.set(log);
+ ParameterHelper aParam = new ParameterHelper(param);
+
+ // run through all documents found in Inputpath
+ foreachPSorPDFinInputPath(aParam);
+ }
+
+
+ public void checkOneFile(String _sDocumentName, String _sResult, ParameterHelper _aParams) throws OfficeException
+ {
+ GlobalLogWriter.println("Document: " + _sDocumentName + " results: " + _sResult);
+// IOffice aOffice = new Office(_aParams, _sResult);
+// aOffice.start();
+// aOffice.load(_sDocumentName);
+// aOffice.storeAsPostscript();
+// aOffice.close();
+ String sJPEGNameSchema = createJPEG(_sDocumentName, "", _aParams);
+
+ // store information only if jpeg files exists
+ int nPages = countPages(sJPEGNameSchema);
+ if (nPages > 0)
+ {
+ createSmallPictures(sJPEGNameSchema);
+
+ // read out tolerance file
+ String sFileDir = FileHelper.getPath(_sDocumentName);
+ String sBasename = FileHelper.getBasename(_sDocumentName);
+ int nTolerance = 0;
+ String sToleranceFile = FileHelper.appendPath(sFileDir, "tolerance.ini");
+ File aToleranceFile = new File(sToleranceFile);
+ if (aToleranceFile.exists())
+ {
+ IniFile aIniFile = new IniFile(sToleranceFile);
+ nTolerance = aIniFile.getIntValue(sBasename, "accept", 0); // default for all pages
+ aIniFile.close();
+ }
+
+ String sIndexFile = FileHelper.appendPath(_sResult, "index.ini");
+ File aIndexFile = new File(sIndexFile);
+ if (aIndexFile.exists())
+ {
+ // store only if an index file exists
+ IniFile aIniFile = new IniFile(sIndexFile);
+ aIniFile.insertValue(sBasename, "jpegschema", sJPEGNameSchema);
+ aIniFile.insertValue(sBasename, "pages", nPages);
+ aIniFile.insertValue(sBasename, "tolerance", nTolerance);
+ aIniFile.close();
+ }
+ }
+ else
+ {
+ assure("There are no pages in document:'" + _sDocumentName + "', maybe document currupt?", false, true);
+ }
+ }
+
+/**
+ * Create a lot of smaller and nicer Pictures of the big fat pages.
+ * Looks better
+ * @param _sJPEGSchema
+ */
+ public void createSmallPictures(String _sJPEGSchema)
+ {
+ ParameterHelper aParam = new ParameterHelper(param);
+ if (! aParam.createSmallPictures())
+ {
+ return;
+ }
+
+ int nPages = 0;
+ if (_sJPEGSchema.length() > 0)
+ {
+ // TODO: if there doesn't exists a '%04d' in the schema we will return 9999 which is a little bit wrong here.
+ for (int i=1;i<10000;i++)
+ {
+ String sJPEGFilename = getFilenameForJPEGSchema(_sJPEGSchema, i);
+ if (FileHelper.exists(sJPEGFilename))
+ {
+ convertToNearSameFileWithWidth340(sJPEGFilename);
+ // m_aFileList.add(sNewJPEGFilename); // as long as the files exist, fill the array
+ nPages ++;
+ }
+ else
+ {
+ break; // stop file check
+ }
+ }
+ }
+ // return nPages;
+ }
+
+/**
+ * convert a picture to a new picture with 340 pixel width.
+ * @param _sJPEGFilename
+ */
+public static void convertToNearSameFileWithWidth340(String _sJPEGFilename)
+{
+ ParameterHelper aParam = new ParameterHelper(param);
+ if (! aParam.createSmallPictures())
+ {
+ return;
+ }
+ String sJPEGFilename = _sJPEGFilename.replaceAll("\\\\", "/");
+// if (OSHelper.isWindows())
+// {
+// sJPEGFilename = sJPEGFilename.replaceAll("/", "\\\\");
+// }
+ String sNewJPEGFilename;
+ sNewJPEGFilename = util.utils.replaceAll13(sJPEGFilename, ".jpg", "_w340.jpg");
+ convertToWidth340(sJPEGFilename, sNewJPEGFilename);
+}
+
+ /**
+ * convert chart2_Regression.ods.ps_180DPI_0001.jpg -filter Catrom -resize
+340x chart2_Regression.ods.ps_180DPI_0001_w340.jpg
+
+Point wie bisher
+Cubic schlecht, weil unscharf
+...
+Triangle ganz brauchbar (default?)
+Catrom am besten
+
+ * @param _sFrom
+ * @param _To
+ */
+private static void convertToWidth340(String _sFrom, String _To)
+{
+ // int nResult = 0;
+
+ String sConvertEXE = "convert";
+ if (OSHelper.isLinuxIntel())
+ {
+ sConvertEXE = "convert";
+ }
+ if (OSHelper.isWindows())
+ {
+ // TODO!
+ // HACK Hard coded!
+ // sConvertEXE = "C:\\Programme\\ImageMagick-6.0.3-q8\\convert.exe";
+ sConvertEXE = "convert.exe";
+ String sConvertPath = (String)param.get("imagemagick.path");
+ if (sConvertPath != null)
+ {
+ sConvertEXE = FileHelper.appendPath(sConvertPath, sConvertEXE);
+ }
+ }
+
+ String[] sCommandArray =
+ {
+ sConvertEXE,
+ _sFrom,
+ "-filter", "Catrom",
+ "-resize", "340x",
+ _To
+ };
+ ProcessHandler aHandler = new ProcessHandler(sCommandArray);
+ boolean bBackValue = aHandler.executeSynchronously();
+ int nExitCode = aHandler.getExitCode();
+
+ String sBack = aHandler.getOutputText();
+ if (sBack.length() > 0)
+ {
+ GlobalLogWriter.println("'" + sBack + "'");
+ }
+ // try to interpret the result, which we get as a String
+// try
+// {
+// int nIdx = sBack.indexOf("\n");
+// if (nIdx > 0)
+// {
+// sBack = sBack.substring(0, nIdx);
+// }
+//
+// nResult = Integer.valueOf(sBack).intValue();
+// }
+// catch(java.lang.NumberFormatException e)
+// {
+// GlobalLogWriter.get().println("Number format exception");
+// nResult = 0;
+// }
+ // return nResult;
+}
+
+/**
+ * create out of a given Postscript/PDF _sFile a list of JPEGs, one for every page
+ * @param _sFile
+ * @param _sAdditional
+ * @param _aParam
+ * @return the schema of the first jpeg name
+ */
+ String createJPEG(String _sFile, String _sAdditional, ParameterHelper _aParam)
+ {
+ if (_sFile.startsWith("file:///"))
+ {
+ _sFile = FileHelper.getSystemPathFromFileURL(_sFile);
+ }
+ File aFile = new File(_sFile);
+ if (aFile.exists())
+ {
+ String sAbsFile = aFile.getAbsolutePath();
+ if (!sAbsFile.equals(_sFile))
+ {
+ _sFile = sAbsFile;
+ }
+ }
+ else
+ {
+ GlobalLogWriter.println("File: '" + _sFile + "' doesn't exist.");
+ return "";
+ }
+ String sFileDir = FileHelper.getPath(_sFile);
+ String sBasename = FileHelper.getBasename(_sFile);
+// String sNameNoSuffix = FileHelper.getNameNoSuffix(sBasename);
+
+ String sTmpDir = util.utils.getUsersTempDir();
+ if (_aParam.getOutputPath() != null)
+ {
+ sTmpDir = _aParam.getOutputPath();
+ }
+
+ String sJPEGNameSchema = "";
+ if (_sFile.toLowerCase().endsWith("ps") ||
+ _sFile.toLowerCase().endsWith("prn") ||
+ _sFile.toLowerCase().endsWith("pdf"))
+ {
+ // seems to be a Postscript of PDF file
+
+ sJPEGNameSchema = createJPEGsFromPostscript(sTmpDir, sFileDir, sBasename, _aParam.getResolutionInDPI());
+ }
+ else if (_sFile.toLowerCase().endsWith("jpg") ||
+ _sFile.toLowerCase().endsWith("jpeg"))
+ {
+ // do nothing, it's already a picture.
+ return _sFile;
+ }
+ else
+ {
+ // we assume it's an office document.
+ // Office files will not handled here, we need a PS or PDF file
+ }
+ return sJPEGNameSchema;
+ }
+
+ private String getJPEGName(String _sOutputPath, String _sBasename, int _nResolutionInDPI, String _sGS_PageOutput)
+ {
+ // String fs = System.getProperty("file.separator");
+ String sName = _sBasename + "_" + String.valueOf(_nResolutionInDPI) + "DPI_" + _sGS_PageOutput + ".jpg";
+ String sJPEGName = FileHelper.appendPath(_sOutputPath, sName);
+ return sJPEGName;
+ }
+
+ /**
+ * Create via ghostscript (gs) from the reference file for every page a JPEG file
+ *
+ * MUST set:
+ * m_sOutputPath, m_sReferenceFile, m_sReferencePath
+ *
+ * return exit code from gs command
+ */
+
+ private static final String m_sGS_PageOutput = "%04d";
+
+ private String createJPEGsFromPostscript(String _sOutputPath, String _sSourcePath, String _sSourceFile, int _nResolutionInDPI)
+ {
+ FileHelper.makeDirectories("", _sOutputPath);
+
+ // create a jpeg from original prn
+ // String fs = System.getProperty("file.separator");
+
+ String sJPEGNameSchema = getJPEGName(_sOutputPath, _sSourceFile, _nResolutionInDPI, m_sGS_PageOutput);
+ String sPostscriptOrPDFFile = FileHelper.appendPath(_sSourcePath, _sSourceFile);
+ String sGhostscriptEXE = "gs";
+ if (OSHelper.isWindows())
+ {
+ sGhostscriptEXE = "gswin32c.exe";
+ String sGhostscriptEXE2 = (String)param.get("gs.exe");
+ if (sGhostscriptEXE2 != null)
+ {
+ sGhostscriptEXE = sGhostscriptEXE2;
+ }
+ String sGhostscriptPath = (String)param.get("gs.path");
+ if (sGhostscriptPath != null)
+ {
+ sGhostscriptEXE = FileHelper.appendPath(sGhostscriptPath, sGhostscriptEXE);
+ }
+ }
+
+// String sCommand = sGhostscriptEXE + " -dNOPROMPT -dBATCH -sDEVICE=jpeg -r" + String.valueOf(_nResolutionInDPI) + " -dNOPAUSE -sOutputFile=" + StringHelper.doubleQuoteIfNeed(sJPGFilename) + " " + StringHelper.doubleQuoteIfNeed(sOriginalFile);
+ String[] sCommandArray =
+ {
+ sGhostscriptEXE,
+ "-dNOPROMPT",
+ "-dBATCH",
+ "-sDEVICE=jpeg",
+ "-r" + String.valueOf(_nResolutionInDPI),
+ "-dNOPAUSE",
+ "-sOutputFile=" + sJPEGNameSchema,
+ sPostscriptOrPDFFile
+
+
+
+ };
+ // System.out.println("Start Command array");
+ // try
+ // {
+ // Runtime.getRuntime().exec(sCommandArray);
+ // } catch (Exception e) {
+ // System.out.println("FAILED");
+ // }
+ // System.out.println("done");
+
+// TODO: gives ghostscript an error we can handle?
+ ProcessHandler aHandler = new ProcessHandler(sCommandArray);
+ boolean bBackValue = aHandler.executeSynchronously();
+ assure("There seems to be a problem with ghostscript", bBackValue, true);
+ int nExitCode = aHandler.getExitCode();
+ // ArrayList m_aFileList = new ArrayList();
+
+ // String sJPEGNameSchema = "";
+ if (nExitCode == 0)
+ {
+ // TODO: return a real filename, due to the fact we don't know how much files are created, maybe better to return a list
+ int nPages = countPages(sJPEGNameSchema);
+ if (nPages == 0)
+ {
+ // return only a valid schema name if there at least one page.
+ sJPEGNameSchema = "";
+ assure("Document '" + sPostscriptOrPDFFile + "' doesn't create pages.", false, true);
+ }
+ }
+ else
+ {
+ assure("There seems to be a problem with ghostscript and '" + sPostscriptOrPDFFile + "' exit code: " + nExitCode, false, true);
+ GlobalLogWriter.println("Warning: There seems to be a problem with '" + sGhostscriptEXE + "'...");
+ }
+ // String[] aList = new String[m_aFileList.size()];
+ // aList = (String[])m_aFileList.toArray(aList);
+ return sJPEGNameSchema; // sNewJPEGFilename;
+ }
+
+ public static String getFilenameForJPEGSchema(String _sJPEGSchema, int _nPage)
+ {
+ if (_nPage < 1 || _nPage > 9999)
+ {
+ return "";
+ }
+ final String sFilename = util.utils.replaceAll13(_sJPEGSchema, m_sGS_PageOutput, StringHelper.createValueString(_nPage, 4));
+ return sFilename;
+ }
+
+ /**
+ * Return the number of really exists JPEG files
+ * Give a JPEG Schema which contains something like '%04d' which will be converted by a number between 0001 and 9999 always
+ * with leading '0' (zero)
+ * @param _sJPEGSchema
+ * @return number of really existing pages of a given JPEG schema
+ */
+ public int countPages(String _sJPEGSchema)
+ {
+ int nPages = 0;
+ if (_sJPEGSchema.length() > 0)
+ {
+ // TODO: if there doesn't exists a '%04d' in the schema we will return 9999 which is a little bit wrong here.
+ for (int i=1;i<10000;i++)
+ {
+ String sNewJPEGFilename = getFilenameForJPEGSchema(_sJPEGSchema, i);
+ if (FileHelper.exists(sNewJPEGFilename))
+ {
+ // m_aFileList.add(sNewJPEGFilename); // as long as the files exist, fill the array
+ nPages ++;
+ }
+ else
+ {
+ break; // stop file check
+ }
+ }
+ }
+ return nPages;
+ }
+
+// public static void main(String [] _args)
+// {
+//// DONE: give an index.ini file ok
+//// String args[] = {
+//// "-TimeOut", "3600000",
+//// "-tb", "java_complex",
+//// "-o", "graphical.JPEGCreator",
+//// "-DOC_COMPARATOR_INPUT_PATH", "C:\\CWS\\temp\\output\\index.ini",
+//// "-DOC_COMPARATOR_OUTPUT_PATH", "C:\\CWS\\temp\\output",
+//// "-DOC_COMPARATOR_PRINT_MAX_PAGE", "9999",
+//// "-DOC_COMPARATOR_GFX_OUTPUT_DPI_RESOLUTION", "180",
+//// "-DOC_COMPARATOR_HTML_OUTPUT_PREFIX", "http://so-gfxcmp-lin.germany.sun.com/gfxcmp_ui/cw.php?inifile=",
+////// "-DOC_COMPARATOR_REFERENCE_CREATOR_TYPE", "PDF", /* default: "OOo" */
+////// "-DOC_COMPARATOR_REFERENCE_CREATOR_TYPE", "msoffice", /* default: "OOo" */
+////// "-OFFICE_VIEWABLE", "false",
+//// "-AppExecutionCommand", "\"C:/Programme/sun/staroffice 9/program/soffice.exe\" -norestore -nocrashreport -accept=pipe,name=ll93751;urp;",
+//// "-NoOffice"
+//// };
+//
+//// Done: give a directory, where exist pdf/ps files ok.
+//// Done: inputpath (given file) doesn't exists, ok.
+//// Done: give a ps/pdf file. ok.
+//
+// String args[] = {
+// "-TimeOut", "3600000",
+// "-tb", "java_complex",
+// "-o", "graphical.JPEGCreator",
+// "-DOC_COMPARATOR_INPUT_PATH", "C:\\CWS\\temp\\output\\Names7.odt.pdf",
+// "-DOC_COMPARATOR_OUTPUT_PATH", "C:\\CWS\\temp\\output",
+// "-DOC_COMPARATOR_PRINT_MAX_PAGE", "9999",
+// "-DOC_COMPARATOR_GFX_OUTPUT_DPI_RESOLUTION", "180",
+// "-DOC_COMPARATOR_HTML_OUTPUT_PREFIX", "http://so-gfxcmp-lin.germany.sun.com/gfxcmp_ui/cw.php?inifile=",
+//// "-DOC_COMPARATOR_REFERENCE_CREATOR_TYPE", "PDF", /* default: "OOo" */
+//// "-DOC_COMPARATOR_REFERENCE_CREATOR_TYPE", "msoffice", /* default: "OOo" */
+//// "-OFFICE_VIEWABLE", "false",
+// "-AppExecutionCommand", "\"C:/Programme/sun/staroffice 9/program/soffice.exe\" -norestore -nocrashreport -accept=pipe,name=ll93751;urp;",
+// "-NoOffice"
+// };
+//
+// org.openoffice.Runner.main(args);
+// }
+
+}
diff --git a/qadevOOo/runner/graphical/JPEGEvaluator.java b/qadevOOo/runner/graphical/JPEGEvaluator.java
new file mode 100644
index 000000000000..07b265b62355
--- /dev/null
+++ b/qadevOOo/runner/graphical/JPEGEvaluator.java
@@ -0,0 +1,163 @@
+/*
+ * ************************************************************************
+ *
+ * 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
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ * ***********************************************************************
+ */
+
+package graphical;
+
+// import java.io.File;
+
+/**
+ *
+ * @author ll93751
+ */
+public class JPEGEvaluator extends EnhancedComplexTestCase
+{
+ // @Override
+ public String[] getTestMethodNames()
+ {
+ return new String[]{"EvaluateResult"};
+ }
+
+ /**
+ * test function.
+ */
+ public void EvaluateResult()
+ {
+ GlobalLogWriter.set(log);
+ ParameterHelper aParam = new ParameterHelper(param);
+
+ // run through all documents found in Inputpath
+ foreachResultCreateHTML(aParam);
+ }
+
+ public void checkOneFile(String _sDocument, String _sResult, ParameterHelper _aParams) throws OfficeException
+ {
+ // throw new UnsupportedOperationException("Not supported yet.");
+ // int dummy = 0;
+
+ String sBasename = FileHelper.getBasename(_sDocument);
+ String sResultIniFile = _sDocument + ".ini";
+// File aFile = new File(sResultIniFile);
+// assure("Result file doesn't exists " + sResultIniFile, aFile.exists());
+//
+// int good = 0;
+// int bad = 0;
+// int ugly = 0;
+//
+// IniFile aResultIniFile = new IniFile(sResultIniFile);
+// int nPages = aResultIniFile.getIntValue("global", "pages", 0);
+// for (int i=0;i<nPages;i++)
+// {
+// String sCurrentPage = "page" + String.valueOf(i + 1);
+// int nPercent = aResultIniFile.getIntValue(sCurrentPage, "percent", -1);
+// if (nPercent == 0)
+// {
+// good++;
+// }
+// else if (nPercent <= 5)
+// {
+// bad ++;
+// }
+// else
+// {
+// ugly ++;
+// }
+// }
+//
+// assure("Error: document doesn't contains pages", nPages > 0);
+
+ HTMLResult aOutputter = new HTMLResult(_sResult, sBasename + ".html" );
+ aOutputter.header(_sResult);
+ aOutputter.indexSection(sBasename);
+
+ IniFile aResultIniFile = new IniFile(sResultIniFile);
+ String sStatusRunThrough = aResultIniFile.getValue("global", "state");
+ String sStatusMessage = aResultIniFile.getValue("global", "info");
+
+// // TODO: this information has to come out of the ini files
+// String sStatusRunThrough = "PASSED, ";
+// String sPassed = "OK";
+//
+// String sStatusMessage = "From " + nPages + " page(s) are: ";
+// String sGood = "";
+// String sBad = "";
+// String sUgly = "";
+//
+// if (good > 0)
+// {
+// sGood = " good:=" + good;
+// sStatusMessage += sGood;
+// }
+// if (bad > 0)
+// {
+// sBad = " bad:=" + bad;
+// sStatusMessage += sBad;
+// }
+// if (ugly > 0)
+// {
+// sUgly = " ugly:=" + ugly;
+// sStatusMessage += sUgly;
+// }
+//
+// // Failure matrix
+// // 0 1
+// // ugly OK FAILED
+// // bad OK
+// // good OK
+//
+// if (ugly > 0)
+// {
+// sPassed = "FAILED";
+// }
+// else
+// {
+// if (bad > 0)
+// {
+// sPassed = "NEED A LOOK";
+// }
+// else
+// {
+// sPassed = "OK";
+// }
+// }
+// sStatusRunThrough += sPassed;
+// aResultIniFile.insertValue("global", "state", sStatusRunThrough);
+// aResultIniFile.insertValue("global", "info", sStatusMessage);
+// aResultIniFile.close();
+
+ String sHTMLFile = _aParams.getHTMLPrefix(); // "http://so-gfxcmp-lin/gfxcmp_ui/cw.php?inifile=";
+ sHTMLFile += _sDocument + ".ini";
+ aOutputter.indexLine(sHTMLFile, sBasename, sStatusRunThrough, sStatusMessage);
+ aOutputter.close();
+ // IniFile aIniFile = new IniFile(_sDocument);
+ // aIniFile.
+
+ }
+
+
+}
diff --git a/qadevOOo/runner/graphical/MSOfficePostscriptCreator.java b/qadevOOo/runner/graphical/MSOfficePostscriptCreator.java
new file mode 100644
index 000000000000..86eb28143ed2
--- /dev/null
+++ b/qadevOOo/runner/graphical/MSOfficePostscriptCreator.java
@@ -0,0 +1,1004 @@
+/*************************************************************************
+ *
+ * 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
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package graphical;
+
+import java.io.File;
+import java.io.FileWriter;
+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.
+ * It also offers functions to check what type of document it is.
+ * It handles *.doc as word documents and use word to print
+ * *.xls as excel
+ * *.ppt as powerpoint
+ */
+
+//class ProcessHelper
+//{
+// ArrayList m_aArray;
+//}
+
+public class MSOfficePostscriptCreator implements IOffice
+{
+ private String m_sPrinterName; // within Windows the tools need a printer name;
+
+ public void setPrinterName(String _s)
+ {
+ m_sPrinterName = _s;
+ }
+
+ private ParameterHelper m_aParameterHelper;
+ private String m_sDocumentName;
+ private String m_sResult;
+
+ // CTor
+ public MSOfficePostscriptCreator(ParameterHelper _aParam, String _sResult)
+ {
+ m_aParameterHelper = _aParam;
+ m_sResult = _sResult;
+// String sKillCommand = (String)_aParam.getTestParameters().get(util.PropertyName.APP_KILL_COMMAND);
+// if (sKillCommand == null)
+// {
+// sKillCommand = "";
+// }
+// if (sKillCommand.length() > 0)
+// {
+// sKillCommand += ";";
+// }
+ String sKillCommand = "C:/bin/kill.exe -9 winword;C:/bin/kill.exe -9 excel";
+ _aParam.getTestParameters().put(util.PropertyName.APP_KILL_COMMAND, sKillCommand);
+ }
+
+ public void load(String _sDocumentName) throws OfficeException
+ {
+ m_sDocumentName = _sDocumentName;
+
+ if (! isMSOfficeDocumentFormat(m_sDocumentName))
+ {
+ GlobalLogWriter.println("This document type is not recognized as MSOffice format, as default fallback StarOffice/OpenOffice.org instead is used.");
+ throw new OfficeException("This document type is not recognized as MSOffice format, as default fallback StarOffice/OpenOffice.org instead is used.");
+ }
+ }
+
+ public void storeAsPostscript() throws OfficeException
+ {
+ GlobalLogWriter.println("USE MSOFFICE AS EXPORT FORMAT.");
+ try
+ {
+ String sDocumentName = m_sDocumentName + ".ps";
+ printToFileWithMSOffice(m_aParameterHelper,
+ m_sDocumentName,
+ m_sResult);
+ File aFile = new File(sDocumentName);
+ if (aFile.exists())
+ {
+ String sBasename = FileHelper.getBasename(sDocumentName);
+ FileHelper.addBasenameToIndex(m_sResult, sBasename, "msoffice", "postscript", m_sDocumentName);
+ }
+ }
+ catch(OfficeException e)
+ {
+ e.printStackTrace();
+ GlobalLogWriter.println(e.getMessage());
+ throw new OfficeException("Exception caught. Problem with MSOffice printer methods.");
+ }
+ catch(java.io.IOException e)
+ {
+ GlobalLogWriter.println(e.getMessage());
+ throw new OfficeException("IOException caught. Problem with MSOffice printer methods.");
+ }
+ }
+
+ public void start() throws OfficeException
+ {
+ // we don't have an office to start
+ }
+
+ public void close() throws OfficeException
+ {
+ // we don't have an office to stop
+ }
+
+ // -----------------------------------------------------------------------------
+ private boolean isWordDocument(String _sSuffix)
+ {
+ if (_sSuffix.toLowerCase().endsWith(".doc") ||
+ _sSuffix.toLowerCase().endsWith(".rtf") ||
+ _sSuffix.toLowerCase().endsWith(".dot"))
+ {
+ return true;
+ }
+ return false;
+ }
+
+ private boolean isExcelDocument(String _sSuffix)
+ {
+ // xlt templates
+ // xlw
+ // xla addin
+ if (_sSuffix.toLowerCase().endsWith(".xls"))
+ {
+ return true;
+ }
+ /* temporal insertion by SUS
+ if (_sSuffix.endsWith(".xml"))
+ {
+ return true;
+ }*/
+ return false;
+ }
+
+ private boolean isPowerPointDocument(String _sSuffix)
+ {
+ if (_sSuffix.toLowerCase().endsWith(".pps") ||
+ _sSuffix.toLowerCase().endsWith(".ppt"))
+ {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * returns true, if the given filename has a MS Office suffix.
+ */
+ private boolean isMSOfficeDocumentFormat(String _sFile)
+ {
+ String sDocumentSuffix = FileHelper.getSuffix(_sFile);
+ if (isWordDocument(sDocumentSuffix)) {return true;}
+ if (isExcelDocument(sDocumentSuffix)) {return true;}
+ if (isPowerPointDocument(sDocumentSuffix)) {return true;}
+ // if suffix is xml, return also true, but we can't decide if word or excel
+ if (sDocumentSuffix.toLowerCase().endsWith(".xml")) {return true;}
+ return false;
+ }
+
+ public void storeToFileWithMSOffice( ParameterHelper _aGTA,
+ String _sInputFile,
+ String _sOutputFile) throws OfficeException, java.io.IOException
+ {
+ String sDocumentSuffix = FileHelper.getSuffix(_sInputFile);
+ String sFilterName = _aGTA.getExportFilterName();
+ ArrayList<String> aStartCommand = new ArrayList<String>();
+ if (isWordDocument(sDocumentSuffix))
+ {
+ aStartCommand = createWordStoreHelper();
+ }
+ else if (isExcelDocument(sDocumentSuffix))
+ {
+ aStartCommand = createExcelStoreHelper();
+ }
+ else if (isPowerPointDocument(sDocumentSuffix))
+ {
+ }
+ else if (sDocumentSuffix.toLowerCase().equals(".xml"))
+ {
+ // special case, if xml we prefer word, but with DEFAULT_XML_FORMAT_APP=excel it's changeable.
+ String sDocFormat = getXMLDocumentFormat(_sInputFile);
+ // if (_aGTA.getDefaultXMLFormatApp().toLowerCase().equals("excel"))
+ if (sDocFormat.equals("excel"))
+ {
+ aStartCommand = createExcelStoreHelper();
+ }
+ else
+ {
+ aStartCommand = createWordStoreHelper();
+ }
+ // else
+ // {
+ // }
+ }
+ else
+ {
+ GlobalLogWriter.println("No Microsoft Office document format found.");
+
+ throw new WrongSuffixException("No MS office document format found.");
+ }
+ if (aStartCommand != null)
+ {
+ if (sFilterName == null)
+ {
+// TODO: hardcoded FilterName in perl script
+ sFilterName = ""; // xlXMLSpreadsheet";
+ }
+
+ // String sCommand = sStartCommand + " " +
+ // _sInputFile + " " +
+ // StringHelper.doubleQuote(sFilterName) + " " +
+ // _sOutputFile;
+
+ aStartCommand.add(_sInputFile);
+ aStartCommand.add(sFilterName);
+ aStartCommand.add(_sOutputFile);
+ realStartCommand(aStartCommand);
+ }
+ }
+
+ // -----------------------------------------------------------------------------
+ /**
+ * print the given file (_sInputFile) to the file name (_sPrintFile)
+ * @param _aGTA
+ * @param _sInputFile
+ * @param _sPrintFilename
+ * @throws OfficeException
+ * @throws java.io.IOException
+ */
+ public void printToFileWithMSOffice( ParameterHelper _aGTA,
+ String _sInputFile,
+ String _sPrintFilename) throws OfficeException, java.io.IOException
+ {
+ String sDocumentSuffix = FileHelper.getSuffix(_sInputFile);
+
+ setPrinterName(_aGTA.getPrinterName());
+
+ ArrayList<String> aStartCommand = new ArrayList<String>();
+ if (isWordDocument(sDocumentSuffix))
+ {
+ aStartCommand = createWordPrintHelper();
+ }
+ else if (isExcelDocument(sDocumentSuffix))
+ {
+ aStartCommand = createExcelPrintHelper();
+ }
+ else if (isPowerPointDocument(sDocumentSuffix))
+ {
+ aStartCommand = createPowerPointPrintHelper();
+ }
+ else if (sDocumentSuffix.toLowerCase().equals(".xml"))
+ {
+// TODO: Open XML File and check if we need excel or word
+ String sOfficeType = getOfficeType(_sInputFile);
+
+ // special case, if xml we prefer word, but with DEFAULT_XML_FORMAT_APP=excel it's changeable.
+ // if (_aGTA.getDefaultXMLFormatApp().toLowerCase().equals("excel"))
+ if (sOfficeType.equals("excel"))
+ {
+ aStartCommand = createExcelPrintHelper();
+ }
+ else if (sOfficeType.equals("word"))
+ {
+ aStartCommand = createWordPrintHelper();
+ }
+ else
+ {
+ return;
+ }
+ }
+ else
+ {
+ GlobalLogWriter.println("No Microsoft Office document format found.");
+// TODO: use a better Exception!!!
+ throw new WrongSuffixException("No Mircosoft Office document format found.");
+ }
+
+ if (aStartCommand.isEmpty() == false)
+ {
+ String sPrinterName = m_sPrinterName;
+ if (sPrinterName == null)
+ {
+ sPrinterName = "";
+ }
+
+ // String sCommand = sStartCommand + " " +
+ // _sInputFile + " " +
+ // StringHelper.doubleQuote(m_sPrinterName) + " " +
+ // _sPrintFilename;
+ aStartCommand.add(_sInputFile);
+ aStartCommand.add(m_sPrinterName);
+ aStartCommand.add(_sPrintFilename);
+
+ realStartCommand(aStartCommand);
+ }
+ String sUserDir = System.getProperty("user.home");
+ _aGTA.getPerformance().readWordValuesFromFile(FileHelper.appendPath(sUserDir, "msofficeloadtimes.txt"));
+ FileHelper.createInfoFile(_sPrintFilename, _aGTA, "msoffice");
+ TimeHelper.waitInSeconds(2, "Give Microsoft Office some time to print.");
+ }
+
+ public void realStartCommand(ArrayList _aStartCommand) throws OfficeException
+ {
+ if (_aStartCommand.isEmpty())
+ {
+ throw new OfficeException/*WrongEnvironmentException*/("Given list is empty.");
+ }
+
+ try
+ {
+ // Convert the StartCommand ArrayList to a String List
+ int nValues = _aStartCommand.size();
+ String[] aList = new String[nValues];
+ for (int i=0;i<nValues;i++)
+ {
+ String aStr = (String) _aStartCommand.get(i);
+ if (aStr == null)
+ {
+ aStr = "";
+ }
+ if (aStr.length() == 0)
+ {
+ aStr = "\"\"";
+ }
+ aList[i] = new String(aStr);
+ }
+
+ // This is really the latest point where we can check if we are running within windows environment
+ if (! OSHelper.isWindows())
+ {
+ // TODO: use a better Exception!!!
+ throw new WrongEnvironmentException("We doesn't work within windows environment.");
+ }
+
+
+ ProcessHandler aHandler = new ProcessHandler(aList);
+ boolean bBackValue = aHandler.executeSynchronously();
+ }
+ catch (IndexOutOfBoundsException e)
+ {
+ throw new WrongEnvironmentException("Given list is too short.");
+ }
+
+ // return aHandler.getExitCode();
+ }
+
+
+ private String getPerlExe()
+ {
+ final String sPerlExe = System.getProperty("perl.exe", "perl");
+ return sPerlExe;
+ }
+
+ ArrayList<String> createWordPrintHelper() throws java.io.IOException
+ {
+ // create a program in tmp file
+ String sTmpPath = util.utils.getUsersTempDir();
+ String ls = System.getProperty("line.separator");
+
+ String sPrintViaWord = "printViaWord.pl";
+
+ ArrayList<String> aList = searchLocalFile(sPrintViaWord);
+ if (aList.isEmpty() == false)
+ {
+ return aList;
+ }
+
+ String sFileName = FileHelper.appendPath(sTmpPath, sPrintViaWord);
+ File aFile = new File(sFileName);
+ 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( "use Time::HiRes; " + 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: word_print.pl <Word file> <name of printer> <output file> .\\n " + ls );
+ out.write( " Please use the same string for the name of the printer as you can find \\n " + ls );
+ out.write( " under Start-Control Panel-Printer and Faxes \\n " + ls );
+ out.write( " The name could look like the the following line: \\n " + ls );
+ out.write( " Apple LaserWriter II NT v47.0 \\n " + ls );
+ out.write( " Sample command line: \\n " + ls );
+ out.write( " execl_print.pl c:\\book1.doc Apple LaserWriter II NT v47.0 c:\\output\\book1.ps \\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( "my $startWordTime = Time::HiRes::time(); " + ls );
+ out.write( "my $Word = Win32::OLE->new('Word.Application'); " + ls );
+ out.write( "my $stopWordTime = Time::HiRes::time() - $startWordTime; " + ls );
+ out.write( "# $Word->{'Visible'} = 1; # if you want to see what's going on " + ls );
+ out.write( "# , ReadOnly => 1})" + ls );
+ out.write(ls);
+ out.write( "my $startLoadWordTime = Time::HiRes::time(); " + ls );
+ out.write( "$Word->Documents->Open({Filename => $ARGV[0]}) " + ls );
+ out.write( " || die('Unable to open document ', Win32::OLE->LastError()); " + ls );
+ out.write( "my $stopLoadWordTime = Time::HiRes::time() - $startLoadWordTime; " + ls );
+ out.write(ls);
+ out.write( "my $startPrintWordTime = Time::HiRes::time(); " + 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( "my $stopPrintWordTime = Time::HiRes::time() - $startPrintWordTime;" + ls);
+
+ out.write( "# ActiveDocument.Close(SaveChanges:=WdSaveOptions.wdDoNotSaveChanges)" + ls );
+ out.write( "my $sVersion = $Word->Application->Version();"+ls);
+ out.write( "$Word->ActiveDocument->Close({SaveChanges => 0}); " + ls );
+ out.write( "$Word->Quit(); " + ls );
+
+ out.write( "local *FILE;" + ls);
+ out.write( "if (open(FILE, \">$ENV{HOME}/msofficeloadtimes.txt\"))" + ls);
+ out.write( "{" + ls);
+ out.write( " print FILE \"name=$ARGV[0]\\n\";" + ls);
+ out.write( " print FILE \"WordVersion=$sVersion\\n\";" + ls);
+ out.write( " print FILE \"WordStartTime=$stopWordTime\\n\";" + ls);
+ out.write( " print FILE \"WordLoadTime=$stopLoadWordTime\\n\";" + ls);
+ out.write( " print FILE \"WordPrintTime=$stopPrintWordTime\\n\";" + ls);
+ out.write( " close(FILE);" + ls);
+ out.write( "}" + ls);
+ out.close();
+
+ aList.add(getPerlExe());
+ aList.add(sFileName);
+ return aList;
+ }
+
+ // TODO: Maybe give a possibility to say where search the script from outside
+
+ ArrayList<String> searchLocalFile(String _sScriptName)
+ {
+ String userdir = System.getProperty("user.dir");
+
+ ArrayList<String> aList = new ArrayList<String>();
+ String sFileName = FileHelper.appendPath(userdir, _sScriptName);
+ File aPerlScript = new File(sFileName);
+ if (FileHelper.isDebugEnabled())
+ {
+ GlobalLogWriter.println("Search for local existance of " + aPerlScript.getAbsolutePath());
+ }
+
+ if (aPerlScript.exists())
+ {
+ if (FileHelper.isDebugEnabled())
+ {
+ GlobalLogWriter.println("OK, found it, use this instead the internal one.");
+ }
+
+ String sName = aPerlScript.getAbsolutePath();
+ // String sCommand = "perl " + sName;
+ // System.out.println(sCommand);
+ aList.add("perl");
+ aList.add(sName);
+ return aList;
+ }
+ return aList;
+ }
+
+ ArrayList<String> createWordStoreHelper() throws java.io.IOException
+ {
+ // create a program in tmp file
+ String sTmpPath = util.utils.getUsersTempDir();
+ String ls = System.getProperty("line.separator");
+
+ // ArrayList aList = new ArrayList();
+ 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;
+ }
+
+
+ ArrayList<String> createExcelPrintHelper() throws java.io.IOException
+ {
+ // create a program in tmp file
+ String sTmpPath = util.utils.getUsersTempDir();
+ String ls = System.getProperty("line.separator");
+
+ String sPrintViaExcel = "printViaExcel.pl";
+
+ ArrayList<String> aList = searchLocalFile(sPrintViaExcel);
+ if (aList.isEmpty() == false)
+ {
+ return aList;
+ }
+ String sName = FileHelper.appendPath(sTmpPath, sPrintViaExcel);
+ 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("#BEGIN" + ls);
+ out.write("#{" + ls);
+ out.write("#" + ls);
+ out.write("# # insert HACK" + ls);
+ out.write("# unshift(@INC, '');" + ls);
+ out.write("#}" + 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( " " + 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: printViaExcel.pl <Excel file> <name of printer> <output file> .\\n " + ls );
+ out.write( " Please use the same string for the name of the printer as you can find \\n " + ls );
+ out.write( " under Start-Control Panel-Printer and Faxes \\n " + ls );
+ out.write( " The name could look like the the following line: \\n " + ls );
+ out.write( " Apple LaserWriter II NT v47.0 \\n " + ls );
+ out.write( " Sample command line: \\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 STDERR \"Too less arguments.\\n\"; " + ls );
+ out.write( " print STDERR \"ARGV[0] $ARGV[0]\\n\"; " + ls );
+ out.write( " print STDERR \"ARGV[1] $ARGV[1]\\n\"; " + ls );
+ out.write( " print STDERR \"ARGV[2] $ARGV[2]\\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( " " + ls );
+ out.write( " " + ls );
+ out.write( " " + ls );
+ out.write( "my $Book = $Excel->Workbooks->Open( $ARGV[0] ); " + ls );
+ out.write( " $Book->PrintOut({Copies => 1, " + ls );
+ out.write( " ActivePrinter => $ARGV[1], " + ls );
+ out.write( " PrToFileName => $ARGV[2], " + ls );
+ out.write( " Collate => 1 " + ls );
+ out.write( " }); " + ls );
+ out.write( "# Close worksheets without store changes" + ls );
+ out.write( "# $Book->Close({SaveChanges => 0}); " + ls );
+ out.write( "my $sVersion = $Excel->Application->Version();"+ls);
+ out.write( "$Excel->Quit(); " + ls );
+ out.write( "local *FILE;" + ls);
+ out.write( "if (open(FILE, \">$ENV{HOME}/msofficeloadtimes.txt\"))" + ls);
+ out.write( "{" + ls);
+ out.write( " print FILE \"name=$ARGV[0]\\n\";" + ls);
+ out.write( " print FILE \"ExcelVersion=$sVersion\\n\";" + ls);
+// out.write( " print FILE \"WordStartTime=$stopWordTime\\n\";" + ls);
+// out.write( " print FILE \"WordLoadTime=$stopLoadWordTime\\n\";" + ls);
+// out.write( " print FILE \"WordPrintTime=$stopPrintWordTime\\n\";" + ls);
+ out.write( " close(FILE);" + ls);
+ out.write( "}" + ls);
+ out.close();
+
+ aList.add(getPerlExe());
+ aList.add(sName);
+ return aList;
+ }
+
+ 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;
+ }
+
+ ArrayList<String> createPowerPointPrintHelper() throws java.io.IOException
+ {
+ // create a program in tmp file
+ String sTmpPath = util.utils.getUsersTempDir();
+ String ls = System.getProperty("line.separator");
+
+ String sPrintViaPowerPoint = "printViaPowerPoint.pl";
+
+ ArrayList<String> aList = searchLocalFile(sPrintViaPowerPoint);
+ if (aList.isEmpty() == false)
+ {
+ return aList;
+ }
+ String sName = FileHelper.appendPath(sTmpPath, sPrintViaPowerPoint);
+ 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 $2 ' " + 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( " " + ls );
+ out.write( "use Win32::OLE qw(in with); " + ls );
+ out.write( "use Win32::OLE::Const 'Microsoft PowerPoint'; " + ls );
+ out.write( " " + ls );
+ out.write( "# ------ usage ------ " + ls );
+ out.write( "sub print_usage() " + ls );
+ out.write( "{ " + ls );
+ out.write( " print STDERR \"Usage: powerpoint_print.pl <PowerPoint file> <name of printer> <output file> .\\n " + ls );
+ out.write( " Please use the same string for the name of the printer as you can find \\n " + ls );
+ out.write( " under Start-Control Panel-Printer and Faxes \\n " + ls );
+ out.write( " The name could look like the the following line: \\n " + ls );
+ out.write( " Apple LaserWriter II NT v47.0 \\n " + ls );
+ out.write( " Sample command line: \\n " + ls );
+ out.write( " powerpoint_print.pl c:\\book.ppt Apple LaserWriter II NT v47.0 c:\\output\\book.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 $PowerPoint = Win32::OLE->GetActiveObject('PowerPoint.Application') " + ls );
+ out.write( " || Win32::OLE->new('PowerPoint.Application', 'Quit'); # get already active Excel " + ls );
+ out.write( " # application or open new " + ls );
+ out.write( " " + ls );
+ out.write( " " + ls );
+ out.write( " " + ls );
+ out.write( " $PowerPoint->{'Visible'} = 1; " + ls );
+ out.write( " my $Presentation = $PowerPoint->Presentations->Add; " + ls );
+ out.write( " my $Presentation = $PowerPoint->Presentations->Open( $ARGV[0] ); " + ls );
+ out.write( "# we can't change active printer in powerpoint " + ls );
+ out.write( "# $Presentation->PrintOptions->{ActivePrinter} = $ARGV[1]; " + ls );
+ out.write( " print \"Active printer is: \" . $Presentation->PrintOptions->{ActivePrinter} . \"\\n\"; " + ls );
+ out.write( " $Presentation->PrintOptions->{PrintInBackground} = 0; " + ls );
+ out.write( " # PrintColorType = 1 means print in color and PrintColorType = 2 means print in gray " + ls );
+ out.write( " $Presentation->PrintOptions->{PrintColorType} = 1; " + ls );
+ out.write( " " + ls );
+ out.write( " $Presentation->PrintOut({PrintToFile => $ARGV[2]}); " + ls );
+ out.write( " sleep 5; " + ls );
+ out.write( " print \"Presentation has been printed\\n\"; " + ls );
+ out.write( "my $sVersion = $Presentation->Application->Version();"+ls);
+ out.write( " $PowerPoint->Quit(); " + ls );
+
+ out.write( "local *FILE;" + ls);
+ out.write( "if (open(FILE, \">$ENV{HOME}/msofficeloadtimes.txt\"))" + ls);
+ out.write( "{" + ls);
+ out.write( " print FILE \"name=$ARGV[0]\\n\";" + ls);
+ out.write( " print FILE \"PowerPointVersion=$sVersion\\n\";" + ls);
+// out.write( " print FILE \"WordStartTime=$stopWordTime\\n\";" + ls);
+// out.write( " print FILE \"WordLoadTime=$stopLoadWordTime\\n\";" + ls);
+// out.write( " print FILE \"WordPrintTime=$stopPrintWordTime\\n\";" + ls);
+ out.write( " close(FILE);" + ls);
+ out.write( "}" + ls);
+ out.close();
+
+ aList.add(getPerlExe());
+ aList.add(sName);
+ return aList;
+ }
+
+ /**
+ @param _sFilename a name to a ms office xml file
+ @return 'word' or 'excel' or '' if type not known
+ */
+ public String getOfficeType(String _sFilename)
+ {
+ File aFile = new File(_sFilename);
+ if (! aFile.exists())
+ {
+ GlobalLogWriter.println("couldn't find file " + _sFilename);
+ return "";
+ }
+ RandomAccessFile aReader = null;
+ String sOfficeType = "";
+ try
+ {
+ aReader = new RandomAccessFile(aFile,"r");
+ String aLine = "";
+ while (aLine != null)
+ {
+ aLine = aReader.readLine();
+ if (aLine != null)
+ {
+ aLine = aLine.trim();
+ if ( (! (aLine.length() < 2) ) &&
+ (! aLine.startsWith("#")) &&
+ (! aLine.startsWith(";")) )
+ {
+ int nIdx = aLine.indexOf("mso-application");
+ if (nIdx > 0)
+ {
+ if (aLine.indexOf("Word.Document") > 0)
+ {
+ sOfficeType = "word";
+ }
+ else if (aLine.indexOf("Excel") > 0)
+ {
+ sOfficeType = "excel";
+ }
+ else
+ {
+ GlobalLogWriter.println("Unknown/unsupported data file: " + aLine);
+ }
+ }
+ }
+ }
+ }
+ }
+ catch (java.io.FileNotFoundException fne)
+ {
+ System.out.println("couldn't open file " + _sFilename);
+ System.out.println("Message: " + fne.getMessage());
+ }
+ catch (java.io.IOException ie)
+ {
+ System.out.println("Exception while reading file " + _sFilename);
+ System.out.println("Message: " + ie.getMessage());
+ }
+ try
+ {
+ aReader.close();
+ }
+ catch (java.io.IOException ie)
+ {
+ System.out.println("Couldn't close file " + _sFilename);
+ System.out.println("Message: " + ie.getMessage());
+ }
+ return sOfficeType;
+ }
+
+ private static String getXMLDocumentFormat(String _sInputFile)
+ {
+ String sType = "word"; // default
+ try
+ {
+ // ---- Parse XML file ----
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ // factory.setNamespaceAware( true );
+ // factory.setValidating( true );
+ DocumentBuilder builder = factory.newDocumentBuilder();
+ Document document = builder.parse( new File (_sInputFile) );
+ Node rootNode = document.getDocumentElement();
+
+ // ---- Get list of nodes to given tag ----
+ // document.
+ // NodeList ndList = document.getElementsByTagName( sToSearch /* argv[2] */ );
+ // System.out.println( "\nNode list at the beginning:" );
+ 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
+ }
+ // printNodesFromList( ndList );
+ }
+ catch (java.lang.Exception e)
+ {
+ }
+ return sType;
+ }
+
+// public static void main(String [] _args)
+// {
+// String sTest = getXMLDocumentFormat("c:/cws/temp/input/Blah Fasel.xml");
+// }
+}
diff --git a/qadevOOo/runner/graphical/Office.java b/qadevOOo/runner/graphical/Office.java
new file mode 100644
index 000000000000..8ecee36cc742
--- /dev/null
+++ b/qadevOOo/runner/graphical/Office.java
@@ -0,0 +1,170 @@
+/*
+ * ************************************************************************
+ *
+ * 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
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ * ***********************************************************************
+ */
+
+package graphical;
+
+import java.util.ArrayList;
+
+/**
+ *
+ * @author ll93751
+ */
+public class Office implements IOffice
+{
+ private ParameterHelper m_aParameterHelper;
+ private String m_sDocumentName;
+ private String m_sResult;
+ private IOffice m_aOffice = null;
+
+ public Office(ParameterHelper _aParam, String _sResult)
+ {
+ m_aParameterHelper = _aParam;
+ m_sResult = _sResult;
+
+ if (_aParam.getReferenceType().toLowerCase().equals("ooo") ||
+ _aParam.getReferenceType().toLowerCase().equals("ps") ||
+ _aParam.getReferenceType().toLowerCase().equals("pdf"))
+ {
+ m_aOffice = new OpenOfficePostscriptCreator(_aParam, m_sResult);
+ }
+ else if (_aParam.getReferenceType().toLowerCase().equals("msoffice"))
+ {
+ m_aOffice = new MSOfficePostscriptCreator(_aParam, m_sResult);
+ }
+ }
+
+
+ /**
+ * Load a document with an already started Office.
+ * @param _sDocumentName
+ * @throws graphical.OfficeException
+ */
+ public void load(String _sDocumentName) throws OfficeException
+ {
+ m_sDocumentName = _sDocumentName;
+ // check if given file is a picture, then do nothing
+ String sDocumentSuffix = FileHelper.getSuffix(m_sDocumentName);
+ if (sDocumentSuffix.toLowerCase().endsWith(".png") ||
+ sDocumentSuffix.toLowerCase().endsWith(".gif") ||
+ sDocumentSuffix.toLowerCase().endsWith(".jpg") ||
+ sDocumentSuffix.toLowerCase().endsWith(".bmp"))
+ {
+ throw new OfficeException("The given document is not a document type.");
+ }
+
+ // TODO: we should start the office after we know if we really need an Office.
+ if (m_aOffice != null)
+ {
+ if (sDocumentSuffix.toLowerCase().endsWith(".odb"))
+ {
+ if (m_aParameterHelper.getReferenceType().toLowerCase().equals("msoffice"))
+ {
+ // we can't handle .odb with msoffice
+ return;
+ }
+ // TODO: run through all documents which exists as reports in odb files
+ OpenOfficeDatabaseReportExtractor aExtractor = new OpenOfficeDatabaseReportExtractor(m_aParameterHelper);
+ ArrayList aList = aExtractor.load(m_sDocumentName);
+ if (aList != null)
+ {
+ // remove the whole section about the 'name'.odb there are no information we need
+ // we will create a new one.
+ String sIniFile = FileHelper.appendPath(m_sResult, "index.ini");
+ IniFile aIniFile2 = new IniFile(sIniFile);
+ String sSection = FileHelper.getBasename(_sDocumentName); // name of the odb file
+ aIniFile2.removeSection(sSection);
+ aIniFile2.close();
+
+ for (int i=0; i<aList.size();i++)
+ {
+ String sDocumentName = (String)aList.get(i);
+ m_aOffice.load(sDocumentName);
+ m_aOffice.storeAsPostscript();
+
+
+ // foreach Report found in the .odb file, create an entry 'report'<number> in the original <name>.odb Section
+ // so it is possible to run through all reports by the given .odb name
+ IniFile aIniFile = new IniFile(sIniFile);
+ // String sSection = FileHelper.getBasename(_sDocumentName); // name of the odb file
+ int nFileCount = aIniFile.getIntValue(sSection, "reportcount", 0);
+ String sValue = FileHelper.getBasename(sDocumentName); // name of the corresponding report
+ aIniFile.insertValue(sSection, "report" + nFileCount, sValue);
+ aIniFile.insertValue(sSection, "reportcount", nFileCount + 1);
+ aIniFile.close();
+ }
+ }
+ else
+ {
+ throw new OfficeException("Can't open the document " + m_sDocumentName);
+ }
+ }
+ else
+ {
+ m_aOffice.load(_sDocumentName);
+ }
+ }
+ }
+
+ public void storeAsPostscript() throws OfficeException
+ {
+ if (m_aOffice != null)
+ {
+ if (m_sDocumentName.endsWith(".odb"))
+ {
+ // this has already be done by load() for odb files.
+ }
+ else
+ {
+ m_aOffice.storeAsPostscript();
+ }
+
+// FileHelper.addBasenameToIndex(sOutputFilename);
+ }
+ }
+
+ public void start() throws OfficeException
+ {
+ if (m_aOffice != null)
+ {
+ m_aOffice.start();
+ }
+ }
+
+ public void close() throws OfficeException
+ {
+ if (m_aOffice != null)
+ {
+ m_aOffice.close();
+ }
+ }
+
+
+
+
+}
diff --git a/qadevOOo/runner/graphical/OfficeException.java b/qadevOOo/runner/graphical/OfficeException.java
new file mode 100644
index 000000000000..bc5a24fd5b97
--- /dev/null
+++ b/qadevOOo/runner/graphical/OfficeException.java
@@ -0,0 +1,45 @@
+/*
+ * ************************************************************************
+ *
+ * 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
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ * ***********************************************************************
+ */
+
+package graphical;
+
+/**
+ *
+ * @author ll93751
+ * Exception which occur if something goes wrong at load document.
+ */
+
+public class OfficeException extends Exception
+{
+ public OfficeException(String _aMessage)
+ {
+ super(_aMessage);
+ }
+
+}
diff --git a/qadevOOo/runner/graphical/OpenOfficeDatabaseReportExtractor.java b/qadevOOo/runner/graphical/OpenOfficeDatabaseReportExtractor.java
new file mode 100644
index 000000000000..a0592d5ce143
--- /dev/null
+++ b/qadevOOo/runner/graphical/OpenOfficeDatabaseReportExtractor.java
@@ -0,0 +1,560 @@
+/*
+ * ************************************************************************
+ *
+ * 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
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ * ***********************************************************************
+ */
+
+package graphical;
+
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.container.XNameAccess;
+import com.sun.star.frame.FrameSearchFlag;
+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.lang.XServiceInfo;
+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 complexlib.Assurance;
+// import complexlib.ComplexTestCase.AssureException;
+import helper.OfficeProvider;
+import helper.PropertyHelper;
+import helper.URLHelper;
+import java.io.File;
+import java.util.ArrayList;
+
+/**
+ *
+ * @author ll93751
+ */
+
+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;
+ }
+}
+
+public class OpenOfficeDatabaseReportExtractor extends Assurance
+{
+ private ParameterHelper m_aParameterHelper;
+
+ public OpenOfficeDatabaseReportExtractor(ParameterHelper _aParameter)
+ {
+ m_aParameterHelper = _aParameter;
+ }
+
+ private XDesktop m_xDesktop = null;
+ private XDesktop getXDesktop()
+ {
+
+ if (m_xDesktop == null)
+ {
+ try
+ {
+ XInterface xInterface = (XInterface) getMultiServiceFactory().createInstance( "com.sun.star.frame.Desktop" );
+ m_xDesktop = UnoRuntime.queryInterface(XDesktop.class, xInterface);
+ }
+ catch (com.sun.star.uno.Exception e)
+ {
+ GlobalLogWriter.println("ERROR: uno.Exception caught");
+ GlobalLogWriter.println("Message: " + e.getMessage());
+ }
+ }
+ return m_xDesktop;
+ }
+
+ private void showElements(XNameAccess _xNameAccess)
+ {
+ if (_xNameAccess != null)
+ {
+ String[] sElementNames = _xNameAccess.getElementNames();
+ for(int i=0;i<sElementNames.length; i++)
+ {
+ System.out.println("Value: [" + i + "] := " + sElementNames[i]);
+ }
+ }
+ else
+ {
+ System.out.println("Warning: Given object is null.");
+ }
+ }
+
+
+ private OfficeProvider m_aProvider = null;
+ private XMultiServiceFactory m_xMultiServiceFactory = null;
+ private XMultiServiceFactory getMultiServiceFactory()
+ {
+ if (m_xMultiServiceFactory == null)
+ {
+ m_xMultiServiceFactory = m_aParameterHelper.getMultiServiceFactory();
+ }
+ return m_xMultiServiceFactory;
+ }
+// private void startOffice()
+// {
+// // int tempTime = m_aParameterHelper.getTestParameters().getInt("SingleTimeOut");
+// param.put("TimeOut", new Integer(300000));
+// System.out.println("TimeOut: " + param.getInt("TimeOut"));
+// System.out.println("ThreadTimeOut: " + param.getInt("ThreadTimeOut"));
+//
+// // OfficeProvider aProvider = null;
+// m_aProvider = new OfficeProvider();
+// m_xXMultiServiceFactory = (XMultiServiceFactory) m_aProvider.getManager(param);
+// param.put("ServiceFactory", m_xXMultiServiceFactory);
+// }
+//
+// private void stopOffice()
+// {
+// if (m_aProvider != null)
+// {
+// m_aProvider.closeExistingOffice(param, true);
+// m_aProvider = null;
+// }
+// TimeHelper.waitInSeconds(2, "Give close Office some time.");
+// }
+
+ private String m_sMailAddress = null;
+ private String m_sParentDistinct = null;
+
+ // private String m_sUPDMinor;
+ // private String m_sCWS_WORK_STAMP;
+
+ private static String m_sSourceVersion;
+ private static String m_sDestinationVersion;
+ private static String m_sSourceName;
+ private static String m_sDestinationName;
+
+ private static final int WRITER = 1;
+ private static final int CALC = 2;
+
+ /**
+ * This is the main test Function of current ReportDesignerTest
+ * @param _sDocument
+ * @return
+ */
+
+ 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();
+ File aOutputPath = new File(sOutputPath);
+ aOutputPath.mkdirs();
+
+ String sFilename = FileHelper.getBasename(_sDocument);
+ String sDestinationFile = FileHelper.appendPath(sOutputPath, sFilename);
+ FileHelper.copy(_sDocument, sDestinationFile);
+
+ // now the fix reference of the AbsoluteReferenceFile should exist.
+ assure("There exists no file: " + sDestinationFile, FileHelper.exists(sDestinationFile));
+
+ String sFileURL = URLHelper.getFileURLFromSystemPath(sDestinationFile);
+ GlobalLogWriter.println("File URL: " + sFileURL);
+
+ 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
+// aReadOnly.Name = "ReadOnly";
+// aReadOnly.Value = Boolean.TRUE;
+// aPropertyList.add(aReadOnly);
+
+ XComponent xDocComponent = loadComponent(sFileURL, getXDesktop(), aPropertyList);
+
+ GlobalLogWriter.println("Load done");
+// context = createUnoService("com.sun.star.sdb.DatabaseContext")
+// oDataBase = context.getByName("hh")
+// oDBDoc = oDataBase.DatabaseDocument
+//
+// dim args(1) as new com.sun.star.beans.PropertyValue
+// args(0).Name = "ActiveConnection"
+// args(0).Value = oDBDoc.getCurrentController().getPropertyValue("ActiveConnection")
+// reportContainer = oDBDoc.getReportDocuments()
+// report = reportContainer.loadComponentFromURL("Report40","",0,args)
+
+ 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.println("createInstance com.sun.star.sdb.DatabaseContext done");
+
+// XNameAccess xNameAccess = (XNameAccess) UnoRuntime.queryInterface(XNameAccess.class, x);
+// showElements(xNameAccess);
+// Object aObj = xNameAccess.getByName(sFileURL);
+// 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 = UnoRuntime.queryInterface(XOfficeDatabaseDocument.class, xDocComponent);
+
+// XOfficeDatabaseDocument xOfficeDBDoc = (XOfficeDatabaseDocument)UnoRuntime.queryInterface(XOfficeDatabaseDocument.class, xDataSource);
+ assure("can't access DatabaseDocument", xOfficeDBDoc != null);
+// GlobalLogWriter.println("2");
+
+ XModel xDBSource = UnoRuntime.queryInterface(XModel.class, xOfficeDBDoc);
+ Object aController = xDBSource.getCurrentController();
+ assure("Controller of xOfficeDatabaseDocument is empty!", aController != null);
+// GlobalLogWriter.println("3");
+
+ XDatabaseDocumentUI aDBDocUI = UnoRuntime.queryInterface(XDatabaseDocumentUI.class, aController);
+ aDBDocUI.connect();
+ boolean isConnect = aDBDocUI.isConnected();
+ if (isConnect)
+ {
+ GlobalLogWriter.println("Connection is true");
+ }
+ else
+ {
+ GlobalLogWriter.println("Connection is false");
+ }
+
+ // aHelper = new PropertySetHelper(aController);
+
+ XReportDocumentsSupplier xSupplier = UnoRuntime.queryInterface(XReportDocumentsSupplier.class, xOfficeDBDoc);
+ XNameAccess xNameAccess = xSupplier.getReportDocuments();
+ assure("xOfficeDatabaseDocument returns no Report Document", xNameAccess != null);
+// GlobalLogWriter.println("5");
+
+ showElements(xNameAccess);
+
+ // Object aActiveConnectionObj = aHelper.getPropertyValueAsObject("ActiveConnection");
+ Object aActiveConnectionObj = aDBDocUI.getActiveConnection();
+ assure("ActiveConnection is empty", aActiveConnectionObj != null);
+// GlobalLogWriter.println("5");
+
+ ArrayList<PropertyValue> aPropertyList2 = new ArrayList<PropertyValue>();
+
+ PropertyValue aActiveConnection = new PropertyValue();
+ aActiveConnection.Name = "ActiveConnection";
+ aActiveConnection.Value = aActiveConnectionObj;
+ aPropertyList2.add(aActiveConnection);
+
+ aList = loadAndStoreReports(xNameAccess, aPropertyList2 /*, _nType*/ );
+ createDBEntry(/*_nType*/);
+ }
+ catch(Exception/*com.sun.star.uno.Exception*/ e)
+ {
+ GlobalLogWriter.println("ERROR: Exception caught");
+ GlobalLogWriter.println("Message: " + 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
+ // util.utils.shortWait(2000);
+
+ closeComponent(xDocComponent);
+ return aList;
+ }
+
+ private String getDocumentPoolName(/*int _nType*/)
+ {
+ return "AutogenReportDesignTest";
+ // return getFileFormat(_nType);
+ }
+
+// -----------------------------------------------------------------------------
+ private void createDBEntry(/*int _nType*/)
+ {
+ // try to connect the database
+ String sDBConnection = (String)m_aParameterHelper.getTestParameters().get( convwatch.PropertyName.DB_CONNECTION_STRING );
+ if (sDBConnection != null && sDBConnection.length() > 0)
+ {
+ GlobalLogWriter.println("DBConnection: " + sDBConnection);
+// TODO: DB
+// DB.init(sDBConnection);
+
+ // String sFixRefSubDirectory = "ReportDesign_qa_complex_" + getFileFormat(_nType);
+ String sFixRefSubDirectory = "ReportDesignFixRef";
+
+ String sSourceVersion = m_sSourceVersion;
+ // String sSourceVersion = sFixRefSubDirectory;
+ String sSourceName = m_sSourceName;
+ // String sSourceCreatorType = "fixref";
+ String sSourceCreatorType = "";
+ String sDestinationVersion = m_sDestinationVersion;
+ // if (sDestinationVersion.length() == 0)
+ // {
+ // sDestinationVersion = m_sUPDMinor;
+ // }
+ String sDestinationName = m_sDestinationName;
+ String sDestinationCreatorType = "";
+ String sDocumentPoolDir = getOutputPath(/*_nType*/);
+ String sDocumentPoolName = getDocumentPoolName(/*_nType*/);
+ String sSpecial = "";
+
+// TODO: DB
+// DB.insertinto_documentcompare(sSourceVersion, sSourceName, sSourceCreatorType,
+// m_sDestinationVersion, sDestinationName, sDestinationCreatorType,
+// sDocumentPoolDir, sDocumentPoolName, m_sMailAddress,
+// sSpecial, m_sParentDistinct);
+ TimeHelper.waitInSeconds(1, "wait for DB.");
+ // DB.test();
+ // System.exit(1);
+ }
+ }
+
+ private ArrayList<String> loadAndStoreReports(XNameAccess _xNameAccess, ArrayList<PropertyValue> _aPropertyList /*, int _nType*/ )
+ {
+ ArrayList<String> aList = new ArrayList<String>();
+ if (_xNameAccess != null)
+ {
+ String[] sElementNames = _xNameAccess.getElementNames();
+ for(int i=0;i<sElementNames.length; i++)
+ {
+ String sReportName = sElementNames[i];
+ XComponent xDoc = loadComponent(sReportName, _xNameAccess, _aPropertyList);
+// util.utils.shortWait(1000);
+ // print? or store?
+ String sDocumentPathName = storeComponent(sReportName, xDoc /*, _nType*/);
+ aList.add(sDocumentPathName);
+// util.utils.shortWait(1000);
+ closeComponent(xDoc);
+// util.utils.shortWait(1000);
+ // sBackPath contains the path where to find the extracted ODB Document
+ }
+ }
+ return aList;
+ }
+
+ private String getFormatExtension(Object _xComponent /* int _nType*/ )
+ {
+ String sExtension;
+ XServiceInfo xServiceInfo = UnoRuntime.queryInterface( XServiceInfo.class, _xComponent );
+ if ( xServiceInfo.supportsService( "com.sun.star.sheet.SpreadsheetDocument" ) )
+ {
+ // calc
+ sExtension = ".ods";
+ }
+ else if (xServiceInfo.supportsService("com.sun.star.text.TextDocument"))
+ {
+ //writer
+ sExtension = ".odt";
+ }
+ else
+ {
+ sExtension = ".UNKNOWN";
+ }
+ return sExtension;
+ }
+
+ // switch(_nType)
+ // {
+ // case WRITER:
+ // sExtension = ".odt";
+ // break;
+ // case CALC:
+ // sExtension = ".ods";
+ // break;
+ // default:
+ // sExtension = ".UNKNOWN";
+ // }
+ // return sExtension;
+ // }
+ // private String getFileFormat(int _nType)
+ // {
+ // String sFileType;
+ // switch(_nType)
+ // {
+ // case WRITER:
+ // sFileType = "writer8";
+ // break;
+ // case CALC:
+ // sFileType = "calc8";
+ // break;
+ // default:
+ // sFileType = "UNKNOWN";
+ // }
+ // return sFileType;
+ // }
+
+ private String m_sOutputPath = null;
+
+ private String getOutputPath(/*int _nType*/)
+ {
+ if (m_sOutputPath == null)
+ {
+ String sOutputPath = (String)m_aParameterHelper.getTestParameters().get( convwatch.PropertyName.DOC_COMPARATOR_OUTPUT_PATH );
+ sOutputPath = helper.StringHelper.removeQuoteIfExists(sOutputPath);
+
+ // sOutputPath += "tmp_123";
+ sOutputPath = FileHelper.appendPath(sOutputPath, DateHelper.getDateTimeForFilename());
+ // sOutputPath += System.getProperty("file.separator");
+
+ // sOutputPath += getFileFormat(_nType);
+ // sOutputPath += System.getProperty("file.separator");
+
+ File aOutputFile = new File(sOutputPath); // create the directory of the given output path
+ aOutputFile.mkdirs();
+ m_sOutputPath = sOutputPath;
+ }
+ return m_sOutputPath;
+ }
+
+ /*
+ store given _xComponent under the given Name in DOC_COMPARATOR_INPUTPATH
+ */
+ private String storeComponent(String _sName, Object _xComponent /*, int _nType*/ )
+ {
+ String sOutputPath = getOutputPath(/*_nType*/);
+
+// // add DocumentPoolName
+// sOutputPath = FileHelper.appendPath(sOutputPath, getDocumentPoolName(/*_nType*/));
+// // sOutputPath += System.getProperty("file.separator");
+//
+// File aOutputFile = new File(sOutputPath); // create the directory of the given output path
+// aOutputFile.mkdirs();
+
+
+ String sName = _sName + getFormatExtension(_xComponent /*_nType*/);
+ sOutputPath = FileHelper.appendPath(sOutputPath, sName);
+
+ // we need the name and path
+ String sBackPathName = sOutputPath;
+
+ String sOutputURL = URLHelper.getFileURLFromSystemPath(sOutputPath);
+
+ ArrayList<PropertyValue> aPropertyList = new ArrayList<PropertyValue>(); // 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)
+ {
+ GlobalLogWriter.println("store document as URL: '" + sOutputURL + "'");
+ try
+ {
+ aStorable.storeAsURL(sOutputURL, PropertyHelper.createPropertyValueArrayFormArrayList(aPropertyList));
+ }
+ catch (com.sun.star.io.IOException e)
+ {
+ GlobalLogWriter.println("ERROR: Exception caught");
+ GlobalLogWriter.println("Can't write document URL: '" + sOutputURL + "'");
+ GlobalLogWriter.println("Message: " + e.getMessage());
+ }
+ }
+ return sBackPathName;
+ }
+
+ 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);
+ GlobalLogWriter.println("Load component: '" + _sName + "'");
+ xDocComponent = xComponentLoader.loadComponentFromURL(_sName, "_blank", FrameSearchFlag.ALL, aLoadProperties);
+ GlobalLogWriter.println("Load component: '" + _sName + "' done");
+ }
+ catch (com.sun.star.io.IOException e)
+ {
+ 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.println("ERROR: Exception caught");
+ GlobalLogWriter.println("Illegal Arguments given to loadComponentFromURL.");
+ GlobalLogWriter.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)
+ {
+ GlobalLogWriter.println("ERROR: CloseVetoException caught");
+ GlobalLogWriter.println("CloseVetoException occured Can't close document.");
+ GlobalLogWriter.println("Message: " + e.getMessage());
+ }
+ }
+
+}
diff --git a/qadevOOo/runner/graphical/OpenOfficePostscriptCreator.java b/qadevOOo/runner/graphical/OpenOfficePostscriptCreator.java
new file mode 100644
index 000000000000..d918634f8d30
--- /dev/null
+++ b/qadevOOo/runner/graphical/OpenOfficePostscriptCreator.java
@@ -0,0 +1,1427 @@
+/*************************************************************************
+ *
+ * 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
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package graphical;
+
+import com.sun.star.frame.FrameSearchFlag;
+import com.sun.star.util.XCloseable;
+import helper.OfficeProvider;
+import helper.OfficeWatcher;
+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;
+import com.sun.star.frame.XComponentLoader;
+import com.sun.star.lang.XComponent;
+import com.sun.star.frame.XStorable;
+import com.sun.star.view.XPrintable;
+import com.sun.star.lang.XServiceInfo;
+import com.sun.star.frame.XModel;
+import com.sun.star.uno.AnyConverter;
+
+import helper.URLHelper;
+import helper.PropertyHelper;
+import helper.OSHelper;
+
+// import helper.Parameter;
+import java.io.File;
+
+/**
+ * This Object is to print a given document with OpenOffice.org / StarOffice
+ * over the normal printer driver
+ * or over it's pdf exporter
+ */
+public class OpenOfficePostscriptCreator implements IOffice
+{
+ private ParameterHelper m_aParameterHelper;
+ private String m_sOutputURL;
+ private String m_sBasename;
+ private String m_sDocumentName;
+ private XComponent m_aDocument;
+
+ public OpenOfficePostscriptCreator(ParameterHelper _aParam, String _sResult)
+ {
+ m_aParameterHelper = _aParam;
+ String sOutputURL = _sResult;
+ if (! sOutputURL.startsWith("file:"))
+ {
+ sOutputURL = URLHelper.getFileURLFromSystemPath(_sResult);
+ }
+ m_sOutputURL = sOutputURL;
+ m_aDocument = null;
+ }
+
+
+ public void load(String _sDocumentName) throws OfficeException
+ {
+ m_sDocumentName = _sDocumentName;
+
+ String sInputFileURL = URLHelper.getFileURLFromSystemPath(m_sDocumentName);
+ m_aDocument = loadFromURL(m_aParameterHelper, sInputFileURL);
+ if (m_aDocument == null)
+ {
+ GlobalLogWriter.println("loadDocumentFromURL() failed with document: " + sInputFileURL);
+ throw new OfficeException("load(): failed with document" + sInputFileURL);
+ }
+
+ m_sBasename = FileHelper.getBasename(m_sDocumentName);
+ }
+
+ public void storeAsPostscript() throws OfficeException
+ {
+ if (m_aDocument != null)
+ {
+ String sDocumentName = FileHelper.appendPath(m_sOutputURL, m_sBasename);
+ if (m_aParameterHelper.getReferenceType().toLowerCase().equals("ooo") ||
+ m_aParameterHelper.getReferenceType().toLowerCase().equals("ps") )
+ {
+ String sPrintURL = sDocumentName + ".ps";
+
+ impl_printToFileWithOOo(m_aParameterHelper, m_aDocument, sDocumentName, sPrintURL /*_sPrintFileURL*/);
+ String sBasename = FileHelper.getBasename(sPrintURL);
+ FileHelper.addBasenameToIndex(m_sOutputURL, sBasename, "OOo", "postscript", m_sDocumentName);
+ }
+ else if (m_aParameterHelper.getReferenceType().toLowerCase().equals("pdf"))
+ {
+ String sPDFURL = sDocumentName + ".pdf";
+ storeAsPDF(m_aParameterHelper, m_aDocument, sPDFURL);
+
+ String sBasename = FileHelper.getBasename(sPDFURL);
+ FileHelper.addBasenameToIndex(m_sOutputURL, sBasename, "pdf", "pdf-export", m_sDocumentName);
+ }
+ else
+ {
+ throw new OfficeException("unknown reference type");
+ }
+ GlobalLogWriter.println("Close document.");
+ m_aDocument.dispose();
+ }
+ }
+
+ public void start() throws OfficeException
+ {
+ startOffice();
+ }
+
+ public void close() throws OfficeException
+ {
+ stopOffice();
+ }
+
+
+
+
+
+ private void showProperty(PropertyValue _aValue)
+ {
+ String sName = _aValue.Name;
+ String sValue;
+ try
+ {
+ sValue = AnyConverter.toString(_aValue.Value);
+ GlobalLogWriter.println("Property " + sName + ":=" + sValue);
+ }
+ catch (com.sun.star.lang.IllegalArgumentException e)
+ {
+ GlobalLogWriter.println("showProperty: can't convert a object to string. " + e.getMessage());
+ }
+ }
+
+ /**
+ * shows the FilterName and MediaType from the given XComponent
+ */
+ private String getDocumentType( XComponent _aDoc )
+ {
+ XModel xModel = UnoRuntime.queryInterface( XModel.class, _aDoc);
+ PropertyValue[] aArgs = xModel.getArgs();
+ for (int i=0;i<aArgs.length;i++)
+ {
+ PropertyValue aValue = aArgs[i];
+ // System.out.print("Property: '" + aValue.Name);
+ // System.out.println("' := '" + aValue.Value + "'");
+ if (aValue.Name.equals("FilterName") ||
+ aValue.Name.equals("MediaType"))
+ {
+ String sNameValue = "'" + aValue.Name + "' := '" + aValue.Value + "'";
+ return sNameValue;
+ }
+ }
+ return "";
+ }
+
+ private void showDocumentType( XComponent _aDoc )
+ {
+ String sNameValue = getDocumentType(_aDoc);
+ GlobalLogWriter.println(" Property: '" + sNameValue);
+ }
+ /**
+ * load a OpenOffice.org document from a given URL (_sInputURL)
+ * the ParameterHelper must contain a living MultiServiceFactory object
+ * or we crash here.
+ * Be aware, the ownership of the document gets to you, you have to close it.
+ */
+ private XComponent loadFromURL(ParameterHelper _aGTA,
+ String _sInputURL)
+ {
+ XComponent aDoc = null;
+ try
+ {
+ if (_aGTA.getMultiServiceFactory() == null)
+ {
+ GlobalLogWriter.println("MultiServiceFactory in GraphicalTestArgument not set.");
+ return null;
+ }
+ Object oDsk = _aGTA.getMultiServiceFactory().createInstance("com.sun.star.frame.Desktop");
+ XDesktop aDesktop = UnoRuntime.queryInterface(XDesktop.class, oDsk);
+
+ if (aDesktop != null)
+ {
+ GlobalLogWriter.println("com.sun.star.frame.Desktop created.");
+ // String sInputURL = aCurrentParameter.sInputURL;
+ // String sOutputURL = aCurrentParameter.sOutputURL;
+ // String sPrintFileURL = aCurrentParameter.sPrintToFileURL;
+ // System.out.println(_sInputURL);
+
+
+ // set here the loadComponentFromURL() properties
+ // at the moment only 'Hidden' is set, so no window is opened at work
+
+ ArrayList<PropertyValue> aPropertyList = new ArrayList<PropertyValue>();
+
+ // check which properties should set and count it.
+ // if (_aGTA.isHidden())
+ // {
+ // nPropertyCount ++;
+ // }
+ // if (_aGTA.getImportFilterName() != null && _aGTA.getImportFilterName().length() > 0)
+ // {
+ // nPropertyCount ++;
+ // }
+
+ // initialize the propertyvalue
+ // int nPropertyIndex = 0;
+ // aProps = new PropertyValue[ nPropertyCount ];
+
+ // set all property values
+ if (_aGTA.isHidden())
+ {
+ PropertyValue Arg = new PropertyValue();
+ Arg.Name = "Hidden";
+ Arg.Value = Boolean.TRUE;
+ aPropertyList.add(Arg);
+ showProperty(Arg);
+ }
+ if (_aGTA.getImportFilterName() != null && _aGTA.getImportFilterName().length() > 0)
+ {
+ PropertyValue Arg = new PropertyValue();
+ Arg.Name = "FilterName";
+ Arg.Value = _aGTA.getImportFilterName();
+ aPropertyList.add(Arg);
+ showProperty(Arg);
+ }
+ PropertyValue ReadOnly = new PropertyValue();
+ ReadOnly.Name = "ReadOnly";
+ ReadOnly.Value = Boolean.TRUE;
+ aPropertyList.add(ReadOnly);
+ showProperty(ReadOnly);
+
+ GlobalLogWriter.println(DateHelper.getDateTimeForHumanreadableLog() + " Load document");
+ // GlobalLogWriter.flush();
+
+ XComponentLoader aCompLoader = UnoRuntime.queryInterface( XComponentLoader.class, aDesktop);
+
+ // XComponent aDoc = null;
+
+ _aGTA.getPerformance().startTime(PerformanceContainer.Load);
+ aDoc = aCompLoader.loadComponentFromURL(_sInputURL, "_blank", FrameSearchFlag.ALL, PropertyHelper.createPropertyValueArrayFormArrayList(aPropertyList) );
+ _aGTA.getPerformance().stopTime(PerformanceContainer.Load);
+ if (aDoc != null)
+ {
+ GlobalLogWriter.println(DateHelper.getDateTimeForHumanreadableLog() + " Load document done.");
+ showDocumentType(aDoc);
+ _aGTA.setDocumentType(getDocumentType(aDoc));
+// TODO: TimeHelper.waitInSeconds(20, "Wait after load document. Maybe helps due to layouting problems.");
+ }
+ else
+ {
+ GlobalLogWriter.println(" Load document failed.");
+ if (_aGTA.getImportFilterName() != null && _aGTA.getImportFilterName().length() > 0)
+ {
+ GlobalLogWriter.println(" Please check FilterName := '" + _aGTA.getImportFilterName() + "'");
+ }
+ GlobalLogWriter.println("");
+ }
+ }
+ else
+ {
+ GlobalLogWriter.println("com.sun.star.frame.Desktop failed.");
+ }
+ }
+ catch ( com.sun.star.uno.Exception e )
+ {
+ // Some exception occures.FAILED
+ GlobalLogWriter.println("UNO Exception caught.");
+ GlobalLogWriter.println("Message: " + e.getMessage());
+ e.printStackTrace();
+ aDoc = null;
+ }
+ return aDoc;
+ }
+
+ private boolean exportToPDF(XComponent _xComponent, String _sDestinationName)
+ {
+ XServiceInfo xServiceInfo =
+ UnoRuntime.queryInterface(
+ XServiceInfo.class, _xComponent
+ );
+
+ ArrayList<PropertyValue> aPropertyList = new ArrayList<PropertyValue>();
+ PropertyValue aFiltername = new PropertyValue();
+ aFiltername.Name = "FilterName";
+ aFiltername.Value = getFilterName_forPDF(xServiceInfo);
+ aPropertyList.add(aFiltername);
+ showProperty(aFiltername);
+ boolean bWorked = true;
+
+// TODO: TimeHelper.waitInSeconds(20, "Wait before storeToURL. Maybe helps due to layouting problems.");
+ try
+ {
+ XStorable store =
+ UnoRuntime.queryInterface(
+ XStorable.class, _xComponent
+ );
+ store.storeToURL(_sDestinationName, PropertyHelper.createPropertyValueArrayFormArrayList(aPropertyList));
+ }
+ catch (com.sun.star.io.IOException e)
+ {
+ GlobalLogWriter.println("IO Exception caught.");
+ GlobalLogWriter.println("Message: " + e.getMessage());
+ bWorked = false;
+ }
+
+ return bWorked;
+ }
+
+
+ private String getFilterName_forPDF(XServiceInfo xServiceInfo)
+ {
+ String filterName = "";
+
+ if (xServiceInfo.supportsService("com.sun.star.text.TextDocument"))
+ {
+ //writer
+ filterName = "writer_pdf_Export";
+ }
+ else if ( xServiceInfo.supportsService( "com.sun.star.sheet.SpreadsheetDocument" ) )
+ {
+ //calc
+ filterName = "calc_pdf_Export";
+ }
+ else if ( xServiceInfo.supportsService( "com.sun.star.drawing.DrawingDocument" ) )
+ {
+ //draw
+ filterName = "draw_pdf_Export";
+ }
+ else if ( xServiceInfo.supportsService( "com.sun.star.presentation.PresentationDocument" ) )
+ {
+ //impress
+ filterName = "impress_pdf_Export";
+ }
+ else if (xServiceInfo.supportsService("com.sun.star.text.WebDocument"))
+ {
+ //html document
+ filterName = "writer_web_pdf_Export";
+ }
+ else if ( xServiceInfo.supportsService("com.sun.star.text.GlobalDocument") )
+ {
+ //master document
+ filterName = "writer_globaldocument_pdf_Export";
+ }
+ else if ( xServiceInfo.supportsService( "com.sun.star.formulaFormulaProperties" ) )
+ {
+ //math document
+ filterName = "math_pdf_Export";
+ }
+
+ return filterName;
+ }
+
+ // -----------------------------------------------------------------------------
+
+// public boolean storeAsPDF(ParameterHelper _aGTA,
+// String _sInputURL,
+// String _sOutputURL)
+// {
+// boolean bBack = false;
+// XComponent aDoc = loadFromURL(_aGTA, _sInputURL);
+//
+// if (aDoc == null)
+// {
+// GlobalLogWriter.println("Can't load document.");
+// return bBack;
+// }
+// bBack = storeAsPDF(_aGTA, aDoc, _sOutputURL);
+// FileHelper.createInfoFile(_sOutputURL, _aGTA, "as pdf");
+//
+// GlobalLogWriter.println("Close document.");
+// aDoc.dispose();
+// return bBack;
+// }
+
+ public boolean storeAsPDF(ParameterHelper _aGTA,
+ XComponent _aDoc,
+ String _sOutputURL) throws OfficeException
+ {
+ // try {
+ boolean bBack = true;
+ _aGTA.getPerformance().startTime(PerformanceContainer.StoreAsPDF);
+ bBack = exportToPDF(_aDoc, _sOutputURL);
+ _aGTA.getPerformance().stopTime(PerformanceContainer.StoreAsPDF);
+
+ if (!bBack)
+ {
+ GlobalLogWriter.println("Can't store document as PDF.");
+// bBack = false;
+ throw new OfficeException("Can't store document as PDF");
+ }
+ else
+ {
+ FileHelper.createInfoFile(_sOutputURL, _aGTA, "as pdf");
+ }
+ return bBack;
+ }
+
+ // -----------------------------------------------------------------------------
+
+ /**
+ * print the document found in file (_sInputURL) to as postscript to file (_sPrintFileURL)
+ * Due to the fact we use a printer to convert the file to postscript, the default printer
+ * to create such postscript format must be installed, this is not tested here.
+ *
+ * @return true, if print has been done.
+ * Be careful, true means only print returns with no errors, to be sure print is really done
+ * check existance of _sPrintFileURL
+ */
+
+// public boolean printToFileWithOOo(ParameterHelper _aGTA,
+// String _sInputURL,
+// String _sOutputURL,
+// String _sPrintFileURL)
+// {
+// // waitInSeconds(1);
+// boolean bBack = false;
+//
+// XComponent aDoc = loadFromURL(_aGTA, _sInputURL);
+// if (aDoc != null)
+// {
+// if ( _sInputURL.equals(_sOutputURL) )
+// {
+// // don't store document
+// // input and output are equal OR
+// GlobalLogWriter.println("Warning: Inputpath and Outputpath are equal. Document will not stored again.");
+// disallowStore();
+// }
+// bBack = impl_printToFileWithOOo(_aGTA, aDoc, _sOutputURL, _sPrintFileURL);
+//
+// GlobalLogWriter.println("Close document.");
+// aDoc.dispose();
+// }
+// else
+// {
+// GlobalLogWriter.println("loadDocumentFromURL() failed with document: " + _sInputURL);
+// }
+// return bBack;
+// }
+
+
+
+ // -----------------------------------------------------------------------------
+ private boolean impl_printToFileWithOOo(ParameterHelper _aGTA,
+ XComponent _aDoc,
+ String _sOutputURL,
+ String _sPrintFileURL)
+ {
+ boolean bBack = false;
+ boolean bFailed = true; // always be a pessimist,
+ if (_aDoc == null)
+ {
+ GlobalLogWriter.println("No document is given.");
+ return bBack;
+ }
+
+ try
+ {
+ if (_sOutputURL != null)
+ {
+ if (isStoreAllowed())
+ {
+ // store the document in an other directory
+ XStorable aStorable = UnoRuntime.queryInterface( XStorable.class, _aDoc);
+ if (aStorable != null)
+ {
+ PropertyValue [] szEmptyArgs = new PropertyValue [0];
+
+ GlobalLogWriter.println(DateHelper.getDateTimeForHumanreadableLog() + " Store document.");
+ _aGTA.getPerformance().startTime(PerformanceContainer.Store);
+ aStorable.storeAsURL(_sOutputURL, szEmptyArgs);
+ _aGTA.getPerformance().stopTime(PerformanceContainer.Store);
+
+ GlobalLogWriter.println(DateHelper.getDateTimeForHumanreadableLog() + " Store document done.");
+ // TimeHelper.waitInSeconds(1, "After store as URL to:" + _sOutputURL);
+ GlobalLogWriter.println("Reload stored file test.");
+ XComponent aDoc = loadFromURL(_aGTA, _sOutputURL);
+ if (aDoc == null)
+ {
+ GlobalLogWriter.println("Reload stored file test failed, can't reload file: " + _sOutputURL);
+ }
+ else
+ {
+ XCloseable xClose = UnoRuntime.queryInterface(XCloseable.class, aDoc);
+ if (xClose != null)
+ {
+ xClose.close(true);
+ }
+ else
+ {
+ aDoc.dispose();
+ }
+ // TimeHelper.waitInSeconds(1, "after close temp document");
+ }
+ }
+ }
+ else
+ {
+ // make sure to create the directory in
+ String sOutputFilename = FileHelper.getSystemPathFromFileURL(_sOutputURL);
+ String sOutputPath = FileHelper.getPath(sOutputFilename);
+ File aFile = new File(sOutputPath);
+ aFile.mkdirs();
+ }
+ }
+ }
+ catch ( com.sun.star.uno.Exception e )
+ {
+ // Some exception occures.FAILED
+ GlobalLogWriter.println("UNO Exception caught.");
+ GlobalLogWriter.println("Message: " + e.getMessage());
+
+ e.printStackTrace();
+ bBack = false;
+ }
+
+ try
+ {
+
+ // System.out.println("Document loaded.");
+ // Change Pagesettings to DIN A4
+
+ GlobalLogWriter.println(DateHelper.getDateTimeForHumanreadableLog() + " Print document.");
+ XPrintable aPrintable = UnoRuntime.queryInterface( XPrintable.class, _aDoc);
+ if (aPrintable != null)
+ {
+ // System.out.println(" Set PaperFormat to DIN A4");
+ // {
+ // PropertyValue[] aPrinterProps = aPrintable.getPrinter();
+ // System.out.println("PrinterProps size: " + String.valueOf(aPrinterProps.length));
+ // int nPropIndex = 0;
+ // while (!"PaperFormat".equals(aPrinterProps[nPropIndex].Name))
+ // {
+ // // System.out.println(aPrinterProps[nPropIndex].Name);
+ // nPropIndex++;
+ // }
+ // aPrinterProps[nPropIndex].Value = com.sun.star.view.PaperFormat.A4;
+ // aPrintable.setPrinter(aPrinterProps);
+ // }
+
+ // configure Office to allow to execute macos
+
+// TODO: We need a possiblity to set the printer name also for StarOffice/OpenOffice
+ if (OSHelper.isWindows())
+ {
+ if (_aGTA.getPrinterName() != null)
+ {
+ ArrayList<PropertyValue> aPropertyList = new ArrayList<PropertyValue>();
+ // PropertyValue [] aPrintProps = new PropertyValue[1];
+ PropertyValue Arg = new PropertyValue();
+ Arg.Name = "Name";
+ Arg.Value = _aGTA.getPrinterName();
+ aPropertyList.add(Arg);
+ showProperty(Arg);
+ // GlobalLogWriter.println("Printername is not null, so set to " + _aGTA.getPrinterName());
+ aPrintable.setPrinter(PropertyHelper.createPropertyValueArrayFormArrayList(aPropertyList));
+ }
+ }
+
+ // set property values for XPrintable.print()
+ // more can be found at "http://api.openoffice.org/docs/common/ref/com/sun/star/view/PrintOptions.html"
+
+ // int nProperties = 1; // default for 'FileName' property
+ // if (_aGTA.printAllPages() == false)
+ // {
+ // // we don't want to print all pages, build Pages string by ourself
+ // nProperties ++;
+ // }
+ // int nPropsCount = 0;
+
+ // If we are a SpreadSheet (calc), we need to set PrintAllSheets property to 'true'
+ XServiceInfo xServiceInfo = UnoRuntime.queryInterface( XServiceInfo.class, _aDoc );
+ if ( xServiceInfo.supportsService( "com.sun.star.sheet.SpreadsheetDocument" ) )
+ {
+ XMultiServiceFactory xMSF = _aGTA.getMultiServiceFactory();
+ Object aSettings = xMSF.createInstance( "com.sun.star.sheet.GlobalSheetSettings" );
+ if (aSettings != null)
+ {
+ XPropertySet xPropSet = UnoRuntime.queryInterface( XPropertySet.class, aSettings );
+ xPropSet.setPropertyValue( "PrintAllSheets", new Boolean( true ) );
+ GlobalLogWriter.println("PrintAllSheets := true");
+ }
+ }
+
+ ArrayList<PropertyValue> aPrintProps = new ArrayList<PropertyValue>();
+ // GlobalLogWriter.println("Property FileName:=" + _sPrintFileURL);
+
+ // PropertyValue [] aPrintProps = new PropertyValue[nProperties];
+ PropertyValue Arg = new PropertyValue();
+ Arg.Name = "FileName";
+ Arg.Value = _sPrintFileURL;
+ // aPrintProps[nPropsCount ++] = Arg;
+ aPrintProps.add(Arg);
+ showProperty(Arg);
+
+
+ // generate pages string
+ if (_aGTA.printAllPages() == false)
+ {
+ String sPages = "";
+ if (_aGTA.getMaxPages() > 0)
+ {
+ sPages = "1-" + String.valueOf(_aGTA.getMaxPages());
+ }
+ if (_aGTA.getOnlyPages().length() != 0)
+ {
+ if (sPages.length() != 0)
+ {
+ sPages += ";";
+ }
+ sPages += String.valueOf(_aGTA.getOnlyPages());
+ }
+
+ Arg = new PropertyValue();
+ Arg.Name = "Pages";
+ Arg.Value = sPages;
+ aPrintProps.add(Arg);
+ showProperty(Arg);
+ }
+
+ // GlobalLogWriter.println("Start printing.");
+
+ _aGTA.getPerformance().startTime(PerformanceContainer.Print);
+ aPrintable.print(PropertyHelper.createPropertyValueArrayFormArrayList(aPrintProps));
+ TimeHelper.waitInSeconds(1, "Start waiting for print ready.");
+
+ GlobalLogWriter.println("Wait until document is printed.");
+ boolean isBusy = true;
+ int nPrintCount = 0;
+ while (isBusy)
+ {
+ PropertyValue[] aPrinterProps = aPrintable.getPrinter();
+ int nPropIndex = 0;
+ while (!"IsBusy".equals(aPrinterProps[nPropIndex].Name))
+ {
+ // System.out.println(aPrinterProps[nPropIndex].Name);
+ nPropIndex++;
+ }
+ isBusy = (aPrinterProps[nPropIndex].Value == Boolean.TRUE) ? true : false;
+ TimeHelper.waitInSeconds(1, "is print ready?");
+ nPrintCount++;
+ if (nPrintCount > 3600)
+ {
+ // we will never wait >1h until print is ready!
+ GlobalLogWriter.println("ERROR: Cancel print due to too long wait.");
+ throw new com.sun.star.uno.Exception("Convwatch exception, wait too long for printing.");
+ }
+ }
+// TODO:
+// TimeHelper.waitInSeconds(40, "Start waiting after print ready.");
+
+ _aGTA.getPerformance().stopTime(PerformanceContainer.Print);
+ GlobalLogWriter.println(DateHelper.getDateTimeForHumanreadableLog() + " Print document done.");
+
+ // Create a .info file near the printed '.ps' or '.prn' file.
+ FileHelper.createInfoFile(_sPrintFileURL, _aGTA);
+ }
+ else
+ {
+ GlobalLogWriter.println("Can't get XPrintable interface.");
+ }
+ bFailed = false;
+ bBack = true;
+ }
+ catch ( com.sun.star.uno.Exception e )
+ {
+ // Some exception occures.FAILED
+ GlobalLogWriter.println("UNO Exception caught.");
+ GlobalLogWriter.println("Message: " + e.getMessage());
+
+ e.printStackTrace();
+ bBack = false;
+ }
+
+ if (bFailed == true)
+ {
+ GlobalLogWriter.println("convwatch.OfficePrint: FAILED");
+ }
+ else
+ {
+ GlobalLogWriter.println("convwatch.OfficePrint: OK");
+ }
+ return bBack;
+ }
+
+
+ /**
+ * @param _aGTA
+ * @param _sAbsoluteOutputPath
+ * @param _sAbsoluteInputFile
+ * @return true, if the reference (*.prrn file) based on given output path and given input path exist.
+ * If OVERWRITE_REFERENCE is set, always return false.
+ */
+ public boolean isReferenceExists(ParameterHelper _aGTA,
+ String _sAbsoluteOutputPath,
+ String _sAbsoluteInputFile)
+ {
+ if (! FileHelper.exists(_sAbsoluteInputFile))
+ {
+ // throw new ConvWatchCancelException("Input file: " + _sAbsoluteInputFile + " does not exist.");
+ return false;
+ }
+
+ // String fs = System.getProperty("file.separator");
+
+ // String sInputFileURL = URLHelper.getFileURLFromSystemPath(_sAbsoluteInputFile);
+
+ String sInputFileBasename = FileHelper.getBasename(_sAbsoluteInputFile);
+ // String sOutputFileURL = null;
+ String sOutputPath;
+ if (_sAbsoluteOutputPath != null)
+ {
+ sOutputPath = _sAbsoluteOutputPath;
+ // FileHelper.makeDirectories("", sOutputPath);
+ }
+ else
+ {
+ String sInputPath = FileHelper.getPath(_sAbsoluteInputFile);
+ sOutputPath = sInputPath;
+ }
+ // sOutputFileURL = URLHelper.getFileURLFromSystemPath(sOutputPath + fs + sInputFileBasename);
+ // sOutputFileURL = null;
+
+ String sPrintFilename = FileHelper.getNameNoSuffix(sInputFileBasename);
+ // String sPrintFileURL;
+
+ String sAbsolutePrintFilename = FileHelper.appendPath(sOutputPath, sPrintFilename + ".prn");
+ if (FileHelper.exists(sAbsolutePrintFilename) && _aGTA.getOverwrite() == false)
+ {
+ GlobalLogWriter.println("Reference already exist, don't overwrite. Set " + PropertyName.DOC_COMPARATOR_OVERWRITE_REFERENCE + "=true to force overwrite.");
+ return true;
+ }
+ return false;
+ }
+
+ // -----------------------------------------------------------------------------
+ /**
+ * create a reference file
+ * _sAbsoluteInputPath contains the source file, if not exists, return with failure.
+ * _sAbsoluteOutputPath contains the destination, where the file will store after load with StarOffice/OpenOffice.org
+ * if is null, print only near the Input file path
+ * _sPrintType ".prn" Print input file with StarOffice/OpenOffice.org and the default printer as PostScript
+ *
+ * @param _aGTA
+ * @return
+ */
+// public static boolean buildReference(ParameterHelper _aGTA,
+// String _sAbsoluteOutputPath,
+// String _sAbsoluteInputFile)
+// throws OfficeException
+// {
+// if (! FileHelper.exists(_sAbsoluteInputFile))
+// {
+// throw new OfficeException("buildReference(): Input file: " + _sAbsoluteInputFile + " does not exist.");
+// }
+//
+// String fs = System.getProperty("file.separator");
+//
+// String sInputFileURL = URLHelper.getFileURLFromSystemPath(_sAbsoluteInputFile);
+//
+// String sInputFileBasename = FileHelper.getBasename(_sAbsoluteInputFile);
+// String sOutputFileURL = null;
+// String sOutputPath;
+// if (_sAbsoluteOutputPath != null)
+// {
+// sOutputPath = _sAbsoluteOutputPath;
+// FileHelper.makeDirectories("", sOutputPath);
+// }
+// else
+// {
+// String sInputPath = FileHelper.getPath(_sAbsoluteInputFile);
+// sOutputPath = sInputPath;
+// }
+// // sOutputFileURL = URLHelper.getFileURLFromSystemPath(sOutputPath + fs + sInputFileBasename);
+// sOutputFileURL = null;
+//
+// String sPrintFilename = FileHelper.getNameNoSuffix(sInputFileBasename);
+// String sPrintFileURL;
+//
+// String sAbsolutePrintFilename = sOutputPath + fs + sPrintFilename + ".prn";
+// if (FileHelper.exists(sAbsolutePrintFilename) && _aGTA.getOverwrite() == false)
+// {
+// GlobalLogWriter.println("Reference already exist, don't overwrite. Set " + PropertyName.DOC_COMPARATOR_OVERWRITE_REFERENCE + "=true to force overwrite.");
+// return true;
+// }
+//
+// if (_aGTA.getReferenceType().toLowerCase().equals("msoffice"))
+// {
+// sPrintFileURL = URLHelper.getFileURLFromSystemPath(sAbsolutePrintFilename);
+// }
+// else if (_aGTA.getReferenceType().toLowerCase().equals("pdf"))
+// {
+//// TODO: If we rename the stored file to *.pdf, we have to be sure that we use *.pdf also as a available reference
+// sPrintFileURL = URLHelper.getFileURLFromSystemPath(sAbsolutePrintFilename );
+// }
+// else if (_aGTA.getReferenceType().toLowerCase().equals("ooo"))
+// {
+// sPrintFileURL = URLHelper.getFileURLFromSystemPath(sAbsolutePrintFilename );
+// }
+// else
+// {
+// GlobalLogWriter.println("OfficePrint.buildreference(): Unknown print type.");
+// return false;
+// }
+// return printToFile(_aGTA, sInputFileURL, sOutputFileURL, sPrintFileURL);
+// }
+
+
+
+ // TODO: Das Teil muss hier raus!
+
+
+// public static boolean printToFile(ParameterHelper _aGTA,
+// String _sInputFileURL,
+// String _sOutputFileURL,
+// String _sPrintFileURL) throws OfficeException
+// {
+// boolean bBack = false;
+// String sPrintFileURL = null;
+//
+//
+// // remember the current timer, to know how long a print process need.
+// // startTimer();
+//
+// if (_aGTA.getReferenceType().toLowerCase().equals("ooo"))
+// {
+// bBack = printToFileWithOOo(_aGTA, _sInputFileURL, _sOutputFileURL, _sPrintFileURL);
+// }
+// else if (_aGTA.getReferenceType().toLowerCase().equals("pdf"))
+// {
+// GlobalLogWriter.println("USE PDF AS EXPORT FORMAT.");
+// bBack = storeAsPDF(_aGTA, _sInputFileURL, _sPrintFileURL);
+// }
+// else if (_aGTA.getReferenceType().toLowerCase().equals("msoffice"))
+// {
+// if (MSOfficePostscriptCreator.isMSOfficeDocumentFormat(_sInputFileURL))
+// {
+// GlobalLogWriter.println("USE MSOFFICE AS EXPORT FORMAT.");
+// MSOfficePostscriptCreator a = new MSOfficePostscriptCreator();
+// try
+// {
+// a.printToFileWithMSOffice(_aGTA, FileHelper.getSystemPathFromFileURL(_sInputFileURL),
+// FileHelper.getSystemPathFromFileURL(_sPrintFileURL));
+// }
+// catch(OfficeException e)
+// {
+// e.printStackTrace();
+// GlobalLogWriter.println(e.getMessage());
+// throw new OfficeException("Exception caught. Problem with MSOffice printer methods.");
+// }
+// catch(java.io.IOException e)
+// {
+// GlobalLogWriter.println(e.getMessage());
+// throw new OfficeException("IOException caught. Problem with MSOffice printer methods.");
+// }
+// bBack = true;
+// }
+// else
+// {
+// GlobalLogWriter.println("This document type is not recognized as MSOffice format, as default fallback StarOffice/OpenOffice.org instead is used.");
+// bBack = printToFileWithOOo(_aGTA, _sInputFileURL, _sOutputFileURL, _sPrintFileURL);
+// }
+// }
+// else
+// {
+// // System.out.println("");
+// throw new OfficeException("OfficePrint.printToFile(): Unknown print type.");
+// }
+// return bBack;
+// }
+
+ // -----------------------------------------------------------------------------
+ // TODO: move this away!
+ // -----------------------------------------------------------------------------
+ void showType(String _sInputURL, XMultiServiceFactory _xMSF)
+ {
+ if (_sInputURL.length() == 0)
+ {
+ return;
+ }
+
+ if (_xMSF == null)
+ {
+ GlobalLogWriter.println("MultiServiceFactory not set.");
+ return;
+ }
+ 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;
+ }
+ if (aTypeDetection != null)
+ {
+ String sType = aTypeDetection.queryTypeByURL(_sInputURL);
+ GlobalLogWriter.println("Type is: " + sType);
+ }
+ }
+
+
+ // -----------------------------------------------------------------------------
+ public String getInternalFilterName(String _sFilterName, XMultiServiceFactory _xMSF)
+ {
+ if (_sFilterName.length() == 0)
+ {
+ // System.out.println("No FilterName set.");
+ return null;
+ }
+
+ if (_xMSF == null)
+ {
+ GlobalLogWriter.println("MultiServiceFactory not set.");
+ return null;
+ }
+ // XFilterFactory aFilterFactory = 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 (_sFilterName.toLowerCase().equals("help"))
+ // {
+ // System.out.println("Show all possible ElementNames from current version." );
+ // String[] aElementNames = aNameAccess.getElementNames();
+ // for (int i = 0; i<aElementNames.length; i++)
+ // {
+ // System.out.println(aElementNames[i]);
+ // }
+ // System.out.println("Must quit.");
+ // System.out.exit(1);
+ // }
+
+ if (! aNameAccess.hasByName(_sFilterName))
+ {
+ GlobalLogWriter.println("FilterFactory.hasByName() says there exist no '" + _sFilterName + "'" );
+ return null;
+ }
+
+ Object[] aElements = null;
+ String[] aExtensions;
+ try
+ {
+ aElements = (Object[]) aNameAccess.getByName(_sFilterName);
+ if (aElements != null)
+ {
+ String sInternalFilterName = null;
+ // System.out.println("getByName().length: " + String.valueOf(aElements.length));
+ for (int i=0;i<aElements.length; i++)
+ {
+ PropertyValue aPropertyValue = (PropertyValue)aElements[i];
+ // System.out.println("PropertyValue.Name: " + aPropertyValue.Name);
+ if (aPropertyValue.Name.equals("Type"))
+ {
+ String sValue = (String)aPropertyValue.Value;
+ // System.out.println("Type: " + sValue);
+ 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;
+ }
+
+ // -----------------------------------------------------------------------------
+
+ String getServiceNameFromFilterName(String _sFilterName, XMultiServiceFactory _xMSF)
+ {
+ if (_sFilterName.length() == 0)
+ {
+ // System.out.println("No FilterName set.");
+ return null;
+ }
+
+ if (_xMSF == null)
+ {
+ GlobalLogWriter.println("MultiServiceFactory not set.");
+ return null;
+ }
+ // XFilterFactory aFilterFactory = 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;
+ String[] aExtensions;
+ try
+ {
+ aElements = (Object[]) aNameAccess.getByName(_sFilterName);
+ if (aElements != null)
+ {
+ String sServiceName = null;
+ // System.out.println("getByName().length: " + String.valueOf(aElements.length));
+ for (int i=0;i<aElements.length; i++)
+ {
+ PropertyValue aPropertyValue = (PropertyValue)aElements[i];
+ if (aPropertyValue.Name.equals("DocumentService"))
+ {
+ String sValue = (String)aPropertyValue.Value;
+ // System.out.println("DocumentService: " + sValue);
+ 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;
+ }
+ // -----------------------------------------------------------------------------
+
+ public static String getFileExtension(String _sInternalFilterName, XMultiServiceFactory _xMSF)
+ {
+ if (_sInternalFilterName.length() == 0)
+ {
+ // System.out.println("No FilterName set.");
+ 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)
+ {
+
+ // System.out.println("Show ElementNames" );
+ // String[] aElementNames = aNameAccess.getElementNames();
+ // for (int i = 0; i<aElementNames.length; i++)
+ // {
+ // System.out.println(aElementNames[i]);
+ // }
+
+ 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;
+ // System.out.println("getByName().length: " + String.valueOf(aElements.length));
+ for (int i=0;i<aElements.length; i++)
+ {
+ PropertyValue aPropertyValue = (PropertyValue)aElements[i];
+ // System.out.println("PropertyValue.Name: " + aPropertyValue.Name);
+ 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;
+ }
+
+ // -----------------------------------------------------------------------------
+ public void convertDocument(String _sInputFile, String _sOutputPath, ParameterHelper _aGTA) throws OfficeException
+ {
+ XMultiServiceFactory xMSF = _aGTA.getMultiServiceFactory();
+ if (xMSF == null)
+ {
+ GlobalLogWriter.println("MultiServiceFactory in GraphicalTestArgument not set.");
+ return;
+ }
+
+ String sInputURL = URLHelper.getFileURLFromSystemPath(_sInputFile);
+ // showType(sInputURL, xMSF);
+ XComponent aDoc = loadFromURL( _aGTA, sInputURL);
+ if (aDoc == null)
+ {
+ GlobalLogWriter.println("Can't load document '"+ sInputURL + "'");
+ return;
+ }
+
+ if (_sOutputPath == null)
+ {
+ GlobalLogWriter.println("Outputpath not set.");
+ return;
+ }
+
+ if (! isStoreAllowed())
+ {
+ GlobalLogWriter.println("It's not allowed to store, check Input/Output path.");
+ return;
+ }
+// TODO: Do we need to wait?
+// TimeHelper.waitInSeconds(1, "wait after loadFromURL.");
+
+ XServiceInfo xServiceInfo = UnoRuntime.queryInterface( XServiceInfo.class, aDoc );
+ // String sFilter = getFilterName_forExcel(xServiceInfo);
+ // System.out.println("Filter is " + sFilter);
+
+ // store the document in an other directory
+ XStorable xStorable = UnoRuntime.queryInterface( XStorable.class, aDoc);
+ if (xStorable == null)
+ {
+ GlobalLogWriter.println("com.sun.star.frame.XStorable is null");
+ return;
+ }
+
+ String sFilterName = _aGTA.getExportFilterName();
+
+ // check how many Properties should initialize
+ int nPropertyCount = 0;
+ // if (sFilterName != null && sFilterName.length() > 0)
+ // {
+ // nPropertyCount ++;
+ // }
+
+ // initialize PropertyArray
+ // PropertyValue [] aStoreProps = new PropertyValue[ nPropertyCount ];
+ // int nPropertyIndex = 0;
+ ArrayList<PropertyValue> aPropertyList = new ArrayList<PropertyValue>();
+
+ String sExtension = "";
+
+ if (sFilterName != null && sFilterName.length() > 0)
+ {
+ String sInternalFilterName = getInternalFilterName(sFilterName, xMSF);
+ String sServiceName = getServiceNameFromFilterName(sFilterName, xMSF);
+
+ GlobalLogWriter.println("Filter detection:");
+ // check if service name from file filter is the same as from the loaded document
+ boolean bServiceFailed = false;
+ if (sServiceName == null || sInternalFilterName == null)
+ {
+ GlobalLogWriter.println("Given FilterName '" + sFilterName + "' seems to be unknown.");
+ bServiceFailed = true;
+ }
+ if (! xServiceInfo.supportsService(sServiceName))
+ {
+ GlobalLogWriter.println("Service from FilterName '" + sServiceName + "' is not supported by loaded document.");
+ bServiceFailed = true;
+ }
+ if (bServiceFailed == true)
+ {
+ GlobalLogWriter.println("Please check '" + PropertyName.DOC_CONVERTER_EXPORT_FILTER_NAME + "' in the property file.");
+ return;
+ }
+
+ if (sInternalFilterName != null && sInternalFilterName.length() > 0)
+ {
+ // get the FileExtension, by the filter name, if we don't get a file extension
+ // we assume the is also no right filter name.
+ sExtension = getFileExtension(sInternalFilterName, xMSF);
+ if (sExtension == null)
+ {
+ GlobalLogWriter.println("Can't found an extension for filtername, take it from the source.");
+ }
+ }
+
+ PropertyValue Arg = new PropertyValue();
+ Arg.Name = "FilterName";
+ Arg.Value = sFilterName;
+ // aStoreProps[nPropertyIndex ++] = Arg;
+ aPropertyList.add(Arg);
+ showProperty(Arg);
+ GlobalLogWriter.println("FilterName is set to: " + sFilterName);
+ }
+
+ String sOutputURL = "";
+ try
+ {
+ // create the new filename with the extension, which is ok to the file format
+ String sInputFileBasename = FileHelper.getBasename(_sInputFile);
+ // System.out.println("InputFileBasename " + sInputFileBasename);
+ String sInputFileNameNoSuffix = FileHelper.getNameNoSuffix(sInputFileBasename);
+ // System.out.println("InputFilename no suffix " + sInputFileNameNoSuffix);
+ String fs = System.getProperty("file.separator");
+ String sOutputFile = _sOutputPath;
+ if (! sOutputFile.endsWith(fs))
+ {
+ sOutputFile += fs;
+ }
+ if (sExtension != null && sExtension.length() > 0)
+ {
+ sOutputFile += sInputFileNameNoSuffix + "." + sExtension;
+ }
+ else
+ {
+ sOutputFile += sInputFileBasename;
+ }
+
+ if (FileHelper.exists(sOutputFile) && _aGTA.getOverwrite() == false)
+ {
+ GlobalLogWriter.println("File already exist, don't overwrite. Set " + PropertyName.DOC_COMPARATOR_OVERWRITE_REFERENCE + "=true to force overwrite.");
+ return;
+ }
+
+ sOutputURL = URLHelper.getFileURLFromSystemPath(sOutputFile);
+
+ GlobalLogWriter.println("Store document as '" + sOutputURL + "'");
+ xStorable.storeAsURL(sOutputURL, PropertyHelper.createPropertyValueArrayFormArrayList(aPropertyList));
+ GlobalLogWriter.println("Document stored.");
+ }
+ catch (com.sun.star.io.IOException e)
+ {
+ GlobalLogWriter.println("Can't store document '" + sOutputURL + "'. Message is :'" + e.getMessage() + "'");
+ }
+// TODO: Do we need to wait?
+// TimeHelper.waitInSeconds(1, "unknown in OfficePrint.convertDocument()");
+
+ }
+
+ /**
+ *
+ * @return false, if 'NoOffice=yes' is given
+ */
+// private boolean shouldOfficeStart()
+// {
+// String sNoOffice = (String)m_aParameterHelper.getTestParameters().get( "NoOffice" );
+// if (sNoOffice != null)
+// {
+// if (sNoOffice.toLowerCase().startsWith("t") || sNoOffice.toLowerCase().startsWith("y"))
+// {
+// return false;
+// }
+// }
+// return true;
+// }
+
+ OfficeProvider m_aProvider = null;
+ private void startOffice()
+ {
+ // SimpleFileSemaphore aSemaphore = new SimpleFileSemaphore();
+// if (shouldOfficeStart())
+// {
+ // if (OSHelper.isWindows())
+ // {
+ // aSemaphore.P(aSemaphore.getSemaphoreFile());
+ // }
+ m_aParameterHelper.getTestParameters().put(util.PropertyName.DONT_BACKUP_USERLAYER, Boolean.TRUE);
+
+ m_aParameterHelper.getPerformance().startTime(PerformanceContainer.OfficeStart);
+ m_aProvider = new OfficeProvider();
+ XMultiServiceFactory xMSF = (XMultiServiceFactory) m_aProvider.getManager(m_aParameterHelper.getTestParameters());
+ m_aParameterHelper.getTestParameters().put("ServiceFactory", xMSF);
+ m_aParameterHelper.getPerformance().stopTime(PerformanceContainer.OfficeStart);
+
+ long nStartTime = m_aParameterHelper.getPerformance().getTime(PerformanceContainer.OfficeStart);
+ // aGTA = getParameterHelper(); // get new TestArguments
+ m_aParameterHelper.getPerformance().setTime(PerformanceContainer.OfficeStart, nStartTime);
+// }
+
+ // Watcher Object is need in log object to give a simple way to say if a running office is alive.
+ // As long as a log comes, it pings the Watcher and says the office is alive, if not an
+ // internal counter increase and at a given point (300 seconds) the office is killed.
+ GlobalLogWriter.println("Set office watcher");
+ if (GlobalLogWriter.get().getWatcher() == null)
+ {
+ OfficeWatcher aWatcher = (OfficeWatcher)m_aParameterHelper.getTestParameters().get("Watcher");
+ GlobalLogWriter.get().setWatcher(aWatcher);
+ }
+ }
+
+ private void stopOffice()
+ {
+ // Office shutdown
+ if (m_aProvider != null)
+ {
+ String sAppExecCmd = (String)m_aParameterHelper.getTestParameters().get("AppExecutionCommand");
+ if (sAppExecCmd != null && sAppExecCmd.length() > 0)
+ {
+ m_aProvider.closeExistingOffice(m_aParameterHelper.getTestParameters(), true);
+ }
+ // if (OSHelper.isWindows())
+ // {
+ // aSemaphore.V(aSemaphore.getSemaphoreFile());
+ // aSemaphore.sleep(2);
+ // // wait some time maybe an other process will take the semaphore
+ // // I know, this is absolutly dirty, but the whole convwatch is dirty and need a big cleanup.
+ // }
+ }
+ }
+
+ private boolean m_bStoreFile;
+ public void disallowStore()
+ {
+ m_bStoreFile = false;
+ }
+ public void allowStore()
+ {
+ m_bStoreFile = true;
+ }
+ public boolean isStoreAllowed()
+ {
+ return false;
+ // return m_bStoreFile;
+ }
+
+}
+
diff --git a/qadevOOo/runner/graphical/ParameterHelper.java b/qadevOOo/runner/graphical/ParameterHelper.java
new file mode 100644
index 000000000000..598ee6c53007
--- /dev/null
+++ b/qadevOOo/runner/graphical/ParameterHelper.java
@@ -0,0 +1,433 @@
+/*
+ * ************************************************************************
+ *
+ * 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
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ * ***********************************************************************
+ */
+
+package graphical;
+
+import com.sun.star.lang.XMultiServiceFactory;
+import lib.TestParameters;
+
+/**
+ * This class object is more a Helper or Controller.
+ * It stores information like:
+ * - How to create a document (with a OpenOffice.org method, or with MS Word, or with OpenOffice.org as pdf)
+ * - some more infos for OpenOffice.org method
+ * - a service factory pointer
+ * - if hidden mode should use
+ * - target name
+ *
+ * - printer name
+ *
+ * - how to handle .xml files, which in Microsoft could be Excel or Word documents
+ *
+ * HOWTO USE:
+ * For OOo,
+ * create an ParameterHelper with a set of TestParameters
+ * ParameterHelper a = new ParameterHelper(params);
+ *
+ * If you wish to use pdf export instead of normal printer output, set also the reference type to 'pdf'
+ * a.setReferenceType("pdf");
+ *
+ *
+ * For MS Office:
+ * create a ParameterHelper and set the reference type to 'msoffice'
+ * ParameterHelper a = new ParameterHelper(params);
+ * a.setReferenceType("msoffice");
+ *
+ * within windows it's better to set also a printer name so it's simply possible to use for normal work the default printer
+ * and for such tests with ConvWatch a extra printer.
+ * a.setPrinterName("CrossOffice Printer");
+ *
+ */
+
+public class ParameterHelper
+{
+ /*
+ TODO:
+ Possible reference types are currently
+ // ooo
+ // pdf
+ // msoffice
+ */
+ private String m_sReferenceType = null;
+
+ // private String m_sTargetFrameName = "_blank";
+
+ private String m_sPrinterName = null;
+
+ private int m_nResolutionInDPI = 180;
+
+ private boolean m_bIncludeSubdirectories;
+
+ private String m_sInputPath = null;
+ private String m_sOutputPath = null;
+// private String m_sReferencePath = null;
+
+ private TestParameters m_aCurrentParams;
+
+ // private GlobalLogWriter m_aLog;
+
+ // CONSTRUCTOR
+ private ParameterHelper(){}
+
+ public ParameterHelper(TestParameters param)
+ {
+ m_aCurrentParams = param;
+ // m_aLog = log;
+ // interpretReferenceType();
+ // interpretPrinterName();
+ }
+
+
+ protected TestParameters getTestParameters()
+ {
+ return m_aCurrentParams;
+ }
+
+ /**
+ * return the input path, if given.
+ * @return
+ */
+ public String getInputPath()
+ {
+ if (m_sInputPath == null)
+ {
+ String sInputPath = (String)getTestParameters().get( PropertyName.DOC_COMPARATOR_INPUT_PATH );
+ if (sInputPath == null || sInputPath.length() == 0)
+ {
+ GlobalLogWriter.println("Please set input path (path to documents) " + PropertyName.DOC_COMPARATOR_INPUT_PATH + "=path.");
+ }
+ else
+ {
+ m_sInputPath = helper.StringHelper.removeQuoteIfExists(sInputPath);
+ }
+ }
+ return m_sInputPath;
+ }
+
+ public String getOutputPath()
+ {
+ if (m_sOutputPath == null)
+ {
+ String sOutputPath = (String)getTestParameters().get( PropertyName.DOC_COMPARATOR_OUTPUT_PATH );
+ if (sOutputPath == null || sOutputPath.length() == 0)
+ {
+ GlobalLogWriter.println("Please set output path (path where to store document results) " + PropertyName.DOC_COMPARATOR_OUTPUT_PATH + "=path.");
+ }
+ else
+ {
+ m_sOutputPath = helper.StringHelper.removeQuoteIfExists(sOutputPath);
+ }
+ }
+ return m_sOutputPath;
+ }
+
+// public String getReferencePath()
+// {
+// if (m_sReferencePath == null)
+// {
+// String sReferencePath = (String)getTestParameters().get( PropertyName.DOC_COMPARATOR_REFERENCE_PATH );
+// if (sReferencePath == null || sReferencePath.length() == 0)
+// {
+// GlobalLogWriter.println("Please set reference path (path to reference documents) " + PropertyName.DOC_COMPARATOR_REFERENCE_PATH + "=path.");
+// }
+// else
+// {
+// m_sReferencePath = sReferencePath;
+// }
+// }
+// return m_sReferencePath;
+// }
+
+
+ public boolean isIncludeSubDirectories()
+ {
+ m_bIncludeSubdirectories = true;
+ String sRECURSIVE = (String)getTestParameters().get( PropertyName.DOC_COMPARATOR_INCLUDE_SUBDIRS );
+// TODO: I need to get the boolean value with get("name") because, if it is not given getBool() returns
+// with a default of 'false' which is not very helpful if the default should be 'true'
+// maybe a getBoolean("name", true) could be a better choise.
+ if (sRECURSIVE == null)
+ {
+ sRECURSIVE = "true";
+ }
+ if (sRECURSIVE.toLowerCase().equals("no") ||
+ sRECURSIVE.toLowerCase().equals("false"))
+ {
+ m_bIncludeSubdirectories = false;
+ }
+ return m_bIncludeSubdirectories;
+ }
+
+ public String getReferenceType()
+ {
+ if (m_sReferenceType == null)
+ {
+ // REFERENCE_TYPE ----------
+
+ String sReferenceType = (String)getTestParameters().get( PropertyName.DOC_COMPARATOR_REFERENCE_TYPE );
+ if (sReferenceType == null || sReferenceType.length() == 0)
+ {
+ m_sReferenceType = "ps";
+ }
+ else
+ {
+ // log.println("found REFERENCE_TYPE " + sReferenceType );
+ m_sReferenceType = sReferenceType;
+ }
+ }
+ return m_sReferenceType;
+ }
+
+ public String getPrinterName()
+ {
+ if (m_sPrinterName == null)
+ {
+ // PRINTER_NAME ----------
+
+ String sPrinterName = (String)getTestParameters().get( PropertyName.DOC_COMPARATOR_PRINTER_NAME );
+ if (sPrinterName == null || sPrinterName.length() == 0)
+ {
+ m_sPrinterName = "";
+ }
+ else
+ {
+ // log.println("found PRINTER_NAME " + sPrinterName );
+ m_sPrinterName = sPrinterName;
+ }
+ }
+ return m_sPrinterName;
+ }
+
+ PerformanceContainer m_aPerformanceContainer = null;
+ /**
+ * helper class for performance analyser features
+ * @return
+ */
+ public PerformanceContainer getPerformance()
+ {
+ if (m_aPerformanceContainer == null)
+ {
+ m_aPerformanceContainer = new PerformanceContainer();
+ }
+ return m_aPerformanceContainer;
+ }
+
+ /**
+ * Helper function to get the buildid of the current used OpenOffice.org
+ * out of the AppExecutionCommand the build ID
+ * @return
+ */
+ public String getBuildID()
+ {
+ String sAPP = (String)m_aCurrentParams.get(util.PropertyName.APP_EXECUTION_COMMAND);
+ // return getBuildID(sAPP);
+// TODO: here we need the getBuildID(string) method
+ String sBuildID = BuildID.getBuildID(sAPP);
+ return sBuildID;
+ }
+
+ /**
+ * @return integer value, which contain resolution in DPI.
+ */
+ public int getResolutionInDPI()
+ {
+ return m_nResolutionInDPI;
+ }
+ // get methods
+ public XMultiServiceFactory getMultiServiceFactory()
+ {
+ XMultiServiceFactory xMSF = (XMultiServiceFactory)m_aCurrentParams.getMSF();
+
+ // check if MultiServiceFactory is given
+ if (getReferenceType().toLowerCase().equals("pdf") ||
+ getReferenceType().toLowerCase().equals("ps") ||
+ getReferenceType().toLowerCase().equals("ooo"))
+ {
+ if (xMSF == null)
+ {
+ GlobalLogWriter.println("ERROR! MultiServiceFactory not given.");
+ }
+ }
+ return xMSF;
+ }
+
+ // Hidden = true hiddes a used OpenOffice.org, all code is executed in the background
+ // This parameter is not used for RefType: msoffice
+ // boolean m_bHidden = true;
+
+
+ public boolean isHidden()
+ {
+ // HIDDEN
+
+ String sOfficeViewable = (String)m_aCurrentParams.get(PropertyName.OFFICE_VIEWABLE);
+ if (sOfficeViewable != null)
+ {
+ if (sOfficeViewable.toLowerCase().equals("yes") ||
+ sOfficeViewable.toLowerCase().equals("true"))
+ {
+ return false; // setViewable();
+ }
+ else
+ {
+ return true; // setHidden();
+ }
+ }
+ return true; /* default: hidden */
+ }
+
+ // get/set for FilterName
+ // get the right Filtername (internal Name) from
+ // http://framework.openoffice.org/files/documents/25/897/filter_description.html
+
+ String m_sImportFilterName = "";
+ String m_sExportFilterName = "";
+ public void setImportFilterName(String _sImportFilterName)
+ {
+ m_sImportFilterName = _sImportFilterName;
+ }
+ public String getImportFilterName()
+ {
+ return m_sImportFilterName;
+ }
+ public void setExportFilterName(String _sExportFilterName)
+ {
+ m_sExportFilterName = _sExportFilterName;
+ }
+ public String getExportFilterName()
+ {
+ return m_sExportFilterName;
+ }
+ String m_sDocumentType = "";
+ public void setDocumentType(String _sName)
+ {
+ m_sDocumentType = _sName;
+ }
+ public String getDocumentType()
+ {
+ return m_sDocumentType;
+ }
+
+
+// String m_sDefaultXMLFormatApplication = null;
+// public String getDefaultXMLFormatApp()
+// {
+// if (m_sDefaultXMLFormatApplication == null)
+// {
+// // DEFAULT_XML_FORMAT_APP ------
+//
+// String sDefaultXMLFormatApp = (String)m_aCurrentParams.get( PropertyName.DOC_COMPARATOR_DEFAULT_XML_FORMAT_APP );
+// if (sDefaultXMLFormatApp == null || sDefaultXMLFormatApp.length() == 0)
+// {
+// m_sDefaultXMLFormatApplication = "word";
+// }
+// else
+// {
+// m_sDefaultXMLFormatApplication = sDefaultXMLFormatApp;
+// }
+// }
+// return m_sDefaultXMLFormatApplication;
+// }
+
+
+ // Pages -------------------------------------------------------------------
+
+ /**
+ * @return the number of pages to be print
+ */
+ public int getMaxPages()
+ {
+ // default is 0 (print all pages)
+ int nMaxPages = m_aCurrentParams.getInt( PropertyName.DOC_COMPARATOR_PRINT_MAX_PAGE );
+ return nMaxPages;
+ }
+
+ /**
+ * @return as string, which pages should be print, e.g. '1-4;6' here, page 1 to 4 and page 6.
+ */
+ public String getOnlyPages()
+ {
+ // default is null, there is no page which we want to print only.
+ String sOnlyPage = (String)m_aCurrentParams.get(PropertyName.DOC_COMPARATOR_PRINT_ONLY_PAGE);
+ if (sOnlyPage == null)
+ {
+ sOnlyPage = "";
+ }
+ return sOnlyPage;
+ }
+
+ /**
+ * @return true, if there should not print all pages at all, use getMaxPages() and or getOnlyPages() to get which pages to print
+ */
+ public boolean printAllPages()
+ {
+ if ( (getMaxPages() > 0) ||
+ (getOnlyPages().length() != 0))
+ {
+ return false;
+ }
+ return true;
+ }
+
+ public boolean getOverwrite()
+ {
+ boolean bOverwrite = m_aCurrentParams.getBool( PropertyName.DOC_COMPARATOR_OVERWRITE_REFERENCE);
+ return bOverwrite;
+ }
+
+ private String m_sHTMLPrefix = null;
+ public String getHTMLPrefix()
+ {
+ if (m_sHTMLPrefix == null)
+ {
+ String sPrefix = (String)getTestParameters().get( PropertyName.DOC_COMPARATOR_HTML_OUTPUT_PREFIX );
+ if (sPrefix == null || sPrefix.length() == 0)
+ {
+ GlobalLogWriter.println("Please set html prefix " + PropertyName.DOC_COMPARATOR_HTML_OUTPUT_PREFIX + "=prefix.");
+ }
+ else
+ {
+ m_sHTMLPrefix = sPrefix;
+ }
+ }
+ return m_sHTMLPrefix;
+ }
+
+ public boolean createSmallPictures()
+ {
+ // boolean bCreateSmallPictures = true;
+ boolean bNoSmallPictures = m_aCurrentParams.getBool( PropertyName.NO_SMALL_PICTURES);
+ if (bNoSmallPictures == true)
+ {
+ return false;
+ }
+ return true;
+ }
+
+}
diff --git a/qadevOOo/runner/graphical/PerformanceContainer.java b/qadevOOo/runner/graphical/PerformanceContainer.java
new file mode 100644
index 000000000000..ab3b292926e5
--- /dev/null
+++ b/qadevOOo/runner/graphical/PerformanceContainer.java
@@ -0,0 +1,271 @@
+/*************************************************************************
+ *
+ * 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
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package graphical;
+
+import java.io.File;
+// import java.io.FileWriter;
+// import java.io.OutputStream;
+// import java.io.PrintStream;
+import java.io.PrintStream;
+import java.io.RandomAccessFile;
+// import java.io.StringWriter;
+// import java.lang.Double;
+
+
+public class PerformanceContainer /* extends *//* implements */ {
+ private long m_nStartTime;
+
+ /*
+ simple helper functions to start/stop a timer, to know how long a process need in milliseconds
+ */
+ public long getStartTime()
+ {
+ return System.currentTimeMillis();
+ }
+ public void setStartTime(long _nStartTime)
+ {
+ m_nStartTime = _nStartTime;
+ }
+
+ /*
+ return the time, which is done until last startTime()
+ */
+ private long meanTime(long _nCurrentTimer)
+ {
+ if (_nCurrentTimer == 0)
+ {
+ GlobalLogWriter.println("Forgotten to initialise a start timer.");
+ return 0;
+ }
+ long nMeanTime = System.currentTimeMillis();
+ return nMeanTime - _nCurrentTimer;
+ }
+
+ /*
+ public long stopTimer()
+ {
+ if (m_nStartTime == 0)
+ {
+ System.out.println("Forgotten to initialise start timer.");
+ return 0;
+ }
+ long nStopTime = System.currentTimeMillis();
+ return nStopTime - m_nStartTime;
+ }
+ */
+
+ final static int Load = 0;
+ final static int Store = 1;
+ final static int Print = 2;
+ final static int OfficeStart = 3;
+ final static int StoreAsPDF = 4;
+ final static int OfficeStop = 5;
+ final static int AllTime = 6;
+ final static int LAST_VALUE = 7; // THIS MUST BE ALWAYS THE LAST AND THE BIGGEST VALUE!
+
+ private long m_nTime[];
+ private String m_sMSOfficeVersion;
+
+ public PerformanceContainer()
+ {
+ m_nTime = new long[LAST_VALUE];
+ // @todo: is this need?
+ for (int i=0;i<LAST_VALUE;i++)
+ {
+ m_nTime[i] = 0;
+ }
+ }
+
+ public void setTime(int _nIndex, long _nValue)
+ {
+ m_nTime[_nIndex] = _nValue;
+ }
+ public long getTime(int _nIndex)
+ {
+ return m_nTime[_nIndex];
+ }
+
+ public void startTime(int _nIndex)
+ {
+ m_nTime[_nIndex] = getStartTime();
+ }
+
+ public void stopTime(int _nIndex)
+ {
+ m_nTime[_nIndex] = meanTime(m_nTime[_nIndex]);
+ }
+
+ public String getMSOfficeVersion()
+ {
+ return m_sMSOfficeVersion;
+ }
+
+ public void print(PrintStream out)
+ {
+ // String ls = System.getProperty("line.separator");
+ // out.
+ out.println("loadtime=" + String.valueOf(m_nTime[ Load ]));
+ out.println("storetime=" + String.valueOf(m_nTime[ Store ]));
+ out.println("printtime=" + String.valueOf(m_nTime[ Print ]));
+ out.println("officestarttime=" + String.valueOf(m_nTime[ OfficeStart ]));
+ out.println("officestoptime=" + String.valueOf(m_nTime[ OfficeStop ]));
+ out.println("storeaspdftime=" + String.valueOf(m_nTime[ StoreAsPDF ]));
+ out.println("alltime=" + String.valueOf(m_nTime[ AllTime ]));
+ }
+
+ public void print(IniFile _aIniFile, String _sSection)
+ {
+ // String ls = System.getProperty("line.separator");
+ // out.
+ _aIniFile.insertValue(_sSection, "loadtime" , String.valueOf(m_nTime[ Load ]));
+ _aIniFile.insertValue(_sSection, "storetime" , String.valueOf(m_nTime[ Store ]));
+ _aIniFile.insertValue(_sSection, "printtime" , String.valueOf(m_nTime[ Print ]));
+ _aIniFile.insertValue(_sSection, "officestarttime" , String.valueOf(m_nTime[ OfficeStart ]));
+ _aIniFile.insertValue(_sSection, "officestoptime" , String.valueOf(m_nTime[ OfficeStop ]));
+ _aIniFile.insertValue(_sSection, "storeaspdftime" , String.valueOf(m_nTime[ StoreAsPDF ]));
+ _aIniFile.insertValue(_sSection, "alltime" , String.valueOf(m_nTime[ AllTime ]));
+ }
+
+ public static double stringToDouble(String _sStr)
+ {
+ double nValue = 0;
+ try
+ {
+ nValue = Double.parseDouble( _sStr );
+ }
+ catch (NumberFormatException e)
+ {
+ GlobalLogWriter.println("Can't convert string to double " + _sStr);
+ }
+ return nValue;
+ }
+
+ public static long secondsToMilliSeconds(double _nSeconds)
+ {
+ return (long)(_nSeconds * 1000.0);
+ }
+
+ /*
+ Helper function, which read some values from a given file
+
+ sample of wordinfofile
+ name=c:\doc-pool\wntmsci\samples\msoffice\word\LineSpacing.doc
+ WordVersion=11.0
+ WordStartTime=0.340490102767944
+ WordLoadTime=0.650935888290405
+ WordPrintTime=0.580835103988647
+ */
+ public void readWordValuesFromFile(String sFilename)
+ {
+ File aFile = new File(sFilename);
+ if (! aFile.exists())
+ {
+ GlobalLogWriter.println("couldn't find file " + sFilename);
+ return;
+ }
+
+ RandomAccessFile aRandomAccessFile = null;
+ try
+ {
+ aRandomAccessFile = new RandomAccessFile(aFile,"r");
+ String sLine = "";
+ while (sLine != null)
+ {
+ sLine = aRandomAccessFile.readLine();
+ if ( (sLine != null) &&
+ (! (sLine.length() < 2) ) &&
+ (! sLine.startsWith("#")))
+ {
+ if (sLine.startsWith("WordStartTime="))
+ {
+ String sTime = sLine.substring(14);
+ m_nTime[OfficeStart] = secondsToMilliSeconds(stringToDouble(sTime));
+ }
+ else if (sLine.startsWith("WordLoadTime="))
+ {
+ String sTime = sLine.substring(13);
+ m_nTime[Load] = secondsToMilliSeconds(stringToDouble(sTime));
+ }
+ else if (sLine.startsWith("WordPrintTime="))
+ {
+ String sTime = sLine.substring(14);
+ m_nTime[Print] = secondsToMilliSeconds(stringToDouble(sTime));
+ }
+ else if (sLine.startsWith("WordVersion="))
+ {
+ String sMSOfficeVersion = sLine.substring(12);
+ m_sMSOfficeVersion = "Word:" + sMSOfficeVersion;
+ }
+ else if (sLine.startsWith("ExcelVersion="))
+ {
+ String sMSOfficeVersion = sLine.substring(13);
+ m_sMSOfficeVersion = "Excel:" + sMSOfficeVersion;
+ }
+ else if (sLine.startsWith("PowerPointVersion="))
+ {
+ String sMSOfficeVersion = sLine.substring(18);
+ m_sMSOfficeVersion = "PowerPoint:" + sMSOfficeVersion;
+ }
+ }
+ }
+ }
+ catch (java.io.FileNotFoundException fne)
+ {
+ GlobalLogWriter.println("couldn't open file " + sFilename);
+ GlobalLogWriter.println("Message: " + fne.getMessage());
+ }
+ catch (java.io.IOException ie)
+ {
+ GlobalLogWriter.println("Exception while reading file " + sFilename);
+ GlobalLogWriter.println("Message: " + ie.getMessage());
+ }
+ try
+ {
+ aRandomAccessFile.close();
+ }
+ catch (java.io.IOException ie)
+ {
+ GlobalLogWriter.println("Couldn't close file " + sFilename);
+ GlobalLogWriter.println("Message: " + ie.getMessage());
+ }
+ }
+
+// public static void main(String[] args)
+// {
+// BorderRemover a = new BorderRemover();
+// try
+// {
+// a.createNewImageWithoutBorder(args[0], args[1]);
+// }
+// catch(java.io.IOException e)
+// {
+// System.out.println("Exception caught.");
+// }
+//
+// }
+}
diff --git a/qadevOOo/runner/graphical/PixelCounter.java b/qadevOOo/runner/graphical/PixelCounter.java
new file mode 100644
index 000000000000..e625c2a75b12
--- /dev/null
+++ b/qadevOOo/runner/graphical/PixelCounter.java
@@ -0,0 +1,247 @@
+/*************************************************************************
+ *
+ * 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
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package graphical;
+
+
+// -----------------------------------------------------------------------------
+abstract class CountPixel
+{
+ protected int m_nCount = 0;
+ public int getCount() {return m_nCount;}
+ public abstract void count(int _nRGB);
+}
+
+// -----------------------------------------------------------------------------
+class CountNotWhite extends CountPixel
+{
+ public CountNotWhite()
+ {
+ // System.out.println("CountWhite()");
+ }
+
+ public void countold(final int pixel)
+ {
+ // final int alpha = (pixel >> 24) & 0xff;
+ final int red = (pixel >> 16) & 0xff;
+ final int green = (pixel >> 8) & 0xff;
+ final int blue = (pixel ) & 0xff;
+
+ // System.out.println(String.valueOf(red) + ":" + String.valueOf(green) + ":" + String.valueOf(blue));
+ if (red == 0xff && green == 0xff && blue == 0xff)
+ {
+ return;
+ }
+ ++m_nCount;
+ }
+ public void count(final int pixel)
+ {
+ // final int alpha = (pixel >> 24) & 0xff;
+ final int blue = (pixel ) & 0xff;
+ if (blue != 0xff)
+ {
+ ++m_nCount;
+ return;
+ }
+ final int green = (pixel >> 8) & 0xff;
+ if (green != 0xff)
+ {
+ ++m_nCount;
+ return;
+ }
+ final int red = (pixel >> 16) & 0xff;
+ if (red != 0xff)
+ {
+ ++m_nCount;
+ return;
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+class CountNotBlack extends CountPixel
+{
+ public CountNotBlack()
+ {
+ // System.out.println("CountBlack()");
+ }
+
+ public void countold(final int pixel)
+ {
+ // final int alpha = (pixel >> 24) & 0xff;
+ final int red = (pixel >> 16) & 0xff;
+ final int green = (pixel >> 8) & 0xff;
+ final int blue = (pixel ) & 0xff;
+
+ if (red == 0x00 && green == 0x00 && blue == 0x00)
+ {
+ return;
+ }
+ ++m_nCount;
+ }
+ public void count(final int pixel)
+ {
+ // final int alpha = (pixel >> 24) & 0xff;
+ final int blue = (pixel ) & 0xff;
+ if (blue != 0x00)
+ {
+ ++m_nCount;
+ return;
+ }
+ final int green = (pixel >> 8) & 0xff;
+ if (green != 0x00)
+ {
+ ++m_nCount;
+ return;
+ }
+ final int red = (pixel >> 16) & 0xff;
+ if (red != 0x00)
+ {
+ ++m_nCount;
+ return;
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+class graphics_stuff
+{
+// public int stuff()
+// {
+//// (1) decoding
+// int rgba = 0; // ...; // comes from PixelGrabber, BufferedImage.getRGB etc.
+// int red = (rgba >> 16) & 0xff;
+// int green = (rgba >> 8) & 0xff;
+// int blue = rgba & 0xff;
+// int alpha = (rgba >> 24) & 0xff;
+//// (2) now modify red, green, blue and alpha as you like;
+//// make sure that each of the four values stays in the
+//// interval 0 to 255
+//// ...
+//// (3) and encode back to an int, e.g. to give it to MemoryImageSource or
+//// BufferedImage.setRGB
+// rgba = (alpha << 24) | (red << 16) | (green << 8) | blue;
+// return 0;
+// }
+
+// public static void handlesinglepixel(int x, int y, int pixel)
+// {
+// int alpha = (pixel >> 24) & 0xff;
+// int red = (pixel >> 16) & 0xff;
+// int green = (pixel >> 8) & 0xff;
+// int blue = (pixel ) & 0xff;
+// // Deal with the pixel as necessary...
+// }
+
+ public static void countPixel(ImageHelper img, int _x, int _y, int _w, int _h, CountPixel _aPixelCounter)
+ {
+ for (int y = 0; y < _h; y++) {
+ for (int x = 0; x < _w; x++) {
+ // handlesinglepixel(x+i, y+j, pixels[j * w + i]);
+ _aPixelCounter.count(img.getPixel(x,y));
+ }
+ }
+ }
+ public static int countNotWhitePixel(ImageHelper _aImage)
+ {
+ final int w = _aImage.getWidth();
+ final int h = _aImage.getHeight();
+
+ CountPixel aCountNotWhite = new CountNotWhite();
+ countPixel(_aImage, 0, 0, w, h, aCountNotWhite);
+ return aCountNotWhite.getCount();
+ }
+
+ public static int countNotBlackPixel(ImageHelper _aImage)
+ {
+ final int w = _aImage.getWidth();
+ final int h = _aImage.getHeight();
+
+ CountPixel aCountNotBlack = new CountNotBlack();
+ countPixel(_aImage, 0, 0, w, h, aCountNotBlack);
+ return aCountNotBlack.getCount();
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+public class PixelCounter {
+ // private Image m_aImage;
+ // ImageHelper m_aImage;
+
+
+ public int countNotWhitePixel(String _sFile)
+ throws java.io.IOException
+ {
+ ImageHelper aImage = ImageHelper.createImageHelper(_sFile);
+ final int nw = graphics_stuff.countNotWhitePixel(aImage);
+ return nw;
+ }
+
+ public int countNotBlackPixel(String _sFile)
+ throws java.io.IOException
+ {
+ ImageHelper aImage = ImageHelper.createImageHelper(_sFile);
+ final int nw = graphics_stuff.countNotBlackPixel(aImage);
+ return nw;
+ }
+
+ public static int countNotWhitePixelsFromImage(String _sFile)
+ throws java.io.IOException
+ {
+ PixelCounter a = new PixelCounter();
+ return a.countNotWhitePixel(_sFile);
+ }
+
+ public static int countNotBlackPixelsFromImage(String _sFile)
+ throws java.io.IOException
+ {
+ PixelCounter a = new PixelCounter();
+ return a.countNotBlackPixel(_sFile);
+ }
+
+ // -----------------------------------------------------------------------------
+
+// public static void main(String[] args) {
+//
+// String a = helper.StringHelper.createValueString(10, 4);
+// int dummy = 1;
+///*
+// BorderRemover a = new BorderRemover();
+// try
+// {
+// a.createNewImageWithoutBorder(args[0], args[1]);
+// }
+// catch(java.io.IOException e)
+// {
+// System.out.println("Exception caught.");
+// }
+// */
+// }
+}
+
+
diff --git a/qadevOOo/runner/graphical/PostscriptCreator.java b/qadevOOo/runner/graphical/PostscriptCreator.java
new file mode 100644
index 000000000000..ab7ad4536fa6
--- /dev/null
+++ b/qadevOOo/runner/graphical/PostscriptCreator.java
@@ -0,0 +1,137 @@
+/*
+ * ************************************************************************
+ *
+ * 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
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ * ***********************************************************************
+ */
+
+package graphical;
+
+
+/**
+ *
+ * @author ll93751
+ */
+public class PostscriptCreator extends EnhancedComplexTestCase
+{
+
+ // @Override
+ public String[] getTestMethodNames()
+ {
+ return new String[]{"DocumentToPostscript"};
+ }
+
+ /**
+ * test function.
+ */
+ public void DocumentToPostscript()
+ {
+ GlobalLogWriter.set(log);
+ ParameterHelper aParam = new ParameterHelper(param);
+
+ param.put(util.PropertyName.OFFICE_CLOSE_TIME_OUT, 2000);
+ // run through all documents found in Inputpath
+ foreachDocumentinInputPath(aParam);
+ }
+
+
+ public void checkOneFile(String _sDocumentName, String _sResult, ParameterHelper _aParams) throws OfficeException
+ {
+ GlobalLogWriter.println("Document: " + _sDocumentName + " results: " + _sResult);
+ IOffice aOffice = new Office(_aParams, _sResult);
+
+ PerformanceContainer a = new PerformanceContainer();
+ a.startTime(PerformanceContainer.AllTime);
+
+ // _aParams.getTestParameters().put(util.PropertyName.DEBUG_IS_ACTIVE, Boolean.TRUE);
+ a.startTime(PerformanceContainer.OfficeStart);
+ aOffice.start();
+ a.stopTime(PerformanceContainer.OfficeStart);
+
+ // _aParams.getTestParameters().put(util.PropertyName.DEBUG_IS_ACTIVE, Boolean.FALSE);
+
+ // This force an error! _sDocumentName = helper.StringHelper.doubleQuote(_sDocumentName);
+ try
+ {
+ a.startTime(PerformanceContainer.Load);
+ aOffice.load(_sDocumentName);
+ a.stopTime(PerformanceContainer.Load);
+
+ a.startTime(PerformanceContainer.Print);
+ aOffice.storeAsPostscript();
+ a.stopTime(PerformanceContainer.Print);
+ }
+ finally
+ {
+ a.startTime(PerformanceContainer.OfficeStop);
+ aOffice.close();
+ a.stopTime(PerformanceContainer.OfficeStop);
+
+ a.stopTime(PerformanceContainer.AllTime);
+
+ a.print( System.out );
+ }
+ }
+
+
+
+
+// public static void main(String [] _args)
+// {
+// String args[] = {
+// "-TimeOut", "3600000",
+// "-tb", "java_complex",
+// "-o", "graphical.PostscriptCreator",
+//// "-DOC_COMPARATOR_INPUT_PATH", "D:\\temp\\input",
+//// "-DOC_COMPARATOR_OUTPUT_PATH", "D:\\temp\\output",
+//// "-DOC_COMPARATOR_REFERENCE_PATH", "D:\\temp\\output\\ref",
+//// "-DOC_COMPARATOR_PRINT_MAX_PAGE", "9999",
+//// "-DOC_COMPARATOR_GFX_OUTPUT_DPI_RESOLUTION", "180",
+//// "-DOC_COMPARATOR_HTML_OUTPUT_PREFIX", "http://so-gfxcmp-lin.germany.sun.com/gfxcmp_ui/cw.php?inifile=",
+////// "-DOC_COMPARATOR_REFERENCE_CREATOR_TYPE", "PDF", /* default: "OOo" */
+////// "-DOC_COMPARATOR_REFERENCE_CREATOR_TYPE", "msoffice", /* default: "OOo" */
+////// "-OFFICE_VIEWABLE", "false",
+//// "-AppExecutionCommand", "\"C:/home/ll93751/staroffice9_DEV300_m25/Sun/StarOffice 9/program/soffice.exe\" -norestore -nocrashreport -accept=pipe,name=ll93751;urp;",
+////// "-NoOffice"
+// "-DOC_COMPARATOR_PRINT_MAX_PAGE","9999",
+// "-DOC_COMPARATOR_GFX_OUTPUT_DPI_RESOLUTION","180",
+// "-DOC_COMPARATOR_HTML_OUTPUT_PREFIX","http://so-gfxcmp.germany.sun.com/gfxcmp_ui/cw.php?inifile=",
+// "-DOC_COMPARATOR_REFERENCE_CREATOR_TYPE","OOo",
+// "-DOC_COMPARATOR_DB_INFO_STRING","p:DEV300_m18,c:,d:LLA_test,src:DEV300_m18,dest:,doc:LLA_test,id:34715,distinct:2008-06-27_13-39-09_d6f22d4c-958d-10",
+// "-DISTINCT","2008-06-27_13-39-09_d6f22d4c-958d-10",
+// "-TEMPPATH","//so-gfxcmp-lin/gfxcmp-data/wntmsci/temp/2008-06-27_13-39-09_d6f22d4c-958d-10/34715",
+//// "ConnectionString","socket,host=localhost,port=8101",
+// "-OFFICE_VIEWABLE","true",
+// "-wntmsci.DOC_COMPARATOR_INPUT_PATH","\\\\so-gfxcmp-lin\\doc-pool\\LLA_test\\issue_79214.odb",
+// "-wntmsci.DOC_COMPARATOR_OUTPUT_PATH","\\\\so-gfxcmp-lin\\gfxcmp-data\\wntmsci\\convwatch-output\\LLA_test\\DEV300_m11",
+// "-wntmsci.AppExecutionCommand","\"C:\\gfxcmp\\programs\\staroffice8_DEV300_m11\\Sun\\StarOffice 9\\program\\soffice.exe\" -norestore -nocrashreport -accept=pipe,name=ll93751;urp;",
+// "-wntmsci.AppKillCommand","\"C:\\bin\\pskill.exe soffice.bin;C:\\bin\\pskill.exe winword;C:\\bin\\pskill.exe excel\"",
+//
+// };
+//
+// org.openoffice.Runner.main(args);
+// }
+
+}
diff --git a/qadevOOo/runner/graphical/PropertyName.java b/qadevOOo/runner/graphical/PropertyName.java
new file mode 100644
index 000000000000..729fd0c33c38
--- /dev/null
+++ b/qadevOOo/runner/graphical/PropertyName.java
@@ -0,0 +1,73 @@
+/*
+ * ************************************************************************
+ *
+ * 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
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ * ***********************************************************************
+ */
+
+package graphical;
+
+/**
+ *
+ * @author ll93751
+ */
+public interface PropertyName
+{
+ final public static String DOC_COMPARATOR_INPUT_PATH = "DOC_COMPARATOR_INPUT_PATH";
+ final public static String DOC_COMPARATOR_OUTPUT_PATH = "DOC_COMPARATOR_OUTPUT_PATH";
+// final public static String DOC_COMPARATOR_DIFF_PATH = "DOC_COMPARATOR_DIFF_PATH";
+// final public static String DOC_COMPARATOR_REFERENCE_PATH = "DOC_COMPARATOR_REFERENCE_PATH";
+// final public static String DOC_COMPARATOR_REFERENCE_INPUT_PATH = "DOC_COMPARATOR_REFERENCE_INPUT_PATH";
+ final public static String DOC_COMPARATOR_REFERENCE_TYPE = "DOC_COMPARATOR_REFERENCE_CREATOR_TYPE";
+ final public static String DOC_COMPARATOR_PRINTER_NAME = "DOC_COMPARATOR_PRINTER_NAME";
+// final public static String DOC_COMPARATOR_DEFAULT_XML_FORMAT_APP = "DOC_COMPARATOR_DEFAULT_XML_FORMAT_APP";
+ final public static String DOC_COMPARATOR_INCLUDE_SUBDIRS = "DOC_COMPARATOR_INCLUDE_SUBDIRS";
+ final public static String DOC_COMPARATOR_PRINT_MAX_PAGE = "DOC_COMPARATOR_PRINT_MAX_PAGE";
+ final public static String DOC_COMPARATOR_PRINT_ONLY_PAGE = "DOC_COMPARATOR_PRINT_ONLY_PAGE";
+ final public static String DOC_COMPARATOR_GFX_OUTPUT_DPI_RESOLUTION = "DOC_COMPARATOR_GFX_OUTPUT_DPI_RESOLUTION";
+ final public static String DOC_COMPARATOR_OVERWRITE_REFERENCE = "DOC_COMPARATOR_OVERWRITE_REFERENCE";
+
+ final public static String DOC_COMPARATOR_HTML_OUTPUT_PREFIX = "DOC_COMPARATOR_HTML_OUTPUT_PREFIX";
+// final public static String DOC_COMPARATOR_GFXCMP_WITH_BORDERMOVE = "DOC_COMPARATOR_GFXCMP_WITH_BORDERMOVE";
+
+ final public static String DOC_CONVERTER_IMPORT_FILTER_NAME = "DOC_CONVERTER_IMPORT_FILTER_NAME";
+ final public static String DOC_CONVERTER_EXPORT_FILTER_NAME = "DOC_CONVERTER_EXPORT_FILTER_NAME";
+ final public static String DOC_CONVERTER_OFFICE_PROGRAM = "DOC_CONVERTER_OFFICE_PROGRAM";
+// final public static String DOC_CONVERTER_REUSE_OFFICE = "DOC_CONVERTER_REUSE_OFFICE";
+
+ final public static String DOC_COMPARATOR_LEAVE_OUT_FILES = "DOC_COMPARATOR_LEAVE_OUT_FILES";
+
+ final public static String DOC_COMPARATOR_DB_INFO_STRING = "DOC_COMPARATOR_DB_INFO_STRING";
+
+// final public static String TEMPPATH = "TEMPPATH";
+
+ // set this variable to "true" or "yes" and loadComponentFromURL works with property Hidden=false
+ final public static String OFFICE_VIEWABLE = "OFFICE_VIEWABLE";
+
+// final public static String DB_CONNECTION_STRING = "DB_CONNECTION_STRING";
+// final public static String CHECK_NEED_TOOLS = "CHECK_NEED_TOOLS";
+// final public static String CREATE_DEFAULT = "CREATE_DEFAULT_REFERENCE";
+ final public static String NO_SMALL_PICTURES = "NoSmallPictures";
+}
diff --git a/qadevOOo/runner/graphical/TimeHelper.java b/qadevOOo/runner/graphical/TimeHelper.java
new file mode 100644
index 000000000000..057f9cd19494
--- /dev/null
+++ b/qadevOOo/runner/graphical/TimeHelper.java
@@ -0,0 +1,91 @@
+/*
+ * ************************************************************************
+ *
+ * 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
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ * ***********************************************************************
+ */
+
+package graphical;
+
+import java.util.Calendar;
+
+/**
+ *
+ * @author ll93751
+ */
+public class TimeHelper
+{
+ /*
+ wait a second the caller don't need to handle the interruptexception
+ @param _nSeconds how long should we wait
+ @param _sReason give a good reason, why we have to wait
+ */
+ static void waitInSeconds(int _nSeconds, String _sReason)
+ {
+ GlobalLogWriter.println("Wait 0.25 * " + String.valueOf(_nSeconds) + " sec. Reason: " + _sReason);
+ try {
+ java.lang.Thread.sleep(_nSeconds * 250);
+ } catch (java.lang.InterruptedException e2) {}
+ }
+
+ private int m_nSeconds;
+ private int m_nMilliSeconds;
+ private long m_nRealMilliSeconds;
+
+ private boolean m_bIsStopped = false;
+
+ public TimeHelper()
+ {}
+
+ public void start()
+ {
+ m_bIsStopped = false;
+ Calendar cal = Calendar.getInstance();
+ m_nSeconds = cal.get(Calendar.SECOND);
+ m_nMilliSeconds = cal.get(Calendar.MILLISECOND);
+ }
+ public void stop()
+ {
+ Calendar cal = Calendar.getInstance();
+ m_bIsStopped = true;
+ int nSeconds = cal.get(Calendar.SECOND);
+ m_nSeconds = nSeconds - m_nSeconds;
+ if (m_nSeconds < 0)
+ {
+ // add a minute
+ m_nSeconds += 60;
+ }
+
+ int nMilliSeconds = cal.get(Calendar.MILLISECOND);
+ m_nMilliSeconds = nMilliSeconds - m_nMilliSeconds;
+ m_nRealMilliSeconds = m_nSeconds * 1000 + m_nMilliSeconds;
+ }
+
+ public String getTime()
+ {
+ return String.valueOf(m_nRealMilliSeconds);
+ }
+
+}
diff --git a/qadevOOo/runner/graphical/Tolerance.java b/qadevOOo/runner/graphical/Tolerance.java
new file mode 100644
index 000000000000..90e853c9124c
--- /dev/null
+++ b/qadevOOo/runner/graphical/Tolerance.java
@@ -0,0 +1,23 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package graphical;
+
+/**
+ *
+ * @author ll93751
+ */
+public class Tolerance
+{
+ private int m_nTolerance;
+ public Tolerance(int _nAccept)
+ {
+ m_nTolerance = _nAccept;
+ }
+ public int getAccept()
+ {
+ return m_nTolerance;
+ }
+}
diff --git a/qadevOOo/runner/graphical/WrongEnvironmentException.java b/qadevOOo/runner/graphical/WrongEnvironmentException.java
new file mode 100644
index 000000000000..24ab5532b2e7
--- /dev/null
+++ b/qadevOOo/runner/graphical/WrongEnvironmentException.java
@@ -0,0 +1,42 @@
+/*
+ * ************************************************************************
+ *
+ * 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
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ * ***********************************************************************
+ */
+
+package graphical;
+
+/**
+ *
+ * @author ll93751
+ */
+public class WrongEnvironmentException extends OfficeException
+{
+ public WrongEnvironmentException(String _aMessage)
+ {
+ super(_aMessage);
+ }
+}
diff --git a/qadevOOo/runner/graphical/WrongSuffixException.java b/qadevOOo/runner/graphical/WrongSuffixException.java
new file mode 100644
index 000000000000..d8632ea50e72
--- /dev/null
+++ b/qadevOOo/runner/graphical/WrongSuffixException.java
@@ -0,0 +1,42 @@
+/*
+ * ************************************************************************
+ *
+ * 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
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ * ***********************************************************************
+ */
+
+package graphical;
+
+/**
+ *
+ * @author ll93751
+ */
+public class WrongSuffixException extends OfficeException
+{
+ public WrongSuffixException(String _aMessage)
+ {
+ super(_aMessage);
+ }
+}
diff --git a/qadevOOo/runner/graphical/makefile.mk b/qadevOOo/runner/graphical/makefile.mk
new file mode 100644
index 000000000000..4e1b0e98cba1
--- /dev/null
+++ b/qadevOOo/runner/graphical/makefile.mk
@@ -0,0 +1,76 @@
+#*************************************************************************
+#
+# 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
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+PRJ=..$/..
+
+PRJNAME = OOoRunner
+PACKAGE = convwatch
+TARGET = runner_convwatch
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+# --- Files --------------------------------------------------------
+
+JARFILES = ridl.jar unoil.jar jurt.jar juh.jar jut.jar java_uno.jar
+JAVAFILES = \
+BuildID.java \
+DateHelper.java \
+DirectoryHelper.java \
+EnhancedComplexTestCase.java \
+FileHelper.java \
+GlobalLogWriter.java \
+HTMLResult.java \
+IDocument.java \
+IOffice.java \
+ImageHelper.java \
+IniFile.java \
+JPEGComparator.java \
+JPEGCreator.java \
+JPEGEvaluator.java \
+MSOfficePostscriptCreator.java \
+Office.java \
+OfficeException.java \
+OpenOfficeDatabaseReportExtractor.java \
+OpenOfficePostscriptCreator.java \
+ParameterHelper.java \
+PerformanceContainer.java \
+PixelCounter.java \
+PostscriptCreator.java \
+PropertyName.java \
+TimeHelper.java \
+WrongEnvironmentException.java \
+WrongSuffixException.java \
+Tolerance.java
+
+# GraphicalComparator.java
+
+JAVACLASSFILES= $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class)
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk