summaryrefslogtreecommitdiff
path: root/qadevOOo/runner/convwatch
diff options
context:
space:
mode:
Diffstat (limited to 'qadevOOo/runner/convwatch')
-rw-r--r--qadevOOo/runner/convwatch/Basename.java61
-rw-r--r--qadevOOo/runner/convwatch/BorderRemover.java319
-rw-r--r--qadevOOo/runner/convwatch/BuildID.java163
-rw-r--r--qadevOOo/runner/convwatch/ConvWatch.java432
-rw-r--r--qadevOOo/runner/convwatch/ConvWatchCancelException.java38
-rw-r--r--qadevOOo/runner/convwatch/ConvWatchException.java37
-rw-r--r--qadevOOo/runner/convwatch/ConvWatchStarter.java445
-rw-r--r--qadevOOo/runner/convwatch/CrashLoopTest.java57
-rw-r--r--qadevOOo/runner/convwatch/DB.java541
-rw-r--r--qadevOOo/runner/convwatch/DBHelper.java316
-rwxr-xr-xqadevOOo/runner/convwatch/DateHelper.java58
-rw-r--r--qadevOOo/runner/convwatch/DirectoryHelper.java156
-rw-r--r--qadevOOo/runner/convwatch/DocumentConverter.java277
-rw-r--r--qadevOOo/runner/convwatch/EnhancedComplexTestCase.java130
-rw-r--r--qadevOOo/runner/convwatch/FileHelper.java405
-rw-r--r--qadevOOo/runner/convwatch/FilenameHelper.java398
-rw-r--r--qadevOOo/runner/convwatch/GfxCompare.java196
-rw-r--r--qadevOOo/runner/convwatch/GlobalLogWriter.java57
-rw-r--r--qadevOOo/runner/convwatch/GraphicalDifferenceCheck.java410
-rw-r--r--qadevOOo/runner/convwatch/GraphicalTestArguments.java744
-rw-r--r--qadevOOo/runner/convwatch/HTMLOutputter.java418
-rw-r--r--qadevOOo/runner/convwatch/INIOutputter.java207
-rw-r--r--qadevOOo/runner/convwatch/ImageHelper.java116
-rw-r--r--qadevOOo/runner/convwatch/IniFile.java452
-rw-r--r--qadevOOo/runner/convwatch/LISTOutputter.java104
-rw-r--r--qadevOOo/runner/convwatch/MSOfficePrint.java870
-rw-r--r--qadevOOo/runner/convwatch/NameHelper.java89
-rw-r--r--qadevOOo/runner/convwatch/OSHelper.java84
-rw-r--r--qadevOOo/runner/convwatch/OfficePrint.java1377
-rw-r--r--qadevOOo/runner/convwatch/PRNCompare.java805
-rw-r--r--qadevOOo/runner/convwatch/PerformanceContainer.java250
-rw-r--r--qadevOOo/runner/convwatch/PixelCounter.java206
-rw-r--r--qadevOOo/runner/convwatch/PropertyName.java67
-rw-r--r--qadevOOo/runner/convwatch/ReferenceBuilder.java304
-rwxr-xr-xqadevOOo/runner/convwatch/ReportDesignerTest.java694
-rw-r--r--qadevOOo/runner/convwatch/SimpleFileSemaphore.java189
-rw-r--r--qadevOOo/runner/convwatch/StatusHelper.java108
-rw-r--r--qadevOOo/runner/convwatch/StringHelper.java103
-rwxr-xr-xqadevOOo/runner/convwatch/TimeHelper.java44
-rw-r--r--qadevOOo/runner/convwatch/TriState.java76
-rw-r--r--qadevOOo/runner/convwatch/ValueNotFoundException.java36
-rw-r--r--qadevOOo/runner/convwatch/makefile.mk86
42 files changed, 11925 insertions, 0 deletions
diff --git a/qadevOOo/runner/convwatch/Basename.java b/qadevOOo/runner/convwatch/Basename.java
new file mode 100644
index 000000000000..05381e841eed
--- /dev/null
+++ b/qadevOOo/runner/convwatch/Basename.java
@@ -0,0 +1,61 @@
+/*************************************************************************
+ *
+ * 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 convwatch;
+
+// -----------------------------------------------------------------------------
+// Helper stuff to
+// abstract class Name
+// {
+// abstract public String getName();
+// }
+// class PRN extends Name
+// {
+// public String getName() {return "-ref";}
+// }
+// class PS extends Name
+// {
+// public String getName() {return "-test";}
+// }
+//
+// public class Basename /* extends *//* implements */ {
+// String fs;
+// Basename()
+// {
+// fs = System.getProperty("file.separator");
+// }
+// String getJPEGName(String _sOutputPath, String _sBasename, String _sGS_PageOutput, Name _aPostNameAdd)
+// {
+// String sBaseNameNoSuffix = FileHelper.getNameNoSuffix(_sBasename);
+// String sJPEGName = _sOutputPath + fs + sBaseNameNoSuffix + "-" + _sGS_PageOutput + _aPostNameAdd.getName() + ".jpg";
+// return sJPEGName;
+// }
+//
+// public static void main( String[] argv ) {
+//
+// }
+// }
diff --git a/qadevOOo/runner/convwatch/BorderRemover.java b/qadevOOo/runner/convwatch/BorderRemover.java
new file mode 100644
index 000000000000..986f6ff6582b
--- /dev/null
+++ b/qadevOOo/runner/convwatch/BorderRemover.java
@@ -0,0 +1,319 @@
+/*************************************************************************
+ *
+ * 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 convwatch;
+
+import convwatch.ImageHelper;
+import java.io.File;
+import java.awt.image.RenderedImage;
+import java.awt.image.BufferedImage;
+import java.lang.reflect.Method;
+
+// -----------------------------------------------------------------------------
+class Rect
+{
+ int x;
+ int y;
+ int w;
+ int h;
+
+ public Rect(int _x, int _y, int _w, int _h)
+ {
+ x = _x;
+ y = _y;
+ w = _w;
+ h = _h;
+ }
+ public int getX() {return x;}
+ public int getY() {return y;}
+ public int getWidth() {return w;}
+ public int getHeight() {return h;}
+}
+
+class BorderRemover
+{
+ ImageHelper m_aImage;
+
+ // Helper values, filled after find Border
+
+ // --------------------------------- test mode ---------------------------------
+
+ // void pixelValue(int pixel)
+ // {
+ // int alpha = (pixel >> 24) & 0xff;
+ // int red = (pixel >> 16) & 0xff;
+ // int green = (pixel >> 8) & 0xff;
+ // int blue = (pixel ) & 0xff;
+ // int dummy = 0;
+ // }
+
+ /*
+ * compares 2 colors with a given tolerance. So it's possible to check differences approximate.
+ * @param _nColor1
+ * @param _nColor2
+ * @param _nTolerance is a percentage value how strong the colors could be differ
+
+ */
+ boolean compareColorWithTolerance(int _nColor1, int _nColor2, int _nTolerance)
+ {
+ // int alpha1 = (_nColor1 >> 24) & 0xff;
+ int red1 = (_nColor1 >> 16) & 0xff;
+ int green1 = (_nColor1 >> 8) & 0xff;
+ int blue1 = (_nColor1 ) & 0xff;
+
+ // int alpha2 = (_nColor2 >> 24) & 0xff;
+ int red2 = (_nColor2 >> 16) & 0xff;
+ int green2 = (_nColor2 >> 8) & 0xff;
+ int blue2 = (_nColor2 ) & 0xff;
+
+ if (_nTolerance > 100)
+ {
+ _nTolerance = 100;
+ }
+
+ // calculate tolerance halve
+ double nTolerable = (_nTolerance * 256 / 100);
+ if (nTolerable < 0)
+ {
+ nTolerable = 0;
+ }
+
+ // X - th < Y < X + th
+ // if ((red1 - nTolerable) < red2 && red2 < (red1 + nTolerable))
+ // is the same
+ // abs (X - Y) < th
+ if (Math.abs(red1 - red2) < nTolerable)
+ {
+ if (Math.abs(green1 - green2) < nTolerable)
+ {
+ if (Math.abs(blue1 - blue2) < nTolerable)
+ {
+ return true;
+ }
+ else
+ {
+ // blue differ
+ }
+ }
+ else
+ {
+ // green differ
+ }
+ }
+ else
+ {
+ // red differ
+ }
+
+ return false;
+ }
+
+ /**
+ * create a new image from an exist one without it's borders
+ * open the file (_sFilenameFrom) as an image, check if it contains any borders and remove
+ * the borders.
+ */
+ public boolean createNewImageWithoutBorder(String _sFilenameFrom, String _sFilenameTo)
+ throws java.io.IOException
+ {
+ // System.out.println("load image: " + fileName);
+ m_aImage = ImageHelper.createImageHelper(_sFilenameFrom);
+
+ // System.out.println("image width:" + String.valueOf(m_aImage.getWidth()));
+ // System.out.println("image height:" + String.valueOf(m_aImage.getHeight()));
+
+ // int nw = graphics_stuff.countNotWhitePixel(m_aImage);
+ // System.out.println("not white pixels:" + String.valueOf(nw));
+
+ // int nb = graphics_stuff.countNotBlackPixel(m_aImage);
+ // System.out.println("not black pixels:" + String.valueOf(nb));
+
+ int nBorderColor = m_aImage.getPixel(0,0);
+ Rect aInnerRect = findBorder(m_aImage, nBorderColor);
+
+ RenderedImage aImage = createImage(m_aImage, aInnerRect);
+
+ File aWriteFile = new File(_sFilenameTo);
+ // GlobalLogWriter.get().println("Hello World: File to: " + _sFilenameTo);
+
+ Exception ex = null;
+ try
+ {
+ Class imageIOClass = Class.forName("javax.imageio.ImageIO");
+ // GlobalLogWriter.get().println("Hello World: get Class");
+
+ Method getWriterMIMETypesMethod = imageIOClass.getDeclaredMethod("getWriterMIMETypes", new Class[]{ });
+ // GlobalLogWriter.get().println("Hello World: get Methode");
+
+ Object aObj = getWriterMIMETypesMethod.invoke(imageIOClass, new Object[]{ });
+ String[] types = (String[])aObj;
+ // GlobalLogWriter.get().println("Hello World: types: " + Arrays.asList(types) );
+
+ Method writeMethod = imageIOClass.getDeclaredMethod("write", new Class[]{ java.awt.image.RenderedImage.class,
+ java.lang.String.class,
+ java.io.File.class});
+ // GlobalLogWriter.get().println("Hello World: get Methode");
+ writeMethod.invoke(imageIOClass, new Object[]{aImage, "image/jpeg", aWriteFile});
+ }
+ catch(java.lang.ClassNotFoundException e) {
+ e.printStackTrace();
+ ex = e;
+ }
+ catch(java.lang.NoSuchMethodException e) {
+ e.printStackTrace();
+ ex = e;
+ }
+ catch(java.lang.IllegalAccessException e) {
+ e.printStackTrace();
+ ex = e;
+ }
+ catch(java.lang.reflect.InvocationTargetException e) {
+ e.printStackTrace();
+ 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());
+ }
+// ImageIO.write(aImage, "jpg", aWriteFile);
+
+ return true;
+ }
+
+
+ /**
+ * runs through the image, pixel by pixel
+ * as long as found pixels like the color at (0,0) this is interpreted as border.
+ * as result it fills the m_nXMin, m_nXMax, m_nYMin, m_nYMax values.
+ */
+
+ Rect findBorder(ImageHelper _aImage, int _nBorderColor)
+ {
+ int h = _aImage.getHeight();
+ int w = _aImage.getWidth();
+ int nXMin = w;
+ int nXMax = 0;
+ int nYMin = h;
+ int nYMax = 0;
+
+ for (int y = 0; y < h; y++)
+ {
+ for (int x = 0; x < nXMin; x++)
+ {
+ // handlesinglepixel(x+i, y+j, pixels[j * w + i]);
+ int nCurrentColor = _aImage.getPixel(x, y);
+ if (! compareColorWithTolerance(nCurrentColor, _nBorderColor, 10))
+ {
+ // pixelValue(nCurrentColor);
+ // System.out.print("*");
+ nXMin = java.lang.Math.min(nXMin, x);
+ nYMin = java.lang.Math.min(nYMin, y);
+ }
+ // else
+ // {
+ // System.out.print(" ");
+ // }
+ }
+ }
+ for (int y = 0; y < h; y++)
+ {
+ for (int nx = w - 1; nx >= nXMax; --nx)
+ {
+ int ny = h - y - 1;
+ int nCurrentColor = _aImage.getPixel(nx, ny);
+ if (! compareColorWithTolerance(nCurrentColor, _nBorderColor, 10))
+ {
+ nXMax = java.lang.Math.max(nXMax, nx);
+ nYMax = java.lang.Math.max(nYMax, ny);
+ }
+ }
+ // System.out.println();
+ }
+ // System.out.println("xmin: " + String.valueOf(nXMin));
+ // System.out.println("xmax: " + String.valueOf(nXMax));
+ // System.out.println("ymin: " + String.valueOf(nYMin));
+ // System.out.println("ymax: " + String.valueOf(nYMax));
+
+ Rect aRect;
+ if (nXMin < nXMax && nYMin < nYMax)
+ {
+ int nw = nXMax - nXMin + 1;
+ int nh = nYMax - nYMin + 1;
+
+ // this is the rectangle around the image content.
+ aRect = new Rect(nXMin, nYMin, nw, nh );
+ }
+ else
+ {
+ // create the smalles possible image
+ aRect = new Rect(0,0,1,1);
+ }
+
+
+ // m_nXMin = nXMin;
+ // m_nXMax = nXMax;
+ // m_nYMin = nYMin;
+ // m_nYMax = nYMax;
+ return aRect;
+ }
+
+ RenderedImage createImage(ImageHelper _aImage, Rect _aRect) throws IllegalArgumentException
+ {
+// TODO: throw if w or h < 0
+ int w = _aRect.getWidth();
+ int h = _aRect.getHeight();
+
+ if (w <= 0 || h <= 0)
+ {
+ throw new IllegalArgumentException("width or height are too small or negative.");
+ }
+
+ BufferedImage aBI = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
+
+ int nXOffset = _aRect.getX();
+ int nYOffset = _aRect.getY();
+
+ // Memory Block move
+ for (int y = 0; y < h; y++)
+ {
+ for (int x = 0; x < w; x++)
+ {
+ // aPixels[y * w + x] = m_aImage.getPixel(m_nXMin + x, m_nYMin + y);
+ aBI.setRGB(x, y, _aImage.getPixel(x + nXOffset, y + nYOffset));
+ }
+ }
+ // java.awt.image.MemoryImageSource aSource = new java.awt.image.MemoryImageSource(w, h, aPixels, 0, w);
+// return java.awt.Component.createImage(aSource);
+ // return java.awt.Toolkit.getDefaultToolkit().createImage(aSource);
+ return aBI;
+ }
+
+}
diff --git a/qadevOOo/runner/convwatch/BuildID.java b/qadevOOo/runner/convwatch/BuildID.java
new file mode 100644
index 000000000000..efb091d160f9
--- /dev/null
+++ b/qadevOOo/runner/convwatch/BuildID.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 convwatch;
+
+import java.io.File;
+import helper.OSHelper;
+import convwatch.IniFile;
+import java.util.Date;
+
+public class BuildID
+{
+ public static String getBuildID(String _sApp)
+ {
+ String sOfficePath = "";
+ if (_sApp.startsWith("\""))
+ {
+ int nIdx = _sApp.indexOf("\"", 1);
+ if (nIdx == -1)
+ {
+ }
+ else
+ {
+ // leave double qoute out.
+ sOfficePath = _sApp.substring(1, nIdx);
+ }
+ }
+ else
+ {
+ // 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);
+ }
+ }
+ GlobalLogWriter.get().println("Office path: " + sOfficePath);
+
+ String fs = System.getProperty("file.separator");
+ String sBuildID = "";
+ File aSOfficeFile = new File(sOfficePath);
+ if (aSOfficeFile.exists())
+ {
+ int nIdx = sOfficePath.lastIndexOf(fs);
+ sOfficePath = sOfficePath.substring(0, nIdx);
+ // ok. System.out.println("directory: " + sOfficePath);
+ sBuildID = getBuildIDFromBootstrap(sOfficePath);
+ if (sBuildID.length() == 0)
+ {
+ sBuildID = getBuildIDFromVersion(sOfficePath);
+ }
+ }
+ else
+ {
+ GlobalLogWriter.get().println("soffice executable not found.");
+ }
+
+ int dummy = 0;
+ return sBuildID;
+ }
+
+ private static String getBuildIDFromBootstrap(String _sOfficePath)
+ {
+ String fs = System.getProperty("file.separator");
+ String sBuildID = "";
+ String sOfficePath = _sOfficePath;
+ if (OSHelper.isWindows())
+ {
+ sOfficePath += fs + "bootstrap.ini";
+ }
+ else
+ {
+ sOfficePath += fs + "bootstraprc";
+ }
+ IniFile aIniFile = new IniFile(sOfficePath);
+ if (aIniFile.is())
+ {
+ sBuildID = aIniFile.getValue("Bootstrap", "buildid");
+ }
+ else
+ {
+ GlobalLogWriter.get().println("Property Build, can't open file '" + sOfficePath + "', please check.");
+ }
+ return sBuildID;
+ }
+
+ private static String getBuildIDFromVersion(String _sOfficePath)
+ {
+ String fs = System.getProperty("file.separator");
+ String sBuildID = "";
+ String sOfficePath = _sOfficePath;
+ if (OSHelper.isWindows())
+ {
+ sOfficePath += fs + "version.ini";
+ }
+ else
+ {
+ sOfficePath += fs + "versionrc";
+ }
+ IniFile aIniFile = new IniFile(sOfficePath);
+ if (aIniFile.is())
+ {
+ sBuildID = aIniFile.getValue("Version", "buildid");
+ }
+ else
+ {
+ GlobalLogWriter.get().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);
+// }
+
+}
+
diff --git a/qadevOOo/runner/convwatch/ConvWatch.java b/qadevOOo/runner/convwatch/ConvWatch.java
new file mode 100644
index 000000000000..76dc3522d2e0
--- /dev/null
+++ b/qadevOOo/runner/convwatch/ConvWatch.java
@@ -0,0 +1,432 @@
+/*************************************************************************
+ *
+ * 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 convwatch;
+
+import convwatch.ConvWatchException;
+import convwatch.ConvWatchCancelException;
+import convwatch.FileHelper;
+import convwatch.OfficePrint;
+import convwatch.PRNCompare;
+import convwatch.StatusHelper;
+import helper.URLHelper;
+import java.io.File;
+
+public class ConvWatch
+{
+
+ String getBuildID_FromFile(String _sInfoFile)
+ {
+ String sBuildID = "";
+ IniFile aIniFile = new IniFile(_sInfoFile);
+ if (aIniFile.is())
+ {
+ sBuildID = aIniFile.getValue("", "buildid");
+ }
+ return sBuildID;
+ }
+ /**
+ * Check if given document (_sAbsoluteInputFile) and it's postscript representation (_sAbsoluteReferenceFile) produce
+ * the same output like the StarOffice / OpenOffice.org which is accessable with XMultiServiceFactory.
+ * Here a simple graphically difference check is run through.
+ *
+ * Hint: In the OutputPath all needed files will create, there must
+ * be very much space. It's not possible to say how much.
+ * One page need up to 800kb as jpeg.
+ * Sample: If a document contains 2 pages, we need 2*800kb for prn
+ * output and 2*800kb for ps output and 2*800kb for it's difference
+ * output. So up to 4800kb or 4.8mb.
+ *
+ * RAM is need least 300mb. Will say, it's tested on a pc with 128mb RAM and 256mb swap.
+ *
+ * It's also absolutlly impossible to say, how much time this functions consume.
+ */
+
+ StatusHelper[] createPostscriptStartCheck(GraphicalTestArguments _aGTA,
+ String _sOutputPath, String _sAbsoluteInputFile, String _sAbsoluteReferenceFile)
+ throws ConvWatchCancelException
+ {
+// TODO: some more checks
+
+ if (! FileHelper.exists(_sAbsoluteInputFile))
+ {
+ throw new ConvWatchCancelException("createPostscriptStartCheck: Input file: " + _sAbsoluteInputFile + " does not exist.");
+ }
+
+ if (_sAbsoluteReferenceFile == null)
+ {
+ // we assume, that the prn file is near the document
+ String sAbsoluteInputFileNoSuffix = FileHelper.getNameNoSuffix(_sAbsoluteInputFile);
+ _sAbsoluteReferenceFile = sAbsoluteInputFileNoSuffix + ".prn";
+ }
+
+ String fs = System.getProperty("file.separator");
+ File aAbsoluteReferenceFile = new File(_sAbsoluteReferenceFile);
+
+ if (aAbsoluteReferenceFile.isDirectory())
+ {
+ String sBasename = FileHelper.getBasename(_sAbsoluteInputFile);
+ String sNameNoSuffix = FileHelper.getNameNoSuffix(sBasename);
+ String sAbsoluteReferenceFileInfo = _sAbsoluteReferenceFile + fs + sNameNoSuffix + ".info";
+ _sAbsoluteReferenceFile = _sAbsoluteReferenceFile + fs + sNameNoSuffix + ".prn";
+
+ // Read the reference from the info file
+ String sRefBuildID = "";
+ if (FileHelper.exists(sAbsoluteReferenceFileInfo))
+ {
+ sRefBuildID = getBuildID_FromFile(sAbsoluteReferenceFileInfo);
+ }
+ _aGTA.setRefBuildID(sRefBuildID);
+
+ }
+ else
+ {
+ // java file has problems to check for directories, if the given directory doesn't exist.
+ String sName = FileHelper.getBasename(_sAbsoluteReferenceFile);
+ // thanks to Mircosoft, every document has a suffix, so if a name doesn't have a suffix, it must be a directory name
+ int nIdx = sName.indexOf('.');
+ if (nIdx == -1)
+ {
+ // must be a directory
+ throw new ConvWatchCancelException("createPostscriptStartCheck: Given reference directory: '" + _sAbsoluteReferenceFile + "' does not exist.");
+ }
+ }
+
+
+ boolean bAbsoluteReferenceFile = true;
+ if (! FileHelper.exists(_sAbsoluteReferenceFile))
+ {
+ if (_aGTA.createDefaultReference())
+ {
+ GlobalLogWriter.get().println("Reference File doesn't exist, will create a default");
+ bAbsoluteReferenceFile = false;
+ }
+ else
+ {
+ throw new ConvWatchCancelException("createPostscriptStartCheck: Given reference file: " + _sAbsoluteReferenceFile + " does not exist.");
+ }
+ }
+
+ FileHelper.makeDirectories("", _sOutputPath);
+
+ // runner.convwatch.compare();
+
+ String sAbsoluteInputFileURL = URLHelper.getFileURLFromSystemPath(_sAbsoluteInputFile);
+
+ String sInputFile = FileHelper.getBasename(_sAbsoluteInputFile);
+ // System.out.println("InputFile: " + sInputFile);
+
+ String sInputFileNoSuffix = FileHelper.getNameNoSuffix(sInputFile);
+ // System.out.println("BasenameNoSuffix: " + sInputFileNoSuffix);
+
+
+ String sAbsoluteOutputFile = _sOutputPath + fs + sInputFile;
+ String sAbsoluteOutputFileURL = URLHelper.getFileURLFromSystemPath(sAbsoluteOutputFile);
+
+ String sReferenceFile = FileHelper.getBasename(_sAbsoluteReferenceFile);
+ String sReferenceFileNoSuffix = FileHelper.getNameNoSuffix(sReferenceFile);
+ String sPostScriptFile = sReferenceFileNoSuffix + ".ps";
+ // System.out.println("PostscriptFile: " + sPostScriptFile);
+
+ String sAbsolutePrintFile = _sOutputPath + fs + sPostScriptFile;
+ String sAbsolutePrintFileURL = URLHelper.getFileURLFromSystemPath(sAbsolutePrintFile);
+
+ // System.out.println("AbsoluteInputFileURL: " + sAbsoluteInputFileURL);
+ // System.out.println("AbsoluteOutputFileURL: " + sAbsoluteOutputFileURL);
+ // System.out.println("AbsolutePrintFileURL: " + sAbsolutePrintFileURL);
+
+ // store and print the sAbsoluteInputFileURL file with StarOffice / OpenOffice.org
+ OfficePrint.printToFile(_aGTA, sAbsoluteInputFileURL, sAbsoluteOutputFileURL, sAbsolutePrintFileURL);
+
+ // wait(2);
+
+ if (! FileHelper.exists(sAbsolutePrintFile))
+ {
+ throw new ConvWatchCancelException("createPostscriptStartCheck: Printed file " + sAbsolutePrintFile + " does not exist.");
+ }
+
+ if (bAbsoluteReferenceFile == false)
+ {
+ // copy AbsolutePrintFile to AbsoluteReferenceFile
+ String sDestinationFile = sAbsolutePrintFile; // URLHelper.getSystemPathFromFileURL(...)
+ String sSourceFile = _sAbsoluteReferenceFile;
+ FileHelper.copy(sDestinationFile, sSourceFile);
+ // now the fix reference of the AbsoluteReferenceFile should exist.
+ if (! FileHelper.exists(_sAbsoluteReferenceFile))
+ {
+ throw new ConvWatchCancelException("createPostscriptStartCheck: Given reference file: " + _sAbsoluteReferenceFile + " does not exist, after try to copy.");
+ }
+ }
+
+ PRNCompare a = new PRNCompare();
+ String sInputPath = FileHelper.getPath(_sAbsoluteInputFile);
+ String sReferencePath = FileHelper.getPath(_sAbsoluteReferenceFile);
+ // String sReferenceFile = FileHelper.getBasename(sAbsoluteReferenceFile);
+
+ // System.out.println("InputPath: " + sInputPath);
+ // System.out.println("sReferencePath: " + sReferencePath);
+ // System.out.println("sReferenceFile: " + sReferenceFile);
+
+ a.setInputPath( sInputPath );
+ a.setReferencePath( sReferencePath );
+ a.setOutputPath( _sOutputPath );
+ // a.setDocFile( "1_Gov.ppt");
+ a.setReferenceFile( sReferenceFile );
+ a.setPostScriptFile(sPostScriptFile );
+ if (_aGTA.printAllPages() == true)
+ {
+ a.setMaxPages(9999);
+ }
+ else
+ {
+ if (_aGTA.getMaxPages() > 0)
+ {
+ a.setMaxPages(_aGTA.getMaxPages());
+ }
+ if (_aGTA.getOnlyPages().length() != 0)
+ {
+ // we can't interpret the string of getOnlyPages() right without much logic, so print all pages here!
+ a.setMaxPages(9999);
+ }
+ }
+
+ a.setResolutionInDPI(_aGTA.getResolutionInDPI());
+ a.setBorderMove(_aGTA.getBorderMove());
+ a.setDocumentType(_aGTA.getDocumentType());
+
+ StatusHelper[] aList = a.compare();
+
+ _aGTA.setBorderMove(a.getBorderMove());
+ return aList;
+ }
+
+ // -----------------------------------------------------------------------------
+ // 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;
+ }
+
+ // -----------------------------------------------------------------------------
+
+ static void createINIStatus_DiffDiff(StatusHelper[] aDiffDiffList, String _sFilenamePrefix, String _sOutputPath, String _sAbsoluteInputFile, String _sBuildID)
+ {
+ // Status
+ String fs = System.getProperty("file.separator");
+ String sBasename = FileHelper.getBasename(_sAbsoluteInputFile);
+ String sNameNoSuffix = FileHelper.getNameNoSuffix(sBasename);
+ String sINIFile = _sFilenamePrefix + sNameNoSuffix + ".ini";
+
+// HTMLOutputter HTMLoutput = HTMLOutputter.create(_sOutputPath, sHTMLFile, _sFilenamePrefix, "");
+// HTMLoutput.header(sNameNoSuffix);
+// HTMLoutput.checkDiffDiffSection(sBasename);
+
+ INIOutputter INIoutput = INIOutputter.create(_sOutputPath, sINIFile, _sFilenamePrefix, "");
+ INIoutput.createHeader();
+ // LLA? what if the are no values in the list? true or false;
+ INIoutput.writeSection("global");
+ INIoutput.writeValue("pages", String.valueOf(aDiffDiffList.length));
+ INIoutput.writeValue("buildid", _sBuildID);
+ INIoutput.writeValue("diffdiff", "yes");
+ INIoutput.writeValue("basename", sBasename);
+
+ for (int i=0;i<aDiffDiffList.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)
+ boolean bCurrentResult = (aDiffDiffList[i].nDiffStatus == StatusHelper.DIFF_NO_DIFFERENCES); // logic: nDiff==0 = true if there is no difference
+
+// HTMLoutput.checkDiffDiffLine(aDiffDiffList[i], bCurrentResult);
+ INIoutput.checkDiffDiffLine(aDiffDiffList[i], bCurrentResult);
+ }
+ // Status
+// HTMLoutput.close();
+ INIoutput.close();
+ }
+
+
+ // -----------------------------------------------------------------------------
+
+ public static boolean check(GraphicalTestArguments _aGTA,
+ String _sOutputPath, String _sAbsoluteInputFile, String _sAbsoluteReferenceFile)
+ throws ConvWatchCancelException, ConvWatchException
+ {
+ ConvWatch a = new ConvWatch();
+ StatusHelper[] aList = a.createPostscriptStartCheck(_aGTA, _sOutputPath, _sAbsoluteInputFile, _sAbsoluteReferenceFile);
+ DB.writeNumberOfPages(aList.length);
+
+ boolean bResultIsOk = createINIStatus(aList, "", _sOutputPath, _sAbsoluteInputFile, _aGTA.getBuildID(), _aGTA.getRefBuildID());
+
+ if (! bResultIsOk)
+ {
+ // it could be that this will store in a DB, there are problems with '\'
+ String sErrorMessage = "Graphical compare failed with file ";
+ String sErrorFile = _sAbsoluteInputFile.replace('\\', '/');
+ sErrorMessage = sErrorMessage + "'" + sErrorFile + "'";
+ DB.writeErrorFile(sErrorFile);
+ throw new ConvWatchException(sErrorMessage);
+ }
+ return bResultIsOk;
+ }
+
+ // -----------------------------------------------------------------------------
+ public static boolean checkDiffDiff(GraphicalTestArguments _aGTA,
+ String _sOutputPath, String _sAbsoluteInputFile, String _sAbsoluteReferenceFile,
+ String _sAbsoluteDiffPath)
+ throws ConvWatchCancelException, ConvWatchException
+ {
+ ConvWatch a = new ConvWatch();
+ _aGTA.setBorderMove(TriState.FALSE);
+ StatusHelper[] aList = a.createPostscriptStartCheck(_aGTA, _sOutputPath, _sAbsoluteInputFile, _sAbsoluteReferenceFile);
+
+ // Status
+ boolean bResultIsOk = createINIStatus(aList, "", _sOutputPath, _sAbsoluteInputFile, _aGTA.getBuildID(), _aGTA.getRefBuildID());
+
+ StatusHelper[] aDiffDiffList = new StatusHelper[aList.length];
+
+ String fs = System.getProperty("file.separator");
+
+ boolean bDiffIsOk = true;
+ boolean bFoundAOldDiff = false;
+
+ PRNCompare aCompare = new PRNCompare();
+ // LLA? what if the are no values in the list? true or false;
+ for (int i=0;i<aList.length; i++)
+ {
+ String sOrigDiffName = aList[i].m_sDiffGfx;
+ String sDiffBasename = FileHelper.getBasename(sOrigDiffName);
+
+ String sNewDiffName = _sAbsoluteDiffPath + fs + sDiffBasename;
+ if (! FileHelper.exists(sNewDiffName))
+ {
+ GlobalLogWriter.get().println("checkDiffDiff: Old diff file: '" + sNewDiffName + "' does not exist." );
+ continue;
+ }
+ // String sNewDiffName = _sAbsoluteDiffPath + fs + sDiffBasename;
+
+ // make a simple difference between these both diff files.
+ String sSourcePath1 = FileHelper.getPath(sOrigDiffName);
+ String sSourceFile1 = sDiffBasename;
+ String sSourcePath2 = _sAbsoluteDiffPath;
+ String sSourceFile2 = sDiffBasename;
+
+ StatusHelper aCurrentStatus = aCompare.checkDiffDiff(_sOutputPath, sSourcePath1, sSourceFile1, sSourcePath2, sSourceFile2);
+ boolean bCurrentResult = (aCurrentStatus.nDiffStatus == StatusHelper.DIFF_NO_DIFFERENCES); // logic: nDiff==0 = true if there is no difference
+ bDiffIsOk &= bCurrentResult;
+ bFoundAOldDiff = true;
+
+ aDiffDiffList[i] = aCurrentStatus;
+ }
+
+ createINIStatus_DiffDiff(aDiffDiffList, "DiffDiff_", _sOutputPath, _sAbsoluteInputFile, _aGTA.getBuildID());
+
+ if (bFoundAOldDiff == false)
+ {
+ throw new ConvWatchCancelException("No old difference file found." );
+ }
+ if (! bDiffIsOk)
+ {
+ throw new ConvWatchException("Graphical difference compare failed with file '" + _sAbsoluteInputFile + "'");
+ }
+ return bDiffIsOk;
+ }
+
+ // public static void main( String[] argv )
+ // {
+ // PRNCompare a = new PRNCompare();
+ // a.setInputPath( "/cws/so-cwsserv06/qadev18/SRC680/src.m47/convwatch.keep/input/msoffice/xp/PowerPoint");
+ // a.setDocFile( "1_Gov.ppt");
+ // a.setReferencePath( "/cws/so-cwsserv06/qadev18/SRC680/src.m47/convwatch.keep/input/msoffice/xp/PowerPoint");
+ // a.setReferenceFile( "1_Gov.prn" );
+ //
+ // a.setOutputPath( "/tmp/convwatch_java");
+ // a.setPostScriptFile("1_Gov.ps" );
+ // }
+}
diff --git a/qadevOOo/runner/convwatch/ConvWatchCancelException.java b/qadevOOo/runner/convwatch/ConvWatchCancelException.java
new file mode 100644
index 000000000000..2042f600b4cc
--- /dev/null
+++ b/qadevOOo/runner/convwatch/ConvWatchCancelException.java
@@ -0,0 +1,38 @@
+/*************************************************************************
+ *
+ * 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 convwatch;
+
+import convwatch.ConvWatchException;
+
+public class ConvWatchCancelException extends ConvWatchException
+{
+ public ConvWatchCancelException(String _aMessage)
+ {
+ super(_aMessage);
+ }
+}
diff --git a/qadevOOo/runner/convwatch/ConvWatchException.java b/qadevOOo/runner/convwatch/ConvWatchException.java
new file mode 100644
index 000000000000..f0fab0852deb
--- /dev/null
+++ b/qadevOOo/runner/convwatch/ConvWatchException.java
@@ -0,0 +1,37 @@
+/*************************************************************************
+ *
+ * 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 convwatch;
+
+public class ConvWatchException extends Exception
+{
+ public ConvWatchException(String _aMessage)
+ {
+ super(_aMessage);
+ }
+}
+
diff --git a/qadevOOo/runner/convwatch/ConvWatchStarter.java b/qadevOOo/runner/convwatch/ConvWatchStarter.java
new file mode 100644
index 000000000000..c81ba3dfca85
--- /dev/null
+++ b/qadevOOo/runner/convwatch/ConvWatchStarter.java
@@ -0,0 +1,445 @@
+/*************************************************************************
+ *
+ * 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 convwatch;
+
+// imports
+import java.util.ArrayList;
+import java.io.File;
+import java.io.FileFilter;
+
+import convwatch.EnhancedComplexTestCase;
+import com.sun.star.lang.XMultiServiceFactory;
+
+import convwatch.ConvWatchException;
+import convwatch.DirectoryHelper;
+import convwatch.GraphicalTestArguments;
+import convwatch.HTMLOutputter;
+import helper.OfficeProvider;
+import helper.OfficeWatcher;
+import helper.OSHelper;
+import convwatch.PerformanceContainer;
+
+/**
+ * The following Complex Test will test
+ * an already created document and it's postscript output (by an older office version)
+ * with a new office version.
+ * This test use Ghostscript for the jpeg export and graphically compare tools from ImageMagick.
+ * Read the manual for more information.
+ *
+ * this is only the starter program
+ * more is found in qadevOOo/runner/convwatch/*
+ */
+
+public class ConvWatchStarter extends EnhancedComplexTestCase
+{
+ // The first of the mandatory functions:
+ /**
+ * Return the name of the test.
+ * In this case it is the actual name of the service.
+ * @return The tested service.
+ */
+ // public String getTestObjectName() {
+ // return "ConvWatch runner";
+ // }
+
+ // The second of the mandatory functions: return all test methods as an
+ // array. There is only one test function in this example.
+ /**
+ * Return all test methods.
+ * @return The test methods.
+ */
+ public String[] getTestMethodNames() {
+ return new String[]{"compareGraphicalDiffs"};
+ }
+
+ String m_sInputPath = "";
+ String m_sReferencePath = "";
+ String m_sOutputPath = "";
+ String m_sDiffPath = null;
+
+ private void initMember()
+ {
+ // MUST PARAMETER
+ // INPUTFILE ----------
+ String sINPATH = (String)param.get( PropertyName.DOC_COMPARATOR_INPUT_PATH );
+ boolean bQuit = false;
+ if (sINPATH == null || sINPATH.length() == 0)
+ {
+ log.println("Please set input path (path to documents) " + PropertyName.DOC_COMPARATOR_INPUT_PATH + "=path.");
+ bQuit = true;
+ }
+ else
+ {
+ log.println("found " + PropertyName.DOC_COMPARATOR_INPUT_PATH + " " + sINPATH);
+ m_sInputPath = sINPATH;
+ }
+
+ // REFERENCE_PATH ----------
+ String sREF = (String)param.get( PropertyName.DOC_COMPARATOR_REFERENCE_PATH );
+ if (sREF == null || sREF.length() == 0)
+ {
+ // log.println("Please set reference file (path to good documents) REFERENCEFILE=path.");
+ log.println("Assumtion, reference directory and input directory are the same.");
+ m_sReferencePath = m_sInputPath;
+ }
+ else
+ {
+ log.println("found " + PropertyName.DOC_COMPARATOR_REFERENCE_PATH + " " + sREF);
+ m_sReferencePath = sREF;
+ }
+
+ // OUTPUT_PATH ----------
+ String sOUT = (String)param.get( PropertyName.DOC_COMPARATOR_OUTPUT_PATH );
+ if (sOUT == null || sOUT.length() == 0)
+ {
+ log.println("Please set output path (path to a temp directory) " + PropertyName.DOC_COMPARATOR_OUTPUT_PATH + "=path.");
+ bQuit = true;
+ }
+ else
+ {
+ log.println("found " + PropertyName.DOC_COMPARATOR_OUTPUT_PATH + " " + sOUT);
+ m_sOutputPath = sOUT;
+ }
+
+ if (bQuit == true)
+ {
+ // log.println("must quit.");
+ assure("Must quit", false);
+ }
+
+
+ // DIFF_PATH ----------
+ String sDIFF = (String)param.get( PropertyName.DOC_COMPARATOR_DIFF_PATH );
+ if (sDIFF == null || sDIFF.length() == 0)
+ {
+ }
+ else
+ {
+ log.println("found " + PropertyName.DOC_COMPARATOR_DIFF_PATH + " " + sDIFF);
+ m_sDiffPath = sDIFF;
+ }
+
+ if (m_sInputPath.startsWith("file:") ||
+ m_sReferencePath.startsWith("file:") ||
+ m_sOutputPath.startsWith("file:"))
+ {
+ assure("We can't handle file: URL right, use system path instead.", false);
+ }
+
+ }
+
+
+ /**
+ *
+ * @return a List of software which must accessable as an external executable
+ */
+ protected Object[] mustInstalledSoftware()
+ {
+ ArrayList aList = new ArrayList();
+ // Tools from ImageMagick
+ if (! OSHelper.isWindows())
+ {
+ aList.add( "composite -version" );
+ aList.add( "identify -version" );
+
+ // Ghostscript
+ aList.add( "gs -version" );
+ }
+ else
+ {
+ aList.add( "composite.exe -version" );
+ aList.add( "identify.exe -version" );
+
+ // Ghostscript
+ aList.add( "gswin32c.exe -version" );
+ }
+
+ return aList.toArray();
+ }
+
+
+ /**
+ * The test method itself.
+ * Don't try to call it from outside, it is started only from qadevOOo runner
+ */
+
+ /* protected */
+ public void compareGraphicalDiffs()
+ {
+ GlobalLogWriter.set(log);
+ String sDBConnection = (String)param.get( PropertyName.DB_CONNECTION_STRING );
+ // check if all need software is installed and accessable
+ checkEnvironment(mustInstalledSoftware());
+
+ GraphicalTestArguments aGTA = getGraphicalTestArguments();
+ if (aGTA == null)
+ {
+ assure("Must quit", false);
+ }
+ if (aGTA.cancelRequest())
+ {
+ return;
+ }
+
+ initMember();
+
+ aGTA.allowStore();
+
+ String sBuildID = aGTA.getBuildID();
+ log.println("Current Office has buildid: " + sBuildID);
+
+ // LLA: sample code, how to access all parameters
+ // for (Enumeration e = param.keys() ; e.hasMoreElements() ;)
+ // {
+ // System.out.println(e.nextElement());
+ // }
+
+ String fs = System.getProperty("file.separator");
+
+ String sHTMLName = "index.html";
+ File aInputPathTest = new File(m_sInputPath);
+ if (!aInputPathTest.isDirectory())
+ {
+ int n = m_sInputPath.lastIndexOf(fs);
+ sHTMLName = m_sInputPath.substring(n + 1);
+ sHTMLName += ".html";
+ }
+ HTMLOutputter HTMLoutput = HTMLOutputter.create(m_sOutputPath, sHTMLName, "", "");
+ HTMLoutput.header( m_sOutputPath );
+ HTMLoutput.indexSection( m_sOutputPath );
+ LISTOutputter LISToutput = LISTOutputter.create(m_sOutputPath, "allfiles.txt");
+
+ DB.init(aGTA.getDBInfoString() + "," + sDBConnection);
+
+ File aInputPath = new File(m_sInputPath);
+ if (aInputPath.isDirectory())
+ {
+ // check a whole directory
+ // a whole directory
+ FileFilter aFileFilter = FileHelper.getFileFilter();
+
+ Object[] aList = DirectoryHelper.traverse(m_sInputPath, aFileFilter, aGTA.includeSubDirectories());
+ 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];
+ log.println("- next file is: ------------------------------");
+ log.println(sEntry);
+
+ String sNewSubDir = FileHelper.removeFirstDirectorysAndBasenameFrom(sEntry, m_sInputPath);
+
+ String sNewReferencePath = m_sReferencePath;
+ String sNewOutputPath = m_sOutputPath;
+ String sNewDiffPath = m_sDiffPath;
+ if (sNewSubDir.length() > 0)
+ {
+ if (sNewReferencePath != null)
+ sNewReferencePath = sNewReferencePath + fs + sNewSubDir;
+ // String sNameNoSuffix = FileHelper.getNameNoSuffix(FileHelper.getBasename(sEntry));
+ // sNewReferenceFile = sNewReferencePath + fs + sNameNoSuffix + ".prn";
+
+ sNewOutputPath = sNewOutputPath + fs + sNewSubDir;
+ if (sNewDiffPath != null)
+ sNewDiffPath = sNewDiffPath + fs + sNewSubDir;
+ }
+
+ // NameHelper aNameContainer = new NameHelper(m_sOutputPath, sNewSubDir, FileHelper.getBasename(sEntry));
+ // aNameContainer.print();
+
+ if (aGTA.checkIfUsableDocumentType(sEntry))
+ {
+ runGDCWithStatus(HTMLoutput, LISToutput, sEntry, sNewOutputPath, sNewReferencePath, sNewDiffPath, sNewSubDir);
+ }
+ if (aGTA.cancelRequest())
+ {
+ break;
+ }
+ }
+ }
+ }
+ else
+ {
+ // check exact name
+ if (aGTA.checkIfUsableDocumentType(m_sInputPath))
+ {
+ runGDCWithStatus(HTMLoutput, LISToutput, m_sInputPath, m_sOutputPath, m_sReferencePath, m_sDiffPath, "");
+ }
+ }
+
+ LISToutput.close();
+ HTMLoutput.close();
+ log.println("The file '" + HTMLoutput.getFilename() + "' shows a html based status.");
+ DB.writeHTMLFile(HTMLoutput.getFilename());
+ }
+
+
+ // -----------------------------------------------------------------------------
+ void runGDCWithStatus(HTMLOutputter _aHTMLoutput, LISTOutputter _aLISToutput, String _sInputFile, String _sOutputPath, String _sReferencePath, String _sDiffPath, String _sNewSubDir )
+ {
+ // start a fresh Office
+ GraphicalTestArguments aGTA = getGraphicalTestArguments();
+
+ OfficeProvider aProvider = null;
+ // SimpleFileSemaphore aSemaphore = new SimpleFileSemaphore();
+ if (aGTA.shouldOfficeStart())
+ {
+ // if (OSHelper.isWindows())
+ // {
+ // aSemaphore.P(aSemaphore.getSemaphoreFile());
+ // }
+
+ aGTA.getPerformance().startTime(PerformanceContainer.OfficeStart);
+ aProvider = new OfficeProvider();
+ XMultiServiceFactory xMSF = (XMultiServiceFactory) aProvider.getManager(param);
+ param.put("ServiceFactory", xMSF);
+ aGTA.getPerformance().stopTime(PerformanceContainer.OfficeStart);
+
+ long nStartTime = aGTA.getPerformance().getTime(PerformanceContainer.OfficeStart);
+ aGTA = getGraphicalTestArguments(); // get new TestArguments
+ aGTA.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.get().println("Set office watcher");
+ OfficeWatcher aWatcher = (OfficeWatcher)param.get("Watcher");
+ GlobalLogWriter.get().setWatcher(aWatcher);
+ // initializeWatcher(param);
+
+ String sStatusRunThrough = "";
+ String sStatusMessage = "";
+ try
+ {
+ DB.destination_start();
+ // better was:
+ // load document
+ // create postscript from document
+ // check file
+ GraphicalDifferenceCheck.checkOneFile(_sInputFile, _sOutputPath, _sReferencePath, _sDiffPath, aGTA);
+ sStatusRunThrough = "PASSED, OK";
+ DB.destination_finished();
+ }
+ catch(ConvWatchCancelException e)
+ {
+ assure(e.getMessage(), false, true);
+ sStatusRunThrough = "CANCELLED, FAILED";
+ sStatusMessage = e.getMessage();
+ DB.destination_failed(sStatusRunThrough, sStatusMessage);
+ }
+ catch(ConvWatchException e)
+ {
+ assure(e.getMessage(), false, true);
+ sStatusMessage = e.getMessage();
+ sStatusRunThrough = "PASSED, FAILED";
+ DB.destination_failed(sStatusRunThrough, sStatusMessage);
+ }
+ catch(com.sun.star.lang.DisposedException e)
+ {
+ assure(e.getMessage(), false, true);
+ sStatusMessage = e.getMessage();
+ sStatusRunThrough = "FAILED, FAILED";
+ DB.destination_failed(sStatusRunThrough, sStatusMessage);
+ }
+
+ GlobalLogWriter.get().println("Watcher count is: " + aWatcher.getPing());
+
+ // Office shutdown
+ if (aProvider != null)
+ {
+ aProvider.closeExistingOffice(param, 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.
+ // }
+ }
+
+ // -------------------- Status --------------------
+ String fs = System.getProperty("file.separator");
+ String sBasename = FileHelper.getBasename(_sInputFile);
+ String sFilenameNoSuffix = FileHelper.getNameNoSuffix(sBasename);
+
+ // -------------------- List of all files -----------------
+ String sListFile;
+ if (_sNewSubDir.length() > 0)
+ {
+ sListFile = _sNewSubDir + fs + sFilenameNoSuffix + ".ini";
+ }
+ else
+ {
+ sListFile = sFilenameNoSuffix + ".ini";
+ }
+ _aLISToutput.writeValue(sListFile);
+
+ // -------------------- HTML --------------------
+ String sLink;
+ String sLinkDD;
+ String sLinkName;
+ String sLinkDDName;
+ String sHTMLPrefix = aGTA.getHTMLOutputPrefix();
+
+ GlobalLogWriter.get().println("----------------------------------------------------------------------");
+ GlobalLogWriter.get().println(" OutputPath: " + _sOutputPath);
+ GlobalLogWriter.get().println(" NewPath: " + _sNewSubDir);
+ GlobalLogWriter.get().println("----------------------------------------------------------------------");
+
+// if (_sNewSubDir.length() > 0)
+// {
+// sLink = sHTMLPrefix /* + "/cw.php?inifile=" */ + _sOutputPath + fs + _sNewSubDir + fs + sFilenameNoSuffix + ".ini";
+// sLinkDD = sHTMLPrefix /* + "/cw.php?inifile=" */ + _sOutputPath + fs + _sNewSubDir + fs + "DiffDiff_" + sFilenameNoSuffix + ".ini";
+// }
+// else
+// {
+ sLink = sHTMLPrefix /* + "/cw.php?inifile=" */ + _sOutputPath + fs + sFilenameNoSuffix + ".ini";
+ // sLinkDD = sHTMLPrefix /* + "/cw.php?inifile=" */ + _sOutputPath + fs + _sNewSubDir + fs + "DiffDiff_" + sFilenameNoSuffix + ".ini";
+ sLinkDD = sHTMLPrefix /* + "/cw.php?inifile=" */ + _sOutputPath + fs + "DiffDiff_" + sFilenameNoSuffix + ".ini";
+// }
+ sLinkName = sFilenameNoSuffix;
+ sLinkDDName = sFilenameNoSuffix + " (DiffDiff)";
+
+ if (_sDiffPath != null && _sDiffPath.length() > 0)
+ {
+ _aHTMLoutput.indexLine( sLinkDD, sLinkDDName, sLink, sLinkName, sStatusRunThrough, sStatusMessage );
+ }
+ else
+ {
+ _aHTMLoutput.indexLine( sLink, sLinkName, "", "", sStatusRunThrough, sStatusMessage );
+ }
+
+ }
+
+
+}
diff --git a/qadevOOo/runner/convwatch/CrashLoopTest.java b/qadevOOo/runner/convwatch/CrashLoopTest.java
new file mode 100644
index 000000000000..6eb7b35391b8
--- /dev/null
+++ b/qadevOOo/runner/convwatch/CrashLoopTest.java
@@ -0,0 +1,57 @@
+/*************************************************************************
+ *
+ * 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 convwatch;
+
+public class CrashLoopTest extends ReferenceBuilder
+{
+ // The first of the mandatory functions:
+ /**
+ * Return the name of the test.
+ * In this case it is the actual name of the service.
+ * @return The tested service.
+ */
+ public String getTestObjectName() {
+ return "CrashLoopTest runner";
+ }
+
+ // The second of the mandatory functions: return all test methods as an
+ // array. There is only one test function in this example.
+ /**
+ * Return all test methods.
+ * @return The test methods.
+ */
+ public String[] getTestMethodNames() {
+ return new String[]{"testcrashandloops"};
+ }
+
+ public void testcrashandloops()
+ {
+ buildreference();
+ }
+
+}
diff --git a/qadevOOo/runner/convwatch/DB.java b/qadevOOo/runner/convwatch/DB.java
new file mode 100644
index 000000000000..4f6ab74a738b
--- /dev/null
+++ b/qadevOOo/runner/convwatch/DB.java
@@ -0,0 +1,541 @@
+package convwatch;
+
+import java.sql.Connection;
+import java.util.StringTokenizer;
+import java.util.ArrayList;
+import helper.OSHelper;
+
+// import convwatch.DBHelper;
+
+public class DB extends DBHelper
+{
+ private static DB m_aDB = null;
+
+ // private ctor
+ private DB()
+ {
+ }
+
+ private static synchronized DB getDB()
+ {
+ if (m_aDB == null)
+ {
+ m_aDB = new DB();
+ }
+ return m_aDB;
+ }
+
+ private String m_sSourceVersion;
+ private String m_sDestinationVersion;
+ private String m_sDocumentPool;
+ private String m_sEnvironment;
+ private String m_sDocID;
+ private String m_sDBDistinct;
+
+ public static void init(String _sDBInfoString)
+ {
+ if (_sDBInfoString == null) return;
+ getDB().fillVariables(_sDBInfoString);
+ getDB().updatestate_status("source started");
+ }
+
+ public static void test()
+ {
+ getDB().sql_test();
+ }
+
+ public static void source_start()
+ {
+ getDB().updatestate_status("source started");
+ }
+
+ public static void source_finished()
+ {
+ getDB().updatestate_status( "source finished");
+ }
+
+ public static void source_failed(String _sMessage)
+ {
+ getDB().updatestate_status("source failed");
+ getDB().updateinfo_status(_sMessage);
+ }
+
+ public static void destination_start()
+ {
+ getDB().updatestate_status("destination started");
+ }
+
+ public static void destination_finished()
+ {
+ getDB().updatestate_status("PASSED-OK");
+ }
+
+ public static void destination_failed(String _sStatus, String _sMessage)
+ {
+ getDB().updatestate_status(_sStatus);
+ getDB().updateinfo_status(_sMessage);
+ }
+ public static void writeNumberOfPages(int _nPages)
+ {
+ getDB().updatepagecount_documents(_nPages);
+ }
+ public static void writeErrorFile(String _sErrorFile)
+ {
+ getDB().updateerrorfile_status(_sErrorFile);
+ }
+ public static void writeHTMLFile(String _sHTMLFile)
+ {
+ getDB().updatehtmlfile_status(_sHTMLFile);
+ }
+
+ public static void writeToDB(String _sFilename,
+ String _sBasename,
+ String _sFileFormat,
+ String _sBuildID,
+ String _sSourceType,
+ int _nResolution )
+ {
+ GlobalLogWriter.get().println("DB: Filename:" + _sFilename);
+ GlobalLogWriter.get().println("DB: Basename:" + _sBasename);
+ GlobalLogWriter.get().println("DB: FileFormat:" + _sFileFormat);
+ GlobalLogWriter.get().println("DB: BuildID:" + _sBuildID);
+ GlobalLogWriter.get().println("DB: SourceType:" + _sSourceType);
+ GlobalLogWriter.get().println("DB: Resolution:" + _nResolution);
+ }
+
+ private String getEnvironment()
+ {
+ if (OSHelper.isWindows())
+ {
+ return "wntmsci";
+ }
+ else if ( OSHelper.isSolarisIntel())
+ {
+ return "unxsoli";
+ }
+ else if ( OSHelper.isSolarisSparc())
+ {
+ return "unxsols";
+ }
+ else if ( OSHelper.isLinuxIntel())
+ {
+ return "unxlngi";
+ }
+ else
+ {
+ GlobalLogWriter.get().println("DB: Unknown environment.");
+ GlobalLogWriter.get().println("DB: os.name := " + System.getProperty("os.name").toLowerCase());
+ GlobalLogWriter.get().println("DB: os.arch := " + System.getProperty("os.arch"));
+ return "";
+ }
+ }
+
+ // fill some db access important variables with values given out of a simple string
+ // DOC_COMPARATOR_DB_INFO_STRING=p:m220,c:m224,d:demo_lla,src:m220,dest:m224,doc:demo_lla,id:294,distinct:81
+
+ private void fillVariables(String _sInfo)
+ {
+ fillDBConnection(_sInfo);
+ m_sEnvironment = getEnvironment();
+
+ StringTokenizer aTokenizer = new StringTokenizer(_sInfo,",",false);
+ while (aTokenizer.hasMoreTokens())
+ {
+ String sPart = aTokenizer.nextToken();
+ if (sPart.startsWith("p:"))
+ {
+ m_sSourceVersion = sPart.substring(2);
+ GlobalLogWriter.get().println("DB: source version: " + m_sSourceVersion);
+ }
+ else if (sPart.startsWith("src:"))
+ {
+ m_sSourceVersion = sPart.substring(4);
+ GlobalLogWriter.get().println("DB: source version: " + m_sSourceVersion);
+ }
+ else if (sPart.startsWith("c:"))
+ {
+ m_sDestinationVersion = sPart.substring(2);
+ GlobalLogWriter.get().println("DB: destination version: " + m_sDestinationVersion);
+ }
+ else if (sPart.startsWith("dest:"))
+ {
+ m_sDestinationVersion = sPart.substring(5);
+ GlobalLogWriter.get().println("DB: destination version: " + m_sDestinationVersion);
+ }
+ else if (sPart.startsWith("d:"))
+ {
+ m_sDocumentPool = sPart.substring(2);
+ GlobalLogWriter.get().println("DB: documentpool version: " + m_sDocumentPool);
+ }
+ else if (sPart.startsWith("doc:"))
+ {
+ m_sDocumentPool = sPart.substring(4);
+ GlobalLogWriter.get().println("DB: documentpool version: " + m_sDocumentPool);
+ }
+ else if (sPart.startsWith("id:"))
+ {
+ m_sDocID = sPart.substring(3);
+ GlobalLogWriter.get().println("DB: docid: " + m_sDocID);
+ }
+ else if (sPart.startsWith("distinct:"))
+ {
+ m_sDBDistinct = sPart.substring(9);
+ GlobalLogWriter.get().println("DB: distinct: " + m_sDBDistinct);
+ }
+ else
+ {
+ }
+ }
+ }
+
+ // public static void insertinto_file(String _sFilename,
+ // String _sBasename,
+ // String _sFileFormat,
+ // String _sBuildID,
+ // String _sSourceType,
+ // int _nResolution )
+ // {
+ // Connection aCon = new ShareConnection().getConnection();
+ //
+ // String sFilename = _sFilename.replace('\\', '/');
+ //
+ // String sDeleteOld = "DELETE FROM file WHERE filename = " + Quote(sFilename);
+ // ExecSQL(aCon, sDeleteOld);
+ //
+ // String sValueLine = "type, filename, basename, fileformat, buildid, resolution, date";
+ // StringBuffer aDataLine = new StringBuffer();
+ // aDataLine.append( Quote(_sSourceType) ) . append( sComma ) .
+ // append( Quote( sFilename) ) . append( sComma ) .
+ // append( Quote( _sBasename) ) . append( sComma ) .
+ // append( Quote( _sFileFormat) ) . append( sComma ) .
+ // append( Quote( _sBuildID) ) . append( sComma ) .
+ // append( _nResolution) . append( sComma ) .
+ // append( Quote( today() ) );
+ //
+ // SQLinsertValues(aCon, "file", sValueLine, aDataLine.toString());
+ // }
+
+ // public static void updatestate_currentdocs(String _sFilename,
+ // String _sState)
+ // {
+ // Connection aCon = new ShareConnection().getConnection();
+ //
+ // String sFilename = _sFilename.replace('\\', '/');
+ //
+ // // String sDeleteOld = "DELETE FROM file WHERE filename = " + Quote(sFilename);
+ // // ExecSQL(aCon, sDeleteOld);
+ //
+ // String sSet = "state=" + Quote(_sState);
+ // String sWhere = getWhereClause() + sAND + "name=" + Quote(sFilename);
+ // SQLupdateValue( aCon, "currentdocs", sSet, sWhere );
+ // }
+
+ private void sql_test()
+ {
+ String sUUID = getDBDistinct();
+ System.out.println("UUID: " + sUUID);
+ }
+
+ public ArrayList QuerySQL(Connection _aCon, String _sSQL)
+ {
+ java.sql.Statement oStmt = null;
+ Connection oCon = null;
+ ArrayList aResultList = new ArrayList();
+ try
+ {
+ oStmt = _aCon.createStatement();
+
+ java.sql.ResultSet aResultSet = oStmt.executeQuery(_sSQL);
+ java.sql.ResultSetMetaData aResultSetMetaData = aResultSet.getMetaData();
+
+ int nColumnCount = aResultSetMetaData.getColumnCount(); // java sql starts with '1'
+ // String[] aColumnName = new String[nColumnCount];
+ // for(int i=1;i<nColumnCount;i++)
+ // {
+ // String aColumnName[i - 1] = aResultSetMetaData.getColumnName(i);
+ // }
+
+ while( aResultSet.next() )
+ {
+ StringBuffer aResult = new StringBuffer();
+ try
+ {
+ Object aObj = null;
+
+
+ aResult.append("sqlresult: ");
+ for (int i=1;i<=nColumnCount;i++)
+ {
+ String sColumnName = aResultSetMetaData.getColumnName(i);
+ aResult.append(sColumnName).append("=");
+ String sValue;
+ int nSQLType = aResultSetMetaData.getColumnType(i);
+ switch(nSQLType)
+ {
+ case java.sql.Types.VARCHAR:
+ sValue = "'" + aResultSet.getString(i) + "'";
+ break;
+ case java.sql.Types.INTEGER:
+ {
+ int nValue = aResultSet.getInt(i);
+ sValue = String.valueOf(nValue);
+ break;
+ }
+
+ default:
+ sValue = "UNSUPPORTED TYPE";
+ }
+ aResult.append(sValue).append(", ");
+ // String sName = aObj.getClass().getName();
+ // System.out.println("sqlresult: Class name: " + sName);
+ }
+ String sResult = aResult.toString();
+ aResultList.add(sResult);
+ // System.out.println(sResult);
+ }
+ catch (java.sql.SQLException e)
+ {
+ }
+ }
+ }
+ catch (java.sql.SQLException e)
+ {
+ String sError = e.getMessage();
+ GlobalLogWriter.get().println("DB: Original SQL error: " + sError);
+ // throw new ValueNotFoundException("Cant execute SQL: " + _sSQL);
+ }
+ return aResultList;
+ }
+
+ private void updatestate_status(String _sStatus)
+ {
+ Connection aCon = new ShareConnection().getConnection();
+
+ // String sInfo = _sInfo.replace('\\', '/');
+
+ // String sDeleteOld = "DELETE FROM file WHERE filename = " + Quote(sFilename);
+ // ExecSQL(aCon, sDeleteOld);
+
+ String sSet = "state=" + Quote(_sStatus);
+ String sWhere = getWhereClause();
+ if (sWhere.length() > 0)
+ {
+ SQLupdateValue( aCon, "status", sSet, sWhere );
+ }
+ }
+ private void updateinfo_status(String _sInfo)
+ {
+ Connection aCon = new ShareConnection().getConnection();
+
+ // String sInfo = _sInfo.replace('\\', '/');
+
+ // String sDeleteOld = "DELETE FROM file WHERE filename = " + Quote(sFilename);
+ // ExecSQL(aCon, sDeleteOld);
+
+ String sSet = "info=" + Quote(_sInfo);
+ String sWhere = getWhereClause();
+ SQLupdateValue( aCon, "status", sSet, sWhere );
+ }
+ private void updateerrorfile_status(String _sErrorFile)
+ {
+ Connection aCon = new ShareConnection().getConnection();
+
+ String sErrorFile = _sErrorFile.replace('\\', '/');
+
+ String sSet = "errorfile=" + Quote(sErrorFile);
+ String sWhere = getWhereClause();
+ SQLupdateValue( aCon, "status", sSet, sWhere );
+ }
+ private void updatehtmlfile_status(String _sHtmlFile)
+ {
+ Connection aCon = new ShareConnection().getConnection();
+
+ String sHtmlFile = _sHtmlFile.replace('\\', '/');
+
+ String sSet = "htmlfile=" + Quote(sHtmlFile);
+ String sWhere = getWhereClause();
+ SQLupdateValue( aCon, "status", sSet, sWhere );
+ }
+ private void updatepagecount_documents(int _nPageCount)
+ {
+ Connection aCon = new ShareConnection().getConnection();
+
+ String sSet = "pagecount=" + _nPageCount;
+ String sWhere = getWhereClause();
+ SQLupdateValue( aCon, "documents", sSet, sWhere );
+
+ }
+
+
+ private String getWhereClause()
+ {
+ StringBuffer aWhereClause = new StringBuffer();
+ // WHERE environment='' and referenceversion='' and currentversion='' and documentpool=''
+ // aWhere.append( "environment" ). append(sEqual) . append(Quote(m_sEnvironment)) .
+ // append(sAND) .
+ // append( "referenceversion" ). append(sEqual) . append(Quote(m_sSourceVersion)) .
+ // append(sAND) .
+ // append( "currentversion" ). append(sEqual) . append(Quote(m_sDestinationVersion)) .
+ // append(sAND) .
+ // append( "documentpool" ). append(sEqual) . append(Quote(m_sDocumentPool));
+ boolean bAND = false;
+ if (m_sDocID != null)
+ {
+ aWhereClause.append( "docid" ). append(sEqual) . append(m_sDocID);
+ bAND = true;
+ }
+ if (bAND)
+ {
+ aWhereClause.append(sAND);
+ }
+ if (m_sDBDistinct != null)
+ {
+ aWhereClause.append( "dbdistinct2" ). append(sEqual) . append(Quote(m_sDBDistinct));
+ }
+ return aWhereClause.toString();
+ }
+
+ private String getDBDistinct()
+ {
+ Connection aCon = new ShareConnection().getConnection();
+
+ String sSQL = "SELECT uuid()";
+ ArrayList aResultList = QuerySQL(aCon, sSQL);
+
+ for (int i=0;i<aResultList.size();i++)
+ {
+ String sResult = (String)aResultList.get(i);
+
+ StringTokenizer aTokenizer = new StringTokenizer(sResult,",",false);
+ while (aTokenizer.hasMoreTokens())
+ {
+ String sToken = aTokenizer.nextToken();
+ // System.out.println("PART: " + sToken);
+ int nIndex = sToken.indexOf("uuid()=");
+ // System.out.println("Index " + nIndex);
+ int nIndexTuettel = sToken.indexOf("'", nIndex);
+ // System.out.println("IndexTuettel " + nIndexTuettel);
+ int nIndexTuettel2 = sToken.lastIndexOf("'");
+ // System.out.println("IndexTuettel2 " + nIndexTuettel2);
+ String sUuid = sToken.substring(nIndexTuettel + 1, nIndexTuettel2);
+ // if (sPart.startsWith("p:"))
+ // {
+ // m_sSourceVersion = sPart.substring(2);
+ // GlobalLogWriter.get().println("DB: source version: " + m_sSourceVersion);
+ // }
+ return sUuid;
+ }
+ // System.out.println(sResult);
+ }
+
+ return "0";
+ }
+
+ public static void insertinto_documentcompare(String _sSourceVersion, String _sSourceName, String _sSourceCreatorType,
+ String _sDestinationVersion, String _sDestinationName, String _sDestinationCreatorType,
+ String _sDocumentPoolDir, String _sDocumentPoolName, String _sMailAddress,
+ String _sSpecial, String _sParentDistinct)
+ {
+ getDB().insertinto_documentcompare_impl( _sSourceVersion, _sSourceName, _sSourceCreatorType,
+ _sDestinationVersion, _sDestinationName, _sDestinationCreatorType,
+ _sDocumentPoolDir, _sDocumentPoolName, _sMailAddress,
+ _sSpecial, _sParentDistinct);
+ }
+
+ private void insertinto_documentcompare_impl(String _sSourceVersion, String _sSourceName, String _sSourceCreatorType,
+ String _sDestinationVersion, String _sDestinationName, String _sDestinationCreatorType,
+ String _sDocumentPoolDir, String _sDocumentPoolName, String _sMailAddress,
+ String _sSpecial, String _sParentDistinct)
+ {
+ // $sSQLInsert = "INSERT INTO documentcompare
+ if (_sParentDistinct == null)
+ {
+ _sParentDistinct = "";
+ }
+
+ Connection aCon = new ShareConnection().getConnection();
+
+ String sValueLine="dbdistinct2, environment, sourceversion, sourcename, sourcecreatortype, destinationversion, destinationname, destinationcreatortype, documentpoolpath, documentpool, mailfeedback, state, special, parentdistinct, startdate";
+ String sDocumentPoolDir = _sDocumentPoolDir.replace('\\', '/');
+ StringBuffer aDataLine = new StringBuffer();
+ aDataLine.append( Quote(getDBDistinct()) ) . append( sComma ) .
+ append( Quote( getEnvironment()) ) . append( sComma ) .
+ append( Quote( _sSourceVersion) ) . append( sComma ) .
+ append( Quote( _sSourceName) ) . append( sComma ) .
+ append( Quote( _sSourceCreatorType ) ) . append( sComma ) .
+ append( Quote( _sDestinationVersion) ) . append( sComma ) .
+ append( Quote( _sDestinationName) ) . append( sComma ) .
+ append( Quote( _sDestinationCreatorType ) ) . append( sComma ) .
+ append( Quote( sDocumentPoolDir) ) . append( sComma ) .
+ append( Quote( _sDocumentPoolName) ) . append( sComma ) .
+ append( Quote( _sMailAddress) ) . append( sComma ) .
+ append( Quote( "new" )) . append ( sComma ) .
+ append( Quote( _sSpecial ) ) . append( sComma ) .
+ append( Quote( _sParentDistinct ) ) . append( sComma ) .
+ append( Quote( today() ));
+
+ SQLinsertValues(aCon, "documentcompare", sValueLine, aDataLine.toString());
+ }
+
+ // public static void filesRemove(String _sDBInfoString)
+ // {
+ // if (_sDBInfoString == null) return;
+ // fillVariables(_sDBInfoString);
+ //
+ // Connection aCon = new ShareConnection().getConnection();
+ //
+ // String sDeleteSQL = "DELETE FROM currentdocs WHERE " + getWhereClause();
+ //
+ // ExecSQL(aCon, sDeleteSQL);
+ // }
+ //
+ // public static void fileInsert(String _sDBInfoString,
+ // String _sFilename,
+ // String _sRemovePath)
+ // {
+ // if (_sDBInfoString == null) return;
+ // fillVariables(_sDBInfoString);
+ //
+ // String sFilename = _sFilename.replace('\\', '/');
+ //
+ // Connection aCon = new ShareConnection().getConnection();
+ //
+ // String sValueLine = "environment, referenceversion, currentversion, documentpool, name, state";
+ // StringBuffer aDataLine = new StringBuffer();
+ // aDataLine.append( Quote(m_sEnvironment) ) . append( sComma ) .
+ // append( Quote( m_sSourceVersion) ) . append( sComma ) .
+ // append( Quote( m_sDestinationVersion) ) . append( sComma ) .
+ // append( Quote( m_sDocumentPool) ) . append( sComma ) .
+ // append( Quote( sFilename) ) . append( sComma ) .
+ // append( Quote( "undone"));
+ //
+ // SQLinsertValues(aCon, "currentdocs", sValueLine, aDataLine.toString());
+ // }
+
+
+ // public static void insertinto_file(String _sFilename, String _sFileFormat, String _sBuildID)
+ // {
+ // Connection aCon = new ShareConnection().getConnection();
+ //
+ // String sValueLine = "type, filename, fileformat, buildid, date";
+ // StringBuffer aDataLine = new StringBuffer();
+ // aDataLine.append( "1" ) . append( sComma ) .
+ // append( Quote( _sFilename) ) . append( sComma ) .
+ // append( Quote( _sFileFormat) ) . append( sComma ) .
+ // append( Quote( _sBuildID) ) . append( sComma ) .
+ // append( Quote( today() ) );
+ //
+ // SQLinsertValues(aCon, "file", sValueLine, aDataLine.toString());
+ // }
+
+ // public static void main( String[] args )
+ // {
+ //
+ // String _sFilename = "";
+ // String _sFileFormat = "";
+ // String _sBuildID = "";
+ //
+ // // insertinto_file("c:\temp\test.txt", "test", "txt", "nix", "", 0);
+ // fillVariables("p:m128,c:m134,d:demo");
+ // }
+}
diff --git a/qadevOOo/runner/convwatch/DBHelper.java b/qadevOOo/runner/convwatch/DBHelper.java
new file mode 100644
index 000000000000..e28fafb65ec4
--- /dev/null
+++ b/qadevOOo/runner/convwatch/DBHelper.java
@@ -0,0 +1,316 @@
+/*************************************************************************
+ *
+ * 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 convwatch;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.Statement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+import java.lang.Thread;
+import java.util.StringTokenizer;
+
+class ShareConnection
+{
+ private Connection m_aConnection = null;
+ public ShareConnection()
+ {}
+
+ public Connection getConnection()
+ {
+ if (m_aConnection == null)
+ {
+ try
+ {
+ m_aConnection = DBHelper.getMySQLConnection();
+ }
+ catch(java.sql.SQLException e)
+ {
+ GlobalLogWriter.get().println("DB: ERROR: can't connect to DB.");
+ m_aConnection = null;
+ }
+ }
+ return m_aConnection;
+ }
+}
+
+ class MySQLThread extends Thread
+ {
+ Connection m_aCon = null;
+ String m_sSQL;
+ public MySQLThread(Connection _aCon, String _sSQL)
+ {
+ m_aCon = _aCon;
+ m_sSQL = _sSQL;
+ }
+
+ public void run()
+ {
+ Statement oStmt = null;
+ if (m_aCon == null)
+ {
+ GlobalLogWriter.get().println("DB: ERROR: in ExecSQL, connection not established.");
+ return;
+ }
+
+ // Connection oCon = null;
+ try
+ {
+ // oCon = getMySQLConnection();
+ oStmt = m_aCon.createStatement();
+
+ GlobalLogWriter.get().println("DB: " + m_sSQL);
+ /* ResultSet oResult = */
+ oStmt.executeUpdate(m_sSQL);
+ }
+ catch(Exception e)
+ {
+ GlobalLogWriter.get().println("DB: Couldn't execute sql string '" + m_sSQL + "'");
+ GlobalLogWriter.get().println("DB: Reason: " + e.getMessage());
+ }
+ }
+ }
+
+public class DBHelper
+{
+ /**
+ * This method inserts given values into<br>
+ * the table 'states'
+ * @param values a set of comma separated values to be inserted
+ */
+
+ public void SQLinsertValues(Connection _aCon, String _sTableName, String value_names, String values)
+ {
+ if (_aCon == null)
+ {
+ GlobalLogWriter.get().println("DB: ERROR: in SQLinsertValues, connection not established.");
+ return;
+ }
+
+ // String aInsertStr = "";
+ //
+ // aInsertStr = "INSERT INTO " + _sTableName + " (" + value_names + " ) VALUES (" + values + ")";
+ // ExecSQL(_aCon, aInsertStr);
+ StringBuffer aInsertStr = new StringBuffer();
+
+ aInsertStr.append( "INSERT INTO " ) . append( _sTableName );
+ aInsertStr.append( " (").append( value_names ).append ( ")" );
+ aInsertStr.append(" VALUES (" ).append( values ).append( ")" );
+ ExecSQL(_aCon, aInsertStr.toString() );
+ }
+
+ public void SQLupdateValue(Connection _aCon, String _sTableName, String _sSet, String _sWhere)
+ {
+ if (_aCon == null)
+ {
+ GlobalLogWriter.get().println("DB: ERROR: in SQLinsertValues, connection not established.");
+ return;
+ }
+
+ // String aUpdateStr = "";
+ //
+ // aUpdateStr = "UPDATE " + _sTableName + " SET " + _sSet + " WHERE " + _sWhere;
+ // ExecSQL( _aCon, aUpdateStr );
+ StringBuffer aUpdateStr = new StringBuffer();
+
+ aUpdateStr.append( "UPDATE " ).append( _sTableName )
+ .append( " SET " ).append( _sSet )
+ .append( " WHERE " ).append( _sWhere );
+ ExecSQL( _aCon, aUpdateStr.toString() );
+ }
+
+ private static String m_sDBServerName;
+ private static String m_sDBName;
+ private static String m_sDBUser;
+ private static String m_sDBPasswd;
+
+ protected synchronized void fillDBConnection(String _sInfo)
+ {
+ StringTokenizer aTokenizer = new StringTokenizer(_sInfo,",",false);
+ while (aTokenizer.hasMoreTokens())
+ {
+ String sPart = aTokenizer.nextToken();
+ if (sPart.startsWith("db:"))
+ {
+ m_sDBName = sPart.substring(3);
+ // GlobalLogWriter.get().println("DB: source version: " + m_sSourceVersion);
+ }
+ else if (sPart.startsWith("user:"))
+ {
+ m_sDBUser = sPart.substring(5);
+ }
+ else if (sPart.startsWith("passwd:"))
+ {
+ m_sDBPasswd = sPart.substring(7);
+ }
+ else if (sPart.startsWith("server:"))
+ {
+ m_sDBServerName = sPart.substring(7);
+ }
+ }
+ }
+
+ /**
+ * This method establishes a Connection<br>
+ * with the database 'module_unit' on jakobus
+ */
+
+ public static Connection getMySQLConnection() throws SQLException
+ {
+ try
+ {
+ Class.forName("org.gjt.mm.mysql.Driver");
+ String sConnection = "jdbc:mysql://" + m_sDBServerName + ":3306/" + m_sDBName;
+ // Connection mysql = DriverManager.getConnection(
+ // "jdbc:mysql://jakobus:3306/jobs_convwatch","admin","admin");
+ Connection mysql = DriverManager.getConnection(sConnection, m_sDBUser, m_sDBPasswd);
+ return mysql;
+ }
+ catch (ClassNotFoundException e)
+ {
+ GlobalLogWriter.get().println("DB: Class not found exception caught: " + e.getMessage());
+ GlobalLogWriter.get().println("DB: Maybe mysql.jar is not added to the classpath.");
+ }
+ return null;
+ }
+
+
+ /**
+ * This method removes all entries of the given<br>
+ * module/platform combination
+ * @param mdl the name of the module, e.g. sal
+ * @param os the name of the platform, e.g. unxsols
+ */
+ // LLA: public static void SQLdeleteValues(Connection _aCon, String _sEnvironment, String _sUnitName, String _sMethodName, String _sCWS, String _sDate)
+ // LLA: {
+ // LLA: String sSQL =
+ // LLA: "DELETE FROM states WHERE " +
+ // LLA: " unit=" + DatabaseEntry.Quote(_sUnitName) +
+ // LLA: " AND pf=" + DatabaseEntry.Quote (_sEnvironment) +
+ // LLA: " AND meth=" + DatabaseEntry.Quote (_sMethodName) +
+ // LLA: " AND cws=" + DatabaseEntry.Quote(_sCWS) +
+ // LLA: " AND dt=" + DatabaseEntry.Quote(_sDate);
+ // LLA:
+ // LLA: // ExecSQL(_aCon, sSQL);
+ // LLA: }
+
+ protected synchronized void ExecSQL(Connection _aCon, String _sSQL)
+ {
+ MySQLThread aSQLThread = new MySQLThread(_aCon, _sSQL);
+ aSQLThread.start();
+ }
+
+
+
+ // public static int QueryIntFromSQL(String _sSQL, String _sColumnName, String _sValue)
+ // {
+ // boolean bNeedSecondTry = false;
+ // int nValue = 0;
+ // do
+ // {
+ // try
+ // {
+ // nValue = QueryIntFromSQL(_sSQL, _sColumnName, _sValue);
+ // }
+ // catch (ValueNotFoundException e)
+ // {
+ // bNeedSecondTry = true;
+ // String sSQL = "INSERT INTO " + _sTable + "(" + _sColumnName + ") VALUES (" + _sValue + ")";
+ // ExecSQL(sSQL);
+ // }
+ // } while (bNeedSecondTry);
+ // return nValue;
+ // }
+
+ public int QueryIntFromSQL(Connection _aCon, String _sSQL, String _sColumnName)
+ throws ValueNotFoundException
+ {
+ Statement oStmt = null;
+ Connection oCon = null;
+ int nValue = 0;
+ try
+ {
+ // oCon = getMySQLConnection();
+ oStmt = _aCon.createStatement();
+
+ ResultSet oResult = oStmt.executeQuery(_sSQL);
+ oResult.next();
+
+ try
+ {
+ if (_sColumnName.length() == 0)
+ {
+ // take the first row value (started with 1)
+ nValue = oResult.getInt(1);
+ }
+ else
+ {
+ nValue = oResult.getInt(_sColumnName);
+ }
+ // System.out.println("value: " + String.valueOf(nValue));
+ }
+ catch (SQLException e)
+ {
+ String sError = e.getMessage();
+ GlobalLogWriter.get().println("DB: Original SQL error: " + sError);
+ throw new ValueNotFoundException("Cant execute SQL: " + _sSQL);
+ }
+ }
+ catch(SQLException e)
+ {
+ String sError = e.getMessage();
+ GlobalLogWriter.get().println("DB: Couldn't execute sql string " + _sSQL + "\n" + sError);
+ }
+ return nValue;
+ }
+
+ public String Quote(String _sToQuote)
+ {
+ String ts = "'";
+ String ds = "\"";
+ int nQuote = _sToQuote.indexOf(ts);
+ if (nQuote >= 0)
+ {
+ return ds + _sToQuote + ds;
+ }
+ return ts + _sToQuote + ts;
+ }
+
+/* default date format in the MySQL DB yyyy-MM-dd */
+ public static String today()
+ {
+ return DateHelper.getDateString("yyyy-MM-dd");
+ }
+
+ public static final String sComma = ",";
+ public static final String sEqual = "=";
+ public static final String sAND = " AND ";
+
+}
+
diff --git a/qadevOOo/runner/convwatch/DateHelper.java b/qadevOOo/runner/convwatch/DateHelper.java
new file mode 100755
index 000000000000..59207ea3ee3a
--- /dev/null
+++ b/qadevOOo/runner/convwatch/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 convwatch;
+
+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/convwatch/DirectoryHelper.java b/qadevOOo/runner/convwatch/DirectoryHelper.java
new file mode 100644
index 000000000000..a15d790b9c25
--- /dev/null
+++ b/qadevOOo/runner/convwatch/DirectoryHelper.java
@@ -0,0 +1,156 @@
+/*************************************************************************
+ *
+ * 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 convwatch;
+
+import java.io.File;
+import java.io.FileFilter;
+import java.util.ArrayList;
+
+/**
+ * Helper for directory access
+ *
+ * @author Lars.Langhans@sun.com
+ */
+public class DirectoryHelper
+{
+ ArrayList m_aFileList = new ArrayList();
+ 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);
+ * }
+ *
+ */
+ 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/convwatch/DocumentConverter.java b/qadevOOo/runner/convwatch/DocumentConverter.java
new file mode 100644
index 000000000000..f6583dd5fdbc
--- /dev/null
+++ b/qadevOOo/runner/convwatch/DocumentConverter.java
@@ -0,0 +1,277 @@
+/*************************************************************************
+ *
+ * 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 convwatch;
+
+// imports
+import java.io.File;
+import java.io.FileFilter;
+import java.util.ArrayList;
+
+import com.sun.star.lang.XMultiServiceFactory;
+
+import convwatch.DirectoryHelper;
+import convwatch.OfficePrint;
+import convwatch.ConvWatchException;
+import convwatch.EnhancedComplexTestCase;
+import convwatch.PropertyName;
+import helper.OfficeProvider;
+
+/**
+ * The following Complex Test will test
+ * an already created document and it's postscript output (by an older office version)
+ * with a new office version.
+ * This test use Ghostscript for the jpeg export and graphically compare tools from ImageMagick.
+ * Read the manual for more information.
+ *
+ * this is only the starter program
+ * more is found in qadevOOo/runner/convwatch/*
+ */
+
+public class DocumentConverter extends EnhancedComplexTestCase
+{
+ // The first of the mandatory functions:
+ /**
+ * Return the name of the test.
+ * In this case it is the actual name of the service.
+ * @return The tested service.
+ */
+ public String getTestObjectName() {
+ return "DocumentConverter runner";
+ }
+
+ // The second of the mandatory functions: return all test methods as an
+ // array. There is only one test function in this example.
+ /**
+ * Return all test methods.
+ * @return The test methods.
+ */
+ public String[] getTestMethodNames() {
+ return new String[]{"convert"};
+ }
+
+ // This test is fairly simple, so there is no need for before() or after()
+ // methods.
+
+ public void before()
+ {
+ // System.out.println("before()");
+ }
+
+ public void after()
+ {
+ // System.out.println("after()");
+ }
+
+ // The test method itself.
+ private String m_sInputPath = "";
+ private String m_sReferencePath = "";
+ private boolean m_bIncludeSubdirectories = true;
+
+ void initMember()
+ {
+ // MUST PARAMETER
+ // INPUT_PATH ----------
+ String sINPATH = (String)param.get( PropertyName.DOC_COMPARATOR_INPUT_PATH );
+ boolean bQuit = false;
+ String sError = "";
+ if (sINPATH == null || sINPATH.length() == 0)
+ {
+ log.println("Please set input path (path to documents) " + PropertyName.DOC_COMPARATOR_INPUT_PATH + "=path.");
+ bQuit = true;
+ }
+ else
+ {
+ log.println("found " + PropertyName.DOC_COMPARATOR_INPUT_PATH + " " + sINPATH);
+ m_sInputPath = sINPATH;
+ }
+
+ // REFERENCE_PATH ----------
+ String sREF = (String)param.get( PropertyName.DOC_COMPARATOR_REFERENCE_PATH );
+ if (sREF == null || sREF.length() == 0)
+ {
+ log.println("Please set output path (path to a directory, where the references should stay) " + PropertyName.DOC_COMPARATOR_REFERENCE_PATH + "=path.");
+ bQuit = true;
+ }
+ else
+ {
+ log.println("found " + PropertyName.DOC_COMPARATOR_REFERENCE_PATH + " " + sREF);
+ m_sReferencePath = sREF;
+ }
+
+ if (bQuit == true)
+ {
+ // log.println("must quit.");
+ assure("Must quit, Parameter problems.", false);
+ }
+
+ if (m_sInputPath.startsWith("file:") ||
+ m_sReferencePath.startsWith("file:"))
+ {
+ assure("We can't handle file: URL right, use system path instead.", false);
+ }
+
+ }
+
+ /**
+ * Function returns a List of software which must accessable as an external executable
+ */
+ protected Object[] mustInstalledSoftware()
+ {
+ ArrayList aList = new ArrayList();
+ // aList.add("perl -version");
+ return aList.toArray();
+ }
+
+ // the test ======================================================================
+ public void convert()
+ {
+ GlobalLogWriter.set(log);
+ // check if all need software is installed and accessable
+ checkEnvironment(mustInstalledSoftware());
+
+ // test_removeFirstDirectorysAndBasenameFrom();
+ // Get the MultiServiceFactory.
+ // XMultiServiceFactory xMSF = (XMultiServiceFactory)param.getMSF();
+ GraphicalTestArguments aGTA = getGraphicalTestArguments();
+ if (aGTA == null)
+ {
+ assure("Must quit", false);
+ }
+
+ initMember();
+
+ File aInputPath = new File(m_sInputPath);
+ if (aInputPath.isDirectory())
+ {
+ String fs = System.getProperty("file.separator");
+
+ String sRemovePath = aInputPath.getAbsolutePath();
+ // a whole directory
+ FileFilter aFileFilter = FileHelper.getFileFilter();
+
+ Object[] aList = DirectoryHelper.traverse(m_sInputPath, aFileFilter, aGTA.includeSubDirectories());
+ for (int i=0;i<aList.length;i++)
+ {
+ String sEntry = (String)aList[i];
+
+ String sNewReferencePath = m_sReferencePath + fs + FileHelper.removeFirstDirectorysAndBasenameFrom(sEntry, m_sInputPath);
+ log.println("- next file is: ------------------------------");
+ log.println(sEntry);
+
+ if (aGTA.checkIfUsableDocumentType(sEntry))
+ {
+ runGDC(sEntry, sNewReferencePath);
+ }
+ if (aGTA.cancelRequest())
+ {
+ break;
+ }
+ }
+ }
+ else
+ {
+ if (aGTA.checkIfUsableDocumentType(m_sInputPath))
+ {
+ runGDC(m_sInputPath, m_sReferencePath);
+ }
+ }
+ }
+
+ void runGDC(String _sInputFile, String _sReferencePath)
+ {
+ // first do a check if the reference not already exist, this is a big speedup, due to the fact,
+ // we don't need to start a new office.
+ GraphicalTestArguments aGTA_local = getGraphicalTestArguments();
+ // if (GraphicalDifferenceCheck.isReferenceExists(_sInputFile, _sReferencePath, aGTA_local) == false)
+ // {
+ // start a fresh Office
+ OfficeProvider aProvider = null;
+ if (aGTA_local.restartOffice())
+ {
+ aProvider = new OfficeProvider();
+ XMultiServiceFactory xMSF = (XMultiServiceFactory) aProvider.getManager(param);
+ param.put("ServiceFactory", xMSF);
+ }
+ GraphicalTestArguments aGTA = getGraphicalTestArguments();
+
+ if (aGTA.getOfficeProgram().toLowerCase().equals("msoffice"))
+ {
+ // ReferenceType is MSOffice
+ GlobalLogWriter.get().println("USE MSOFFICE AS EXPORT FORMAT.");
+ MSOfficePrint a = new MSOfficePrint();
+ try
+ {
+ String sInputFileBasename = FileHelper.getBasename(_sInputFile);
+ String fs = System.getProperty("file.separator");
+ FileHelper.makeDirectories("", _sReferencePath);
+ String sOutputFile = _sReferencePath;
+ if (sOutputFile.endsWith(fs))
+ {
+ sOutputFile += sInputFileBasename;
+ }
+ else
+ {
+ sOutputFile += fs + sInputFileBasename;
+ }
+
+ a.storeToFileWithMSOffice(aGTA, _sInputFile, sOutputFile);
+ }
+ catch(ConvWatchCancelException e)
+ {
+ GlobalLogWriter.get().println(e.getMessage());
+ }
+ catch(java.io.IOException e)
+ {
+ GlobalLogWriter.get().println(e.getMessage());
+ }
+ }
+ else
+ {
+ try
+ {
+ OfficePrint.convertDocument(_sInputFile, _sReferencePath, aGTA);
+ }
+ catch(ConvWatchCancelException e)
+ {
+ assure(e.getMessage(), false);
+ }
+ catch(ConvWatchException e)
+ {
+ assure(e.getMessage(), false);
+ }
+ }
+
+ if (aGTA.restartOffice())
+ {
+ // Office shutdown
+ aProvider.closeExistingOffice(param, true);
+ }
+ // }
+ }
+}
+
diff --git a/qadevOOo/runner/convwatch/EnhancedComplexTestCase.java b/qadevOOo/runner/convwatch/EnhancedComplexTestCase.java
new file mode 100644
index 000000000000..7c51940d7801
--- /dev/null
+++ b/qadevOOo/runner/convwatch/EnhancedComplexTestCase.java
@@ -0,0 +1,130 @@
+/*************************************************************************
+ *
+ * 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 convwatch;
+
+import complexlib.ComplexTestCase;
+import helper.ProcessHandler;
+import convwatch.GraphicalTestArguments;
+
+/**
+ * Some Helperfunctions which are nice in ReferenceBuilder and ConvWatchTest
+ */
+
+public abstract class EnhancedComplexTestCase extends ComplexTestCase
+{
+ // public void before()
+ // {
+ // // System.out.println("before()");
+ // }
+ //
+ // public void after()
+ // {
+ // // System.out.println("after()");
+ // }
+
+ void checkExistance(String _sScriptFile, String _sName)
+ {
+ boolean bBackValue = false;
+ // Process testshl = Runtime.getRuntime().exec(scriptFile);
+ ProcessHandler aHandler = new ProcessHandler(_sScriptFile);
+ bBackValue = aHandler.executeSynchronously();
+ TimeHelper.waitInSeconds(1, "wait after ProcessHandler.executeSynchronously()");
+
+ StringBuffer aBuffer = new StringBuffer();
+ aBuffer.append(aHandler.getErrorText()).append(aHandler.getOutputText());
+ String sText = aBuffer.toString();
+
+ if (sText.length() == 0)
+ {
+ String sError = "Must quit. " + _sName + " may be not accessable.";
+ assure(sError, false);
+ // System.exit(1);
+ }
+ else
+ {
+ // System.out.println("Output from script:");
+ // System.out.println(sText);
+ }
+ }
+
+ // -----------------------------------------------------------------------------
+
+ protected void checkEnvironment(Object[] _aList)
+ {
+ // checks if some packages already installed,
+ // this function will not return if packages are not installed,
+ // it will call System.exit(1)!
+
+ if (needCheckForInstalledSoftware())
+ {
+ for (int i=0;i<_aList.length;i++)
+ {
+ String sCommand = (String)_aList[i];
+ // TODO: nice to have, a pair object
+ checkExistance(sCommand, sCommand);
+ }
+ }
+ }
+
+ // -----------------------------------------------------------------------------
+
+ protected abstract Object[] mustInstalledSoftware();
+ public boolean needCheckForInstalledSoftware()
+ {
+ String sNEEDCHECK = (String)param.get( PropertyName.CHECK_NEED_TOOLS );
+// 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 (sNEEDCHECK == null)
+ {
+ sNEEDCHECK = "false";
+ }
+ if (sNEEDCHECK.toLowerCase().equals("yes") ||
+ sNEEDCHECK.toLowerCase().equals("true"))
+ {
+ return true;
+ }
+ return false;
+ }
+
+ // -----------------------------------------------------------------------------
+
+ public GraphicalTestArguments getGraphicalTestArguments()
+ {
+ GraphicalTestArguments aGTA = new GraphicalTestArguments(param);
+ if (aGTA.getImportFilterName() != null && aGTA.getImportFilterName().toLowerCase().equals("help"))
+ {
+ aGTA = null;
+ }
+ if (aGTA.getExportFilterName() != null && aGTA.getExportFilterName().toLowerCase().equals("help"))
+ {
+ aGTA = null;
+ }
+ return aGTA;
+ }
+}
diff --git a/qadevOOo/runner/convwatch/FileHelper.java b/qadevOOo/runner/convwatch/FileHelper.java
new file mode 100644
index 000000000000..2ff9ede2f8d4
--- /dev/null
+++ b/qadevOOo/runner/convwatch/FileHelper.java
@@ -0,0 +1,405 @@
+/*************************************************************************
+ *
+ * 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 convwatch;
+
+import java.io.File;
+import java.io.FileFilter;
+import java.util.StringTokenizer;
+import helper.OSHelper;
+
+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.get().println(sOSName);
+ GlobalLogWriter.get().println(sOSArch);
+ GlobalLogWriter.get().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.get().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(fs);
+ 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(fs);
+ 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.get().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.get().println("Found file: " + sName);
+ GlobalLogWriter.get().println("Activate debug mode.");
+ GlobalLogWriter.get().println("If debug mode is no longer necessary, remove the above file.");
+ m_bDebugTextShown = true;
+ }
+ bDebug = true;
+ }
+ return bDebug;
+ }
+
+ public static void copy(String _sSource, String _sDestination)
+ {
+ 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;
+ }
+
+ if (pathname.getName().endsWith(".prn"))
+ {
+ 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;
+ }
+}
+
diff --git a/qadevOOo/runner/convwatch/FilenameHelper.java b/qadevOOo/runner/convwatch/FilenameHelper.java
new file mode 100644
index 000000000000..3d49703dc995
--- /dev/null
+++ b/qadevOOo/runner/convwatch/FilenameHelper.java
@@ -0,0 +1,398 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+/**
+ * Helper class to hold a Filename or a FileURL
+ * Something like File in Java,
+ * with some more extensions direct to ConvWatch and it's name conventions
+ *
+ *
+ */
+package convwatch;
+
+import helper.URLHelper;
+import convwatch.FileHelper;
+import helper.StringHelper;
+import util.utils;
+
+interface Filenamer
+{
+ public String getSuffix();
+ public String getFileURL();
+ public String getAbsoluteSystemFilename();
+ public String getFilename();
+ public String getSystemPath();
+}
+
+// -----------------------------------------------------------------------------
+
+abstract class FilenameHelper_impl implements Filenamer
+{
+ String fs; // file separator like '/'
+ String m_sPath;
+ String m_sFilename;
+ String m_sSuffix;
+ int m_nNumber = 0;
+
+ public String getNumber()
+ {
+ return StringHelper.createValueString(m_nNumber, 4);
+ }
+ public void setNumber(int _n)
+ {
+ m_nNumber = _n;
+ }
+ void initMember()
+ {
+ fs = System.getProperty("file.separator");
+ }
+
+ /**
+ * initialise a FilenameHelper_impl with a complete filename.
+ * if the filename starts with 'file:///' it is interpret as a file URL
+ *
+ */
+ public FilenameHelper_impl()
+ {
+ initMember();
+ }
+
+ public void setCompleteFilename(String _sFilename)
+ {
+ if (_sFilename.startsWith("file:///"))
+ {
+ _sFilename = FileHelper.getSystemPathFromFileURL(_sFilename);
+ }
+ _sFilename = utils.replaceAll13(_sFilename, "\\\\", "/");
+
+ String sPath = checkPath(FileHelper.getPath(_sFilename));
+ String sFilenameWithSuffix = checkFilename(FileHelper.getBasename(_sFilename));
+ String sSuffix = splitSuffix(sFilenameWithSuffix);
+
+ m_sPath = sPath;
+ m_sFilename = FileHelper.getNameNoSuffix(sFilenameWithSuffix);
+ m_sSuffix = sSuffix;
+ }
+
+ /**
+ * initialise a FilenameHelper_impl with a path a name and a suffix separately
+ */
+ public FilenameHelper_impl(String _sPath, String _sName, String _sSuffix)
+ {
+ initMember();
+ _sPath = utils.replaceAll13(_sPath, "\\\\", "/");
+
+ String sPath = checkPath(_sPath);
+ String sFilename = checkFilename(_sName);
+ String sSuffix = checkSuffix(_sSuffix);
+
+ m_sPath = sPath;
+ m_sFilename = sFilename;
+ m_sSuffix = sSuffix;
+ }
+
+ /**
+ * @return the current path as a OOo path URL
+ */
+ public String getFileURL()
+ {
+ String sSystemPath = createAbsoluteFilename();
+ String sFileURL = URLHelper.getFileURLFromSystemPath(sSystemPath);
+ return sFileURL;
+ }
+
+
+ /**
+ * @return the current path as a system path
+ */
+ public String getAbsoluteSystemFilename()
+ {
+ String sSystemFilename = createAbsoluteFilename();
+ sSystemFilename = utils.replaceAll13(sSystemFilename, "/", fs);
+ return sSystemFilename;
+ }
+
+ /**
+ * @return the filename without it's suffix
+ */
+ public String getName()
+ {
+ return m_sFilename;
+ }
+ /**
+ * set only the filename, maybe it's is only a directory.
+ */
+ public void setName(String _sName)
+ {
+ m_sFilename = _sName;
+ }
+ public void setPath(String _sName)
+ {
+ m_sPath = _sName;
+ }
+
+ /**
+ * @return a created name
+ */
+ abstract public String buildName();
+ // {
+ // return getName();
+ // }
+
+ /**
+ * @return the complete filename with it's suffix
+ */
+ public String getFilename()
+ {
+ return buildName() + "." + getSuffix();
+ }
+
+ /**
+ * @return the path as system path
+ */
+ public String getSystemPath()
+ {
+ String sSystemPath = m_sPath;
+ sSystemPath = utils.replaceAll13(sSystemPath, "/", fs);
+ return sSystemPath;
+ }
+ /**
+ * @return true, if current SystemPath is a directory
+ */
+ public boolean isDirectory()
+ {
+ return FileHelper.isDir(getSystemPath());
+ }
+
+ /**
+ * @return true, if the file really exist.
+ */
+ public boolean exists()
+ {
+ return FileHelper.exists(createAbsoluteFilename());
+ }
+
+ /**
+ * @return the current suffix
+ */
+ public String getSuffix()
+ {
+ return m_sSuffix;
+ }
+ /**
+ * @return the complete name. Without convert the path separator!
+ */
+ String createAbsoluteFilename()
+ {
+ return m_sPath + fs + getFilename();
+ }
+
+ /*
+ * remove follows 'file separators'
+ */
+ String checkPath(String _sPath)
+ {
+ String sPath;
+ if (_sPath.endsWith("/") || _sPath.endsWith("\\"))
+ {
+ sPath = _sPath.substring(0, _sPath.length() - 1);
+ }
+ else
+ {
+ sPath = _sPath;
+ }
+ return sPath;
+ }
+
+ String checkFilename(String _sFilename)
+ {
+ String sFilename;
+ if (_sFilename.startsWith("/") || _sFilename.startsWith("\\"))
+ {
+ sFilename = _sFilename.substring(1);
+ }
+ else
+ {
+ sFilename = _sFilename;
+ }
+ return sFilename;
+ }
+
+ String checkSuffix(String _sSuffix)
+ {
+ String sSuffix;
+ if (_sSuffix.startsWith("."))
+ {
+ sSuffix = _sSuffix.substring(1);
+ }
+ else
+ {
+ sSuffix = _sSuffix;
+ }
+ return sSuffix;
+ }
+
+ String splitSuffix(String _sName)
+ {
+ String sSuffix = FileHelper.getSuffix(_sName);
+ return checkSuffix(sSuffix);
+ }
+
+ public boolean equals(FilenameHelper_impl _aOtherFN)
+ {
+ String sPath = createAbsoluteFilename();
+ String sPathOther = _aOtherFN.createAbsoluteFilename();
+ if (sPath.equals(sPathOther))
+ {
+ return true;
+ }
+ return false;
+ }
+
+}
+
+/**
+ * Original filename
+ */
+class OriginalFilename extends FilenameHelper_impl
+{
+ public String buildName()
+ {
+ return getName();
+ }
+
+ public OriginalFilename(){}
+ public OriginalFilename(String _path, String _filename, String _ext) { super(_path, _filename, _ext);}
+}
+
+/**
+ * Reference from original
+ */
+class OriginalReferenceFilename extends FilenameHelper_impl
+{
+ public String getSuffix()
+ {
+ return "prn";
+ }
+ public String buildName()
+ {
+ return getName();
+ }
+ public OriginalReferenceFilename(){}
+ public OriginalReferenceFilename(String _path, String _filename, String _ext) { super(_path, _filename, _ext);}
+}
+
+/**
+ * picture from reference from original
+ */
+class OriginalReferencePictureFilename extends FilenameHelper_impl
+{
+ public String getSuffix()
+ {
+ return "jpg";
+ }
+ public String buildName()
+ {
+ return getName() + "-" + getNumber() + "-ref";
+ }
+ public String getBuildString()
+ {
+ return getName() + "-" + "%04d" + "-ref";
+ }
+
+ public OriginalReferencePictureFilename(){}
+ public OriginalReferencePictureFilename(String _path, String _filename, String _ext) { super(_path, _filename, _ext);}
+}
+
+/**
+ * Reference from OpenOffice.org
+ */
+class CurrentReferenceFilename extends FilenameHelper_impl
+{
+ public String getSuffix()
+ {
+ return "ps";
+ }
+ public String buildName()
+ {
+ return getName();
+ }
+
+ public CurrentReferenceFilename(){}
+ public CurrentReferenceFilename(String _path, String _filename, String _ext) { super(_path, _filename, _ext);}
+}
+
+/**
+ * picture from reference from OpenOffice.org
+ */
+class CurrentReferencePictureFilename extends FilenameHelper_impl
+{
+ public String getSuffix()
+ {
+ return "jpg";
+ }
+ public String buildName()
+ {
+ return getName() + "-" + getNumber() + "-new-ref";
+ }
+ public String getBuildString()
+ {
+ return getName() + "-" + "%04d" + "-new-ref";
+ }
+
+ public CurrentReferencePictureFilename(){}
+ public CurrentReferencePictureFilename(String _path, String _filename, String _ext) { super(_path, _filename, _ext);}
+}
+
+
+public class FilenameHelper
+{
+
+ public static void main(String[] args)
+ {
+ OriginalReferenceFilename d = new OriginalReferenceFilename();
+ d.setCompleteFilename("c:\\dir1\\dir2\\name.ext");
+ System.out.println("Suffix: " + d.getSuffix());
+ System.out.println("Path: " + d.getSystemPath());
+ System.out.println("Absolute system path filename: " + d.getAbsoluteSystemFilename());
+ System.out.println("URL: " + d.getFileURL());
+ System.out.println("Filename: " + d.getFilename());
+
+ OriginalReferenceFilename a = new OriginalReferenceFilename("/dir1/dir2/", "name",".ext");
+ OriginalReferenceFilename a1 = new OriginalReferenceFilename("/dir1/dir2","name.ext","");
+ OriginalReferenceFilename a2 = new OriginalReferenceFilename("/dir1/dir2","/name.ext","");
+ OriginalReferenceFilename a3 = new OriginalReferenceFilename("/dir1/dir2","/name",".ext");
+ OriginalReferenceFilename a4 = new OriginalReferenceFilename("/dir1/dir2","name","ext");
+
+
+ // OriginalReferenceFilename b = new OriginalReferenceFilename("c:/dir1/dir2/name.ext");
+ // OriginalReferenceFilename c = new OriginalReferenceFilename("file:///dir1/dir2/name.ext");
+ // OriginalReferenceFilename e = new OriginalReferenceFilename("c:\\dir1\\dir2\\name");
+ // OriginalReferenceFilename f = new OriginalReferenceFilename("c:\\dir1\\dir2");
+ // OriginalReferenceFilename g = new OriginalReferenceFilename("c:\\dir1\\dir2\\");
+ }
+}
diff --git a/qadevOOo/runner/convwatch/GfxCompare.java b/qadevOOo/runner/convwatch/GfxCompare.java
new file mode 100644
index 000000000000..b45897475c23
--- /dev/null
+++ b/qadevOOo/runner/convwatch/GfxCompare.java
@@ -0,0 +1,196 @@
+/*************************************************************************
+ *
+ * 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 convwatch;
+
+import java.util.ArrayList;
+import convwatch.EnhancedComplexTestCase;
+import convwatch.PRNCompare;
+import convwatch.GraphicalTestArguments;
+import helper.URLHelper;
+import convwatch.OfficePrint;
+import java.io.File;
+
+public class GfxCompare extends EnhancedComplexTestCase
+{
+ // The first of the mandatory functions:
+ /**
+ * Return the name of the test.
+ * In this case it is the actual name of the service.
+ * @return The tested service.
+ */
+ // public String getTestObjectName() {
+ // return "ConvWatch runner";
+ // }
+
+ // The second of the mandatory functions: return all test methods as an
+ // array. There is only one test function in this example.
+ /**
+ * Return all test methods.
+ * @return The test methods.
+ */
+
+ public String[] getTestMethodNames() {
+ return new String[]{"gfxcompare"};
+ }
+
+ /**
+ *
+ * @return a List of software which must accessable as an external executable
+ */
+ protected Object[] mustInstalledSoftware()
+ {
+ ArrayList aList = new ArrayList();
+ // Tools from ImageMagick
+ aList.add( "composite -version" );
+ aList.add( "identify -version" );
+
+ // Ghostscript
+ aList.add( "gs -version" );
+ return aList.toArray();
+ }
+
+
+ GraphicalTestArguments m_aArguments = null;
+ /**
+ * The test method itself.
+ * Don't try to call it from outside, it is started only from qadevOOo runner
+ */
+
+ /* protected */
+ public void gfxcompare()
+ {
+ GlobalLogWriter.set(log);
+
+ // check if all need software is installed and accessable
+ checkEnvironment(mustInstalledSoftware());
+
+ m_aArguments = getGraphicalTestArguments();
+
+ String sFile1 = (String)param.get("FILE1");
+ String sFile2 = (String)param.get("FILE2");
+ compare(sFile1, sFile2);
+ }
+
+ // -----------------------------------------------------------------------------
+
+ String createJPEG(String _sFile, String _sAdditional)
+ {
+ String sJPEGFile = "";
+ 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.get().println("File: '" + _sFile + "' doesn't exist.");
+ return "";
+ }
+ String sFileDir = FileHelper.getPath(_sFile);
+ String sBasename = FileHelper.getBasename(_sFile);
+ String sNameNoSuffix = FileHelper.getNameNoSuffix(sBasename);
+
+ String fs = System.getProperty("file.separator");
+ String sTmpDir = util.utils.getUsersTempDir();
+ if (m_aArguments.getOutputPath() != null)
+ {
+ sTmpDir = m_aArguments.getOutputPath();
+ }
+
+ if (_sFile.toLowerCase().endsWith("ps") ||
+ _sFile.toLowerCase().endsWith("prn") ||
+ _sFile.toLowerCase().endsWith("pdf"))
+ {
+ // seems to be a Postscript of PDF file
+
+ String[] aList = PRNCompare.createJPEGFromPostscript(sTmpDir, sFileDir, sBasename, m_aArguments.getResolutionInDPI());
+ sJPEGFile = aList[0];
+ }
+ 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.
+ String sInputURL;
+ String sOutputURL;
+ String sPrintFileURL;
+
+ String sInputFile = sFileDir + fs + sBasename;
+ sInputURL = URLHelper.getFileURLFromSystemPath(sInputFile);
+
+ String sOutputFile = sTmpDir + fs + sBasename;
+ sOutputURL = URLHelper.getFileURLFromSystemPath(sOutputFile);
+
+ String sPrintFile = sTmpDir + fs + sNameNoSuffix + _sAdditional + ".ps";
+ sPrintFileURL = URLHelper.getFileURLFromSystemPath(sPrintFile);
+
+ try
+ {
+ OfficePrint.printToFile(m_aArguments, sInputURL, sOutputURL, sPrintFileURL);
+ sJPEGFile = createJPEG(sPrintFile, _sAdditional);
+ }
+ catch (ConvWatchCancelException e)
+ {
+ GlobalLogWriter.get().println("Exception caught, can't create:" + sPrintFileURL);
+ }
+ }
+ return sJPEGFile;
+ }
+
+
+ public String compare(String _sFile1, String _sFile2)
+ {
+ String sJPEGFile1 = createJPEG(_sFile1, "-1");
+ String sJPEGFile2 = createJPEG(_sFile2, "-2");
+
+ if (sJPEGFile1.length() > 0 && sJPEGFile2.length() > 0)
+ {
+ String sDiffFile = PRNCompare.compareJPEGs(sJPEGFile1, sJPEGFile2);
+
+ if (sDiffFile.length() > 0)
+ {
+ GlobalLogWriter.get().println("Difference created: " + sDiffFile);
+ }
+ return sDiffFile;
+ }
+ return "";
+ }
+
+}
diff --git a/qadevOOo/runner/convwatch/GlobalLogWriter.java b/qadevOOo/runner/convwatch/GlobalLogWriter.java
new file mode 100644
index 000000000000..fe785915cc02
--- /dev/null
+++ b/qadevOOo/runner/convwatch/GlobalLogWriter.java
@@ -0,0 +1,57 @@
+/*************************************************************************
+ *
+ * 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 convwatch;
+
+import share.LogWriter;
+import stats.SimpleLogWriter;
+
+public class GlobalLogWriter
+{
+ private static LogWriter m_aGlobalLogWriter = null;
+ public 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);
+// }
+
+ public static synchronized void set(LogWriter _aLog)
+ {
+ m_aGlobalLogWriter = _aLog;
+ }
+
+}
+
diff --git a/qadevOOo/runner/convwatch/GraphicalDifferenceCheck.java b/qadevOOo/runner/convwatch/GraphicalDifferenceCheck.java
new file mode 100644
index 000000000000..efce96c1c15b
--- /dev/null
+++ b/qadevOOo/runner/convwatch/GraphicalDifferenceCheck.java
@@ -0,0 +1,410 @@
+/*************************************************************************
+ *
+ * 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 convwatch;
+
+import convwatch.GraphicalTestArguments;
+import convwatch.OfficePrint;
+import convwatch.ConvWatchCancelException;
+import convwatch.FileHelper;
+import java.io.File;
+
+import helper.URLHelper;
+import com.sun.star.lang.XComponent;
+import com.sun.star.frame.XStorable;
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.lang.XServiceInfo;
+import com.sun.star.uno.UnoRuntime;
+
+public class GraphicalDifferenceCheck
+{
+ private static void showVersion()
+ {
+ // DEBUG only
+ if (FileHelper.isDebugEnabled())
+ {
+ GlobalLogWriter.get().println("");
+ GlobalLogWriter.get().println("+##############################+");
+ GlobalLogWriter.get().println("##### THIS IS CONVWATCH #####");
+ GlobalLogWriter.get().println("##### Debug Version 1.0015 #####");
+ GlobalLogWriter.get().println("+##############################+");
+ GlobalLogWriter.get().println("");
+ }
+ }
+
+ /**
+ * Creates references form documents used by the graphical difference check
+ *
+ * @param _sInputPath the original document path
+ * @param _sReferencePath the directory where the document will print as file or export as pdf.
+ *
+ * @throws ConvWatchException if there are problems, see message
+ *
+ * Stops rest, if one creation of reference fails.
+ */
+ public static void createReferences(String _sInputPath, String _sReferencePath, GraphicalTestArguments _aGTA) throws ConvWatchException
+ {
+//!
+// System.out.println("createReferences() InputPath: " + _sInputPath + " refpath: " + _sReferencePath);
+ showVersion();
+ File aInputPath = new File(_sInputPath);
+
+// System.out.println("Inputpath in file: " + aInputPath.getAbsolutePath());
+//!
+// if (aInputPath.exists())
+// {
+// System.out.println("Inputpath exists");
+// }
+// else
+// {
+// System.out.println("Inputpath doesn't exists");
+// return;
+// }
+
+ if (aInputPath.isDirectory())
+ {
+ String fs = System.getProperty("file.separator");
+
+ String sRemovePath = aInputPath.getAbsolutePath();
+ // a whole directory
+
+ Object[] aList = DirectoryHelper.traverse(_sInputPath, FileHelper.getFileFilter(), _aGTA.includeSubDirectories());
+ for (int i=0;i<aList.length;i++)
+ {
+ String sEntry = (String)aList[i];
+ String sNewReferencePath = _sReferencePath + fs + FileHelper.removeFirstDirectorysAndBasenameFrom(sEntry, _sInputPath);
+ createOneReferenceFile(sEntry, sNewReferencePath, _aGTA);
+ }
+ }
+ else
+ {
+//!
+ // System.out.println("No directory.");
+ createOneReferenceFile(_sInputPath, _sReferencePath, _aGTA);
+ }
+ }
+
+
+ /**
+ * Creates a reference for a single document used by the graphical difference check
+ *
+ * @param _sInputFile the original document
+ * @param _sReferencePath the directory where the document will print as file or export as pdf.
+ *
+ * @throws ConvWatchException if the are problems, see containing message
+ */
+ public static boolean createOneReferenceFile(String _sInputFile, String _sReferencePath, GraphicalTestArguments _aGTA) throws ConvWatchException
+ {
+ showVersion();
+ if (_aGTA != null)
+ {
+ _aGTA.setInputFile(_sInputFile);
+ }
+ return OfficePrint.buildReference(_aGTA, _sReferencePath, _sInputFile);
+ }
+
+ /**
+ * Check if a reference exist
+ *
+ * @param _sInputFile the original document
+ * @param _sReferencePath the directory where the document will print as file or export as pdf.
+ *
+ * @throws ConvWatchException if the are problems, see containing message
+ */
+ public static boolean isReferenceExists(String _sInputFile, String _sReferencePath, GraphicalTestArguments _aGTA)
+ {
+ return OfficePrint.isReferenceExists(_aGTA, _sReferencePath, _sInputFile);
+ }
+
+
+ /**
+ * Used for the comparance of graphical differences.
+ * Method compares one document (_sInputFile) with an older document of the same name in the provided directory (_sReferencePath).
+ *
+ * @param _sInputPath the original document path
+ * @param _sOutputPath path where the same directory structure of the given input path will create. All the result documents
+ * needed very much disk space (up to 10MB per page).
+ * The path _sOutputPath must be writeable.
+ * @param _sReferencePath the directory where the document will print as file or export as pdf.
+ * @param _GTA Helper class for lot of parameter to control the office.
+ *
+ * Disadvantage: stops rest if one test file has a problem.
+ */
+ public static boolean check(String _sInputPath, String _sOutputPath, String _sReferencePath, GraphicalTestArguments _aGTA ) throws ConvWatchException
+ {
+ return check(_sInputPath, _sOutputPath, _sReferencePath, null, _aGTA);
+ }
+
+ /**
+ * Used for the comparance of graphical differences.
+ * Method compares one document (_sInputFile) with an older document of the same name in the provided directory (_sReferencePath).
+ *
+ * @param _sInputPath the original document path
+ * @param _sReferencePath the directory where the document will print as file or export as pdf.
+ * @param _sOutputPath path where the same directory structure of the given input path will create. All the result documents
+ * needed very much disk space (up to 10MB per page).
+ * The path _sOutputPath must be writeable.
+ * @param _sDiffPath Path to older differences.
+ * @param _GTA Helper class for lot of parameter to control the office.
+ *
+ *
+ * Stops all, if one creation of reference fails
+ */
+ public static boolean check(String _sInputPath, String _sOutputPath, String _sReferencePath, String _sDiffPath, GraphicalTestArguments _aGTA ) throws ConvWatchException
+ {
+ showVersion();
+
+ boolean bOk = true;
+
+ File aInputPath = new File(_sInputPath);
+ if (aInputPath.isDirectory())
+ {
+ String fs = System.getProperty("file.separator");
+ // a whole directory
+ Object[] aList = DirectoryHelper.traverse(_sInputPath, FileHelper.getFileFilter(), _aGTA.includeSubDirectories());
+ if (aList.length != 0)
+ {
+ for (int i=0;i<aList.length;i++)
+ {
+ String sEntry = (String)aList[i];
+ String sNewSubDir = FileHelper.removeFirstDirectorysAndBasenameFrom(sEntry, _sInputPath);
+ String sNewReferencePath = _sReferencePath;
+ String sNewOutputPath = _sOutputPath;
+ String sNewDiffPath = _sDiffPath;
+ if (sNewSubDir.length() > 0)
+ {
+ if (sNewReferencePath != null)
+ {
+ sNewReferencePath = sNewReferencePath + fs + sNewSubDir;
+ }
+
+ sNewOutputPath = sNewOutputPath + fs + sNewSubDir;
+ if (sNewDiffPath != null)
+ {
+ sNewDiffPath = sNewDiffPath + fs + sNewSubDir;
+ }
+ }
+ bOk &= checkOneFile(sEntry, sNewOutputPath, sNewReferencePath, sNewDiffPath, _aGTA);
+ }
+ }
+ }
+ else
+ {
+ bOk = /* GraphicalDifferenceCheck.*/ checkOneFile(_sInputPath, _sOutputPath, _sReferencePath, _sDiffPath, _aGTA);
+ }
+ return bOk;
+ }
+
+ /**
+ * Used for the comparance of graphical differences.
+ * Method compares one document (_sInputFile) with an older document of the same name in the provided directory (_sReferencePath).
+ *
+ * The path _sOutputPath must be writeable
+ */
+ public static boolean checkOneFile(String _sInputFile, String _sOutputPath, String _sReferencePath, GraphicalTestArguments _aGTA) throws ConvWatchException
+ {
+ return checkOneFile( _sInputFile, _sOutputPath, _sReferencePath, null, _aGTA);
+ }
+
+
+ /**
+ * Used for the comparance of graphical differences.
+ * Method compares one document (_sInputFile) with an older document of the same name in the provided directory (_sReferencePath).
+ *
+ * For scenarios, where a difference is known and further changes are of interest, differences itself can be compared.
+ * This functionality is provided by the difference path parameter (_sDiffPath). If set, the difference of the current comparance (between input and reference),
+ * will be compared with the (same named) difference document from a earlier comparance.
+ *
+ * The path _sOutputPath must be writeable
+ */
+ public static boolean checkOneFile(String _sInputFile, String _sOutputPath, String _sReferencePath, String _sDiffPath, GraphicalTestArguments _aGTA ) throws ConvWatchException
+ {
+ showVersion();
+ if (_aGTA != null)
+ {
+ _aGTA.setInputFile(_sInputFile);
+ }
+
+ boolean bOk = false;
+ if (_sDiffPath != null)
+ {
+ // check with an old diff
+ bOk = convwatch.ConvWatch.checkDiffDiff(_aGTA, _sOutputPath, _sInputFile, _sReferencePath, _sDiffPath);
+ }
+ else
+ {
+ // one file
+ bOk = convwatch.ConvWatch.check(_aGTA, _sOutputPath, _sInputFile, _sReferencePath);
+ }
+ return bOk;
+ }
+
+ /**
+ * Instead of providing a saved document for graphical comparance a StarOffice xComponent
+ * will be saved and afterwards compared.
+ *
+ * @param xComponent the test document to be compared as StarOffice component
+ * @param _sOutputPath Path where test results are supposed to been saved. The path _sOutputPath must be writeable.
+ * These documents need sufficient disk space (up to 10MB per page).
+ * A directory structure will be created, which is a mirrored from input path.
+ *
+ * @param resultDocName Name by which the xComponent shall be saved as OpenOffice.org XML document.
+ * If provided without suffix, the suffix will be derived from the export filter.
+ * @param _sReferencePath the directory where the document will print as file or export as pdf.
+ * @param _GTA Helper class for lot of parameter to control the office.
+ */
+ public static boolean checkOneFile(XComponent xComponent, String _sOutputPath, String _resultDocName, String _sReferencePath, GraphicalTestArguments _aGTA ) throws ConvWatchException
+ {
+ showVersion();
+
+ // one file
+ String sInputFile;
+ sInputFile = createInputFile(xComponent, _sOutputPath, _resultDocName);
+ sInputFile = FileHelper.getSystemPathFromFileURL(sInputFile);
+ return convwatch.ConvWatch.check(_aGTA, _sOutputPath, sInputFile, _sReferencePath);
+ }
+
+
+// LLA: old! /**
+// LLA: old! * Returns 'true' if a reference document on the specific output path exists.
+// LLA: old! * The name of the document is corresponding to the input document, which can be
+// LLA: old! * provided by a single name or path.
+// LLA: old! *
+// LLA: old! * @param inputPath the original document name (possibly including path)
+// LLA: old! * @param referencePath the directory where the reference document will be stored
+// LLA: old!
+// LLA: old! */
+// LLA: old! public static boolean isReferencExistent(String inputDocumentPath, String referencePath)
+// LLA: old! {
+// LLA: old! // isolate the document name
+// LLA: old! if(inputDocumentPath.indexOf(File.separator) != -1)
+// LLA: old! inputDocumentPath = inputDocumentPath.substring(inputDocumentPath.lastIndexOf(File.separator) + 1, inputDocumentPath.length());
+// LLA: old!
+// LLA: old! // exchange any arbitray suffix against the refence suffix (.prn)
+// LLA: old! if(inputDocumentPath.indexOf('.') != -1)
+// LLA: old! inputDocumentPath = inputDocumentPath.substring(0, inputDocumentPath.lastIndexOf('.'));
+// LLA: old! inputDocumentPath = inputDocumentPath + ".prn";
+// LLA: old! System.out.println("GraphicalDifference CheckReferenceDocument: " + inputDocumentPath);
+// LLA: old!
+// LLA: old! File refFile = new File(referencePath + inputDocumentPath);
+// LLA: old! if(refFile.exists()){
+// LLA: old! return true;
+// LLA: old! }else
+// LLA: old! return false;
+// LLA: old! }
+
+
+ private static String createInputFile(XComponent xComponent, String _sOutputPath, String resultDocName)
+ throws ConvWatchCancelException
+ {
+
+ // find the adequate XML StarOffice output filter to save the document and adequate suffix
+ StringBuffer suffix = new StringBuffer();
+ String exportFilter = getXMLOutputFilterforXComponent(xComponent, suffix);
+ if(resultDocName == null)
+ resultDocName = "OOoTestDocument";
+ if(resultDocName.indexOf('.') == -1)
+ resultDocName = suffix.insert(0, resultDocName).toString();
+
+ // create a result URL for storing the office document
+ String resultURL = URLHelper.getFileURLFromSystemPath(ensureEndingFileSep(_sOutputPath) + resultDocName);
+
+ XStorable xStorable = null;
+ xStorable = (com.sun.star.frame.XStorable)UnoRuntime.queryInterface(com.sun.star.frame.XStorable.class, xComponent);
+ if(xStorable == null)
+ {
+ throw new ConvWatchCancelException("com.sun.star.frame.XStorable could not be instantiated from the office.");
+ }
+
+ PropertyValue pvFilterName = new PropertyValue("FilterName", -1, exportFilter, com.sun.star.beans.PropertyState.getDefault());
+ PropertyValue pvOverwrite = new PropertyValue("Overwrite", -1, new Boolean(true), com.sun.star.beans.PropertyState.getDefault());
+
+ try
+ {
+ xStorable.storeAsURL(resultURL, new PropertyValue[]{pvFilterName, pvOverwrite});
+ }
+ catch (com.sun.star.io.IOException e)
+ {
+ // wrap IOException
+ throw new ConvWatchCancelException("Wrap IOException caught, " + e.getMessage());
+ }
+
+ GlobalLogWriter.get().println("Saving XComponent as " + resultURL);
+
+ return resultURL;
+ }
+
+
+ private static String getXMLOutputFilterforXComponent(XComponent xComponent, StringBuffer suffix){
+ XServiceInfo xSI = (XServiceInfo) UnoRuntime.queryInterface(XServiceInfo.class, xComponent);
+ if (xSI.supportsService("com.sun.star.text.TextDocument")){
+ resetBuffer(suffix, ".sxw");
+ return "swriter: StarOffice XML (Writer)";
+ }else if (xSI.supportsService("com.sun.star.sheet.SpreadsheetDocument")){
+ resetBuffer(suffix, ".sxc");
+ return "scalc: StarOffice XML (Calc)";
+ }else if (xSI.supportsService("com.sun.star.presentation.PresentationDocument")){
+ resetBuffer(suffix, ".sxi");
+ return "simpress: StarOffice XML (Impress)";
+ }else if(xSI.supportsService("com.sun.star.drawing.DrawingDocument")){
+ resetBuffer(suffix, ".sxd");
+ return "sdraw: StarOffice XML (Draw)";
+ }else if (xSI.supportsService("com.sun.star.formula.FormulaProperties")){
+ resetBuffer(suffix, ".sxm");
+ return "smath: StarOffice XML (Math)";
+ }
+ return null;
+ }
+
+ private static StringBuffer resetBuffer(StringBuffer sb, String suffix)
+ {
+ if(sb != null)
+ {
+ sb.replace(0, sb.length(), suffix);
+ }
+ return sb;
+ }
+
+ private static String ensureEndingFileSep(String s)
+ {
+ if(s != null && !s.equals("") && !s.endsWith(File.separator))
+ {
+ s = s.trim() + File.separator;
+ }
+ else
+ {
+ if(s == null)
+ {
+ s = "";
+ }
+ }
+
+ return s;
+ }
+
+
+}
diff --git a/qadevOOo/runner/convwatch/GraphicalTestArguments.java b/qadevOOo/runner/convwatch/GraphicalTestArguments.java
new file mode 100644
index 000000000000..72d732d3d8de
--- /dev/null
+++ b/qadevOOo/runner/convwatch/GraphicalTestArguments.java
@@ -0,0 +1,744 @@
+/*************************************************************************
+ *
+ * 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 convwatch;
+
+import com.sun.star.lang.XMultiServiceFactory;
+import lib.TestParameters;
+import java.io.File;
+
+import com.sun.star.container.XNameAccess;
+import com.sun.star.uno.UnoRuntime;
+
+/**
+ * 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 GraphicalTestArguments with a set of TestParameters
+ * GraphicalTestArguments a = new GraphicalTestArguments(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 an GraphicalTestArguments and set the reference type to 'msoffice'
+ * GraphicalTestArguments a = new GraphicalTestArguments(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 GraphicalTestArguments
+{
+ /**
+ 2DO:
+ Possible reference types are currently
+ // ooo
+ // pdf
+ // msoffice
+ */
+ String m_sReferenceType = "OOo";
+
+ String m_sTargetFrameName = "_blank";
+
+ String m_sPrinterName = null;
+
+ // 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;
+
+ String m_sDefaultXMLFormatApplication = null;
+
+ boolean m_bIncludeSubdirectories;
+
+ TestParameters m_aCurrentParams;
+
+ int m_nMaxPages = 0; // default is 0 (print all pages)
+ String m_sOnlyPage = ""; // default is "", there is no page which we want to print only.
+
+ int m_nResolutionInDPI = 0;
+
+ boolean m_bStoreFile = true;
+ boolean m_bResuseOffice = false;
+
+ boolean m_bDebugMode = false;
+
+ String m_sLeaveOutNames = null;
+
+ String m_sDistinct = null;
+
+ boolean m_bCreateDefaultReference = false;
+
+ // CONSTRUCTOR
+ private GraphicalTestArguments(){}
+
+ public GraphicalTestArguments(TestParameters param)
+ {
+ m_aCurrentParams = param;
+ // collect interesting information from the ComplexTestCase
+ // ....
+
+ // REFERENCE_TYPE ----------
+ String sReferenceType = (String)param.get( PropertyName.DOC_COMPARATOR_REFERENCE_TYPE );
+ if (sReferenceType == null || sReferenceType.length() == 0)
+ {
+ }
+ else
+ {
+ // log.println("found REFERENCE_TYPE " + sReferenceType );
+ setReferenceType(sReferenceType);
+ }
+
+ // PRINTER_NAME ----------
+ String sPrinterName = (String)param.get( PropertyName.DOC_COMPARATOR_PRINTER_NAME );
+ if (sPrinterName == null || sPrinterName.length() == 0)
+ {
+ }
+ else
+ {
+ // log.println("found PRINTER_NAME " + sPrinterName );
+ setPrinterName(sPrinterName);
+ }
+ // DEFAULT_XML_FORMAT_APP ------
+ String sDefaultXMLFormatApp = (String)param.get( PropertyName.DOC_COMPARATOR_DEFAULT_XML_FORMAT_APP );
+ if (sDefaultXMLFormatApp == null || sDefaultXMLFormatApp.length() == 0)
+ {
+ }
+ else
+ {
+ setDefaultXMLFormatApp(sDefaultXMLFormatApp);
+ }
+
+ m_bIncludeSubdirectories = true;
+ String sRECURSIVE = (String)param.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;
+ }
+
+ // ----------------------------------------
+ m_nMaxPages = param.getInt( PropertyName.DOC_COMPARATOR_PRINT_MAX_PAGE );
+ m_sOnlyPage = (String)param.get(PropertyName.DOC_COMPARATOR_PRINT_ONLY_PAGE);
+
+ m_nResolutionInDPI = param.getInt( PropertyName.DOC_COMPARATOR_GFX_OUTPUT_DPI_RESOLUTION );
+ if (m_nResolutionInDPI == 0)
+ {
+ // 212 DPI is 1754 x 2474 pixel for DIN A4
+ m_nResolutionInDPI = 212;
+ }
+
+ // ----------------------------------------
+ String sImportFilterName = (String)param.get(PropertyName.DOC_CONVERTER_IMPORT_FILTER_NAME);
+ if (sImportFilterName != null && sImportFilterName.length() > 0)
+ {
+ // System.out.println("found " + PropertyName.DOC_CONVERTER_IMPORT_FILTER_NAME + " " + sImportFilterName );
+ m_sImportFilterName = sImportFilterName;
+
+ if (sImportFilterName.toLowerCase().equals("help"))
+ {
+ showInternalFilterName(sImportFilterName, getMultiServiceFactory() );
+ GlobalLogWriter.get().println("Must quit.");
+ }
+ }
+ // ----------------------------------------
+ String sExportFilterName = (String)param.get(PropertyName.DOC_CONVERTER_EXPORT_FILTER_NAME);
+ if (sExportFilterName != null && sExportFilterName.length() > 0)
+ {
+ // System.out.println("found " + PropertyName.DOC_CONVERTER_EXPORT_FILTER_NAME + " " + sExportFilterName );
+ m_sExportFilterName = sExportFilterName;
+ if (sExportFilterName.toLowerCase().equals("help"))
+ {
+ showInternalFilterName(sExportFilterName, getMultiServiceFactory() );
+ GlobalLogWriter.get().println("Must quit.");
+ }
+ }
+
+ // ----------------------------------------
+ String sOfficeProgram = (String)param.get(PropertyName.DOC_CONVERTER_OFFICE_PROGRAM);
+ if (sOfficeProgram != null && sOfficeProgram.length() > 0)
+ {
+ m_sOfficeProgram = sOfficeProgram;
+ }
+ // ----------------------------------------
+ String sREUSE_OFFICE = (String)param.get( PropertyName.DOC_CONVERTER_REUSE_OFFICE);
+ if (sREUSE_OFFICE == null)
+ {
+ sREUSE_OFFICE = "false";
+ }
+ if (sREUSE_OFFICE.toLowerCase().equals("yes") ||
+ sREUSE_OFFICE.toLowerCase().equals("true"))
+ {
+ m_bResuseOffice = true;
+ }
+ else
+ {
+ m_bResuseOffice = false;
+ }
+
+
+ String sHTMLOutputPrefix = (String)param.get( PropertyName.DOC_COMPARATOR_HTML_OUTPUT_PREFIX);
+ if (sHTMLOutputPrefix == null)
+ {
+ m_sHTMLOutputPrefix = "";
+ }
+ else
+ {
+ m_sHTMLOutputPrefix = sHTMLOutputPrefix;
+ }
+
+ String sWithBorderMove = (String)param.get( PropertyName.DOC_COMPARATOR_GFXCMP_WITH_BORDERMOVE);
+ if (sWithBorderMove == null)
+ {
+ sWithBorderMove = "";
+ // m_tWithBorderMove = TriState.UNSET;
+ m_tWithBorderMove = TriState.FALSE;
+ }
+ if (sWithBorderMove.toLowerCase().equals("yes") ||
+ sWithBorderMove.toLowerCase().equals("true"))
+ {
+ m_tWithBorderMove = TriState.TRUE;
+ }
+ else if (sWithBorderMove.toLowerCase().equals("no") ||
+ sWithBorderMove.toLowerCase().equals("false"))
+ {
+ m_tWithBorderMove = TriState.FALSE;
+ }
+ else
+ {
+ m_tWithBorderMove = TriState.FALSE;
+ // m_tWithBorderMove = TriState.UNSET;
+ }
+
+ String sLeaveOutNames = (String)param.get(PropertyName.DOC_COMPARATOR_LEAVE_OUT_FILES);
+ if (sLeaveOutNames != null)
+ {
+ m_sLeaveOutNames = sLeaveOutNames;
+ }
+
+ String sDBInfoString = (String)param.get(PropertyName.DOC_COMPARATOR_DB_INFO_STRING);
+ if (sDBInfoString != null)
+ {
+ m_sDBInfoString = sDBInfoString;
+ }
+
+ // DISTINCT ----------
+ String sDistinct = (String)param.get( "DISTINCT" );
+ if (sDistinct == null || sDistinct.length() == 0)
+ {
+ sDistinct = "";
+ }
+ else
+ {
+ m_sDistinct = sDistinct;
+ }
+ // HIDDEN
+ String sOfficeViewable = (String)param.get(PropertyName.OFFICE_VIEWABLE);
+ if (sOfficeViewable != null)
+ {
+ if (sOfficeViewable.toLowerCase().equals("yes") ||
+ sOfficeViewable.toLowerCase().equals("true"))
+ {
+ setViewable();
+ }
+ else
+ {
+ setHidden();
+ }
+ }
+ // CREATE_DEFAULT
+ String sCreateDefault = (String)param.get(PropertyName.CREATE_DEFAULT);
+ if (sCreateDefault != null)
+ {
+ if (sCreateDefault.toLowerCase().equals("yes") ||
+ sCreateDefault.toLowerCase().equals("true"))
+ {
+ m_bCreateDefaultReference = true;
+ }
+ else
+ {
+ m_bCreateDefaultReference = false;
+ }
+ }
+
+ }
+
+ public boolean checkIfUsableDocumentType(String _sName)
+ {
+ // @todo
+ // check if the name is in the leave out list and then return 'false'
+ if (_sName.toLowerCase().endsWith(".jpg") ||
+ _sName.toLowerCase().endsWith(".png") ||
+ _sName.toLowerCase().endsWith(".gif") ||
+ _sName.toLowerCase().endsWith(".bmp") ||
+ _sName.toLowerCase().endsWith(".prn") ||
+ _sName.toLowerCase().endsWith(".ps"))
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ static void showInternalFilterName(String _sFilterName, XMultiServiceFactory _xMSF)
+ {
+ if (_sFilterName.length() == 0)
+ {
+ // System.out.println("No FilterName set.");
+ return;
+ }
+
+ if (_xMSF == null)
+ {
+ GlobalLogWriter.get().println("MultiServiceFactory not set.");
+ return;
+ }
+ // XFilterFactory aFilterFactory = null;
+ Object aObj = null;
+ try
+ {
+ aObj = _xMSF.createInstance("com.sun.star.document.FilterFactory");
+ }
+ catch(com.sun.star.uno.Exception e)
+ {
+ GlobalLogWriter.get().println("Can't get com.sun.star.document.FilterFactory.");
+ return;
+ }
+ if (aObj != null)
+ {
+ XNameAccess aNameAccess = (XNameAccess)UnoRuntime.queryInterface(XNameAccess.class, aObj);
+ if (aNameAccess != null)
+ {
+
+ if (_sFilterName.toLowerCase().equals("help"))
+ {
+ GlobalLogWriter.get().println("Show all possible ElementNames from current version." );
+ String[] aElementNames = aNameAccess.getElementNames();
+ for (int i = 0; i<aElementNames.length; i++)
+ {
+ GlobalLogWriter.get().println(aElementNames[i]);
+ }
+ }
+ }
+ }
+ }
+
+ /*
+ public GraphicalTestArguments(TestParameters param, Log xxx)
+ {
+ // collect interesting information from the ComplexTestCase
+ // ....
+ }
+ */
+
+ // set methods
+ public void setReferenceType(String _sType)
+ {
+ // special casse, null is not allowed, set to default.
+ if (_sType == null)
+ {
+ m_sReferenceType = "OOo";
+ }
+ else
+ {
+ m_sReferenceType = _sType;
+ }
+ }
+ public void setTargetFrameName(String _sTargetFrameName) {m_sTargetFrameName = _sTargetFrameName;}
+ public void setPrinterName(String _sName) {m_sPrinterName = _sName;}
+ public void setHidden() { m_bHidden = true;}
+ public void setViewable() {m_bHidden = false;}
+ public void setDefaultXMLFormatApp(String _sNameOfApp) {m_sDefaultXMLFormatApplication = _sNameOfApp;}
+
+ // get methods
+ public XMultiServiceFactory getMultiServiceFactory()
+ {
+ XMultiServiceFactory xMSF = (XMultiServiceFactory)m_aCurrentParams.getMSF();
+
+ // check if MultiServiceFactory is given
+ if (getReferenceType().toLowerCase().equals("pdf") ||
+ getReferenceType().toLowerCase().equals("ooo"))
+ {
+ if (xMSF == null)
+ {
+ GlobalLogWriter.get().println("ERROR! MultiServiceFactory not given.");
+ }
+ }
+ return xMSF;
+ }
+
+ public String getReferenceType() {return m_sReferenceType;}
+ public String getTargetFrameName() {return m_sTargetFrameName;}
+ public String getPrinterName() {return m_sPrinterName;}
+ public boolean isHidden() {return m_bHidden;}
+ public String getDefaultXMLFormatApp() {return m_sDefaultXMLFormatApplication;}
+
+
+ /**
+ * @return true, if subdirectories should run through
+ */
+ public boolean includeSubDirectories() {return m_bIncludeSubdirectories;}
+
+ /**
+ * @return the number of pages to be print
+ */
+ public int getMaxPages() {return m_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()
+ {
+ if (m_sOnlyPage == null)
+ {
+ return "";
+ }
+ return m_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;
+ }
+
+ /**
+ * @return integer value, which contain resolution in DPI.
+ */
+ public int getResolutionInDPI() {return m_nResolutionInDPI;}
+
+ public static void checkIfMSWindowsConformPath(String _sPath)
+ {
+ if (_sPath != null && _sPath.length() > 1)
+ {
+ if (_sPath.charAt(1) == ':')
+ {
+ if (_sPath.charAt(2) != '\\')
+ {
+ GlobalLogWriter.get().println("This is not a Microsoft Windows conform path: '" + _sPath + "' please fix.");
+ System.exit(1);
+ }
+ }
+ }
+ }
+
+
+ /**
+ * @return the INPUT_PATH out of the TestParameters
+ */
+ public String getInputPath()
+ {
+ String sInputPath;
+ sInputPath = (String)m_aCurrentParams.get(PropertyName.DOC_COMPARATOR_INPUT_PATH);
+ checkIfMSWindowsConformPath(sInputPath);
+ return sInputPath;
+ }
+ /**
+ * @return the OUTPUT_PATH out of the TestParameters
+ */
+ public String getOutputPath()
+ {
+ String sOutputPath;
+ sOutputPath = (String)m_aCurrentParams.get(PropertyName.DOC_COMPARATOR_OUTPUT_PATH);
+ checkIfMSWindowsConformPath(sOutputPath);
+ return sOutputPath;
+ }
+ /**
+ * @return the REFERENCE_PATH out of the TestParameters
+ */
+ public String getReferencePath()
+ {
+ String sReferencePath;
+ sReferencePath = (String)m_aCurrentParams.get(PropertyName.DOC_COMPARATOR_REFERENCE_PATH);
+ checkIfMSWindowsConformPath(sReferencePath);
+ return sReferencePath;
+ }
+ /**
+ * @return the DIFF_PATH out of the TestParameters
+ */
+ public String getDiffPath()
+ {
+ String sDiffPath;
+ sDiffPath = (String)m_aCurrentParams.get(PropertyName.DOC_COMPARATOR_DIFF_PATH);
+ checkIfMSWindowsConformPath(sDiffPath);
+ return sDiffPath;
+ }
+
+ public boolean getOverwrite()
+ {
+ boolean bOverwrite = m_aCurrentParams.getBool( PropertyName.DOC_COMPARATOR_OVERWRITE_REFERENCE);
+ return bOverwrite;
+ }
+ public String getReferenceInputPath()
+ {
+ String sReferenceInputPath;
+ sReferenceInputPath = (String)m_aCurrentParams.get(PropertyName.DOC_COMPARATOR_REFERENCE_INPUT_PATH);
+ return sReferenceInputPath;
+ }
+
+ /**
+ * Helper function to get the buildid of the current used OpenOffice.org
+ * out of the AppExecutionCommand the build ID
+ */
+ 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 = convwatch.BuildID.getBuildID(sAPP);
+ return sBuildID;
+ }
+
+ public boolean shouldOfficeStart()
+ {
+ String sNoOffice = (String)m_aCurrentParams.get( "NoOffice" );
+ if (sNoOffice != null)
+ {
+ if (sNoOffice.toLowerCase().startsWith("t") || sNoOffice.toLowerCase().startsWith("y"))
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ // Handle for Reference Build ID, is set in ConvWatch.createPostscriptStartCheck()
+ private String m_sRefBuildID;
+
+ public void setRefBuildID(String _sRef)
+ {
+ m_sRefBuildID = _sRef;
+ }
+ public String getRefBuildID()
+ {
+ return m_sRefBuildID;
+ }
+
+ public void disallowStore()
+ {
+ m_bStoreFile = false;
+ }
+ public void allowStore()
+ {
+ m_bStoreFile = true;
+ }
+ public boolean isStoreAllowed()
+ {
+ return m_bStoreFile;
+ }
+ public boolean createDefaultReference()
+ {
+ return m_bCreateDefaultReference;
+ }
+
+
+ // 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_sOfficeProgram = "";
+ public void setOfficeProgram(String _sName)
+ {
+ m_sOfficeProgram = _sName;
+ }
+ public String getOfficeProgram()
+ {
+ return m_sOfficeProgram;
+ }
+
+ public boolean restartOffice()
+ {
+ if (m_bResuseOffice == false)
+ {
+ return true;
+ }
+ return false;
+ }
+
+ String m_sHTMLOutputPrefix = "";
+ public String getHTMLOutputPrefix()
+ {
+ return m_sHTMLOutputPrefix;
+ }
+
+ TriState m_tWithBorderMove = TriState.UNSET;
+ // public TriState isBorderMove()
+ // {
+ // return m_tWithBorderMove;
+ // }
+ public TriState getBorderMove()
+ {
+ return m_tWithBorderMove;
+ }
+ public void setBorderMove(TriState _tBorderMove)
+ {
+ m_tWithBorderMove = _tBorderMove;
+ }
+
+ String m_sDocumentType = "";
+ public void setDocumentType(String _sName)
+ {
+ m_sDocumentType = _sName;
+ }
+ public String getDocumentType()
+ {
+ return m_sDocumentType;
+ }
+
+ /*
+ helper class for performance analyser features
+ */
+ PerformanceContainer m_aPerformanceContainer = null;
+ public PerformanceContainer getPerformance()
+ {
+ if (m_aPerformanceContainer == null)
+ {
+ m_aPerformanceContainer = new PerformanceContainer();
+ }
+ return m_aPerformanceContainer;
+ }
+
+ private String m_aInputFile;
+ public void setInputFile(String _sInputFile)
+ {
+ m_aInputFile = _sInputFile;
+ }
+ public String getInputFile()
+ {
+ return m_aInputFile;
+ }
+
+ private String m_sDBInfoString;
+ public String getDBInfoString()
+ {
+ if (m_sDBInfoString != null)
+ {
+ if (m_sDBInfoString.length() == 0)
+ {
+ return null;
+ }
+ }
+
+ return m_sDBInfoString;
+ }
+
+ public boolean cancelRequest()
+ {
+ File aCancelFile = null;
+ String fs;
+ fs = System.getProperty("file.separator");
+ String sTempPath = (String)m_aCurrentParams.get( PropertyName.TEMPPATH );
+ if (sTempPath != null)
+ {
+ String sGDC_Dir = sTempPath;
+
+ if (m_sDistinct.length() > 0)
+ {
+ sGDC_Dir = sGDC_Dir + fs + m_sDistinct;
+ }
+
+ String sCancelFile = sGDC_Dir + fs + "cancel_compare.txt";
+ aCancelFile = new File(sCancelFile);
+
+ if (aCancelFile.exists())
+ {
+ GlobalLogWriter.get().println("ATTENTION: Found file: '" + sCancelFile + "'.");
+ GlobalLogWriter.get().println("User has canceled the program flow.");
+ return true;
+ }
+ }
+ return false;
+ }
+
+}
+
+
+/*
+public class MSGraphicalTestArguments extends GraphicalTestArguments
+{
+ MSGraphicalTestArguments()
+ {
+ setReferenceType("msoffice");
+ }
+}
+
+public class OOoGraphicalTestArguments extends GraphicalTestArguments
+{
+ OOoGraphicalTestArguments(XMultiServiceFactory _aFactory)
+ {
+ setMultiServiceFactory(_aFactory);
+ }
+}
+*/
diff --git a/qadevOOo/runner/convwatch/HTMLOutputter.java b/qadevOOo/runner/convwatch/HTMLOutputter.java
new file mode 100644
index 000000000000..49edb2c25ac0
--- /dev/null
+++ b/qadevOOo/runner/convwatch/HTMLOutputter.java
@@ -0,0 +1,418 @@
+/*************************************************************************
+ *
+ * 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 convwatch;
+
+import java.io.File;
+import java.io.FileWriter;
+import helper.OSHelper;
+
+public class HTMLOutputter
+{
+ FileWriter m_aOut;
+ String m_sFilename;
+ String m_sNamePrefix; // the HTML files used a suffix to build it's right name
+
+ /**
+ * ls is the current line separator (carridge return)
+ */
+ String ls;
+
+ HTMLOutputter() {}
+ public static HTMLOutputter create( String _sOutputPath, String _sHTMLFilename, String _sNamePrefix, String _sTitle )
+ {
+ FileHelper.makeDirectories("", _sOutputPath);
+ HTMLOutputter a = new HTMLOutputter();
+ String fs = System.getProperty("file.separator");
+ String sFilename = _sOutputPath + fs + _sHTMLFilename;
+
+ try
+ {
+ File outputFile = new File(sFilename);
+ a.m_aOut = new FileWriter(outputFile.toString());
+ a.ls = System.getProperty("line.separator");
+ }
+ catch (java.io.IOException e)
+ {
+ e.printStackTrace();
+ GlobalLogWriter.get().println("ERROR: Can't create HTML Outputter");
+ return null;
+ }
+ a.m_sFilename = sFilename;
+ a.m_sNamePrefix = _sNamePrefix;
+ return a;
+ }
+ public String getFilename() {return m_sFilename;}
+
+ public void header(String _sTitle)
+ {
+ try
+ {
+ m_aOut.write( "<html>" + ls);
+ m_aOut.write( "<head>" + ls);
+ m_aOut.write( "<title>" + _sTitle + "</title>" + ls);
+ m_aOut.write( "<link rel=\"stylesheet\" type=\"text/css\" href=\"/gfxcmp_ui/xmloff.css\" media=\"screen\" />" + ls);
+ m_aOut.write( "<link rel=\"stylesheet\" type=\"text/css\" href=\"/gfxcmp_ui/style.css\" media=\"screen\" />" + ls);
+ m_aOut.write( "</head>" + ls);
+ m_aOut.write( "<body bgcolor=white>" + ls);
+ m_aOut.flush();
+ }
+ catch (java.io.IOException e)
+ {
+ }
+ }
+
+ final static String TEST_TABLETITLE = "Test";
+ final static String VISUAL_STATUS_TABLETITLE = "Visual status";
+ final static String VISUAL_STATUS_MESSAGE_TABLETITLE = "Message";
+
+ public void indexSection(String _sOfficeInfo)
+ {
+ try
+ {
+ m_aOut.write( "<h2>Results for " + _sOfficeInfo + "</h2>" + ls);
+ m_aOut.write( "<p>Legend:<br>");
+ m_aOut.write( stronghtml(FIRSTGFX_TABLETITLE) + " contains the output printed via 'ghostscript' as a jpeg picture.<br>");
+
+ m_aOut.write( "<table class=\"infotable\">" + ls);
+ m_aOut.write( "<TR>");
+ m_aOut.write( tableHeaderCell(TEST_TABLETITLE));
+ m_aOut.write( tableHeaderCell(TEST_TABLETITLE));
+ m_aOut.write( tableHeaderCell(VISUAL_STATUS_TABLETITLE));
+ m_aOut.write( tableHeaderCell(VISUAL_STATUS_MESSAGE_TABLETITLE));
+ m_aOut.write( "</TR>" + ls);
+ m_aOut.flush();
+ }
+ catch (java.io.IOException e)
+ {
+ }
+ }
+
+ String getHREF(String _sHREF, String _sPathInfo)
+ {
+ StringBuffer a = new StringBuffer();
+ if (! OSHelper.isWindows())
+ {
+ // System.out.println("Tu'nix system.");
+ a.append("<A HREF=\"");
+ a.append(_sHREF);
+ a.append("\">");
+ a.append(_sPathInfo);
+ a.append("</A>");
+ }
+ else
+ {
+ // System.out.println("Windows system.");
+ //! this should be replaced by a better method
+ //! name(WIN|UNIX)
+ a.append("<A HREF=\"");
+ a.append(_sHREF);
+ a.append("\">");
+ a.append(_sPathInfo);
+ // a.append("(first)");
+ a.append("</A>");
+ // if (_sHREF.charAt(1) == ':' && (_sHREF.charAt(0) == 'x' || _sHREF.charAt(0) == 'X'))
+ // int index = 0;
+ // index = _sHREF.indexOf("X:");
+ // if (index == -1)
+ // {
+ // index = _sHREF.indexOf("x:");
+ // }
+ // if (index >= 0)
+ // {
+ // // int index = 0;
+ // // remove "X:" and insert "/tausch"
+ // StringBuffer sbUNIXPath = new StringBuffer( _sHREF.substring(0, index) );
+ // sbUNIXPath.append("/tausch");
+ // sbUNIXPath.append(_sHREF.substring(index + 2));
+ // String sUNIXPath = sbUNIXPath.toString();
+ // sUNIXPath = utils.replaceAll13(sUNIXPath, "\\", "/");
+ //
+ // a.append("<A HREF=\"");
+ // a.append(sUNIXPath);
+ // a.append("\">");
+ // a.append("(second)");
+ // a.append("</A>");
+ // }
+ // else
+ // {
+ // System.out.println("Path is '" + _sHREF + "'");
+ // }
+
+ }
+ return a.toString();
+ }
+
+ String tableDataCell(String _sValue)
+ {
+ StringBuffer a = new StringBuffer();
+ a.append("<TD>");
+ a.append(_sValue);
+ a.append("</TD>");
+ return a.toString();
+ }
+
+ 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 _sHTMLFile2, String _sHTMLName2, String _sStatusRunThrough, String _sStatusMessage)
+ {
+ try
+ {
+ m_aOut.write( "<TR>");
+ m_aOut.write(tableDataCell( getHREF(_sHTMLFile, _sHTMLName) ) );
+ if (_sHTMLFile2.length() > 0)
+ {
+ m_aOut.write(tableDataCell( getHREF(_sHTMLFile2, _sHTMLName2) ) );
+ }
+ else
+ {
+ m_aOut.write(tableDataCell( "" ) );
+ }
+
+ m_aOut.write( tableDataCell(_sStatusRunThrough) );
+ m_aOut.write( tableDataCell(_sStatusMessage) );
+ m_aOut.write( "</TR>" + ls);
+
+ m_aOut.flush();
+ }
+ catch (java.io.IOException e)
+ {
+ }
+ }
+
+ public void close()
+ {
+ try
+ {
+ m_aOut.write( "</TABLE>" + ls);
+ m_aOut.write( "</BODY></HTML>" + ls);
+ m_aOut.flush();
+ m_aOut.close();
+ }
+ catch (java.io.IOException e)
+ {
+ }
+ }
+
+// -----------------------------------------------------------------------------
+ String stronghtml(String _sValue)
+ {
+ StringBuffer a = new StringBuffer();
+ a.append("<STRONG>");
+ a.append(_sValue);
+ a.append("</STRONG>");
+ return a.toString();
+ }
+
+ final static String FIRSTGFX_TABLETITLE = "Original print file as jpeg";
+ final static String SECONDGFX_TABLETITLE = "New print file as jpeg";
+ final static String DIFFER_TABLETITLE = "Difference file";
+ final static String STATUS_TABLETITLE = "Status";
+ final static String PIXELDIFF_TABLETITLE = "Pixel difference in %";
+
+ final static String PIXELDIFF_BM_TABLETITLE = "P.diff. in % after remove border";
+ final static String DIFFER_BM_TABLETITLE = "Diff file (RB)";
+
+ final static String OK_TABLETITLE = "OK?";
+ public void checkSection(String _sDocumentName)
+ {
+ try
+ {
+ m_aOut.write( "<H2>Results for the document " + _sDocumentName + "</H2>" + ls);
+
+ m_aOut.write( "<p>Legend:<br>");
+ m_aOut.write( stronghtml(FIRSTGFX_TABLETITLE) + " contains the output printed via 'ghostscript' as a jpeg picture.<br>");
+ m_aOut.write( stronghtml(SECONDGFX_TABLETITLE) + " contains the same document opened within OpenOffice.org also printed via ghostscript as jpeg.<br>");
+ m_aOut.write( stronghtml(DIFFER_TABLETITLE)+" is build via composite from original and new picture. The result should be a whole black picture, if there are no differences.<br>At the moment "+stronghtml(STATUS_TABLETITLE)+" is only ok, if the difference file contains only one color (black).</p>" );
+ m_aOut.write( stronghtml(DIFFER_BM_TABLETITLE) + " is build via composite from original and new picture after the border of both pictures are removed, so differences based on center problems may solved here");
+ m_aOut.write( "</p>");
+ m_aOut.write( "<p>Some words about the percentage value<br>");
+ m_aOut.write( "If a character is on the original page (a) and on the new page this character is moved to an other position only (b) , this means the difference is 100%.<br>");
+ m_aOut.write( "If character (b) is also bigger than character (a) the percentage is grow over the 100% mark.<br>");
+ m_aOut.write( "This tool count only the pixels which are differ to it's background color. It makes no sense to count all pixels, or the difference percentage will most the time in a very low percentage range.");
+ m_aOut.write( "</p>");
+
+ m_aOut.write( "<table class=\"infotable\">" + ls);
+
+ m_aOut.write( "<TR>" + ls);
+ m_aOut.write( tableHeaderCell( FIRSTGFX_TABLETITLE) );
+ m_aOut.write( tableHeaderCell( SECONDGFX_TABLETITLE ) );
+ m_aOut.write( tableHeaderCell(DIFFER_TABLETITLE ) );
+ m_aOut.write( tableHeaderCell(PIXELDIFF_TABLETITLE ) );
+
+ m_aOut.write( tableHeaderCell(DIFFER_BM_TABLETITLE) );
+ m_aOut.write( tableHeaderCell(PIXELDIFF_BM_TABLETITLE ) );
+
+ m_aOut.write( tableHeaderCell( OK_TABLETITLE) );
+
+ m_aOut.write( "</TR>" + ls);
+ m_aOut.flush();
+ }
+ catch (java.io.IOException e)
+ {
+ }
+ }
+
+ public void checkLine(StatusHelper _aStatus, boolean _bCurrentResult)
+ {
+ try
+ {
+ m_aOut.write( "<TR>" + ls);
+ String sLink = getHREF(FileHelper.getBasename(_aStatus.m_sOldGfx), FileHelper.getBasename(_aStatus.m_sOldGfx));
+ m_aOut.write( tableDataCell(sLink) );
+
+ sLink = getHREF(FileHelper.getBasename(_aStatus.m_sNewGfx), FileHelper.getBasename(_aStatus.m_sNewGfx));
+ m_aOut.write( tableDataCell(sLink) );
+
+ sLink = getHREF(FileHelper.getBasename(_aStatus.m_sDiffGfx), FileHelper.getBasename(_aStatus.m_sDiffGfx));
+ m_aOut.write( tableDataCell(sLink) );
+
+ String sPercent = String.valueOf(_aStatus.nPercent) + "%";
+ if (_aStatus.nPercent > 0 && _aStatus.nPercent < 5)
+ {
+ sPercent += " (less 5% is ok)";
+ }
+ m_aOut.write(tableDataCell( sPercent ) );
+
+ if (_aStatus.m_sDiff_BM_Gfx == null)
+ {
+ sLink = "No diffs, therefore no moves";
+ m_aOut.write( tableDataCell(sLink) );
+ m_aOut.write(tableDataCell( "" ) );
+ }
+ else
+ {
+ sLink = getHREF(FileHelper.getBasename(_aStatus.m_sDiff_BM_Gfx), FileHelper.getBasename(_aStatus.m_sDiff_BM_Gfx));
+ m_aOut.write( tableDataCell(sLink) );
+
+ String sPercent2 = String.valueOf(_aStatus.nPercent2) + "%";
+ if (_aStatus.nPercent2 > 0 && _aStatus.nPercent2 < 5)
+ {
+ sPercent2 += " (less 5% is ok)";
+ }
+ m_aOut.write(tableDataCell( sPercent2 ) );
+ }
+
+ // is the check positiv, in a defined range
+ if (_bCurrentResult)
+ {
+ m_aOut.write(tableDataCell( "YES" ) );
+ }
+ else
+ {
+ m_aOut.write(tableDataCell( "NO" ) );
+ }
+
+ m_aOut.write( "</TR>" + ls);
+ }
+ catch (java.io.IOException e)
+ {
+ }
+ }
+
+// -----------------------------------------------------------------------------
+ public void checkDiffDiffSection(String _sDocumentName)
+ {
+ try
+ {
+ m_aOut.write( "<H2>Results for the document " + _sDocumentName + "</H2>" + ls);
+
+ m_aOut.write( "<p>Legend:<br>");
+ m_aOut.write( "</p>");
+
+ m_aOut.write( "<table class=\"infotable\">" + ls);
+
+ m_aOut.write( "<TR>" + ls);
+ m_aOut.write( tableHeaderCell( "Source to actual difference" ) );
+ m_aOut.write( tableHeaderCell( "Actual difference" ) );
+ m_aOut.write( tableHeaderCell(DIFFER_TABLETITLE ) );
+ m_aOut.write( tableHeaderCell(PIXELDIFF_TABLETITLE ) );
+
+ m_aOut.write( tableHeaderCell( OK_TABLETITLE) );
+
+ m_aOut.write( "</TR>" + ls);
+ m_aOut.flush();
+ }
+ catch (java.io.IOException e)
+ {
+ }
+ }
+
+ public void checkDiffDiffLine(StatusHelper _aStatus, boolean _bCurrentResult)
+ {
+ try
+ {
+ m_aOut.write( "<TR>" + ls);
+ // the link to the old difference can't offer here
+ // String sLink = getHREF(FileHelper.getBasename(_aStatus.m_sOldGfx), FileHelper.getBasename(_aStatus.m_sOldGfx));
+ // m_aOut.write( tableDataCell(sLink) );
+
+ String sBasename = FileHelper.getBasename(m_sFilename);
+ String sNew = sBasename.substring(m_sNamePrefix.length());
+
+ String sLink;
+ sLink = getHREF(sNew, sNew);
+ m_aOut.write( tableDataCell(sLink) );
+
+ sLink = getHREF(FileHelper.getBasename(_aStatus.m_sNewGfx), FileHelper.getBasename(_aStatus.m_sNewGfx));
+ m_aOut.write( tableDataCell(sLink) );
+
+ sLink = getHREF(FileHelper.getBasename(_aStatus.m_sDiffGfx), FileHelper.getBasename(_aStatus.m_sDiffGfx));
+ m_aOut.write( tableDataCell(sLink) );
+
+ String sPercent = String.valueOf(_aStatus.nPercent) + "%";
+ // if (_aStatus.nPercent > 0 && _aStatus.nPercent < 5)
+ // {
+ // sPercent += " (less 5% is ok)";
+ // }
+ m_aOut.write(tableDataCell( sPercent ) );
+
+ // is the check positiv, in a defined range
+ if (_bCurrentResult)
+ {
+ m_aOut.write(tableDataCell( "YES" ) );
+ }
+ else
+ {
+ m_aOut.write(tableDataCell( "NO" ) );
+ }
+
+ m_aOut.write( "</TR>" + ls);
+ }
+ catch (java.io.IOException e)
+ {
+ }
+ }
+
+}
diff --git a/qadevOOo/runner/convwatch/INIOutputter.java b/qadevOOo/runner/convwatch/INIOutputter.java
new file mode 100644
index 000000000000..faa542a05cb8
--- /dev/null
+++ b/qadevOOo/runner/convwatch/INIOutputter.java
@@ -0,0 +1,207 @@
+/*************************************************************************
+ *
+ * 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 convwatch;
+
+import java.io.File;
+import java.io.FileWriter;
+
+public class INIOutputter
+{
+ FileWriter m_aOut;
+ String m_sFilename;
+ String m_sNamePrefix; // the HTML files used a suffix to build it's right name
+
+ /**
+ * ls is the current line separator (carridge return)
+ */
+ String ls;
+
+ public static INIOutputter create( String _sOutputPath, String _sHTMLFilename, String _sNamePrefix, String _sTitle )
+ {
+ FileHelper.makeDirectories("", _sOutputPath);
+ INIOutputter a = new INIOutputter();
+ String fs = System.getProperty("file.separator");
+ String sFilename = _sOutputPath + fs + _sHTMLFilename;
+
+ try
+ {
+ File outputFile = new File(sFilename);
+ a.m_aOut = new FileWriter(outputFile.toString());
+ a.ls = System.getProperty("line.separator");
+ }
+ catch (java.io.IOException e)
+ {
+ e.printStackTrace();
+ GlobalLogWriter.get().println("ERROR: Can't create INI Outputter");
+ return null;
+ }
+ a.m_sFilename = sFilename;
+ a.m_sNamePrefix = _sNamePrefix;
+
+ return a;
+ }
+ public String getFilename() {return m_sFilename;}
+
+ public void createHeader()
+ {
+ try
+ {
+ m_aOut.write("; This file is automatically created by a convwatch run" + ls);
+ m_aOut.write("; " + ls);
+ m_aOut.write("; If you see this file in a browser you may have forgotten to set the follows in the property file" + ls);
+ m_aOut.write("; " + PropertyName.DOC_COMPARATOR_HTML_OUTPUT_PREFIX + "=http://lla-1.germany/gfxcmp/cw.php?inifile=" + ls);
+ m_aOut.write("; Please check the documentation if you got confused." + ls);
+ m_aOut.write("; " + ls);
+ m_aOut.write("; " + ls);
+ }
+ catch (java.io.IOException e)
+ {
+ }
+ }
+
+ public void writeSection(String _sSectionName)
+ {
+ try
+ {
+ m_aOut.write("[" + _sSectionName + "]" + ls);
+ m_aOut.flush();
+ }
+ catch (java.io.IOException e)
+ {
+ }
+ }
+
+ public void writeValue(String _sName, String _sValue)
+ {
+ try
+ {
+ m_aOut.write(_sName + "=" + _sValue + ls);
+ m_aOut.flush();
+ }
+ catch (java.io.IOException e)
+ {
+ }
+ }
+
+ public void startSection(int _nNumber)
+ {
+ writeSection( "page" + String.valueOf(_nNumber));
+ }
+
+ public void close()
+ {
+ try
+ {
+ m_aOut.flush();
+ m_aOut.close();
+ }
+ catch (java.io.IOException e)
+ {
+ }
+ }
+
+ public void checkLine(StatusHelper _aStatus, boolean _bCurrentResult)
+ {
+ try
+ {
+ m_aOut.write( "oldgfx=" + _aStatus.m_sOldGfx + ls);
+ m_aOut.write( "newgfx=" + _aStatus.m_sNewGfx + ls);
+ m_aOut.write( "diffgfx=" + _aStatus.m_sDiffGfx + ls);
+
+ String sPercent = String.valueOf(_aStatus.nPercent) + "%";
+ if (_aStatus.nPercent > 0 && _aStatus.nPercent < 5)
+ {
+ sPercent += " (less 5% is ok)";
+ }
+ m_aOut.write("percent=" + sPercent + ls);
+
+ if (_aStatus.m_sDiff_BM_Gfx == null)
+ {
+ m_aOut.write("BM=false" + ls);
+ }
+ else
+ {
+ m_aOut.write("BM=true" + ls);
+ m_aOut.write( "old_BM_gfx=" + _aStatus.m_sOld_BM_Gfx + ls);
+ m_aOut.write( "new_BM_gfx=" + _aStatus.m_sNew_BM_Gfx + ls);
+ m_aOut.write( "diff_BM_gfx=" + _aStatus.m_sDiff_BM_Gfx + ls);
+
+ String sPercent2 = String.valueOf(_aStatus.nPercent2) + "%";
+ if (_aStatus.nPercent2 > 0 && _aStatus.nPercent2 < 5)
+ {
+ sPercent2 += " (less 5% is ok)";
+ }
+ m_aOut.write("percent2=" + sPercent2 + ls);
+ }
+
+ writeResult(_bCurrentResult);
+ m_aOut.flush();
+ }
+ catch (java.io.IOException e)
+ {
+ }
+ }
+
+ void writeResult(boolean _bCurrentResult) throws java.io.IOException
+ {
+ // is the check positiv, in a defined range
+ if (_bCurrentResult)
+ {
+ m_aOut.write("result=YES" + ls);
+ }
+ else
+ {
+ m_aOut.write("result=NO" + ls);
+ }
+ }
+
+ public void checkDiffDiffLine(StatusHelper _aStatus, boolean _bCurrentResult)
+ {
+ try
+ {
+ m_aOut.write( "oldgfx=" + _aStatus.m_sOldGfx + ls);
+ m_aOut.write( "newgfx=" + _aStatus.m_sNewGfx + ls);
+ m_aOut.write( "diffgfx=" + _aStatus.m_sDiffGfx + ls);
+
+ String sPercent = String.valueOf(_aStatus.nPercent) + "%";
+ // if (_aStatus.nPercent > 0 && _aStatus.nPercent < 5)
+ // {
+ // sPercent += " (less 5% is ok)";
+ // }
+ m_aOut.write("percent=" + sPercent + ls);
+
+ // is the check positiv, in a defined range
+ writeResult(_bCurrentResult);
+ m_aOut.flush();
+ }
+ catch (java.io.IOException e)
+ {
+ }
+ }
+
+}
diff --git a/qadevOOo/runner/convwatch/ImageHelper.java b/qadevOOo/runner/convwatch/ImageHelper.java
new file mode 100644
index 000000000000..6eec5dee6b63
--- /dev/null
+++ b/qadevOOo/runner/convwatch/ImageHelper.java
@@ -0,0 +1,116 @@
+/*************************************************************************
+ *
+ * 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 convwatch;
+
+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;
+
+ public 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(int x, 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/convwatch/IniFile.java b/qadevOOo/runner/convwatch/IniFile.java
new file mode 100644
index 000000000000..fbcaaea0b33b
--- /dev/null
+++ b/qadevOOo/runner/convwatch/IniFile.java
@@ -0,0 +1,452 @@
+/*************************************************************************
+ *
+ * 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 convwatch;
+
+import java.io.File;
+import java.io.RandomAccessFile;
+import java.util.ArrayList;
+
+/**
+ 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
+class IniFile
+{
+ /**
+ * internal representation of the ini file content.
+ * Problem, if ini file changed why other write something difference, we don't realise this.
+ */
+ String m_sFilename;
+ ArrayList m_aList;
+ boolean m_bListContainUnsavedChanges = false;
+
+ /**
+ 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();
+ }
+
+ ArrayList loadLines()
+ {
+ File aFile = new File(m_sFilename);
+ ArrayList aLines = new ArrayList();
+ if (! aFile.exists())
+ {
+ GlobalLogWriter.get().println("couldn't find file " + m_sFilename);
+ // DebugHelper.exception(BasicErrorCode.SbERR_FILE_NOT_FOUND, "");
+ // m_bListContainUnsavedChanges = false;
+ return aLines;
+ }
+ RandomAccessFile aReader = null;
+ try
+ {
+ aReader = new RandomAccessFile(aFile,"r");
+ String aLine = "";
+ while (aLine != null)
+ {
+ aLine = aReader.readLine();
+ if (aLine != null)
+ {
+ aLines.add(aLine);
+ }
+ }
+ }
+ catch (java.io.FileNotFoundException fne)
+ {
+ GlobalLogWriter.get().println("couldn't open file " + m_sFilename);
+ GlobalLogWriter.get().println("Message: " + fne.getMessage());
+ // DebugHelper.exception(BasicErrorCode.SbERR_FILE_NOT_FOUND, "");
+ }
+ catch (java.io.IOException ie)
+ {
+ GlobalLogWriter.get().println("Exception occurs while reading from file " + m_sFilename);
+ GlobalLogWriter.get().println("Message: " + ie.getMessage());
+ // DebugHelper.exception(BasicErrorCode.SbERR_INTERNAL_ERROR, ie.getMessage());
+ }
+ try
+ {
+ aReader.close();
+ }
+ catch (java.io.IOException ie)
+ {
+ GlobalLogWriter.get().println("Couldn't close file " + m_sFilename);
+ GlobalLogWriter.get().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;
+ }
+
+ // -----------------------------------------------------------------------------
+
+ boolean isRemark(String _sLine)
+ {
+ if ( ((_sLine.length() < 2) ) ||
+ ( _sLine.startsWith("#")) ||
+ ( _sLine.startsWith(";")) )
+ {
+ return true;
+ }
+ return false;
+ }
+
+ String getItem(int i)
+ {
+ return (String)m_aList.get(i);
+ }
+
+ String buildSectionName(String _sSectionName)
+ {
+ String sFindSection = "[" + _sSectionName + "]";
+ return sFindSection;
+ }
+ String toLowerIfNeed(String _sName)
+ {
+ return _sName.toLowerCase();
+ }
+
+ // return the number where this section starts
+ 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;
+ }
+
+ // return the line number, where the key is found.
+ 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
+ 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("]") */)
+ {
+ // 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
+ 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;
+ }
+
+ 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
+ */
+ public String getValue(String _sSection, String _sKey)
+ {
+ String sValue = "";
+ int i = findKey(_sSection, _sKey);
+ if (i == -1)
+ {
+ // Section not found, therefore the value can't exist
+ return "";
+ }
+
+ sValue = getValue(i);
+
+ return sValue;
+ }
+
+ /**
+ write back the ini file to the disk, only if there exist changes
+ */
+ 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);
+ aFile.delete();
+ if (aFile.exists())
+ {
+ GlobalLogWriter.get().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);
+ aWriter.writeBytes(sLine);
+ aWriter.writeByte((int)'\n');
+ }
+ aWriter.close();
+ }
+
+ catch (java.io.FileNotFoundException fne)
+ {
+ GlobalLogWriter.get().println("couldn't open file for writing " + m_sFilename);
+ GlobalLogWriter.get().println("Message: " + fne.getMessage());
+ // DebugHelper.exception(BasicErrorCode.SbERR_FILE_NOT_FOUND, "");
+ }
+ catch(java.io.IOException ie)
+ {
+ GlobalLogWriter.get().println("Exception occurs while writing to file " + m_sFilename);
+ GlobalLogWriter.get().println("Message: " + ie.getMessage());
+ // DebugHelper.exception(BasicErrorCode.SbERR_INTERNAL_ERROR, ie.getMessage());
+ }
+ }
+
+
+
+ /**
+ 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
+ */
+ 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);
+
+ m_aList.add(sFindSection);
+ 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);
+ 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;
+ // }
+
+
+ /**
+ * some tests for this class
+ */
+// public static void main(String[] args)
+// {
+// IniFile aIniFile = new IniFile("/tmp/inifile");
+// 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");
+//
+// String sValue2 = aIniFile.getValue("Section2","Key");
+// aIniFile.store();
+// }
+}
diff --git a/qadevOOo/runner/convwatch/LISTOutputter.java b/qadevOOo/runner/convwatch/LISTOutputter.java
new file mode 100644
index 000000000000..87c13ea0477a
--- /dev/null
+++ b/qadevOOo/runner/convwatch/LISTOutputter.java
@@ -0,0 +1,104 @@
+/*************************************************************************
+ *
+ * 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 convwatch;
+
+import java.io.File;
+import java.io.FileWriter;
+
+public class LISTOutputter
+{
+ FileWriter m_aOut;
+ String m_sFilename;
+
+ /**
+ * ls is the current line separator (carridge return)
+ */
+ String ls;
+
+ public static LISTOutputter create( String _sOutputPath, String _sFilename)
+ {
+ FileHelper.makeDirectories("", _sOutputPath);
+ LISTOutputter a = new LISTOutputter();
+ String fs = System.getProperty("file.separator");
+ String sFilename = _sOutputPath + fs + _sFilename;
+
+ try
+ {
+ File outputFile = new File(sFilename);
+ a.m_aOut = new FileWriter(outputFile.toString());
+ a.ls = System.getProperty("line.separator");
+ }
+ catch (java.io.IOException e)
+ {
+ e.printStackTrace();
+ GlobalLogWriter.get().println("ERROR: Can't create LIST Outputter");
+ return null;
+ }
+ a.m_sFilename = sFilename;
+
+ return a;
+ }
+ public String getFilename() {return m_sFilename;}
+
+ public void createHeader()
+ {
+ try
+ {
+ m_aOut.write("# This file is automatically created by a convwatch run" + ls);
+ m_aOut.write("# " + ls);
+ }
+ catch (java.io.IOException e)
+ {
+ }
+ }
+
+ public void writeValue(String _sValue)
+ {
+ try
+ {
+ m_aOut.write(_sValue + ls);
+ m_aOut.flush();
+ }
+ catch (java.io.IOException e)
+ {
+ }
+ }
+
+ public void close()
+ {
+ try
+ {
+ m_aOut.flush();
+ m_aOut.close();
+ }
+ catch (java.io.IOException e)
+ {
+ }
+ }
+
+}
diff --git a/qadevOOo/runner/convwatch/MSOfficePrint.java b/qadevOOo/runner/convwatch/MSOfficePrint.java
new file mode 100644
index 000000000000..5be0cfe058ce
--- /dev/null
+++ b/qadevOOo/runner/convwatch/MSOfficePrint.java
@@ -0,0 +1,870 @@
+/*************************************************************************
+ *
+ * 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 convwatch;
+
+import convwatch.FileHelper;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.RandomAccessFile;
+import convwatch.GraphicalTestArguments;
+import helper.ProcessHandler;
+import java.util.ArrayList;
+import helper.OSHelper;
+
+/**
+ * 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 MSOfficePrint
+{
+ private String m_sPrinterName; // within Windows the tools need a printer name;
+
+ public void setPrinterName(String _s) {m_sPrinterName = _s;}
+
+ // -----------------------------------------------------------------------------
+ static boolean isWordDocument(String _sSuffix)
+ {
+ if (_sSuffix.toLowerCase().endsWith(".doc") ||
+ _sSuffix.toLowerCase().endsWith(".rtf") ||
+ _sSuffix.toLowerCase().endsWith(".dot"))
+ {
+ return true;
+ }
+ return false;
+ }
+
+ static 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;
+ }
+
+ static 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.
+ */
+ public static 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( GraphicalTestArguments _aGTA,
+ String _sInputFile,
+ String _sOutputFile) throws ConvWatchCancelException, java.io.IOException
+ {
+ String sDocumentSuffix = FileHelper.getSuffix(_sInputFile);
+ String sFilterName = _aGTA.getExportFilterName();
+ ArrayList aStartCommand = new ArrayList();
+ 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.
+ if (_aGTA.getDefaultXMLFormatApp().toLowerCase().equals("excel"))
+ {
+ aStartCommand = createExcelStoreHelper();
+ }
+ // else
+ // {
+ // }
+ }
+ else
+ {
+ GlobalLogWriter.get().println("No Microsoft Office document format found.");
+// TODO: use a better Exception!!!
+ throw new ConvWatchCancelException/*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)
+ */
+ public void printToFileWithMSOffice( GraphicalTestArguments _aGTA,
+ String _sInputFile,
+ String _sPrintFilename) throws ConvWatchCancelException, java.io.IOException
+ {
+ String sDocumentSuffix = FileHelper.getSuffix(_sInputFile);
+
+ setPrinterName(_aGTA.getPrinterName());
+
+ ArrayList aStartCommand = new ArrayList();
+ 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.get().println("No Microsoft Office document format found.");
+// TODO: use a better Exception!!!
+ throw new ConvWatchCancelException/*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");
+ String fs = System.getProperty("file.separator");
+ if (! sUserDir.endsWith(fs))
+ {
+ sUserDir = sUserDir + fs;
+ }
+ _aGTA.getPerformance().readWordValuesFromFile(sUserDir + "msofficeloadtimes.txt");
+ OfficePrint.createInfoFile(_sPrintFilename, _aGTA, "msoffice");
+ TimeHelper.waitInSeconds(2, "Give Microsoft Office some time to print.");
+ }
+
+ public void realStartCommand(ArrayList _aStartCommand) throws ConvWatchCancelException
+ {
+ if (_aStartCommand.isEmpty())
+ {
+ throw new ConvWatchCancelException/*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 ConvWatchCancelException/*WrongEnvironmentException*/("We doesn't work within windows environment.");
+ }
+
+
+ ProcessHandler aHandler = new ProcessHandler(aList);
+ boolean bBackValue = aHandler.executeSynchronously();
+ }
+ catch (IndexOutOfBoundsException e)
+ {
+ throw new ConvWatchCancelException/*WrongEnvironmentException*/("Given list is too short.");
+ }
+
+ // return aHandler.getExitCode();
+ }
+
+
+ ArrayList createWordPrintHelper() throws java.io.IOException
+ {
+ // create a program in tmp file
+ String sTmpPath = util.utils.getUsersTempDir();
+ String ls = System.getProperty("line.separator");
+ String fs = System.getProperty("file.separator");
+
+ String sPrintViaWord = "printViaWord.pl";
+
+ ArrayList aList = searchLocalFile(sPrintViaWord);
+ if (aList.isEmpty() == false)
+ {
+ return aList;
+ }
+
+ String sName = sTmpPath + fs + sPrintViaWord;
+ File aFile = new File(sName);
+ FileWriter out = new FileWriter(aFile.toString());
+
+
+ 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("perl");
+ aList.add(sName);
+ return aList;
+ }
+
+ // TODO: Maybe give a possibility to say where search the script from outside
+
+ ArrayList searchLocalFile(String _sScriptName)
+ {
+ String userdir = System.getProperty("user.dir");
+ String fs = System.getProperty("file.separator");
+
+ ArrayList aList = new ArrayList();
+ File aPerlScript = new File(userdir + fs + _sScriptName);
+ if (FileHelper.isDebugEnabled())
+ {
+ GlobalLogWriter.get().println("Search for local existance of " + aPerlScript.getAbsolutePath());
+ }
+
+ if (aPerlScript.exists())
+ {
+ if (FileHelper.isDebugEnabled())
+ {
+ GlobalLogWriter.get().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 createWordStoreHelper() throws java.io.IOException
+ {
+ // create a program in tmp file
+ String sTmpPath = util.utils.getUsersTempDir();
+ String ls = System.getProperty("line.separator");
+ String fs = System.getProperty("file.separator");
+
+ // ArrayList aList = new ArrayList();
+ String sSaveViaWord = "saveViaWord.pl";
+
+ ArrayList aList = searchLocalFile(sSaveViaWord);
+ if (aList.isEmpty() == false)
+ {
+ return aList;
+ }
+
+ String sName = sTmpPath + fs + sSaveViaWord;
+ if (FileHelper.isDebugEnabled())
+ {
+ GlobalLogWriter.get().println("No local found, create a perl script: " + sName);
+ }
+
+ File aFile = new File(sName);
+ FileWriter out = new FileWriter(aFile.toString());
+
+ 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("perl");
+ aList.add(sName);
+ return aList;
+ }
+
+
+ ArrayList createExcelPrintHelper() throws java.io.IOException
+ {
+ // create a program in tmp file
+ String sTmpPath = util.utils.getUsersTempDir();
+ String ls = System.getProperty("line.separator");
+ String fs = System.getProperty("file.separator");
+
+ String sPrintViaExcel = "printViaExcel.pl";
+
+ ArrayList aList = searchLocalFile(sPrintViaExcel);
+ if (aList.isEmpty() == false)
+ {
+ return aList;
+ }
+ String sName = sTmpPath + fs + sPrintViaExcel;
+ if (FileHelper.isDebugEnabled())
+ {
+ GlobalLogWriter.get().println("No local found, create a perl script: " + sName);
+ }
+
+ File aFile = new File(sName);
+ FileWriter out = new FileWriter(aFile.toString());
+
+ 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( " " + 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("perl");
+ aList.add(sName);
+ return aList;
+ }
+
+ ArrayList createExcelStoreHelper() throws java.io.IOException
+ {
+ // create a program in tmp file
+ String sTmpPath = util.utils.getUsersTempDir();
+ String ls = System.getProperty("line.separator");
+ String fs = System.getProperty("file.separator");
+
+ String sSaveViaExcel = "saveViaExcel.pl";
+
+ ArrayList aList = searchLocalFile(sSaveViaExcel);
+ if (aList.isEmpty() == false)
+ {
+ return aList;
+ }
+ String sName = sTmpPath + fs + sSaveViaExcel;
+ if (FileHelper.isDebugEnabled())
+ {
+ GlobalLogWriter.get().println("No local found, create a script: " + sName);
+ }
+
+ File aFile = new File(sName);
+ FileWriter out = new FileWriter(aFile.toString());
+
+ 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("perl");
+ aList.add(sName);
+ return aList;
+ }
+
+ ArrayList createPowerPointPrintHelper() throws java.io.IOException
+ {
+ // create a program in tmp file
+ String sTmpPath = util.utils.getUsersTempDir();
+ String ls = System.getProperty("line.separator");
+ String fs = System.getProperty("file.separator");
+
+ String sPrintViaPowerPoint = "printViaPowerPoint.pl";
+
+ ArrayList aList = searchLocalFile(sPrintViaPowerPoint);
+ if (aList.isEmpty() == false)
+ {
+ return aList;
+ }
+ String sName = sTmpPath + fs + sPrintViaPowerPoint;
+ if (FileHelper.isDebugEnabled())
+ {
+ GlobalLogWriter.get().println("No local found, create a script: " + sName);
+ }
+
+ File aFile = new File(sName);
+ FileWriter out = new FileWriter(aFile.toString());
+
+
+ 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("perl");
+ 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.get().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.get().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;
+ }
+
+}
diff --git a/qadevOOo/runner/convwatch/NameHelper.java b/qadevOOo/runner/convwatch/NameHelper.java
new file mode 100644
index 000000000000..cddf3aca75f2
--- /dev/null
+++ b/qadevOOo/runner/convwatch/NameHelper.java
@@ -0,0 +1,89 @@
+/*************************************************************************
+ *
+ * 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 convwatch;
+
+/**
+ * This container class should help to handle the name of the current document
+ */
+
+public class NameHelper
+{
+ /**
+ *
+ */
+ String m_sOutputPath;
+
+ /**
+ *
+ */
+ String m_sRelativeOutputPath;
+
+ /**
+ *
+ */
+ String m_sNameNoSuffix;
+ String m_sSuffix;
+
+ public NameHelper(String _sOutputPath, String _sRelativeOutputPath, String _sBasename)
+ {
+ m_sOutputPath = _sOutputPath;
+ m_sRelativeOutputPath = _sRelativeOutputPath;
+ String sNameNoSuffix = FileHelper.getNameNoSuffix(_sBasename);
+ m_sNameNoSuffix = sNameNoSuffix;
+ m_sSuffix = FileHelper.getSuffix(_sBasename);
+ }
+ /**
+ * @return the OutputPath
+ */
+ public String getOutputPath() {return m_sOutputPath;}
+
+ /**
+ * @return the relative OutputPath
+ */
+ public String getRelativePath() {return m_sRelativeOutputPath;}
+
+ /**
+ * @return the document name without it's suffix
+ */
+ public String getName() {return m_sNameNoSuffix;}
+
+ /**
+ * @return the document suffix from the original document
+ */
+ public String getSuffix() {return m_sSuffix;}
+
+ public void print()
+ {
+ GlobalLogWriter.get().println(" Outputpath: " + m_sOutputPath);
+ GlobalLogWriter.get().println("relative Outputpath: " + m_sRelativeOutputPath);
+ GlobalLogWriter.get().println(" Name: " + m_sNameNoSuffix);
+ GlobalLogWriter.get().println(" Suffix: " + m_sSuffix);
+
+ }
+
+}
diff --git a/qadevOOo/runner/convwatch/OSHelper.java b/qadevOOo/runner/convwatch/OSHelper.java
new file mode 100644
index 000000000000..1fbf804831d7
--- /dev/null
+++ b/qadevOOo/runner/convwatch/OSHelper.java
@@ -0,0 +1,84 @@
+/*************************************************************************
+ *
+ * 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 convwatch;
+//
+// class OSHelper
+// {
+// public static boolean isWindows()
+// {
+// String sOSName = System.getProperty("os.name");
+// if (sOSName.toLowerCase().startsWith("windows"))
+// {
+// return true;
+// }
+// return false;
+// }
+// // not need
+// // public static boolean isUnix()
+// public static boolean isSolarisIntel()
+// {
+// if ( ( System.getProperty("os.name").toLowerCase().startsWith("solaris") ||
+// System.getProperty("os.name").toLowerCase().startsWith("sunos") ) &&
+// System.getProperty("os.arch").equals("x86"))
+// {
+// return true;
+// }
+// return false;
+// }
+// public static boolean isSolarisSparc()
+// {
+// if ( ( System.getProperty("os.name").toLowerCase().startsWith("solaris") ||
+// System.getProperty("os.name").toLowerCase().startsWith("sunos") ) &&
+// System.getProperty("os.arch").equals("sparc"))
+// {
+// return true;
+// }
+// return false;
+// }
+// public static boolean isLinuxIntel()
+// {
+// if (System.getProperty("os.name").toLowerCase().startsWith("linux") &&
+// System.getProperty("os.arch").equals("i386"))
+// {
+// return true;
+// }
+// return false;
+// }
+//
+// public static boolean isUnix()
+// {
+// if (isLinuxIntel() ||
+// isSolarisIntel() ||
+// isSolarisSparc())
+// {
+// return true;
+// }
+// return false;
+// }
+//
+// }
diff --git a/qadevOOo/runner/convwatch/OfficePrint.java b/qadevOOo/runner/convwatch/OfficePrint.java
new file mode 100644
index 000000000000..c9a656ac84b4
--- /dev/null
+++ b/qadevOOo/runner/convwatch/OfficePrint.java
@@ -0,0 +1,1377 @@
+/*************************************************************************
+ *
+ * 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 convwatch;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.io.FileWriter;
+
+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 convwatch.FileHelper;
+// import convwatch.MSOfficePrint;
+// import convwatch.GraphicalTestArguments;
+// import convwatch.ConvWatchCancelException;
+
+// import helper.Parameter;
+
+/**
+ * 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 OfficePrint {
+
+
+// static long m_nStartTime;
+// // static Date m_aDateCache = null;
+//
+// /*
+// simple helper functions to start/stop a timer, to know how long a process need in milliseconds
+// */
+// public static void startTimer()
+// {
+// // if (m_aDateCache == null)
+// // {
+// // m_aDateCache = new Date();
+// // }
+// // m_nStartTime = m_aDateCache.getTime();
+// m_nStartTime = System.currentTimeMillis();
+// }
+// public static long stopTimer()
+// {
+// // if (m_aDateCache == null)
+// // {
+// // System.out.println("Forgotten to initialise start timer.");
+// // return 0;
+// // }
+// // long m_nStopTime = m_aDateCache.getTime();
+// if (m_nStartTime == 0)
+// {
+// System.out.println("Forgotten to initialise start timer.");
+// return 0;
+// }
+// long m_nStopTime = System.currentTimeMillis();
+// return m_nStopTime - m_nStartTime;
+// }
+
+
+ private static void showProperty(PropertyValue _aValue)
+ {
+ String sName = _aValue.Name;
+ String sValue;
+ try
+ {
+ sValue = AnyConverter.toString(_aValue.Value);
+ GlobalLogWriter.get().println("Property " + sName + ":=" + sValue);
+ }
+ catch (com.sun.star.lang.IllegalArgumentException e)
+ {
+ // GlobalLogWriter.get().println("showProperty: can't convert a object to string.");
+ GlobalLogWriter.get().println("Property " + sName + ":= a Object which can't convert by AnyConverter()");
+ }
+ }
+
+ /**
+ * shows the FilterName and MediaType from the given XComponent
+ */
+ static 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 "";
+ }
+
+ static void showDocumentType( XComponent _aDoc )
+ {
+ String sNameValue = getDocumentType(_aDoc);
+ GlobalLogWriter.get().println(" Property: '" + sNameValue);
+ }
+ /**
+ * load a OpenOffice.org document from a given URL (_sInputURL)
+ * the GraphicalTestArguments 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.
+ * @param _aGTA
+ * @param _sInputURL
+ * @return
+ */
+ public static XComponent loadFromURL(GraphicalTestArguments _aGTA,
+ String _sInputURL)
+ {
+ XComponent aDoc = null;
+ try
+ {
+ if (_aGTA.getMultiServiceFactory() == null)
+ {
+ GlobalLogWriter.get().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.get().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);
+ }
+
+ GlobalLogWriter.get().println(DateHelper.getDateTimeForHumanreadableLog() + " Load document");
+ // GlobalLogWriter.get().flush();
+
+ XComponentLoader aCompLoader = UnoRuntime.queryInterface( XComponentLoader.class, aDesktop);
+
+ // XComponent aDoc = null;
+
+ _aGTA.getPerformance().startTime(PerformanceContainer.Load);
+ aDoc = aCompLoader.loadComponentFromURL(_sInputURL, "_blank", 0, PropertyHelper.createPropertyValueArrayFormArrayList(aPropertyList) );
+ _aGTA.getPerformance().stopTime(PerformanceContainer.Load);
+ if (aDoc != null)
+ {
+ GlobalLogWriter.get().println(DateHelper.getDateTimeForHumanreadableLog() + " Load document done.");
+ showDocumentType(aDoc);
+ _aGTA.setDocumentType(getDocumentType(aDoc));
+ }
+ else
+ {
+ GlobalLogWriter.get().println(" Load document failed.");
+ if (_aGTA.getImportFilterName() != null && _aGTA.getImportFilterName().length() > 0)
+ {
+ GlobalLogWriter.get().println(" Please check FilterName := '" + _aGTA.getImportFilterName() + "'");
+ }
+ GlobalLogWriter.get().println("");
+ }
+ }
+ else
+ {
+ GlobalLogWriter.get().println("com.sun.star.frame.Desktop failed.");
+ }
+ }
+ catch ( com.sun.star.uno.Exception e )
+ {
+ // Some exception occures.FAILED
+ GlobalLogWriter.get().println("UNO Exception caught.");
+ GlobalLogWriter.get().println("Message: " + e.getMessage());
+ e.printStackTrace();
+ aDoc = null;
+ }
+ return aDoc;
+ }
+
+ static 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;
+
+ try
+ {
+ XStorable store =
+ UnoRuntime.queryInterface(
+ XStorable.class, _xComponent
+ );
+ store.storeToURL(_sDestinationName, PropertyHelper.createPropertyValueArrayFormArrayList(aPropertyList));
+ }
+ catch (com.sun.star.io.IOException e)
+ {
+ GlobalLogWriter.get().println("IO Exception caught.");
+ GlobalLogWriter.get().println("Message: " + e.getMessage());
+ bWorked = false;
+ }
+
+ return bWorked;
+ }
+
+ static 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 static boolean storeAsPDF(GraphicalTestArguments _aGTA,
+ String _sInputURL,
+ String _sOutputURL)
+ {
+ boolean bBack = false;
+ XComponent aDoc = loadFromURL(_aGTA, _sInputURL);
+
+ if (aDoc == null)
+ {
+ GlobalLogWriter.get().println("Can't load document.");
+ return bBack;
+ }
+ bBack = storeAsPDF(_aGTA, aDoc, _sOutputURL);
+ createInfoFile(_sOutputURL, _aGTA, "as pdf");
+
+ GlobalLogWriter.get().println("Close document.");
+ aDoc.dispose();
+ return bBack;
+ }
+
+ public static boolean storeAsPDF(GraphicalTestArguments _aGTA,
+ XComponent _aDoc,
+ String _sOutputURL)
+ {
+ // try {
+ boolean bBack = true;
+ _aGTA.getPerformance().startTime(PerformanceContainer.StoreAsPDF);
+ bBack = exportToPDF(_aDoc, _sOutputURL);
+ _aGTA.getPerformance().stopTime(PerformanceContainer.StoreAsPDF);
+
+ if (!bBack)
+ {
+ GlobalLogWriter.get().println("Can't store document as PDF.");
+ bBack = false;
+ }
+ 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.
+ *
+ * @param _aGTA
+ * @param _sInputURL
+ * @param _sOutputURL
+ * @param _sPrintFileURL
+ * @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 static boolean printToFileWithOOo(GraphicalTestArguments _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.get().println("Warning: Inputpath and Outputpath are equal. Document will not stored again.");
+ _aGTA.disallowStore();
+ }
+ bBack = impl_printToFileWithOOo(_aGTA, aDoc, _sOutputURL, _sPrintFileURL);
+
+ GlobalLogWriter.get().println("Close document.");
+ aDoc.dispose();
+ }
+ else
+ {
+ GlobalLogWriter.get().println("loadDocumentFromURL() failed with document: " + _sInputURL);
+ }
+ return bBack;
+ }
+
+ // -----------------------------------------------------------------------------
+ public static void createInfoFile(String _sFile, GraphicalTestArguments _aGTA)
+ {
+ createInfoFile(_sFile, _aGTA, "");
+ }
+
+ public static void createInfoFile(String _sFile, GraphicalTestArguments _aGTA, String _sSpecial)
+ {
+ String sFilename;
+ if (_sFile.startsWith("file://"))
+ {
+ sFilename = FileHelper.getSystemPathFromFileURL(_sFile);
+ GlobalLogWriter.get().println("CreateInfoFile: '" + sFilename + "'" );
+ }
+ else
+ {
+ sFilename = _sFile;
+ }
+ String sFileDir = FileHelper.getPath(sFilename);
+ String sBasename = FileHelper.getBasename(sFilename);
+ String sNameNoSuffix = FileHelper.getNameNoSuffix(sBasename);
+
+ String fs = System.getProperty("file.separator");
+ String ls = System.getProperty("line.separator");
+ String sInfoFilename = sFileDir + fs + sNameNoSuffix + ".info";
+ File aInfoFile = new File(sInfoFilename);
+
+ String sBuildID = "";
+
+ try
+ {
+ FileWriter out = new FileWriter(aInfoFile.toString());
+ out.write("# automatically created file by graphical compare" + ls);
+ if (_aGTA != null)
+ {
+ if (_sSpecial != null && _sSpecial.equals("msoffice"))
+ {
+ out.write("# buildid from wordloadfile" + ls);
+ sBuildID = _aGTA.getPerformance().getMSOfficeVersion();
+ out.write("buildid=" + sBuildID + ls);
+ }
+ else
+ {
+ out.write("# buildid is read out of the bootstrap file" + ls);
+ sBuildID = _aGTA.getBuildID();
+ out.write("buildid=" + sBuildID + ls);
+ }
+ // if (_sSpecial != null && _sSpecial.length() > 0)
+ // {
+ // out.write("special=" + _sSpecial + ls);
+ // }
+ out.write(ls);
+ out.write("# resolution given in DPI" + ls);
+ out.write("resolution=" + _aGTA.getResolutionInDPI() + ls);
+ }
+ else
+ {
+ out.write("buildid=" + _sSpecial + ls);
+ }
+ // long nTime = stopTimer();
+ // if (nTime != 0)
+ // {
+ // out.write("# time is given in milli seconds" + ls);
+ // out.write("time=" + nTime + ls);
+ // }
+
+ out.write(ls);
+ out.write("# Values out of System.getProperty(...)" + ls);
+ out.write("os.name=" + System.getProperty("os.name") + ls);
+ out.write("os.arch=" + System.getProperty("os.arch") + ls);
+ out.write("os.version=" + System.getProperty("os.version") + ls);
+
+ if (_aGTA != null)
+ {
+ out.write(ls);
+ out.write("# Performance output, values are given in milli sec." + ls);
+ _aGTA.getPerformance().print(out);
+ }
+
+ out.flush();
+ out.close();
+ }
+ catch (java.io.IOException e)
+ {
+ GlobalLogWriter.get().println("can't create Info file.");
+ e.printStackTrace();
+ }
+
+ String sExtension = FileHelper.getSuffix(_aGTA.getInputFile());
+ if (sExtension.startsWith("."))
+ {
+ sExtension = sExtension.substring(1);
+ }
+
+ DB.writeToDB(_aGTA.getInputFile(),
+ sNameNoSuffix,
+ sExtension,
+ sBuildID,
+ _aGTA.getReferenceType(),
+ _aGTA.getResolutionInDPI()
+ );
+ }
+
+
+
+ // -----------------------------------------------------------------------------
+ private static boolean impl_printToFileWithOOo(GraphicalTestArguments _aGTA,
+ XComponent _aDoc,
+ String _sOutputURL,
+ String _sPrintFileURL)
+ {
+ boolean bBack = false;
+ boolean bFailed = true; // always be a pessimist,
+ if (_aDoc == null)
+ {
+ GlobalLogWriter.get().println("No document is given.");
+ return bBack;
+ }
+
+ try
+ {
+ if (_sOutputURL != null)
+ {
+ if (_aGTA.isStoreAllowed())
+ {
+ // store the document in an other directory
+ XStorable aStorable = UnoRuntime.queryInterface( XStorable.class, _aDoc);
+ if (aStorable != null)
+ {
+ PropertyValue [] szEmptyArgs = new PropertyValue [0];
+
+ GlobalLogWriter.get().println(DateHelper.getDateTimeForHumanreadableLog() + " Store document.");
+ _aGTA.getPerformance().startTime(PerformanceContainer.Store);
+ aStorable.storeAsURL(_sOutputURL, szEmptyArgs);
+ _aGTA.getPerformance().stopTime(PerformanceContainer.Store);
+
+ GlobalLogWriter.get().println(DateHelper.getDateTimeForHumanreadableLog() + " Store document done.");
+ TimeHelper.waitInSeconds(2, "After store as URL to:" + _sOutputURL);
+ GlobalLogWriter.get().println("Reload stored file test.");
+ XComponent aDoc = loadFromURL(_aGTA, _sOutputURL);
+ if (aDoc == null)
+ {
+ GlobalLogWriter.get().println("Reload stored file test failed, can't reload file: " + _sOutputURL);
+ }
+ }
+ }
+ }
+ }
+ catch ( com.sun.star.uno.Exception e )
+ {
+ // Some exception occures.FAILED
+ GlobalLogWriter.get().println("UNO Exception caught.");
+ GlobalLogWriter.get().println("Message: " + e.getMessage());
+
+ e.printStackTrace();
+ bBack = false;
+ }
+
+ try
+ {
+
+ // System.out.println("Document loaded.");
+ // Change Pagesettings to DIN A4
+
+ GlobalLogWriter.get().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.get().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.get().println("PrintAllSheets := true");
+ }
+ }
+
+ ArrayList<PropertyValue> aPrintProps = new ArrayList<PropertyValue>();
+ // GlobalLogWriter.get().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);
+
+ 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.get().println("Start printing.");
+
+ _aGTA.getPerformance().startTime(PerformanceContainer.Print);
+ aPrintable.print(PropertyHelper.createPropertyValueArrayFormArrayList(aPrintProps));
+ TimeHelper.waitInSeconds(1, "Start waiting for print ready.");
+
+ GlobalLogWriter.get().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.get().println("ERROR: Cancel print due to too long wait.");
+ throw new com.sun.star.uno.Exception("Convwatch exception, wait too long for printing.");
+ }
+ }
+ _aGTA.getPerformance().stopTime(PerformanceContainer.Print);
+ GlobalLogWriter.get().println(DateHelper.getDateTimeForHumanreadableLog() + " Print document done.");
+
+ // Create a .info file near the printed '.ps' or '.prn' file.
+ createInfoFile(_sPrintFileURL, _aGTA);
+ }
+ else
+ {
+ GlobalLogWriter.get().println("Can't get XPrintable interface.");
+ }
+ bFailed = false;
+ bBack = true;
+ }
+ catch ( com.sun.star.uno.Exception e )
+ {
+ // Some exception occures.FAILED
+ GlobalLogWriter.get().println("UNO Exception caught.");
+ GlobalLogWriter.get().println("Message: " + e.getMessage());
+
+ e.printStackTrace();
+ bBack = false;
+ }
+
+ if (bFailed == true)
+ {
+ GlobalLogWriter.get().println("convwatch.OfficePrint: FAILED");
+ }
+ else
+ {
+ GlobalLogWriter.get().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 static boolean isReferenceExists(GraphicalTestArguments _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 = sOutputPath + fs + sPrintFilename + ".prn";
+ if (FileHelper.exists(sAbsolutePrintFilename) && _aGTA.getOverwrite() == false)
+ {
+ GlobalLogWriter.get().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
+ * @param _sAbsoluteOutputPath
+ * @param _sAbsoluteInputFile
+ * @return
+ * @throws ConvWatchCancelException
+ */
+ public static boolean buildReference(GraphicalTestArguments _aGTA,
+ String _sAbsoluteOutputPath,
+ String _sAbsoluteInputFile)
+ throws ConvWatchCancelException
+ {
+ if (! FileHelper.exists(_sAbsoluteInputFile))
+ {
+ throw new ConvWatchCancelException("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.get().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.get().println("OfficePrint.buildreference(): Unknown print type.");
+ return false;
+ }
+ return printToFile(_aGTA, sInputFileURL, sOutputFileURL, sPrintFileURL);
+ }
+
+ public static boolean printToFile(GraphicalTestArguments _aGTA,
+ String _sInputFileURL,
+ String _sOutputFileURL,
+ String _sPrintFileURL) throws ConvWatchCancelException
+ {
+ boolean bBack = false;
+ String sPrintFileURL = null;
+
+ // check if given file is a picture, then do nothing
+ String sDocumentSuffix = FileHelper.getSuffix(_sInputFileURL);
+ if (sDocumentSuffix.toLowerCase().endsWith(".png") ||
+ sDocumentSuffix.toLowerCase().endsWith(".gif") ||
+ sDocumentSuffix.toLowerCase().endsWith(".jpg") ||
+ sDocumentSuffix.toLowerCase().endsWith(".bmp"))
+ {
+ return false;
+ }
+
+
+ // 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.get().println("USE PDF AS EXPORT FORMAT.");
+ bBack = storeAsPDF(_aGTA, _sInputFileURL, _sPrintFileURL);
+ }
+ else if (_aGTA.getReferenceType().toLowerCase().equals("msoffice"))
+ {
+ if (MSOfficePrint.isMSOfficeDocumentFormat(_sInputFileURL))
+ {
+ GlobalLogWriter.get().println("USE MSOFFICE AS EXPORT FORMAT.");
+ MSOfficePrint a = new MSOfficePrint();
+ try
+ {
+ a.printToFileWithMSOffice(_aGTA, FileHelper.getSystemPathFromFileURL(_sInputFileURL),
+ FileHelper.getSystemPathFromFileURL(_sPrintFileURL));
+ }
+ catch(ConvWatchCancelException e)
+ {
+ e.printStackTrace();
+ GlobalLogWriter.get().println(e.getMessage());
+ throw new ConvWatchCancelException("Exception caught. Problem with MSOffice printer methods.");
+ }
+ catch(java.io.IOException e)
+ {
+ GlobalLogWriter.get().println(e.getMessage());
+ throw new ConvWatchCancelException("IOException caught. Problem with MSOffice printer methods.");
+ }
+ bBack = true;
+ }
+ else
+ {
+ GlobalLogWriter.get().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 ConvWatchCancelException("OfficePrint.printToFile(): Unknown print type.");
+ }
+ return bBack;
+ }
+
+ // -----------------------------------------------------------------------------
+ // TODO: move this away!
+ // -----------------------------------------------------------------------------
+ static void showType(String _sInputURL, XMultiServiceFactory _xMSF)
+ {
+ if (_sInputURL.length() == 0)
+ {
+ return;
+ }
+
+ if (_xMSF == null)
+ {
+ GlobalLogWriter.get().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.get().println("Can't get com.sun.star.document.TypeDetection.");
+ return;
+ }
+ if (aTypeDetection != null)
+ {
+ String sType = aTypeDetection.queryTypeByURL(_sInputURL);
+ GlobalLogWriter.get().println("Type is: " + sType);
+ }
+ }
+
+
+ // -----------------------------------------------------------------------------
+ public static String getInternalFilterName(String _sFilterName, XMultiServiceFactory _xMSF)
+ {
+ if (_sFilterName.length() == 0)
+ {
+ // System.out.println("No FilterName set.");
+ return null;
+ }
+
+ if (_xMSF == null)
+ {
+ GlobalLogWriter.get().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.get().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.get().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.get().println("There are no elements for FilterName '" + _sFilterName + "'");
+ return null;
+ }
+ }
+ catch (com.sun.star.container.NoSuchElementException e)
+ {
+ GlobalLogWriter.get().println("NoSuchElementException caught. " + e.getMessage());
+ }
+ catch (com.sun.star.lang.WrappedTargetException e)
+ {
+ GlobalLogWriter.get().println("WrappedTargetException caught. " + e.getMessage());
+ }
+ }
+ }
+ return null;
+ }
+
+ // -----------------------------------------------------------------------------
+
+ static String getServiceNameFromFilterName(String _sFilterName, XMultiServiceFactory _xMSF)
+ {
+ if (_sFilterName.length() == 0)
+ {
+ // System.out.println("No FilterName set.");
+ return null;
+ }
+
+ if (_xMSF == null)
+ {
+ GlobalLogWriter.get().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.get().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.get().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.get().println("There are no elements for FilterName '" + _sFilterName + "'");
+ return null;
+ }
+ }
+ catch (com.sun.star.container.NoSuchElementException e)
+ {
+ GlobalLogWriter.get().println("NoSuchElementException caught. " + e.getMessage());
+ }
+ catch (com.sun.star.lang.WrappedTargetException e)
+ {
+ GlobalLogWriter.get().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.get().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.get().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.get().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.get().println(" Possible extensions are: " + String.valueOf(aExtensions.length));
+ if (aExtensions.length > 0)
+ {
+ for (int j=0;j<aExtensions.length;j++)
+ {
+ GlobalLogWriter.get().println(" " + aExtensions[j]);
+ }
+ sExtension = aExtensions[0];
+ GlobalLogWriter.get().println("");
+ }
+ }
+ }
+ return sExtension;
+ }
+ else
+ {
+ GlobalLogWriter.get().println("There are no elements for FilterName '" + _sInternalFilterName + "'");
+ return null;
+ }
+ }
+ catch (com.sun.star.container.NoSuchElementException e)
+ {
+ GlobalLogWriter.get().println("NoSuchElementException caught. " + e.getMessage());
+ }
+ catch (com.sun.star.lang.WrappedTargetException e)
+ {
+ GlobalLogWriter.get().println("WrappedTargetException caught. " + e.getMessage());
+ }
+}
+ }
+ return null;
+ }
+
+ // -----------------------------------------------------------------------------
+ public static void convertDocument(String _sInputFile, String _sOutputPath, GraphicalTestArguments _aGTA) throws ConvWatchCancelException
+ {
+ XMultiServiceFactory xMSF = _aGTA.getMultiServiceFactory();
+ if (xMSF == null)
+ {
+ GlobalLogWriter.get().println("MultiServiceFactory in GraphicalTestArgument not set.");
+ return;
+ }
+
+ String sInputURL = URLHelper.getFileURLFromSystemPath(_sInputFile);
+ // showType(sInputURL, xMSF);
+ XComponent aDoc = loadFromURL( _aGTA, sInputURL);
+ if (aDoc == null)
+ {
+ GlobalLogWriter.get().println("Can't load document '"+ sInputURL + "'");
+ return;
+ }
+
+ if (_sOutputPath == null)
+ {
+ GlobalLogWriter.get().println("Outputpath not set.");
+ return;
+ }
+
+ if (! _aGTA.isStoreAllowed())
+ {
+ GlobalLogWriter.get().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.get().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.get().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.get().println("Given FilterName '" + sFilterName + "' seems to be unknown.");
+ bServiceFailed = true;
+ }
+ if (! xServiceInfo.supportsService(sServiceName))
+ {
+ GlobalLogWriter.get().println("Service from FilterName '" + sServiceName + "' is not supported by loaded document.");
+ bServiceFailed = true;
+ }
+ if (bServiceFailed == true)
+ {
+ GlobalLogWriter.get().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.get().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.get().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.get().println("File already exist, don't overwrite. Set " + PropertyName.DOC_COMPARATOR_OVERWRITE_REFERENCE + "=true to force overwrite.");
+ return;
+ }
+
+ sOutputURL = URLHelper.getFileURLFromSystemPath(sOutputFile);
+
+ GlobalLogWriter.get().println("Store document as '" + sOutputURL + "'");
+ xStorable.storeAsURL(sOutputURL, PropertyHelper.createPropertyValueArrayFormArrayList(aPropertyList));
+ GlobalLogWriter.get().println("Document stored.");
+ }
+ catch (com.sun.star.io.IOException e)
+ {
+ GlobalLogWriter.get().println("Can't store document '" + sOutputURL + "'. Message is :'" + e.getMessage() + "'");
+ }
+// TODO: Do we need to wait?
+ TimeHelper.waitInSeconds(1, "unknown in OfficePrint.convertDocument()");
+
+ }
+
+}
+
diff --git a/qadevOOo/runner/convwatch/PRNCompare.java b/qadevOOo/runner/convwatch/PRNCompare.java
new file mode 100644
index 000000000000..1d0503299d67
--- /dev/null
+++ b/qadevOOo/runner/convwatch/PRNCompare.java
@@ -0,0 +1,805 @@
+/*************************************************************************
+ *
+ * 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 convwatch;
+
+
+import helper.ProcessHandler;
+import java.io.File;
+import convwatch.PixelCounter;
+import convwatch.StatusHelper;
+import helper.OSHelper;
+import helper.StringHelper;
+import java.util.ArrayList;
+import util.utils;
+
+// -----------------------------------------------------------------------------
+// --------------------------------- PRNCompare ---------------------------------
+
+// class DifferenceType
+// {
+// final static int NO_DIFFERENCE = 1;
+// final static int DIFFERENCE = 2;
+//
+// public int nValue = NO_DIFFERENCE;
+// public boolean equals(int _n)
+// {
+// if ( _n == nValue ) return true;
+// return false;
+// }
+// }
+
+// -----------------------------------------------------------------------------
+public class PRNCompare
+{
+ // OSHelper m_aHelper;
+ String fs;
+
+ public PRNCompare()
+ {
+ // m_aHelper = new OSHelper();
+ fs = System.getProperty("file.separator");
+ }
+
+ String executeSynchronously(String _sCommand)
+ {
+ // System.out.println(_sCommand);
+
+ ProcessHandler aHandler = new ProcessHandler(_sCommand);
+ boolean bBackValue = aHandler.executeSynchronously();
+
+ String sText = aHandler.getOutputText();
+
+ GlobalLogWriter.get().println("Exitcode: " + String.valueOf(aHandler.getExitCode()));
+ return sText;
+ }
+
+
+ int getMaxNumOfFileEntry(String _sDirectory, String _sBasename)
+ {
+// TODO: check if directory exist should be done earlier
+ File aDirectory = new File(_sDirectory);
+ File[] aDirList = aDirectory.listFiles(
+ /*
+ new FileFilter() {
+ boolean accept(File filename)
+ {
+ if (filename.getName().endsWith("jpg"))
+ return true;
+ return false;
+ }
+ } */
+ );
+
+ int nMaxNumber = 0;
+ for(int n = 0; n<aDirList.length ; n++)
+ {
+ String sDirEntry = aDirList[n].getName();
+ if (sDirEntry.endsWith(".jpg"))
+ {
+ int nNum = nMaxNumber;
+
+ if (sDirEntry.startsWith(_sBasename))
+ {
+ // System.out.println(sDirEntry);
+ int nJpgIdx = sDirEntry.lastIndexOf(".jpg");
+ String sValue = sDirEntry.substring(_sBasename.length(), nJpgIdx);
+ int nValue = 0;
+ try
+ {
+ nValue = Integer.valueOf(sValue).intValue();
+ }
+ catch(java.lang.NumberFormatException e)
+ {
+ }
+
+ // System.out.println(nValue);
+ nNum = nValue;
+ }
+
+ if (nNum > nMaxNumber)
+ {
+ nMaxNumber = nNum;
+ }
+ }
+ }
+ return nMaxNumber;
+ }
+
+ String m_sInputPath;
+ String m_sReferencePath;
+ String m_sOutputPath;
+ String m_sDocFile;
+ String m_sReferenceFile;
+ String m_sPostScriptFile;
+ // String m_sOldDiff;
+ int m_nMaxPages = 0;
+ int m_nResolutionInDPI = 0;
+ TriState m_tUseBorderMove;
+ String m_sDocumentType;
+
+ public void setInputPath(String _sInputPath) { m_sInputPath = _sInputPath; }
+
+ public void setReferencePath(String _sReferencePath) { m_sReferencePath = _sReferencePath; }
+
+ public void setOutputPath(String _sOutPath) { m_sOutputPath = _sOutPath; }
+
+ public void setDocFile(String _sDocFile) { m_sDocFile = _sDocFile;}
+
+ public void setReferenceFile(String _sPRNFile){ m_sReferenceFile = _sPRNFile;}
+
+ public void setPostScriptFile(String _sPSFile){ m_sPostScriptFile = _sPSFile;}
+
+ public void setBorderMove(TriState _b) {m_tUseBorderMove = _b;}
+ public TriState getBorderMove() {return m_tUseBorderMove;}
+ // public void setOldDiffPath(String _sOldDiff)
+ // {
+ // m_sOldDiff = _sOldDiff;
+ // }
+ public void setMaxPages(int _n) {m_nMaxPages = _n;}
+ int getMaxPages() {return m_nMaxPages;}
+
+ public void setResolutionInDPI(int _n) {m_nResolutionInDPI = _n;}
+ int getResolutionInDPI() {return m_nResolutionInDPI;}
+
+ public void setDocumentType(String _sTypeName)
+ {
+ m_sDocumentType = _sTypeName;
+ }
+
+ // -----------------------------------------------------------------------------
+
+ public StatusHelper[] compare()
+ {
+ createJPEGFromPostscript(m_sOutputPath, m_sReferencePath, m_sReferenceFile, getResolutionInDPI());
+// TODO: Assume, that Postscript is already in the OutputPath, this may change.
+ createJPEGFromPostscript(m_sOutputPath, m_sOutputPath, m_sPostScriptFile, getResolutionInDPI());
+ StatusHelper[] aList = createDiffs(m_sOutputPath,
+ m_sOutputPath, m_sReferenceFile,
+ m_sOutputPath, m_sPostScriptFile,
+ getMaxPages(), m_tUseBorderMove);
+
+// TODO: Rename?
+
+ return aList;
+ }
+
+ public StatusHelper[] compare_new()
+ {
+ String[] aRefList = createJPEGFromPostscript(m_sOutputPath, m_sReferencePath, m_sReferenceFile, getResolutionInDPI());
+// TODO: Assume, that Postscript is already in the OutputPath, this may change.
+ String[] aPSList = createJPEGFromPostscript(m_sOutputPath, m_sOutputPath, m_sPostScriptFile, getResolutionInDPI());
+ StatusHelper[] aList = createDiffs(m_sOutputPath,
+ aRefList,
+ aPSList,
+ getMaxPages(), m_tUseBorderMove);
+
+ return aList;
+ }
+
+ static String getJPEGName(String _sOutputPath, String _sBasename, String _sGS_PageOutput)
+ {
+ String fs = System.getProperty("file.separator");
+
+ String sJPEGName = _sOutputPath + fs + _sBasename + _sGS_PageOutput + ".jpg";
+ 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
+ */
+ public static String[] createJPEGFromPostscript(String _sOutputPath, String _sSourcePath, String _sSourceFile, int _nResolutionInDPI)
+ {
+ String sGS_PageOutput = "%04d";
+ // if ( OSHelper.isWindows() )
+ // {
+ // sGS_PageOutput = "%%d";
+ // }
+
+ FileHelper.makeDirectories("", _sOutputPath);
+
+ // create a jpeg from original prn
+ String fs = System.getProperty("file.separator");
+
+ String sJPGFilename = getJPEGName(_sOutputPath, _sSourceFile, sGS_PageOutput);
+ String sOriginalFile = _sSourcePath + fs + _sSourceFile;
+ String sCommand;
+ String sGS = "gs";
+ if (OSHelper.isWindows())
+ {
+ sGS = "gswin32c.exe";
+ }
+
+ sCommand = sGS + " -dNOPROMPT -dBATCH -sDEVICE=jpeg -r" + String.valueOf(_nResolutionInDPI) + " -dNOPAUSE -sOutputFile=" + StringHelper.doubleQuoteIfNeed(sJPGFilename) + " " + StringHelper.doubleQuoteIfNeed(sOriginalFile);
+ String[] sCommandArray =
+ {
+ sGS,
+ "-dNOPROMPT",
+ "-dBATCH",
+ "-sDEVICE=jpeg",
+ "-r" + String.valueOf(_nResolutionInDPI),
+ "-dNOPAUSE",
+ "-sOutputFile=" + sJPGFilename,
+ sOriginalFile
+ };
+ // System.out.println("Start Command array");
+ // try
+ // {
+ // Runtime.getRuntime().exec(sCommandArray);
+ // } catch (Exception e) {
+ // System.out.println("FAILED");
+ // }
+ // System.out.println("done");
+
+ ProcessHandler aHandler = new ProcessHandler(sCommandArray);
+ boolean bBackValue = aHandler.executeSynchronously();
+
+ // TODO: return a real filename, due to the fact we don't know how much files are created, maybe better to return a list
+
+ ArrayList m_aFileList = new ArrayList();
+ for (int i=1;i<9999;i++)
+ {
+ String sNewJPEGFilename = utils.replaceAll13(sJPGFilename, sGS_PageOutput, StringHelper.createValueString(i, 4));
+ if (FileHelper.exists(sNewJPEGFilename))
+ {
+ m_aFileList.add(sNewJPEGFilename); // as long as the files exist, fill the array
+ }
+ else
+ {
+ break; // stop file check
+ }
+ }
+ String[] aList = new String[m_aFileList.size()];
+ aList = (String[])m_aFileList.toArray(aList);
+ return aList; // sNewJPEGFilename;
+ }
+
+ /**
+ * Create Difference Files from the JPEGs
+ * parameter, how much difference files should create
+ *
+ * m_sPostScriptFile
+ * m_sReferenceFile
+ * m_sOutputPath
+ */
+ public StatusHelper[] createDiffs(String _sOutputPath, String _sSourcePath1, String _sSourceFile1, String _sSourcePath2, String _sSourceFile2, int _nMaxDiffs, TriState _tUseBorderMove)
+ {
+ if (_nMaxDiffs < 1)
+ {
+ _nMaxDiffs = 1;
+ }
+
+ String sS1Basename = FileHelper.getBasename(_sSourceFile1);
+ String sS2Basename = FileHelper.getBasename(_sSourceFile2);
+
+ // count, from which file (jpegs) exist more, take the less one
+ // more are not compareable
+ int nS1_Files = getMaxNumOfFileEntry(_sSourcePath1, sS1Basename);
+ int nS2_Files = getMaxNumOfFileEntry(_sSourcePath2, sS2Basename);
+
+ // System.out.println("count of s1 files " + String.valueOf(nS1_Files));
+ // System.out.println("count of s2 files " + String.valueOf(nS2_Files));
+
+ // take the min of both
+ int nMin = Math.min(nS1_Files, nS2_Files);
+ nMin = Math.min(nMin, _nMaxDiffs);
+
+ StatusHelper[] aList = new StatusHelper[nMin];
+
+// TODO: if both document do not have same page count, produce an error
+ // System.out.println("min of both: " + String.valueOf(nMin));
+
+ int nStatusIndex = 0;
+ for (int i=1;i<=nMin;i++)
+ {
+ String sOldGfx = getJPEGName(_sSourcePath1, sS1Basename, StringHelper.createValueString(i, 4));
+ String sNewGfx = getJPEGName(_sSourcePath2, sS2Basename, StringHelper.createValueString(i, 4));
+ String sDiffGfx_ = getJPEGName(_sOutputPath, sS1Basename + ".diff", StringHelper.createValueString(i, 4));
+
+
+ String sDiffGfx = compareJPEGs(sOldGfx, sNewGfx, sDiffGfx_);
+ StatusHelper aStatus = new StatusHelper(sOldGfx, sNewGfx, sDiffGfx);
+
+ // if (FileHelper.exists(sDiffGfx))
+ if (sDiffGfx.length() > 0)
+ {
+ int nResult = identify(sDiffGfx);
+ if (nResult == 1)
+ {
+ aStatus.nDiffStatus = StatusHelper.DIFF_NO_DIFFERENCES;
+ }
+ else
+ {
+ try
+ {
+ int nPercent = estimateGfx(sOldGfx, sNewGfx, sDiffGfx);
+ aStatus.nDiffStatus = StatusHelper.DIFF_DIFFERENCES_FOUND;
+ aStatus.nPercent = nPercent;
+
+ // GlobalLogWriter.get().println("Hello World: Percent:= " + nPercent);
+ // GlobalLogWriter.get().println("Hello World: TriState:= " + _tUseBorderMove.intValue());
+ // GlobalLogWriter.get().println("Hello World: DocType:= " + m_sDocumentType);
+
+// TODO: insert here the new BorderRemover if the percentage value is creater than 75%
+ if (nPercent > 75 &&
+ ((_tUseBorderMove == TriState.TRUE ) ||
+ ((_tUseBorderMove == TriState.UNSET) &&
+ m_sDocumentType.indexOf("MS PowerPoint") > 0)))
+ {
+ setBorderMove(TriState.TRUE);
+
+ String sOld_BM_Gfx = getJPEGName(_sSourcePath1, sS1Basename + ".BM", StringHelper.createValueString(i, 4));
+ String sNew_BM_Gfx = getJPEGName(_sSourcePath2, sS2Basename + ".BM", StringHelper.createValueString(i, 4));
+ String sDiff_BM_Gfx_ = getJPEGName(_sOutputPath, sS1Basename + ".diff.BM", StringHelper.createValueString(i, 4));
+ aStatus.setFilesForBorderMove(sOld_BM_Gfx, sNew_BM_Gfx, sDiff_BM_Gfx_);
+ try
+ {
+ BorderRemover a = new BorderRemover();
+ a.createNewImageWithoutBorder(sOldGfx, sOld_BM_Gfx);
+ a.createNewImageWithoutBorder(sNewGfx, sNew_BM_Gfx);
+
+ String sDiff_BM_Gfx = compareJPEGs( sOld_BM_Gfx, sNew_BM_Gfx, sDiff_BM_Gfx_);
+
+ // if (FileHelper.exists(sDiff_BM_Gfx))
+ if (sDiff_BM_Gfx.length() > 0)
+ {
+ nResult = identify(sDiff_BM_Gfx);
+ if (nResult == 1)
+ {
+ aStatus.nDiffStatus = StatusHelper.DIFF_AFTER_MOVE_DONE_NO_PROBLEMS;
+ aStatus.nPercent2 = 0;
+ }
+ else
+ {
+ nPercent = estimateGfx(sOld_BM_Gfx, sNew_BM_Gfx, sDiff_BM_Gfx);
+ aStatus.nDiffStatus = StatusHelper.DIFF_AFTER_MOVE_DONE_DIFFERENCES_FOUND;
+ aStatus.nPercent2 = nPercent;
+ }
+ }
+ else
+ {
+ }
+ }
+ catch(java.io.IOException e)
+ {
+ GlobalLogWriter.get().println("Exception caught. At border remove: " + e.getMessage());
+ }
+ }
+
+
+ }
+ catch (java.io.IOException e)
+ {
+ GlobalLogWriter.get().println(e.getMessage());
+ }
+ }
+
+ // checkDiff(sOldGfx, sNewGfx, sDiffGfx);
+ // if (i >= _nMaxDiffs)
+ // {
+ // break;
+ // }
+ }
+ aList[nStatusIndex ++] = aStatus;
+ }
+ return aList;
+ }
+
+
+ public StatusHelper[] createDiffs(String _sOutputPath, String[] _aRefList, String[] _aPSList, int _nMaxDiffs, TriState _tUseBorderMove)
+ {
+ if (_nMaxDiffs < 1)
+ {
+ _nMaxDiffs = 1;
+ }
+
+ // count, from which file (jpegs) exist more, take the less one
+ // more are not compareable
+
+ // take the min of both
+ int nMin = Math.min(_aRefList.length, _aPSList.length);
+ nMin = Math.min(nMin, _nMaxDiffs);
+
+ StatusHelper[] aList = new StatusHelper[nMin];
+
+// TODO: if both document do not have same page count, produce an error
+ // System.out.println("min of both: " + String.valueOf(nMin));
+
+ int nStatusIndex = 0;
+ for (int i=1;i<=nMin;i++)
+ {
+ String sOldGfx = _aRefList[i];
+ String sNewGfx = _aPSList[i];
+ // String sDiffGfx_ = getJPEGName(_sOutputPath, sS1Basename + ".diff", StringHelper.createValueString(i, 4));
+
+
+ String sDiffGfx = compareJPEGs(sOldGfx, sNewGfx );
+ StatusHelper aStatus = new StatusHelper(sOldGfx, sNewGfx, sDiffGfx);
+
+ // if (FileHelper.exists(sDiffGfx))
+ if (sDiffGfx.length() > 0)
+ {
+ int nResult = identify(sDiffGfx);
+ if (nResult == 1)
+ {
+ aStatus.nDiffStatus = StatusHelper.DIFF_NO_DIFFERENCES;
+ }
+ else
+ {
+ try
+ {
+ int nPercent = estimateGfx(sOldGfx, sNewGfx, sDiffGfx);
+ // GlobalLogWriter.get().println("Hello World: Percent:= " + nPercent);
+ // GlobalLogWriter.get().println("Hello World: TriState:= " + _tUseBorderMove.intValue());
+ // GlobalLogWriter.get().println("Hello World: DocType:= " + m_sDocumentType);
+
+ aStatus.nDiffStatus = StatusHelper.DIFF_DIFFERENCES_FOUND;
+ aStatus.nPercent = nPercent;
+
+ if (nPercent > 75 &&
+ ((_tUseBorderMove == TriState.TRUE ) ||
+ ((_tUseBorderMove == TriState.UNSET) &&
+ m_sDocumentType.indexOf("MS PowerPoint") > 0)))
+ {
+ _tUseBorderMove = TriState.TRUE;
+// TODO: problem is here, that we have to create some new names.
+
+ String sBasename1 = FileHelper.getBasename(sOldGfx);
+ String sNameNoSuffix1 = FileHelper.getNameNoSuffix(sBasename1);
+ String sBasename2 = FileHelper.getBasename(sNewGfx);
+ String sNameNoSuffix2 = FileHelper.getNameNoSuffix(sBasename2);
+
+ String sTmpDir = util.utils.getUsersTempDir();
+ String fs = System.getProperty("file.separator");
+
+ String sOld_BM_Gfx = sTmpDir + fs + sNameNoSuffix1 + "-BM-" + StringHelper.createValueString(i, 4) + ".jpg";
+ String sNew_BM_Gfx = sTmpDir + fs + sNameNoSuffix2 + "-BM-" + StringHelper.createValueString(i, 4) + ".jpg";
+ try
+ {
+ BorderRemover a = new BorderRemover();
+ a.createNewImageWithoutBorder(sOldGfx, sOld_BM_Gfx);
+ a.createNewImageWithoutBorder(sNewGfx, sNew_BM_Gfx);
+
+ String sDiff_BM_Gfx = compareJPEGs( sOld_BM_Gfx, sNew_BM_Gfx );
+
+ aStatus.setFilesForBorderMove(sOld_BM_Gfx, sNew_BM_Gfx, sDiff_BM_Gfx);
+
+ // if (FileHelper.exists(sDiff_BM_Gfx))
+ if (sDiff_BM_Gfx.length() > 0)
+ {
+ nResult = identify(sDiff_BM_Gfx);
+ if (nResult == 1)
+ {
+ aStatus.nDiffStatus = StatusHelper.DIFF_AFTER_MOVE_DONE_NO_PROBLEMS;
+ aStatus.nPercent2 = 0;
+ }
+ else
+ {
+ nPercent = estimateGfx(sOld_BM_Gfx, sNew_BM_Gfx, sDiff_BM_Gfx);
+ aStatus.nDiffStatus = StatusHelper.DIFF_AFTER_MOVE_DONE_DIFFERENCES_FOUND;
+ aStatus.nPercent2 = nPercent;
+ }
+ }
+ else
+ {
+ }
+ }
+ catch(java.io.IOException e)
+ {
+ GlobalLogWriter.get().println("Exception caught. At border remove: " + e.getMessage());
+ }
+ }
+ }
+ catch (java.io.IOException e)
+ {
+ GlobalLogWriter.get().println(e.getMessage());
+ }
+ }
+
+ // checkDiff(sOldGfx, sNewGfx, sDiffGfx);
+ // if (i >= _nMaxDiffs)
+ // {
+ // break;
+ // }
+ }
+ aList[nStatusIndex ++] = aStatus;
+ }
+ return aList;
+ }
+
+ public static String compareJPEGs(String _sOldGfx, String _sNewGfx)
+ {
+ String sBasename1 = FileHelper.getBasename(_sOldGfx);
+ String sNameNoSuffix1 = FileHelper.getNameNoSuffix(sBasename1);
+ String sBasename2 = FileHelper.getBasename(_sNewGfx);
+ String sNameNoSuffix2 = FileHelper.getNameNoSuffix(sBasename2);
+
+ String sTmpDir = util.utils.getUsersTempDir();
+ String fs = System.getProperty("file.separator");
+
+ String sDiffName = sTmpDir + fs + sNameNoSuffix1 + "-" + sNameNoSuffix2 + "-diff.jpg";
+
+ return compareJPEGs(_sOldGfx, _sNewGfx, sDiffName);
+ }
+
+ public static String compareJPEGs(String _sOldGfx, String _sNewGfx, String _sDiffGfx)
+ {
+ String sComposite = "composite";
+ if (OSHelper.isWindows())
+ {
+ sComposite = "composite.exe";
+ }
+
+ // 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();
+
+ String sBack = aHandler.getOutputText();
+ GlobalLogWriter.get().println("'" + sBack + "'");
+
+ // return aHandler.getExitCode();
+ if (FileHelper.exists(_sDiffGfx))
+ {
+ return _sDiffGfx;
+ }
+ return "";
+ }
+
+ /**
+ * 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 sCommand = sIdentify + " " + sIM_Format + " " + StringHelper.doubleQuoteIfNeed(_sDiffGfx);
+
+ String[] sCommandArray =
+ {
+ sIdentify,
+ "-format",
+ sIM_Format,
+ _sDiffGfx
+ };
+ ProcessHandler aHandler = new ProcessHandler(sCommandArray);
+ boolean bBackValue = aHandler.executeSynchronously();
+ String sBack = aHandler.getOutputText();
+ GlobalLogWriter.get().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;
+ }
+
+ /*
+ * Check 2 different differ files
+ * return 1 if there is no difference between both diff files.
+ */
+
+// TODO: Maybe a StatusHelper is a better return value
+ public StatusHelper checkDiffDiff(String _sOutputPath, String _sSourcePath1, String _sSourceFile1, String _sSourcePath2, String _sSourceFile2)
+ {
+ String sNewGfx = _sSourcePath1 + fs + _sSourceFile1;
+ String sOldGfx = _sSourcePath2 + fs + _sSourceFile2;
+
+ int nNumber = 1;
+ String sDiffGfx;
+ sDiffGfx = getJPEGName(_sOutputPath, _sSourceFile1 + ".diff", StringHelper.createValueString(nNumber, 4));
+
+ StatusHelper aCurrentStatus = new StatusHelper(sOldGfx, sNewGfx, sDiffGfx);
+
+ // String sComposite = "composite";
+ // if (OSHelper.isWindows())
+ // {
+ // sComposite = "composite.exe";
+ // }
+ //
+ // String sCommand = sComposite +" -compose difference " +
+ // StringHelper.doubleQuoteIfNeed(sOldGfx) + " " +
+ // StringHelper.doubleQuoteIfNeed(sNewGfx) + " " +
+ // StringHelper.doubleQuoteIfNeed(sDiffGfx);
+ //
+ //
+ // // System.out.println(sCommand);
+ // // executeSynchronously(sCommand);
+ // ProcessHandler aHandler = new ProcessHandler(sCommand);
+ // boolean bBackValue = aHandler.executeSynchronously();
+
+ compareJPEGs(sOldGfx, sNewGfx, sDiffGfx);
+
+ if (FileHelper.exists(sDiffGfx))
+ {
+ int nResult = identify(sDiffGfx);
+ if (nResult == 1)
+ {
+ aCurrentStatus.nDiffStatus = StatusHelper.DIFF_NO_DIFFERENCES;
+ }
+ else
+ {
+ aCurrentStatus.nDiffStatus = StatusHelper.DIFF_DIFFERENCES_FOUND;
+ try
+ {
+ aCurrentStatus.nPercent = estimateGfx(sOldGfx, sNewGfx, sDiffGfx);
+ }
+ catch (java.io.IOException e)
+ {
+ GlobalLogWriter.get().println(e.getMessage());
+ aCurrentStatus.nPercent = -1;
+ }
+ }
+ // LLA: should diffdiff file delete?
+ // File aFile = new File(sDiffGfx);
+ // aFile.delete();
+ }
+ else
+ {
+ GlobalLogWriter.get().println("composite can't create the diffdiff file.");
+ }
+
+ return aCurrentStatus;
+ }
+
+ // -----------------------------------------------------------------------------
+ /**
+ * 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
+ *
+ * <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.
+ *
+ * >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.
+ *
+ */
+ public int estimateGfx(String _sOldGfx, String _sNewGfx, String _sDiffGfx)
+ throws java.io.IOException
+ {
+ // new count pixels
+ int nNotWhiteCount_OldGraphic = PixelCounter.countNotWhitePixelsFromImage(_sOldGfx);
+ int nNotWhiteCount_NewGraphic = PixelCounter.countNotWhitePixelsFromImage(_sNewGfx);
+ int nNotBlackCount_DiffGraphic = PixelCounter.countNotBlackPixelsFromImage(_sDiffGfx);
+
+ 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.get().println( "Graphics check, pixel based:" + String.valueOf(nPercent) + "% pixel differ ");
+ return nPercent;
+ }
+
+
+
+/*
+ * Some selftest functionallity
+ */
+// public static void main(String[] args)
+// {
+ // System.out.println(FileHelper.getNameNoSuffix("doc.sxw"));
+ // System.out.println(FileHelper.getSuffix("doc.sxw"));
+ // System.out.println(FileHelper.getBasename("doc.sxw"));
+ // System.out.println(FileHelper.getBasename("/tmp/doc.sxw"));
+
+// PRNCompare a = new PRNCompare();
+// a.setInputPath( "/cws/so-cwsserv06/qadev18/SRC680/src.m47/convwatch.keep/input/msoffice/xp/PowerPoint");
+// a.setReferencePath( "/cws/so-cwsserv06/qadev18/SRC680/src.m47/convwatch.keep/input/msoffice/xp/PowerPoint");
+// a.setOutputPath( "/tmp/convwatch_java");
+// a.setDocFile( "1_Gov.ppt");
+// a.setReferenceFile( "1_Gov.prn" );
+// a.setPostScriptFile("1_Gov.ps" );
+ // a.compare();
+
+
+// LLA: 20040804 sample how to build jpegs from reference files
+// a.createJPEGFromPostscript("/tmp/convwatch_java",
+// "/home/apitest/WorkFromHome/20040804/reference", "worddoc.prn" );
+//
+// a.createJPEGFromPostscript("/tmp/convwatch_java",
+// "/home/apitest/WorkFromHome/20040804/reference", "worddoc.ps" );
+
+// Status[] aList = a.createDiffs("/tmp/convwatch_java",
+// "/tmp/convwatch_java", "worddoc.prn",
+// "/tmp/convwatch_java", "worddoc.ps",
+// 2);
+
+// LLA: 20040805 sample how to check 2 gfx files
+// this function return DifferenceType.NO_DIFFERENCE if the pictures contain no graphically difference
+// DifferenceType aReturnValue = a.checkDiffDiff("/tmp/convwatch_java",
+// "/tmp/convwatch_java", "worddoc.prn.diff1.jpg",
+// "/tmp/convwatch_java/old", "worddoc.prn.diff1.jpg");
+// if (aReturnValue.equals( DifferenceType.NO_DIFFERENCE ))
+// {
+// System.out.println("There is no difference between both diff files.");
+// }
+
+ // a.setOldDiff( "/olddiffs");
+// }
+}
diff --git a/qadevOOo/runner/convwatch/PerformanceContainer.java b/qadevOOo/runner/convwatch/PerformanceContainer.java
new file mode 100644
index 000000000000..d0c1e0fb5ed1
--- /dev/null
+++ b/qadevOOo/runner/convwatch/PerformanceContainer.java
@@ -0,0 +1,250 @@
+/*************************************************************************
+ *
+ * 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 convwatch;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.RandomAccessFile;
+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.get().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;
+
+ private long m_nTime[];
+ private String m_sMSOfficeVersion;
+
+ public PerformanceContainer()
+ {
+ m_nTime = new long[5];
+ // @todo: is this need?
+ for (int i=0;i<5;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(FileWriter out) throws java.io.IOException
+ {
+ String ls = System.getProperty("line.separator");
+
+ out.write("loadtime=" + String.valueOf(m_nTime[ Load ]) + ls);
+ out.write("storetime=" + String.valueOf(m_nTime[ Store ]) + ls);
+ out.write("printtime=" + String.valueOf(m_nTime[ Print ]) + ls);
+ out.write("officestarttime=" + String.valueOf(m_nTime[ OfficeStart ]) + ls);
+ out.write("storeaspdftime=" + String.valueOf(m_nTime[ StoreAsPDF ]) + ls);
+ }
+
+ public static double stringToDouble(String _sStr)
+ {
+ double nValue = 0;
+ try
+ {
+ nValue = Double.parseDouble( _sStr );
+ }
+ catch (NumberFormatException e)
+ {
+ GlobalLogWriter.get().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.get().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.get().println("couldn't open file " + sFilename);
+ GlobalLogWriter.get().println("Message: " + fne.getMessage());
+ }
+ catch (java.io.IOException ie)
+ {
+ GlobalLogWriter.get().println("Exception while reading file " + sFilename);
+ GlobalLogWriter.get().println("Message: " + ie.getMessage());
+ }
+ try
+ {
+ aRandomAccessFile.close();
+ }
+ catch (java.io.IOException ie)
+ {
+ GlobalLogWriter.get().println("Couldn't close file " + sFilename);
+ GlobalLogWriter.get().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/convwatch/PixelCounter.java b/qadevOOo/runner/convwatch/PixelCounter.java
new file mode 100644
index 000000000000..116b07e48d8e
--- /dev/null
+++ b/qadevOOo/runner/convwatch/PixelCounter.java
@@ -0,0 +1,206 @@
+/*************************************************************************
+ *
+ * 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 convwatch;
+
+// import java.awt.Image;
+import convwatch.ImageHelper;
+
+// -----------------------------------------------------------------------------
+abstract class CountPixel
+{
+ 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 count(int pixel)
+ {
+ int alpha = (pixel >> 24) & 0xff;
+ int red = (pixel >> 16) & 0xff;
+ int green = (pixel >> 8) & 0xff;
+ 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++;
+ }
+}
+
+// -----------------------------------------------------------------------------
+class CountNotBlack extends CountPixel
+{
+ public CountNotBlack()
+ {
+ // System.out.println("CountBlack()");
+ }
+
+ public void count(int pixel)
+ {
+ int alpha = (pixel >> 24) & 0xff;
+ int red = (pixel >> 16) & 0xff;
+ int green = (pixel >> 8) & 0xff;
+ int blue = (pixel ) & 0xff;
+
+ if (red == 0x00 && green == 0x00 && blue == 0x00)
+ {
+ return;
+ }
+ m_nCount++;
+ }
+}
+
+// -----------------------------------------------------------------------------
+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)
+ {
+ int w = _aImage.getWidth();
+ int h = _aImage.getHeight();
+
+ CountPixel aCountNotWhite = new CountNotWhite();
+ countPixel(_aImage, 0, 0, w, h, aCountNotWhite);
+ return aCountNotWhite.getCount();
+ }
+
+ public static int countNotBlackPixel(ImageHelper _aImage)
+ {
+ int w = _aImage.getWidth();
+ 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
+ {
+ m_aImage = ImageHelper.createImageHelper(_sFile);
+ int nw = graphics_stuff.countNotWhitePixel(m_aImage);
+ return nw;
+ }
+
+ public int countNotBlackPixel(String _sFile)
+ throws java.io.IOException
+ {
+ m_aImage = ImageHelper.createImageHelper(_sFile);
+ int nw = graphics_stuff.countNotBlackPixel(m_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/convwatch/PropertyName.java b/qadevOOo/runner/convwatch/PropertyName.java
new file mode 100644
index 000000000000..00130faf50e3
--- /dev/null
+++ b/qadevOOo/runner/convwatch/PropertyName.java
@@ -0,0 +1,67 @@
+/*************************************************************************
+ *
+ * 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 convwatch;
+
+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";
+
+}
diff --git a/qadevOOo/runner/convwatch/ReferenceBuilder.java b/qadevOOo/runner/convwatch/ReferenceBuilder.java
new file mode 100644
index 000000000000..076d5f5804f4
--- /dev/null
+++ b/qadevOOo/runner/convwatch/ReferenceBuilder.java
@@ -0,0 +1,304 @@
+/*************************************************************************
+ *
+ * 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 convwatch;
+
+// imports
+import java.io.File;
+import java.io.FileFilter;
+import java.util.ArrayList;
+
+import com.sun.star.lang.XMultiServiceFactory;
+
+import convwatch.DirectoryHelper;
+import convwatch.ConvWatchException;
+import convwatch.EnhancedComplexTestCase;
+import convwatch.PropertyName;
+import helper.OfficeProvider;
+import convwatch.PerformanceContainer;
+
+/**
+ * The following Complex Test will test
+ * an already created document and it's postscript output (by an older office version)
+ * with a new office version.
+ * This test use Ghostscript for the jpeg export and graphically compare tools from ImageMagick.
+ * Read the manual for more information.
+ *
+ * this is only the starter program
+ * more is found in qadevOOo/runner/convwatch/*
+ */
+
+public class ReferenceBuilder extends EnhancedComplexTestCase
+{
+ // The first of the mandatory functions:
+ /**
+ * Return the name of the test.
+ * In this case it is the actual name of the service.
+ * @return The tested service.
+ */
+ public String getTestObjectName() {
+ return "ReferenceBuilder runner";
+ }
+
+ // The second of the mandatory functions: return all test methods as an
+ // array. There is only one test function in this example.
+ /**
+ * Return all test methods.
+ * @return The test methods.
+ */
+ public String[] getTestMethodNames() {
+ return new String[]{"buildreference"};
+ }
+
+ // This test is fairly simple, so there is no need for before() or after()
+ // methods.
+
+ public void before()
+ {
+ // System.out.println("before()");
+ }
+
+ public void after()
+ {
+ // System.out.println("after()");
+ }
+
+ // The test method itself.
+ private String m_sInputPath = "";
+ private String m_sReferencePath = "";
+ private boolean m_bIncludeSubdirectories = true;
+
+ void initMember()
+ {
+ // MUST PARAMETER
+ // INPUT_PATH ----------
+ String sINPATH = (String)param.get( PropertyName.DOC_COMPARATOR_INPUT_PATH );
+ boolean bQuit = false;
+ String sError = "";
+ if (sINPATH == null || sINPATH.length() == 0)
+ {
+ log.println("Please set input path (path to documents) " + PropertyName.DOC_COMPARATOR_INPUT_PATH + "=path.");
+ bQuit = true;
+ }
+ else
+ {
+ log.println("found " + PropertyName.DOC_COMPARATOR_INPUT_PATH + " " + sINPATH);
+ m_sInputPath = sINPATH;
+ }
+
+ // REFERENCE_PATH ----------
+ String sREF = (String)param.get( PropertyName.DOC_COMPARATOR_REFERENCE_PATH );
+ if (sREF == null || sREF.length() == 0)
+ {
+ log.println("Please set output path (path to a directory, where the references should stay) " + PropertyName.DOC_COMPARATOR_REFERENCE_PATH + "=path.");
+ bQuit = true;
+ }
+ else
+ {
+ log.println("found " + PropertyName.DOC_COMPARATOR_REFERENCE_PATH + " " + sREF);
+ m_sReferencePath = sREF;
+ }
+
+ if (bQuit == true)
+ {
+ // log.println("must quit.");
+ assure("Must quit, Parameter problems.", false);
+ }
+
+ if (m_sInputPath.startsWith("file:") ||
+ m_sReferencePath.startsWith("file:"))
+ {
+ assure("We can't handle file: URL right, use system path instead.", false);
+ }
+
+ }
+
+ /**
+ * Function returns a List of software which must accessable as an external executable
+ */
+ protected Object[] mustInstalledSoftware()
+ {
+ ArrayList aList = new ArrayList();
+ aList.add("perl -version");
+ return aList.toArray();
+ }
+
+ // the test ======================================================================
+ public void buildreference()
+ {
+ GlobalLogWriter.set(log);
+ String sDBConnection = (String)param.get( PropertyName.DB_CONNECTION_STRING );
+
+ // check if all need software is installed and accessable
+ checkEnvironment(mustInstalledSoftware());
+
+ // test_removeFirstDirectorysAndBasenameFrom();
+ // Get the MultiServiceFactory.
+ // XMultiServiceFactory xMSF = (XMultiServiceFactory)param.getMSF();
+ GraphicalTestArguments aGTA = getGraphicalTestArguments();
+ if (aGTA == null)
+ {
+ assure("Must quit", false);
+ }
+ if (aGTA.cancelRequest())
+ {
+ return;
+ }
+
+ initMember();
+ DB.init(aGTA.getDBInfoString() + "," + sDBConnection);
+ File aInputPath = new File(m_sInputPath);
+ if (aInputPath.isDirectory())
+ {
+ String fs = System.getProperty("file.separator");
+
+ String sRemovePath = aInputPath.getAbsolutePath();
+ // a whole directory
+ FileFilter aFileFilter = FileHelper.getFileFilter();
+
+ Object[] aList = DirectoryHelper.traverse(m_sInputPath, aFileFilter, aGTA.includeSubDirectories());
+ // fill into DB
+ // DB.filesRemove(aGTA.getDBInfoString());
+ // for (int j=0;j<aList.length;j++)
+ // {
+ // String sEntry = (String)aList[j];
+ // DB.fileInsert(aGTA.getDBInfoString(), sEntry, sRemovePath);
+ // }
+
+ // normal run.
+ for (int i=0;i<aList.length;i++)
+ {
+ String sEntry = (String)aList[i];
+
+ String sNewReferencePath = m_sReferencePath + fs + FileHelper.removeFirstDirectorysAndBasenameFrom(sEntry, m_sInputPath);
+ log.println("- next file is: ------------------------------");
+ log.println(sEntry);
+ log.println(sNewReferencePath);
+
+ if (aGTA.checkIfUsableDocumentType(sEntry))
+ {
+ runGDC(sEntry, sNewReferencePath);
+ }
+ if (aGTA.cancelRequest())
+ {
+ break;
+ }
+ }
+ }
+ else
+ {
+ // String sRemovePath = aInputPath.getAbsolutePath();
+ // DB.fileInsert(aGTA.getDBInfoString(), m_sInputPath, sRemovePath);
+ // DB.updatestate_status(aGTA.getDBInfoString(), "started: " + m_sInputPath);
+ if (aGTA.checkIfUsableDocumentType(m_sInputPath))
+ {
+ runGDC(m_sInputPath, m_sReferencePath);
+ }
+ }
+ }
+
+ void runGDC(String _sInputPath, String _sReferencePath)
+ {
+ // first do a check if the reference not already exist, this is a big speedup, due to the fact,
+ // we don't need to start a new office.
+ GraphicalTestArguments aGTA = getGraphicalTestArguments();
+ if (GraphicalDifferenceCheck.isReferenceExists(_sInputPath, _sReferencePath, aGTA) == false)
+ {
+ // start a fresh Office
+ OfficeProvider aProvider = null;
+ // SimpleFileSemaphore aSemaphore = new SimpleFileSemaphore();
+ if (aGTA.shouldOfficeStart())
+ {
+ // if (OSHelper.isWindows())
+ // {
+ // aSemaphore.P(aSemaphore.getSemaphoreFile());
+ // }
+ aGTA.getPerformance().startTime(PerformanceContainer.OfficeStart);
+ aProvider = new OfficeProvider();
+ XMultiServiceFactory xMSF = (XMultiServiceFactory) aProvider.getManager(param);
+ param.put("ServiceFactory", xMSF);
+ aGTA.getPerformance().stopTime(PerformanceContainer.OfficeStart);
+
+ long nStartTime = aGTA.getPerformance().getTime(PerformanceContainer.OfficeStart);
+ aGTA = getGraphicalTestArguments();
+ aGTA.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.get().println("Set office watcher");
+ Object aWatcher = param.get("Watcher");
+ GlobalLogWriter.get().setWatcher(aWatcher);
+ // initializeWatcher(param);
+
+ try
+ {
+ log.println("Reference type is " + aGTA.getReferenceType());
+ DB.source_start();
+ GraphicalDifferenceCheck.createOneReferenceFile(_sInputPath, _sReferencePath, aGTA);
+ DB.source_finished();
+ }
+ catch(ConvWatchCancelException e)
+ {
+ assure(e.getMessage(), false);
+ DB.source_failed(e.getMessage());
+ }
+ catch(ConvWatchException e)
+ {
+ assure(e.getMessage(), false);
+ DB.source_failed(e.getMessage());
+ }
+ catch(com.sun.star.lang.DisposedException e)
+ {
+ assure(e.getMessage(), false, true);
+ DB.source_failed(e.getMessage());
+ }
+
+ // Office shutdown
+ if (aProvider != null)
+ {
+ boolean bClosed = aProvider.closeExistingOffice(param, true);
+ // Hope I can check that the close of the office fails
+ assure("Office closed", bClosed, 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.
+ // }
+ }
+ }
+ else
+ {
+ // Reference already exist, do nothing, but DB change
+ DB.source_finished();
+ }
+ }
+}
+
diff --git a/qadevOOo/runner/convwatch/ReportDesignerTest.java b/qadevOOo/runner/convwatch/ReportDesignerTest.java
new file mode 100755
index 000000000000..703a2b2f3073
--- /dev/null
+++ b/qadevOOo/runner/convwatch/ReportDesignerTest.java
@@ -0,0 +1,694 @@
+/*
+ ************************************************************************
+ *
+ * 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 convwatch;
+
+import java.io.File;
+import java.util.ArrayList;
+
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.container.XNameAccess;
+import com.sun.star.frame.XComponentLoader;
+import com.sun.star.frame.XDesktop;
+import com.sun.star.frame.XModel;
+import com.sun.star.frame.XStorable;
+import com.sun.star.lang.XComponent;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.sdb.XDocumentDataSource;
+import com.sun.star.sdb.XOfficeDatabaseDocument;
+import com.sun.star.sdb.XReportDocumentsSupplier;
+import com.sun.star.sdb.application.XDatabaseDocumentUI;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XInterface;
+import com.sun.star.util.XCloseable;
+import com.sun.star.lang.XServiceInfo;
+
+// import util.BasicMacroTools;
+// import util.DesktopTools;
+// import util.dbg;
+import complexlib.ComplexTestCase;
+import helper.OfficeProvider;
+import helper.URLHelper;
+import helper.OfficeWatcher;
+
+// import convwatch.DB;
+
+// import java.util.Date;
+// import java.text.SimpleDateFormat;
+// import java.text.ParsePosition;
+// import java.sql.Time;
+//
+// import java.io.BufferedReader;
+// import java.io.File;
+// import java.io.FileReader;
+// import java.io.IOException;
+// import java.io.FilenameFilter;
+//
+// import java.util.Vector;
+//
+// import helper.AppProvider;
+// import java.text.DecimalFormat;
+// import util.DynamicClassLoader;
+// import java.util.StringTokenizer;
+
+
+
+
+class PropertySetHelper
+{
+ XPropertySet m_xPropertySet;
+ public PropertySetHelper(Object _aObj)
+ {
+ m_xPropertySet = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, _aObj);
+ }
+
+ /**
+ get a property and don't convert it
+ @param _sName the string name of the property
+ @return the object value of the property without any conversion
+ */
+ public Object getPropertyValueAsObject(String _sName)
+ {
+ Object aObject = null;
+
+ if (m_xPropertySet != null)
+ {
+ try
+ {
+ aObject = m_xPropertySet.getPropertyValue(_sName);
+ }
+ catch (com.sun.star.beans.UnknownPropertyException e)
+ {
+ System.out.println("ERROR: UnknownPropertyException caught. '" + _sName + "'");
+ System.out.println("Message: " + e.getMessage());
+ }
+ catch (com.sun.star.lang.WrappedTargetException e)
+ {
+ System.out.println("ERROR: WrappedTargetException caught.");
+ System.out.println("Message: " + e.getMessage());
+ }
+ }
+ return aObject;
+ }
+}
+
+class PropertyHelper
+{
+ /**
+ Create a PropertyValue[] from a ArrayList
+ @param _aArrayList
+ @return a PropertyValue[]
+ */
+ public static PropertyValue[] createPropertyValueArrayFormArrayList(ArrayList _aPropertyList)
+ {
+ // copy the whole PropertyValue List to an PropertyValue Array
+ PropertyValue[] aSaveProperties = null;
+
+ if (_aPropertyList == null)
+ {
+ aSaveProperties = new PropertyValue[0];
+ }
+ else
+ {
+ if (_aPropertyList.size() > 0)
+ {
+ aSaveProperties = new PropertyValue[_aPropertyList.size()];
+ for (int i = 0;i<_aPropertyList.size(); i++)
+ {
+ aSaveProperties[i] = (PropertyValue) _aPropertyList.get(i);
+ }
+ }
+ else
+ {
+ aSaveProperties = new PropertyValue[0];
+ }
+ }
+ return aSaveProperties;
+ }
+}
+
+public class ReportDesignerTest extends ComplexTestCase {
+
+ String mTestDocumentPath;
+
+ /**
+ * This method returns a list of Strings, each string must be a function name in this class.
+ * @return
+ */
+ public String[] getTestMethodNames()
+ {
+ return new String[] {"ReportDesignTest"}; // MAIN
+ }
+
+ private void checkIfOfficeExists(String _sOfficePathWithTrash)
+ {
+ String sOfficePath = "";
+ int nIndex = _sOfficePathWithTrash.indexOf("soffice.exe");
+ if (nIndex > 0)
+ {
+ sOfficePath = _sOfficePathWithTrash.substring(0, nIndex + 11);
+ }
+ else
+ {
+ nIndex = _sOfficePathWithTrash.indexOf("soffice");
+ if (nIndex > 0)
+ {
+ sOfficePath = _sOfficePathWithTrash.substring(0, nIndex + 7);
+ }
+ }
+
+ // if (sOfficePath.startsWith("\"") ||
+ // sOfficePath.startsWith("'"))
+ // {
+ // sOfficePath = sOfficePath.substring(1);
+ // }
+ sOfficePath = helper.StringHelper.removeQuoteIfExists(sOfficePath);
+
+ log.println(sOfficePath);
+ File sOffice = new File(sOfficePath);
+ if (! sOffice.exists())
+ {
+ log.println("ERROR: There exists no office installation at given path: '" + sOfficePath + "'");
+ System.exit(0);
+ }
+ }
+
+
+ private static XDesktop m_xDesktop = null;
+ public static XDesktop getXDesktop()
+ {
+
+ if (m_xDesktop == null)
+ {
+ try
+ {
+ XInterface xInterface = (XInterface) m_xXMultiServiceFactory.createInstance( "com.sun.star.frame.Desktop" );
+ m_xDesktop = (XDesktop) UnoRuntime.queryInterface(XDesktop.class, xInterface);
+ }
+ catch (com.sun.star.uno.Exception e)
+ {
+ log.println("ERROR: uno.Exception caught");
+ log.println("Message: " + e.getMessage());
+ }
+ }
+ return m_xDesktop;
+ }
+
+ private void showElements(XNameAccess _xNameAccess)
+ {
+ if (_xNameAccess != null)
+ {
+ String[] sElementNames = _xNameAccess.getElementNames();
+ for(int i=0;i<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 static XMultiServiceFactory m_xXMultiServiceFactory = null;
+ private void startOffice()
+ {
+ // int tempTime = param.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
+ */
+ public void ReportDesignTest()
+ {
+ convwatch.GlobalLogWriter.set(log);
+
+ GlobalLogWriter.get().println("Set office watcher");
+ OfficeWatcher aWatcher = (OfficeWatcher)param.get("Watcher");
+ GlobalLogWriter.get().setWatcher(aWatcher);
+
+ try
+ {
+
+ // -------------------- preconditions, try to find an office --------------------
+
+ String sAppExecutionCommand = (String) param.get("AppExecutionCommand");
+ log.println("sAppExecutionCommand='" + sAppExecutionCommand + "'");
+
+ String sUser = System.getProperty("user.name");
+ log.println("user.name='" + sUser + "'");
+
+ // String sVCSID = System.getProperty("VCSID");
+ // log.println("VCSID='" + sVCSID + "'");
+ // m_sMailAddress = sVCSID + "@openoffice.org";
+ m_sMailAddress = System.getProperty("MailAddress");
+ log.println("Assumed mail address: " + m_sMailAddress);
+
+ m_sParentDistinct = System.getProperty("ParentDistinct");
+
+ m_sSourceVersion = System.getProperty("SourceVersion");
+ m_sSourceName = System.getProperty("SourceName");
+ m_sDestinationVersion = System.getProperty("DestinationVersion");
+ m_sDestinationName = System.getProperty("DestinationName");
+ // createDBEntry();
+ // log.println("Current CWS: " + m_sCWS_WORK_STAMP);
+ // log.println("Current MWS: " + m_sUPDMinor);
+
+ if (m_sSourceVersion == null)
+ {
+ System.out.println("Error, Sourceversion is null.");
+ System.exit(1);
+ }
+
+ sAppExecutionCommand = sAppExecutionCommand.replaceAll( "\\$\\{USERNAME\\}", sUser);
+ log.println("sAppExecutionCommand='" + sAppExecutionCommand + "'");
+
+ // an other way to replace strings
+ // sAppExecutionCommand = utils.replaceAll13(sAppExecutionCommand, "${USERNAME}", sUser);
+
+ checkIfOfficeExists(sAppExecutionCommand);
+ param.put("AppExecutionCommand", new String(sAppExecutionCommand));
+
+ // System.exit(1);
+
+ // --------------------------- Start the given Office ---------------------------
+
+ startOffice();
+
+ // ------------------------------ Start a test run ------------------------------
+
+ // String sCurrentDirectory = System.getProperty("user.dir");
+ // log.println("Current Dir: " + sCurrentDirectory);
+ String sDocument = (String) param.get(convwatch.PropertyName.DOC_COMPARATOR_INPUT_PATH);
+ sDocument = helper.StringHelper.removeQuoteIfExists( sDocument );
+ startTestForFile(sDocument);
+ // if (sDocument.toLowerCase().indexOf("writer") >= 0)
+ // {
+ // startTestForFile(sDocument, WRITER);
+ // }
+ // else if (sDocument.toLowerCase().indexOf("calc") >= 0)
+ // {
+ // startTestForFile(sDocument, CALC);
+ // }
+ // else
+ // {
+ // assure("Can't identify the document no 'writer' nor 'calc' in it's name given.", false);
+ // }
+ }
+ catch (AssureException e)
+ {
+ stopOffice();
+ throw new AssureException(e.getMessage());
+ }
+
+ // ------------------------------ Office shutdown ------------------------------
+ stopOffice();
+ }
+
+// -----------------------------------------------------------------------------
+ private void startTestForFile(String _sDocument /*, int _nType*/)
+ {
+ File aFile = new File(_sDocument);
+ assure("Test File '" + _sDocument + "' doesn't exist.", aFile.exists());
+
+ String sFileURL = URLHelper.getFileURLFromSystemPath(_sDocument);
+ log.println("File URL: " + sFileURL);
+
+ XComponent xDocComponent = loadComponent(sFileURL, getXDesktop(), null);
+ log.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)
+
+ try
+ {
+ XInterface x = (XInterface)m_xXMultiServiceFactory.createInstance("com.sun.star.sdb.DatabaseContext");
+ assure("can't create instance of com.sun.star.sdb.DatabaseContext", x != null);
+ log.println("createInstance com.sun.star.sdb.DatabaseContext done");
+
+ XNameAccess xNameAccess = (XNameAccess) UnoRuntime.queryInterface(XNameAccess.class, x);
+ showElements(xNameAccess);
+ Object aObj = xNameAccess.getByName(sFileURL);
+// log.println("1");
+
+ // PropertySetHelper aHelper = new PropertySetHelper(aObj);
+ XDocumentDataSource xDataSource = (XDocumentDataSource)UnoRuntime.queryInterface(XDocumentDataSource.class, aObj);
+// Object aDatabaseDocmuent = aHelper.getPropertyValueAsObject("DatabaseDocument");
+ XOfficeDatabaseDocument xOfficeDBDoc = xDataSource.getDatabaseDocument();
+
+ // XOfficeDatabaseDocument xOfficeDBDoc = (XOfficeDatabaseDocument)UnoRuntime.queryInterface(XOfficeDatabaseDocument.class, aDatabaseDocument);
+ assure("can't access DatabaseDocument", xOfficeDBDoc != null);
+// log.println("2");
+
+ XModel xDBSource = (XModel)UnoRuntime.queryInterface(XModel.class, xOfficeDBDoc);
+ Object aController = xDBSource.getCurrentController();
+ assure("Controller of xOfficeDatabaseDocument is empty!", aController != null);
+// log.println("3");
+
+ XDatabaseDocumentUI aDBDocUI = (XDatabaseDocumentUI)UnoRuntime.queryInterface(XDatabaseDocumentUI.class, aController);
+ aDBDocUI.connect();
+// if (aDBDocUI.isConnected())
+// {
+// System.out.println("true");
+// }
+// else
+// {
+// System.out.println("false");
+// }
+// log.println("4");
+
+ // aHelper = new PropertySetHelper(aController);
+
+ // Object aActiveConnectionObj = aHelper.getPropertyValueAsObject("ActiveConnection");
+ Object aActiveConnectionObj = aDBDocUI.getActiveConnection();
+ assure("ActiveConnection is empty", aActiveConnectionObj != null);
+// log.println("5");
+
+ XReportDocumentsSupplier xSupplier = (XReportDocumentsSupplier)UnoRuntime.queryInterface(XReportDocumentsSupplier.class, xOfficeDBDoc);
+ xNameAccess = xSupplier.getReportDocuments();
+ assure("xOfficeDatabaseDocument returns no Report Document", xNameAccess != null);
+// log.println("5");
+
+ showElements(xNameAccess);
+
+ ArrayList aPropertyList = new ArrayList();
+
+ PropertyValue aActiveConnection = new PropertyValue();
+ aActiveConnection.Name = "ActiveConnection";
+ aActiveConnection.Value = aActiveConnectionObj;
+ aPropertyList.add(aActiveConnection);
+
+ loadAndStoreReports(xNameAccess, aPropertyList /*, _nType*/ );
+ createDBEntry(/*_nType*/);
+ }
+ catch(com.sun.star.uno.Exception e)
+ {
+ log.println("ERROR: Exception caught");
+ log.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
+ closeComponent(xDocComponent);
+ }
+
+ private String getDocumentPoolName(/*int _nType*/)
+ {
+ return "AutogenReportDesignTest";
+ // return getFileFormat(_nType);
+ }
+
+// -----------------------------------------------------------------------------
+ private void createDBEntry(/*int _nType*/)
+ {
+ // try to connect the database
+ String sDBConnection = (String)param.get( convwatch.PropertyName.DB_CONNECTION_STRING );
+ log.println("DBConnection: " + sDBConnection);
+ 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 = "";
+
+ 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 void loadAndStoreReports(XNameAccess _xNameAccess, ArrayList _aPropertyList /*, int _nType*/ )
+ {
+ 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);
+ // print? or store?
+ storeComponent(sReportName, xDoc /*, _nType*/);
+ closeComponent(xDoc);
+ }
+ }
+ }
+
+ private String getFormatExtension(Object _xComponent /* int _nType*/ )
+ {
+ String sExtension;
+ XServiceInfo 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)param.get( convwatch.PropertyName.DOC_COMPARATOR_OUTPUT_PATH );
+ sOutputPath = helper.StringHelper.removeQuoteIfExists(sOutputPath);
+
+ if (!sOutputPath.endsWith("/") || // construct the output file name
+ !sOutputPath.endsWith("\\"))
+ {
+ sOutputPath += System.getProperty("file.separator");
+ }
+ // sOutputPath += "tmp_123";
+ 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 void storeComponent(String _sName, Object _xComponent /*, int _nType*/ )
+ {
+ String sOutputPath = getOutputPath(/*_nType*/);
+
+ // add DocumentPoolName
+ sOutputPath += getDocumentPoolName(/*_nType*/);
+ sOutputPath += System.getProperty("file.separator");
+
+ File aOutputFile = new File(sOutputPath); // create the directory of the given output path
+ aOutputFile.mkdirs();
+
+ sOutputPath += _sName;
+ sOutputPath += getFormatExtension(_xComponent /*_nType*/);
+
+ String sOutputURL = URLHelper.getFileURLFromSystemPath(sOutputPath);
+
+ ArrayList aPropertyList = new ArrayList(); // set some properties for storeAsURL
+
+ // PropertyValue aFileFormat = new PropertyValue();
+ // aFileFormat.Name = "FilterName";
+ // aFileFormat.Value = getFileFormat(_nType);
+ // aPropertyList.add(aFileFormat);
+
+ PropertyValue aOverwrite = new PropertyValue(); // always overwrite already exist files
+ aOverwrite.Name = "Overwrite";
+ aOverwrite.Value = Boolean.TRUE;
+ aPropertyList.add(aOverwrite);
+
+ // store the document in an other directory
+ XStorable aStorable = (XStorable) UnoRuntime.queryInterface( XStorable.class, _xComponent);
+ if (aStorable != null)
+ {
+ log.println("store document as URL: '" + sOutputURL + "'");
+ try
+ {
+ aStorable.storeAsURL(sOutputURL, PropertyHelper.createPropertyValueArrayFormArrayList(aPropertyList));
+ }
+ catch (com.sun.star.io.IOException e)
+ {
+ log.println("ERROR: Exception caught");
+ log.println("Can't write document URL: '" + sOutputURL + "'");
+ log.println("Message: " + e.getMessage());
+ }
+ }
+ }
+
+ private XComponent loadComponent(String _sName, Object _xComponent, ArrayList _aPropertyList)
+ {
+ XComponent xDocComponent = null;
+ XComponentLoader xComponentLoader = (XComponentLoader) UnoRuntime.queryInterface( XComponentLoader.class, _xComponent );
+
+ try
+ {
+ PropertyValue[] aLoadProperties = PropertyHelper.createPropertyValueArrayFormArrayList(_aPropertyList);
+ log.println("Load component: '" + _sName + "'");
+ xDocComponent = xComponentLoader.loadComponentFromURL(_sName, "_blank", 0, aLoadProperties);
+ log.println("Load component: '" + _sName + "' done");
+ }
+ catch (com.sun.star.io.IOException e)
+ {
+ log.println("ERROR: Exception caught");
+ log.println("Can't load document '" + _sName + "'");
+ log.println("Message: " + e.getMessage());
+ }
+ catch (com.sun.star.lang.IllegalArgumentException e)
+ {
+ log.println("ERROR: Exception caught");
+ log.println("Illegal Arguments given to loadComponentFromURL.");
+ log.println("Message: " + e.getMessage());
+ }
+ return xDocComponent;
+ }
+
+ private void closeComponent(XComponent _xDoc)
+ {
+ // Close the document
+ XCloseable xCloseable = (XCloseable) UnoRuntime.queryInterface(XCloseable.class, _xDoc);
+ try
+ {
+ xCloseable.close(true);
+ }
+ catch (com.sun.star.util.CloseVetoException e)
+ {
+ log.println("ERROR: CloseVetoException caught");
+ log.println("CloseVetoException occured Can't close document.");
+ log.println("Message: " + e.getMessage());
+ }
+ }
+
+}
diff --git a/qadevOOo/runner/convwatch/SimpleFileSemaphore.java b/qadevOOo/runner/convwatch/SimpleFileSemaphore.java
new file mode 100644
index 000000000000..9d608bdb332b
--- /dev/null
+++ b/qadevOOo/runner/convwatch/SimpleFileSemaphore.java
@@ -0,0 +1,189 @@
+/*************************************************************************
+ *
+ * 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 convwatch;
+
+import java.io.File;
+import java.io.RandomAccessFile;
+import helper.OSHelper;
+
+public class SimpleFileSemaphore /* extends *//* implements */
+{
+ String m_sInternSemaphoreFile;
+ File m_aInternSemaphoreFile;
+ GlobalLogWriter m_aLog;
+
+ public static void sleep( int _nSeconds)
+ {
+ // wait a second here
+ try
+ {
+ java.lang.Thread.sleep(_nSeconds * 1000);
+ }
+ catch (java.lang.InterruptedException e2)
+ {
+ }
+ }
+
+ public SimpleFileSemaphore() throws IllegalArgumentException
+ {
+ String sInternFileName;
+ if (OSHelper.isWindows())
+ {
+ sInternFileName = "C:/Temp/ConvwatchOOoSemaphore.txt";
+ }
+ else if (OSHelper.isUnix())
+ {
+ sInternFileName = "/tmp/ConvwatchOOoSemaphore.txt";
+ }
+ else
+ {
+ m_sInternSemaphoreFile = null;
+ throw new IllegalArgumentException("Unknown System, can't initialise SimpleFileSemaphore");
+ }
+
+ m_sInternSemaphoreFile = sInternFileName;
+ m_aInternSemaphoreFile = new File(sInternFileName);
+ }
+
+ public File getSemaphoreFile()
+ {
+ return m_aInternSemaphoreFile;
+ }
+// ------------------------------------------------------------------------------
+// wait until resource is available
+ public void P(File _aSemaphore)
+ {
+ int nCount = 0;
+ int nCheckLoop = 1;
+
+ while ( nCheckLoop == 1)
+ {
+ // check if resource is available, if not, wait.
+ if ( _aSemaphore.exists() )
+ {
+ m_aLog.get().println( "Active wait since " + nCount + "sec..");
+ nCount ++;
+ sleep( 1 );
+ }
+ else
+ {
+ sleep( 1 );
+ if ( _aSemaphore.exists() )
+ {
+ // ups
+ m_aLog.get().println( "ups...");
+ }
+ else
+ {
+ nCheckLoop = 0;
+ }
+ }
+ }
+
+ // block resource by ourself
+ try
+ {
+ RandomAccessFile aWriter = new RandomAccessFile(_aSemaphore, "rw");
+ aWriter.writeByte((int)1);
+ aWriter.close();
+ }
+
+ catch (java.io.FileNotFoundException fne)
+ {
+ m_aLog.get().println( "caught: FileNotFoundException");
+ }
+ catch(java.io.IOException ie)
+ {
+ m_aLog.get().println( "caught: IOException");
+ }
+ }
+
+// ------------------------------------------------------------------------------
+// block a resource
+ public void V(File _aSemaphore)
+ {
+
+ if ( _aSemaphore.exists() )
+ {
+ _aSemaphore.delete();
+ }
+ else
+ {
+ m_aLog.get().println("Could be a problem here? No resource block found.");
+ }
+ }
+
+ // --------------------------------- Unit test ---------------------------------
+
+ private static boolean SEMAPHORE_SHOULD_EXIST = true;
+ private static boolean SEMAPHORE_SHOULD_NOT_EXIST = false;
+
+ private static void assure(boolean _b, String _sText)
+ {
+ System.out.print(_sText);
+ System.out.print(" ");
+ if (_b)
+ {
+ System.out.println("ok");
+ }
+ else
+ {
+ System.out.println("FAILED");
+ }
+ }
+
+ private static void testSemaphoreFile(SimpleFileSemaphore a, boolean _bShouldFileExists)
+ {
+ System.out.println("Check if semaphore file exists.");
+ File aSemaphoreFile = a.getSemaphoreFile();
+ if (aSemaphoreFile.exists())
+ {
+ System.out.println("Name is: " + aSemaphoreFile.getAbsolutePath());
+ assure(_bShouldFileExists == SEMAPHORE_SHOULD_EXIST, "Semaphore should exist!");
+ }
+ else
+ {
+ assure(_bShouldFileExists == SEMAPHORE_SHOULD_NOT_EXIST, "Semaphore should not exist!");
+ }
+ }
+
+ public static void main( String[] argv )
+ {
+ SimpleFileSemaphore a = new SimpleFileSemaphore();
+
+ testSemaphoreFile(a, SEMAPHORE_SHOULD_NOT_EXIST);
+
+ a.P(a.getSemaphoreFile());
+
+ testSemaphoreFile(a, SEMAPHORE_SHOULD_EXIST);
+
+ a.V(a.getSemaphoreFile());
+
+ testSemaphoreFile(a, SEMAPHORE_SHOULD_NOT_EXIST);
+ }
+}
diff --git a/qadevOOo/runner/convwatch/StatusHelper.java b/qadevOOo/runner/convwatch/StatusHelper.java
new file mode 100644
index 000000000000..d37fa4a79af4
--- /dev/null
+++ b/qadevOOo/runner/convwatch/StatusHelper.java
@@ -0,0 +1,108 @@
+/*************************************************************************
+ *
+ * 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 convwatch;
+
+public class StatusHelper
+{
+ final static public int DIFF_NOT_REALLY_INITIALISED = 1;
+ final static public int DIFF_NO_DIFFERENCES = 2;
+ final static public int DIFF_DIFFERENCES_FOUND = 3;
+ final static public int DIFF_AFTER_MOVE_DONE_NO_PROBLEMS = 4;
+ final static public int DIFF_AFTER_MOVE_DONE_DIFFERENCES_FOUND = 5;
+
+ // public String m_sOutputPath;
+ public String m_sMainName;
+
+ public String m_sOldGfx;
+ public String m_sNewGfx;
+ public String m_sDiffGfx;
+ public int nDiffStatus = DIFF_NOT_REALLY_INITIALISED;
+ public int nPercent = 0;
+
+ // BorderMove Values
+ public int nPercent2 = 0;
+ public String m_sOld_BM_Gfx;
+ public String m_sNew_BM_Gfx;
+ public String m_sDiff_BM_Gfx;
+
+ public StatusHelper(String _sOldGfx, String _sNewGfx, String _sDiffGfx)
+ {
+ m_sOldGfx = _sOldGfx;
+ m_sNewGfx = _sNewGfx;
+ m_sDiffGfx = _sDiffGfx;
+ }
+ public void setFilesForBorderMove(String _sOldGfx, String _sNewGfx, String _sDiffGfx)
+ {
+ m_sOld_BM_Gfx = _sOldGfx;
+ m_sNew_BM_Gfx = _sNewGfx;
+ m_sDiff_BM_Gfx = _sDiffGfx;
+
+ }
+
+ public void printStatus()
+ {
+ GlobalLogWriter.get().println(" Original file: " + m_sOldGfx);
+ GlobalLogWriter.get().println(" New file: " + m_sNewGfx);
+ GlobalLogWriter.get().println("Difference file: " + m_sDiffGfx);
+ if (nDiffStatus == DIFF_NOT_REALLY_INITIALISED)
+ {
+ GlobalLogWriter.get().println("Early problem, may be the files doesn't exist.");
+ }
+ else if (nDiffStatus == DIFF_NO_DIFFERENCES)
+ {
+ GlobalLogWriter.get().println("No differences found, ok.");
+ }
+ else if (nDiffStatus == DIFF_DIFFERENCES_FOUND)
+ {
+ GlobalLogWriter.get().println("Files differ by " + String.valueOf(nPercent) + "%");
+ }
+ else if (nDiffStatus == DIFF_AFTER_MOVE_DONE_NO_PROBLEMS)
+ {
+ GlobalLogWriter.get().println("No differences found, after move picture.");
+ }
+ else if (nDiffStatus == DIFF_AFTER_MOVE_DONE_DIFFERENCES_FOUND)
+ {
+ GlobalLogWriter.get().println("A picture move is done, the files differ by " + String.valueOf(nPercent2) + " old was " + String.valueOf(nPercent) + "%");
+ }
+ else
+ {
+ GlobalLogWriter.get().println("Unknown DIFF_ values used, not handles yet.");
+ }
+ }
+
+
+
+
+
+// TODO: stream output
+// public stream& statusline(stream)
+// {
+// stream << name << "PASS" << nDiff==0?"PASS":"FAIL" << endl;
+// return stream;
+// }
+}
diff --git a/qadevOOo/runner/convwatch/StringHelper.java b/qadevOOo/runner/convwatch/StringHelper.java
new file mode 100644
index 000000000000..b20e3b6bea01
--- /dev/null
+++ b/qadevOOo/runner/convwatch/StringHelper.java
@@ -0,0 +1,103 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+// LLA: moved to helper.StringHelper package convwatch;
+// LLA: moved to helper.StringHelper
+// LLA: moved to helper.StringHelper public class StringHelper {
+// LLA: moved to helper.StringHelper
+// LLA: moved to helper.StringHelper public static String doubleQuote(String _sStr)
+// LLA: moved to helper.StringHelper {
+// LLA: moved to helper.StringHelper return "\"" + _sStr + "\"";
+// LLA: moved to helper.StringHelper }
+// LLA: moved to helper.StringHelper
+// LLA: moved to helper.StringHelper public static String singleQuote(String _sStr)
+// LLA: moved to helper.StringHelper {
+// LLA: moved to helper.StringHelper return "'" + _sStr + "'";
+// LLA: moved to helper.StringHelper }
+// LLA: moved to helper.StringHelper
+// LLA: moved to helper.StringHelper public static String removeQuoteIfNeed(String _sPath)
+// LLA: moved to helper.StringHelper {
+// LLA: moved to helper.StringHelper String sNewPath = _sPath;
+// LLA: moved to helper.StringHelper
+// LLA: moved to helper.StringHelper if (_sPath.startsWith("\"") ||
+// LLA: moved to helper.StringHelper _sPath.startsWith("'"))
+// LLA: moved to helper.StringHelper {
+// LLA: moved to helper.StringHelper // remove trailing quotes, if exists
+// LLA: moved to helper.StringHelper sNewPath = sNewPath.substring(1);
+// LLA: moved to helper.StringHelper }
+// LLA: moved to helper.StringHelper
+// LLA: moved to helper.StringHelper if (_sPath.endsWith("\"") ||
+// LLA: moved to helper.StringHelper _sPath.endsWith("'"))
+// LLA: moved to helper.StringHelper {
+// LLA: moved to helper.StringHelper // remove trailing quotes, if exists
+// LLA: moved to helper.StringHelper sNewPath = sNewPath.substring(0, sNewPath.length() - 1);
+// LLA: moved to helper.StringHelper }
+// LLA: moved to helper.StringHelper return sNewPath;
+// LLA: moved to helper.StringHelper }
+// LLA: moved to helper.StringHelper
+// LLA: moved to helper.StringHelper public static String doubleQuoteIfNeed(String _sStr)
+// LLA: moved to helper.StringHelper {
+// LLA: moved to helper.StringHelper if (_sStr.startsWith("\"") && _sStr.endsWith("\""))
+// LLA: moved to helper.StringHelper {
+// LLA: moved to helper.StringHelper // don't quote twice
+// LLA: moved to helper.StringHelper return _sStr;
+// LLA: moved to helper.StringHelper }
+// LLA: moved to helper.StringHelper if (_sStr.indexOf(" ") == -1)
+// LLA: moved to helper.StringHelper {
+// LLA: moved to helper.StringHelper // don't quote, if there is no space in name
+// LLA: moved to helper.StringHelper return _sStr;
+// LLA: moved to helper.StringHelper }
+// LLA: moved to helper.StringHelper if (_sStr.indexOf("%") != -1)
+// LLA: moved to helper.StringHelper {
+// LLA: moved to helper.StringHelper return singleQuote(_sStr);
+// LLA: moved to helper.StringHelper }
+// LLA: moved to helper.StringHelper
+// LLA: moved to helper.StringHelper return doubleQuote(_sStr);
+// LLA: moved to helper.StringHelper }
+// LLA: moved to helper.StringHelper
+// LLA: moved to helper.StringHelper /**
+// LLA: moved to helper.StringHelper * Convert a value to a string with a given length, if the len is greater the len of the value string representation
+// LLA: moved to helper.StringHelper * fill it's front with '0'
+// LLA: moved to helper.StringHelper * So ("5", 4) will result in a string "0005"
+// LLA: moved to helper.StringHelper * @param _nValue
+// LLA: moved to helper.StringHelper * @param _nLen
+// LLA: moved to helper.StringHelper * @return
+// LLA: moved to helper.StringHelper */
+// LLA: moved to helper.StringHelper public static String createValueString(int _nValue, int _nLen)
+// LLA: moved to helper.StringHelper {
+// LLA: moved to helper.StringHelper String sValue = String.valueOf(_nValue);
+// LLA: moved to helper.StringHelper StringBuffer a = new StringBuffer();
+// LLA: moved to helper.StringHelper while (_nLen > sValue.length())
+// LLA: moved to helper.StringHelper {
+// LLA: moved to helper.StringHelper a.append('0');
+// LLA: moved to helper.StringHelper _nLen --;
+// LLA: moved to helper.StringHelper }
+// LLA: moved to helper.StringHelper a.append(sValue);
+// LLA: moved to helper.StringHelper return a.toString();
+// LLA: moved to helper.StringHelper }
+// LLA: moved to helper.StringHelper
+// LLA: moved to helper.StringHelper }
diff --git a/qadevOOo/runner/convwatch/TimeHelper.java b/qadevOOo/runner/convwatch/TimeHelper.java
new file mode 100755
index 000000000000..923568db51c8
--- /dev/null
+++ b/qadevOOo/runner/convwatch/TimeHelper.java
@@ -0,0 +1,44 @@
+/*************************************************************************
+ *
+ * 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 convwatch;
+
+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.get().println("Wait " + String.valueOf(_nSeconds) + " sec. Reason: " + _sReason);
+ try {
+ java.lang.Thread.sleep(_nSeconds * 1000);
+ } catch (java.lang.InterruptedException e2) {}
+ }
+}
diff --git a/qadevOOo/runner/convwatch/TriState.java b/qadevOOo/runner/convwatch/TriState.java
new file mode 100644
index 000000000000..7a9e9312c6bb
--- /dev/null
+++ b/qadevOOo/runner/convwatch/TriState.java
@@ -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.
+ *
+ ************************************************************************/
+
+package convwatch;
+
+public class TriState
+{
+ public static final TriState TRUE = new TriState(1);
+ public static final TriState FALSE = new TriState(0);
+ public static final TriState UNSET = new TriState(-1);
+
+ int m_nValue;
+
+ /**
+ Allocates a <code>TriState</code> object representing the
+ <code>value</code> argument.
+
+ @param value the value of the <code>TriState</code>.
+ */
+ public TriState(int value)
+ {
+ m_nValue = value;
+ }
+
+ /**
+ Returns the value of this TriState object as an int
+ * @return the primitive <code>int</code> value of this object.
+ */
+ public int intValue()
+ {
+ return m_nValue;
+ }
+ /**
+ Returns <code>true</code> if and only if the argument is not
+ <code>null</code> and is a <code>TriState</code> object that
+ contains the same <code>int</code> value as this object.
+
+ @param obj the object to compare with.
+ @return <code>true</code> if the objects are the same;
+ <code>false</code> otherwise.
+ */
+
+ public boolean equals(Object obj)
+ {
+ if ((obj != null) &&
+ (obj instanceof TriState))
+ {
+ return m_nValue == ((TriState)obj).intValue();
+ }
+ return false;
+ }
+}
diff --git a/qadevOOo/runner/convwatch/ValueNotFoundException.java b/qadevOOo/runner/convwatch/ValueNotFoundException.java
new file mode 100644
index 000000000000..04957187d126
--- /dev/null
+++ b/qadevOOo/runner/convwatch/ValueNotFoundException.java
@@ -0,0 +1,36 @@
+/*************************************************************************
+ *
+ * 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 convwatch;
+
+class ValueNotFoundException extends Exception
+{
+ ValueNotFoundException(String _sMessage)
+ {
+ super(_sMessage);
+ }
+}
diff --git a/qadevOOo/runner/convwatch/makefile.mk b/qadevOOo/runner/convwatch/makefile.mk
new file mode 100644
index 000000000000..aed1532cea6e
--- /dev/null
+++ b/qadevOOo/runner/convwatch/makefile.mk
@@ -0,0 +1,86 @@
+#*************************************************************************
+#
+# 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 java_uno.jar
+JAVAFILES = \
+ TriState.java \
+ IniFile.java \
+ BuildID.java \
+ GfxCompare.java \
+ FilenameHelper.java \
+ NameHelper.java \
+ HTMLOutputter.java \
+ LISTOutputter.java \
+ INIOutputter.java \
+ PropertyName.java \
+ StatusHelper.java \
+ ConvWatchException.java \
+ ConvWatchCancelException.java \
+ OfficePrint.java \
+ PRNCompare.java \
+ FileHelper.java \
+ OSHelper.java \
+ PixelCounter.java \
+ ImageHelper.java \
+ BorderRemover.java \
+ ConvWatch.java \
+ DirectoryHelper.java \
+ ConvWatchStarter.java \
+ ReferenceBuilder.java \
+ EnhancedComplexTestCase.java \
+ MSOfficePrint.java \
+ GraphicalTestArguments.java \
+ GraphicalDifferenceCheck.java \
+ DocumentConverter.java\
+ DBHelper.java\
+ DB.java\
+ ValueNotFoundException.java \
+ GlobalLogWriter.java \
+ CrashLoopTest.java \
+ ReportDesignerTest.java \
+ DateHelper.java \
+ TimeHelper.java
+
+
+
+
+JAVACLASSFILES= $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class)
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk