summaryrefslogtreecommitdiff
path: root/qadevOOo/runner/convwatch
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2014-12-11 16:25:29 +0200
committerNoel Grandin <noelgrandin@gmail.com>2014-12-12 08:16:17 +0000
commit117a82cd090ddd8efbc500350dc6082730f04720 (patch)
tree50c07684d43c06fd54d17532caca6a3afafd6967 /qadevOOo/runner/convwatch
parent04b183a9bc792a53a9f081353a79486faa4f3872 (diff)
java: remove dead code in qadevOOo
found by running UCDetector over the code many times, like peeling an onion Change-Id: I54d5147eb1b5c921ad236331bc4c1f765b13ca83 Reviewed-on: https://gerrit.libreoffice.org/13445 Reviewed-by: Noel Grandin <noelgrandin@gmail.com> Tested-by: Noel Grandin <noelgrandin@gmail.com>
Diffstat (limited to 'qadevOOo/runner/convwatch')
-rw-r--r--qadevOOo/runner/convwatch/BorderRemover.java261
-rw-r--r--qadevOOo/runner/convwatch/BuildID.java127
-rw-r--r--qadevOOo/runner/convwatch/ConvWatch.java372
-rw-r--r--qadevOOo/runner/convwatch/ConvWatchCancelException.java32
-rw-r--r--qadevOOo/runner/convwatch/ConvWatchException.java33
-rw-r--r--qadevOOo/runner/convwatch/ConvWatchStarter.java387
-rw-r--r--qadevOOo/runner/convwatch/CrashLoopTest.java50
-rw-r--r--qadevOOo/runner/convwatch/DB.java254
-rw-r--r--qadevOOo/runner/convwatch/DBHelper.java29
-rw-r--r--qadevOOo/runner/convwatch/DateHelper.java48
-rw-r--r--qadevOOo/runner/convwatch/DirectoryHelper.java125
-rw-r--r--qadevOOo/runner/convwatch/DocumentConverter.java242
-rw-r--r--qadevOOo/runner/convwatch/EnhancedComplexTestCase.java101
-rw-r--r--qadevOOo/runner/convwatch/FileHelper.java342
-rw-r--r--qadevOOo/runner/convwatch/FilenameHelper.java364
-rw-r--r--qadevOOo/runner/convwatch/GfxCompare.java177
-rw-r--r--qadevOOo/runner/convwatch/GlobalLogWriter.java5
-rw-r--r--qadevOOo/runner/convwatch/GraphicalDifferenceCheck.java339
-rw-r--r--qadevOOo/runner/convwatch/GraphicalTestArguments.java682
-rw-r--r--qadevOOo/runner/convwatch/HTMLOutputter.java178
-rw-r--r--qadevOOo/runner/convwatch/INIOutputter.java190
-rw-r--r--qadevOOo/runner/convwatch/ImageHelper.java98
-rw-r--r--qadevOOo/runner/convwatch/IniFile.java238
-rw-r--r--qadevOOo/runner/convwatch/LISTOutputter.java85
-rw-r--r--qadevOOo/runner/convwatch/MSOfficePrint.java867
-rw-r--r--qadevOOo/runner/convwatch/NameHelper.java80
-rw-r--r--qadevOOo/runner/convwatch/OfficePrint.java1162
-rw-r--r--qadevOOo/runner/convwatch/PRNCompare.java504
-rw-r--r--qadevOOo/runner/convwatch/PerformanceContainer.java221
-rw-r--r--qadevOOo/runner/convwatch/PixelCounter.java138
-rw-r--r--qadevOOo/runner/convwatch/PropertyName.java58
-rw-r--r--qadevOOo/runner/convwatch/ReferenceBuilder.java257
-rw-r--r--qadevOOo/runner/convwatch/ReportDesignerTest.java535
-rw-r--r--qadevOOo/runner/convwatch/SimpleFileSemaphore.java180
-rw-r--r--qadevOOo/runner/convwatch/StatusHelper.java88
-rw-r--r--qadevOOo/runner/convwatch/TimeHelper.java35
-rw-r--r--qadevOOo/runner/convwatch/TriState.java68
-rw-r--r--qadevOOo/runner/convwatch/ValueNotFoundException.java27
38 files changed, 0 insertions, 8979 deletions
diff --git a/qadevOOo/runner/convwatch/BorderRemover.java b/qadevOOo/runner/convwatch/BorderRemover.java
deleted file mode 100644
index dbd933b3ad35..000000000000
--- a/qadevOOo/runner/convwatch/BorderRemover.java
+++ /dev/null
@@ -1,261 +0,0 @@
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-package convwatch;
-
-import java.io.File;
-import java.awt.image.RenderedImage;
-import java.awt.image.BufferedImage;
-import java.lang.reflect.Method;
-
-
-class Rect
-{
- private final int x;
- private final int y;
- private final int w;
- private final 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
-{
- // Helper values, filled after find Border
-
- // --------------------------------- test mode ---------------------------------
-
- /*
- * 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
-
- */
- private 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
- int nTolerable = (int) (_nTolerance * 256.0 / 100.0);
- 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
- {
- ImageHelper aImageHelper = ImageHelper.createImageHelper(_sFilenameFrom);
-
- int nBorderColor = aImageHelper.getPixel(0,0);
- Rect aInnerRect = findBorder(aImageHelper, nBorderColor);
-
- RenderedImage aImage = createImage(aImageHelper, aInnerRect);
-
- File aWriteFile = new File(_sFilenameTo);
-
- Exception ex = null;
- try
- {
- Class<?> imageIOClass = Class.forName("javax.imageio.ImageIO");
-
- Method getWriterMIMETypesMethod = imageIOClass.getDeclaredMethod("getWriterMIMETypes", new Class[]{ });
-
- getWriterMIMETypesMethod.invoke(imageIOClass, new Object[]{ });
- Method writeMethod = imageIOClass.getDeclaredMethod("write", new Class[]{ java.awt.image.RenderedImage.class,
- String.class,
- java.io.File.class});
- 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());
- }
-
- 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.
- */
-
- private 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++)
- {
- int nCurrentColor = _aImage.getPixel(x, y);
- if (! compareColorWithTolerance(nCurrentColor, _nBorderColor, 10))
- {
- nXMin = Math.min(nXMin, x);
- nYMin = Math.min(nYMin, y);
- }
- }
- }
- 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 = Math.max(nXMax, nx);
- nYMax = Math.max(nYMax, ny);
- }
- }
- }
-
- 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);
- }
-
-
- return aRect;
- }
-
- private 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));
- }
- }
- return aBI;
- }
-
-}
diff --git a/qadevOOo/runner/convwatch/BuildID.java b/qadevOOo/runner/convwatch/BuildID.java
deleted file mode 100644
index 6fb16875ca59..000000000000
--- a/qadevOOo/runner/convwatch/BuildID.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-package convwatch;
-
-import java.io.File;
-import helper.OSHelper;
-
-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);
- sBuildID = getBuildIDFromBootstrap(sOfficePath);
- if (sBuildID.length() == 0)
- {
- sBuildID = getBuildIDFromVersion(sOfficePath);
- }
- }
- else
- {
- GlobalLogWriter.get().println("soffice executable not found.");
- }
-
- 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;
- }
-}
-
diff --git a/qadevOOo/runner/convwatch/ConvWatch.java b/qadevOOo/runner/convwatch/ConvWatch.java
deleted file mode 100644
index 1c4ac3d08e6b..000000000000
--- a/qadevOOo/runner/convwatch/ConvWatch.java
+++ /dev/null
@@ -1,372 +0,0 @@
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-package convwatch;
-
-import helper.URLHelper;
-import java.io.File;
-
-public class ConvWatch
-{
-
- private 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 accessible 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.
- */
-
- private 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);
-
- String sAbsoluteInputFileURL = URLHelper.getFileURLFromSystemPath(_sAbsoluteInputFile);
-
- String sInputFile = FileHelper.getBasename(_sAbsoluteInputFile);
-
- FileHelper.getNameNoSuffix(sInputFile);
-
-
- String sAbsoluteOutputFile = _sOutputPath + fs + sInputFile;
- String sAbsoluteOutputFileURL = URLHelper.getFileURLFromSystemPath(sAbsoluteOutputFile);
-
- String sReferenceFile = FileHelper.getBasename(_sAbsoluteReferenceFile);
- String sReferenceFileNoSuffix = FileHelper.getNameNoSuffix(sReferenceFile);
- String sPostScriptFile = sReferenceFileNoSuffix + ".ps";
-
- String sAbsolutePrintFile = _sOutputPath + fs + sPostScriptFile;
- String sAbsolutePrintFileURL = URLHelper.getFileURLFromSystemPath(sAbsolutePrintFile);
-
- // store and print the sAbsoluteInputFileURL file with StarOffice / OpenOffice.org
- OfficePrint.printToFile(_aGTA, sAbsoluteInputFileURL, sAbsoluteOutputFileURL, sAbsolutePrintFileURL);
-
- if (! FileHelper.exists(sAbsolutePrintFile))
- {
- throw new ConvWatchCancelException("createPostscriptStartCheck: Printed file " + sAbsolutePrintFile + " does not exist.");
- }
-
- if (!bAbsoluteReferenceFile)
- {
- // 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 sReferencePath = FileHelper.getPath(_sAbsoluteReferenceFile);
-
- a.setReferencePath( sReferencePath );
- a.setOutputPath( _sOutputPath );
- a.setReferenceFile( sReferenceFile );
- a.setPostScriptFile(sPostScriptFile );
- if (_aGTA.printAllPages())
- {
- 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
- private static boolean createINIStatus(StatusHelper[] aList, String _sFilenamePrefix, String _sOutputPath, String _sAbsoluteInputFile, String _sBuildID, String _sRefBuildID)
- {
- System.getProperty("file.separator");
- String sBasename = FileHelper.getBasename(_sAbsoluteInputFile);
- String sNameNoSuffix = FileHelper.getNameNoSuffix(sBasename);
-// 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" + (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
- INIoutput.checkLine(aList[i], bCurrentResult);
- bResultIsOk &= bCurrentResult;
- }
- // Status
- INIoutput.close();
- return bResultIsOk;
- }
-
-
-
- private static void createINIStatus_DiffDiff(StatusHelper[] aDiffDiffList, String _sFilenamePrefix, String _sOutputPath, String _sAbsoluteInputFile, String _sBuildID)
- {
- System.getProperty("file.separator");
- String sBasename = FileHelper.getBasename(_sAbsoluteInputFile);
- String sNameNoSuffix = FileHelper.getNameNoSuffix(sBasename);
- String sINIFile = _sFilenamePrefix + sNameNoSuffix + ".ini";
-
- INIOutputter INIoutput = INIOutputter.create(_sOutputPath, sINIFile);
- 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" + (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
-
- INIoutput.checkDiffDiffLine(aDiffDiffList[i], bCurrentResult);
- }
- // Status
- 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);
-
- 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;
- }
-
- // 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)
- {
- throw new ConvWatchCancelException("No old difference file found." );
- }
- if (! bDiffIsOk)
- {
- throw new ConvWatchException("Graphical difference compare failed with file '" + _sAbsoluteInputFile + "'");
- }
- return bDiffIsOk;
- }
-
-}
diff --git a/qadevOOo/runner/convwatch/ConvWatchCancelException.java b/qadevOOo/runner/convwatch/ConvWatchCancelException.java
deleted file mode 100644
index f360293e18f3..000000000000
--- a/qadevOOo/runner/convwatch/ConvWatchCancelException.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-package convwatch;
-
-public class ConvWatchCancelException extends ConvWatchException
-{
- public ConvWatchCancelException(String _aMessage)
- {
- super(_aMessage);
- }
-
- public ConvWatchCancelException(String _aMessage, Throwable cause)
- {
- super(_aMessage, cause);
- }
-}
diff --git a/qadevOOo/runner/convwatch/ConvWatchException.java b/qadevOOo/runner/convwatch/ConvWatchException.java
deleted file mode 100644
index efd1e67e3dc9..000000000000
--- a/qadevOOo/runner/convwatch/ConvWatchException.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-package convwatch;
-
-public class ConvWatchException extends Exception
-{
- public ConvWatchException(String _aMessage)
- {
- super(_aMessage);
- }
-
- public ConvWatchException(String _aMessage, Throwable cause)
- {
- super(_aMessage, cause);
- }
-}
-
diff --git a/qadevOOo/runner/convwatch/ConvWatchStarter.java b/qadevOOo/runner/convwatch/ConvWatchStarter.java
deleted file mode 100644
index d6a4cca1e1aa..000000000000
--- a/qadevOOo/runner/convwatch/ConvWatchStarter.java
+++ /dev/null
@@ -1,387 +0,0 @@
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-package convwatch;
-
-import java.util.ArrayList;
-import java.io.File;
-import java.io.FileFilter;
-
-import com.sun.star.lang.XMultiServiceFactory;
-
-import helper.OfficeProvider;
-import helper.OfficeWatcher;
-import helper.OSHelper;
-
-/**
- * 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:
-
- // 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.
- */
- @Override
- 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("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)
- {
- 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 accessible as an external executable
- */
- @Override
- protected String[] mustInstalledSoftware()
- {
- ArrayList<String> aList = new ArrayList<String>();
- // 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(new String[aList.size()]);
- }
-
-
- /**
- * 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 accessible
- 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);
-
- 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;
-
- sNewOutputPath = sNewOutputPath + fs + sNewSubDir;
- if (sNewDiffPath != null)
- sNewDiffPath = sNewDiffPath + fs + sNewSubDir;
- }
-
- 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;
- if (aGTA.shouldOfficeStart())
- {
- 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);
-
- 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);
- }
-
- // -------------------- 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("----------------------------------------------------------------------");
-
- sLink = sHTMLPrefix /* + "/cw.php?inifile=" */ + _sOutputPath + fs + 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
deleted file mode 100644
index 015314980d14..000000000000
--- a/qadevOOo/runner/convwatch/CrashLoopTest.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-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.
- */
- @Override
- 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.
- */
- @Override
- 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
index 8b4c4ff006cf..a9b2f70763c2 100644
--- a/qadevOOo/runner/convwatch/DB.java
+++ b/qadevOOo/runner/convwatch/DB.java
@@ -20,7 +20,6 @@ package convwatch;
import java.sql.Connection;
import java.util.StringTokenizer;
-import java.util.ArrayList;
import helper.OSHelper;
public class DB extends DBHelper
@@ -54,70 +53,6 @@ public class DB extends DBHelper
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())
@@ -203,86 +138,6 @@ public class DB extends DBHelper
}
}
- private void sql_test()
- {
- String sUUID = getDBDistinct();
- System.out.println("UUID: " + sUUID);
- }
-
- private ArrayList<String> QuerySQL(Connection _aCon, String _sSQL)
- {
- java.sql.Statement oStmt = null;
- ArrayList<String> aResultList = new ArrayList<String>();
- try
- {
- try
- {
- oStmt = _aCon.createStatement();
- java.sql.ResultSet aResultSet = null;
- try
- {
- aResultSet = oStmt.executeQuery(_sSQL);
- java.sql.ResultSetMetaData aResultSetMetaData = aResultSet.getMetaData();
-
- int nColumnCount = aResultSetMetaData.getColumnCount(); // java sql starts with '1'
-
- while( aResultSet.next() )
- {
- StringBuffer aResult = new StringBuffer();
- try
- {
- 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 sResult = aResult.toString();
- aResultList.add(sResult);
- }
- catch (java.sql.SQLException e)
- {
- }
- }
- }
- finally
- {
- if (aResultSet != null)
- aResultSet.close();
- }
- }
- finally
- {
- if (oStmt != null)
- oStmt.close();
- }
- }
- catch (java.sql.SQLException e)
- {
- String sError = e.getMessage();
- GlobalLogWriter.get().println("DB: Original SQL error: " + sError);
- }
- return aResultList;
- }
-
private void updatestate_status(String _sStatus)
{
Connection aCon = new ShareConnection().getConnection();
@@ -294,43 +149,6 @@ public class DB extends DBHelper
SQLupdateValue( aCon, "status", sSet, sWhere );
}
}
- private void updateinfo_status(String _sInfo)
- {
- Connection aCon = new ShareConnection().getConnection();
-
- 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()
@@ -353,76 +171,4 @@ public class DB extends DBHelper
return aWhereClause.toString();
}
- private String getDBDistinct()
- {
- Connection aCon = new ShareConnection().getConnection();
-
- String sSQL = "SELECT uuid()";
- ArrayList<String> aResultList = QuerySQL(aCon, sSQL);
-
- for (int i=0;i<aResultList.size();i++)
- {
- String sResult = aResultList.get(i);
-
- StringTokenizer aTokenizer = new StringTokenizer(sResult,",",false);
- if (aTokenizer.hasMoreTokens())
- {
- String sToken = aTokenizer.nextToken();
- int nIndex = sToken.indexOf("uuid()=");
- int nIndexTuettel = sToken.indexOf('\'', nIndex);
- int nIndexTuettel2 = sToken.lastIndexOf('\'');
- String sUuid = sToken.substring(nIndexTuettel + 1, nIndexTuettel2);
- return sUuid;
- }
- }
-
- 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());
- }
-
}
diff --git a/qadevOOo/runner/convwatch/DBHelper.java b/qadevOOo/runner/convwatch/DBHelper.java
index dc76af3ad9d2..34e1e1cfdeee 100644
--- a/qadevOOo/runner/convwatch/DBHelper.java
+++ b/qadevOOo/runner/convwatch/DBHelper.java
@@ -93,28 +93,6 @@ class ShareConnection
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;
- }
-
- 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)
@@ -205,13 +183,6 @@ public class DBHelper
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
deleted file mode 100644
index bef0a09e7a1c..000000000000
--- a/qadevOOo/runner/convwatch/DateHelper.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-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) );
- return aBuf.toString();
- }
-}
diff --git a/qadevOOo/runner/convwatch/DirectoryHelper.java b/qadevOOo/runner/convwatch/DirectoryHelper.java
deleted file mode 100644
index 9d322c52fb5e..000000000000
--- a/qadevOOo/runner/convwatch/DirectoryHelper.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-package convwatch;
-
-import java.io.File;
-import java.io.FileFilter;
-import java.util.ArrayList;
-
-/**
- * Helper for directory access
- */
-public class DirectoryHelper
-{
- private final ArrayList<String> m_aFileList = new ArrayList<String>();
- private boolean m_bRecursiveIsAllowed = true;
-
- private 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();
- }
-
-
-
- private 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)
- {
- // 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 aStr = aDirEntries[ i ].getAbsolutePath();
- m_aFileList.add(aStr);
- }
- catch( Exception exception )
- {
- exception.printStackTrace();
- break;
- }
- }
- }
- }
-}
-
diff --git a/qadevOOo/runner/convwatch/DocumentConverter.java b/qadevOOo/runner/convwatch/DocumentConverter.java
deleted file mode 100644
index a3d930de91ea..000000000000
--- a/qadevOOo/runner/convwatch/DocumentConverter.java
+++ /dev/null
@@ -1,242 +0,0 @@
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-package convwatch;
-
-import java.io.File;
-import java.io.FileFilter;
-import java.util.ArrayList;
-
-import com.sun.star.lang.XMultiServiceFactory;
-
-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.
- */
- @Override
- 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.
- */
- @Override
- 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()
- {
- }
-
- public void after()
- {
- }
-
- // The test method itself.
- private String m_sInputPath = "";
- private String m_sReferencePath = "";
- void initMember()
- {
- // MUST PARAMETER
- // INPUT_PATH ----------
- 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 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)
- {
- 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 accessible as an external executable
- */
- @Override
- protected String[] mustInstalledSoftware()
- {
- ArrayList<String> aList = new ArrayList<String>();
- // aList.add("perl -version");
- return aList.toArray(new String[aList.size()]);
- }
-
- // the test ======================================================================
- public void convert()
- {
- GlobalLogWriter.set(log);
- // check if all need software is installed and accessible
- checkEnvironment(mustInstalledSoftware());
-
- 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");
-
- 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();
- // 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().equalsIgnoreCase("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
- {
- OfficePrint.convertDocument(_sInputFile, _sReferencePath, aGTA);
- }
-
- if (aGTA.restartOffice())
- {
- // Office shutdown
- aProvider.closeExistingOffice(param, true);
- }
- }
-}
-
diff --git a/qadevOOo/runner/convwatch/EnhancedComplexTestCase.java b/qadevOOo/runner/convwatch/EnhancedComplexTestCase.java
deleted file mode 100644
index 52587c62bfe7..000000000000
--- a/qadevOOo/runner/convwatch/EnhancedComplexTestCase.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-package convwatch;
-
-import complexlib.ComplexTestCase;
-import helper.ProcessHandler;
-
-/**
- * Some Helperfunctions which are nice in ReferenceBuilder and ConvWatchTest
- */
-
-public abstract class EnhancedComplexTestCase extends ComplexTestCase
-{
- private void checkExistance(String _sScriptFile, String _sName)
- {
- ProcessHandler aHandler = new ProcessHandler(_sScriptFile);
- 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 accessible.";
- assure(sError, false);
- }
- else
- {
- }
- }
-
-
-
- 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();
- private 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 choice.
- if (sNEEDCHECK == null)
- {
- sNEEDCHECK = "false";
- }
- return sNEEDCHECK.equalsIgnoreCase("yes") ||
- sNEEDCHECK.equalsIgnoreCase("true");
- }
-
-
-
- public GraphicalTestArguments getGraphicalTestArguments()
- {
- GraphicalTestArguments aGTA = new GraphicalTestArguments(param);
- if (aGTA.getImportFilterName() != null && aGTA.getImportFilterName().equalsIgnoreCase("help"))
- {
- aGTA = null;
- }
- if (aGTA.getExportFilterName() != null && aGTA.getExportFilterName().equalsIgnoreCase("help"))
- {
- aGTA = null;
- }
- return aGTA;
- }
-}
diff --git a/qadevOOo/runner/convwatch/FileHelper.java b/qadevOOo/runner/convwatch/FileHelper.java
deleted file mode 100644
index 515fe8ea7365..000000000000
--- a/qadevOOo/runner/convwatch/FileHelper.java
+++ /dev/null
@@ -1,342 +0,0 @@
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-package convwatch;
-
-import java.io.File;
-import java.io.FileFilter;
-import java.util.StringTokenizer;
-import helper.OSHelper;
-
-public class FileHelper
-{
- public FileHelper()
- {
- 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 boolean exists(String _sFile)
- {
- if (_sFile == null) return false;
-
- File aFile = new File(_sFile);
- return aFile.exists();
- }
-
- 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 "";
- }
-
- // creates all directories /tmp/a/b
-
- public static void makeDirectories(String first, String path)
- {
- makeDirectories(first, path, "0777");
- }
-
- private 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();
- //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;
- }
-
- private 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()
- {
- removeFirstDirectorysAndBasenameFrom("/a/b/c/d/e/f.g", "/a/b/c");
- removeFirstDirectorysAndBasenameFrom("/a/b/c/d/e/f.g", "/a/b/c/");
- removeFirstDirectorysAndBasenameFrom("/a/b/c/d/e/f.g", "/b/c");
- }
-
-
- 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();
- String fs = System.getProperty("file.separator");
- String sName = sTmpPath + fs + "DOC_COMPARATOR_DEBUG";
- File aFile = new File(sName);
- if (aFile.exists())
- {
- if (!m_bDebugTextShown)
- {
- 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 = null;
- java.io.FileWriter out = null;
- try
- {
- in = new java.io.FileReader(inputFile);
- try
- {
- out = new java.io.FileWriter(outputFile);
- int c;
-
- while ((c = in.read()) != -1) {
- out.write(c);
- }
-
- }
- finally
- {
- if (out != null)
- out.close();
- }
- }
- finally
- {
- if (in != null)
- in.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
deleted file mode 100644
index ffe462209520..000000000000
--- a/qadevOOo/runner/convwatch/FilenameHelper.java
+++ /dev/null
@@ -1,364 +0,0 @@
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-package convwatch;
-
-import helper.URLHelper;
-import helper.StringHelper;
-
-/**
- * Helper class to hold a Filename or a FileURL
- * Something like File in Java,
- * with some more extensions direct to ConvWatch and its name conventions
- */
-abstract class FilenameHelper_impl
-{
- private String fs; // file separator like '/'
- private String m_sPath;
- private String m_sFilename;
- private String m_sSuffix;
- private int m_nNumber = 0;
-
- public String getNumber()
- {
- return StringHelper.createValueString(m_nNumber, 4);
- }
- public void setNumber(int _n)
- {
- m_nNumber = _n;
- }
- private 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 = _sFilename.replace("\\\\", "/");
-
- 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 = _sPath.replace("\\\\", "/");
-
- 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 = sSystemFilename.replace("/", 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 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 = sSystemPath.replace("/", fs);
- return sSystemPath;
- }
- /**
- * @return true, if current SystemPath is a directory
- */
- public boolean isDirectory()
- {
- return FileHelper.isDir(getSystemPath());
- }
-
-
-
- /**
- * @return the current suffix
- */
- public String getSuffix()
- {
- return m_sSuffix;
- }
- /**
- * @return the complete name. Without convert the path separator!
- */
- private String createAbsoluteFilename()
- {
- return m_sPath + fs + getFilename();
- }
-
- /*
- * remove follows 'file separators'
- */
- private String checkPath(String _sPath)
- {
- String sPath;
- if (_sPath.endsWith("/") || _sPath.endsWith("\\"))
- {
- sPath = _sPath.substring(0, _sPath.length() - 1);
- }
- else
- {
- sPath = _sPath;
- }
- return sPath;
- }
-
- private String checkFilename(String _sFilename)
- {
- String sFilename;
- if (_sFilename.startsWith("/") || _sFilename.startsWith("\\"))
- {
- sFilename = _sFilename.substring(1);
- }
- else
- {
- sFilename = _sFilename;
- }
- return sFilename;
- }
-
- private String checkSuffix(String _sSuffix)
- {
- String sSuffix;
- if (_sSuffix.startsWith("."))
- {
- sSuffix = _sSuffix.substring(1);
- }
- else
- {
- sSuffix = _sSuffix;
- }
- return sSuffix;
- }
-
- private 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();
- return sPath.equals(sPathOther);
- }
-
-}
-
-/**
- * Original filename
- */
-class OriginalFilename extends FilenameHelper_impl
-{
- @Override
- 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
-{
- @Override
- public String getSuffix()
- {
- return "prn";
- }
- @Override
- 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
-{
- @Override
- public String getSuffix()
- {
- return "jpg";
- }
- @Override
- 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
-{
- @Override
- public String getSuffix()
- {
- return "ps";
- }
- @Override
- 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
-{
- @Override
- public String getSuffix()
- {
- return "jpg";
- }
- @Override
- 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());
-
- new OriginalReferenceFilename("/dir1/dir2/", "name",".ext");
- new OriginalReferenceFilename("/dir1/dir2","name.ext","");
- new OriginalReferenceFilename("/dir1/dir2","/name.ext","");
- new OriginalReferenceFilename("/dir1/dir2","/name",".ext");
- new OriginalReferenceFilename("/dir1/dir2","name","ext");
-
- }
-}
diff --git a/qadevOOo/runner/convwatch/GfxCompare.java b/qadevOOo/runner/convwatch/GfxCompare.java
deleted file mode 100644
index b1de0561217e..000000000000
--- a/qadevOOo/runner/convwatch/GfxCompare.java
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-package convwatch;
-
-import java.util.ArrayList;
-import helper.URLHelper;
-import java.io.File;
-
-public class GfxCompare extends EnhancedComplexTestCase
-{
- // The first of the mandatory functions:
-
- // 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.
- */
-
- @Override
- public String[] getTestMethodNames() {
- return new String[]{"gfxcompare"};
- }
-
- /**
- *
- * @return a List of software which must accessible as an external executable
- */
- @Override
- protected String[] mustInstalledSoftware()
- {
- ArrayList<String> aList = new ArrayList<String>();
- // Tools from ImageMagick
- aList.add( "composite -version" );
- aList.add( "identify -version" );
-
- // Ghostscript
- aList.add( "gs -version" );
- return aList.toArray(new String[aList.size()]);
- }
-
-
- 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 accessible
- 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
index aedaf265c940..f77845e56a47 100644
--- a/qadevOOo/runner/convwatch/GlobalLogWriter.java
+++ b/qadevOOo/runner/convwatch/GlobalLogWriter.java
@@ -34,10 +34,5 @@ public class GlobalLogWriter
return m_aGlobalLogWriter;
}
- public static synchronized void set(LogWriter _aLog)
- {
- m_aGlobalLogWriter = _aLog;
- }
-
}
diff --git a/qadevOOo/runner/convwatch/GraphicalDifferenceCheck.java b/qadevOOo/runner/convwatch/GraphicalDifferenceCheck.java
deleted file mode 100644
index f9d1e29edbc4..000000000000
--- a/qadevOOo/runner/convwatch/GraphicalDifferenceCheck.java
+++ /dev/null
@@ -1,339 +0,0 @@
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-package convwatch;
-
-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
- {
- showVersion();
- File aInputPath = new File(_sInputPath);
-
- if (aInputPath.isDirectory())
- {
- String fs = System.getProperty("file.separator");
-
- aInputPath.getAbsolutePath();
-
- 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
- {
- 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.
- */
- 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 _aGTA 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 _aGTA 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).
- *
- * 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 _aGTA 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);
- }
-
- 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 = 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, 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);
- }
-
- GlobalLogWriter.get().println("Saving XComponent as " + resultURL);
-
- return resultURL;
- }
-
-
- private static String getXMLOutputFilterforXComponent(XComponent xComponent, StringBuffer suffix){
- XServiceInfo xSI = 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.length() != 0 && !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
deleted file mode 100644
index 669083bd0778..000000000000
--- a/qadevOOo/runner/convwatch/GraphicalTestArguments.java
+++ /dev/null
@@ -1,682 +0,0 @@
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-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
- */
- private String m_sReferenceType = "OOo";
-
- private String m_sTargetFrameName = "_blank";
-
- private 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
- private boolean m_bHidden = true;
-
- private String m_sDefaultXMLFormatApplication = null;
-
- private boolean m_bIncludeSubdirectories;
-
- private final TestParameters m_aCurrentParams;
-
- private final int m_nMaxPages; // default is 0 (print all pages)
- private final String m_sOnlyPage; // default is "", there is no page which we want to print only.
-
- private int m_nResolutionInDPI = 0;
-
- private boolean m_bStoreFile = true;
- private final boolean m_bResuseOffice;
-
-
-
-
-
- private String m_sDistinct = null;
-
- private boolean m_bCreateDefaultReference = false;
-
- 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
- {
- setReferenceType(sReferenceType);
- }
-
- // PRINTER_NAME ----------
- String sPrinterName = (String)param.get( PropertyName.DOC_COMPARATOR_PRINTER_NAME );
- if (sPrinterName == null || sPrinterName.length() == 0)
- {
- }
- else
- {
- 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 choice.
- if (sRECURSIVE == null)
- {
- sRECURSIVE = "true";
- }
- if (sRECURSIVE.equalsIgnoreCase("no") ||
- sRECURSIVE.equalsIgnoreCase("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)
- {
- m_sImportFilterName = sImportFilterName;
-
- if (sImportFilterName.equalsIgnoreCase("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)
- {
- m_sExportFilterName = sExportFilterName;
- if (sExportFilterName.equalsIgnoreCase("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";
- }
- m_bResuseOffice =
- sREUSE_OFFICE.equalsIgnoreCase("yes") ||
- sREUSE_OFFICE.equalsIgnoreCase("true");
-
-
- 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;
- }
- else if (sWithBorderMove.equalsIgnoreCase("yes") ||
- sWithBorderMove.equalsIgnoreCase("true"))
- {
- m_tWithBorderMove = TriState.TRUE;
- }
- else if (sWithBorderMove.equalsIgnoreCase("no") ||
- sWithBorderMove.equalsIgnoreCase("false"))
- {
- m_tWithBorderMove = TriState.FALSE;
- }
- else
- {
- m_tWithBorderMove = TriState.FALSE;
- // m_tWithBorderMove = TriState.UNSET;
- }
-
- 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.equalsIgnoreCase("yes") ||
- sOfficeViewable.equalsIgnoreCase("true"))
- {
- setViewable();
- }
- else
- {
- setHidden();
- }
- }
- // CREATE_DEFAULT
- String sCreateDefault = (String)param.get(PropertyName.CREATE_DEFAULT);
- if (sCreateDefault != null)
- {
- m_bCreateDefaultReference =
- sCreateDefault.equalsIgnoreCase("yes") ||
- sCreateDefault.equalsIgnoreCase("true");
- }
-
- }
-
- public boolean checkIfUsableDocumentType(String _sName)
- {
- // @todo
- // check if the name is in the leave out list and then return 'false'
- return !(_sName.toLowerCase().endsWith(".jpg") ||
- _sName.toLowerCase().endsWith(".png") ||
- _sName.toLowerCase().endsWith(".gif") ||
- _sName.toLowerCase().endsWith(".bmp") ||
- _sName.toLowerCase().endsWith(".prn") ||
- _sName.toLowerCase().endsWith(".ps"));
- }
-
- private static void showInternalFilterName(String _sFilterName, XMultiServiceFactory _xMSF)
- {
- if (_sFilterName.length() == 0)
- {
- return;
- }
-
- if (_xMSF == null)
- {
- GlobalLogWriter.get().println("MultiServiceFactory not set.");
- return;
- }
- 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 = UnoRuntime.queryInterface(XNameAccess.class, aObj);
- if (aNameAccess != null)
- {
-
- if (_sFilterName.equalsIgnoreCase("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]);
- }
- }
- }
- }
- }
-
- // set methods
- private 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;}
- private void setPrinterName(String _sName) {m_sPrinterName = _sName;}
- private void setHidden() { m_bHidden = true;}
- private void setViewable() {m_bHidden = false;}
- private void setDefaultXMLFormatApp(String _sNameOfApp) {m_sDefaultXMLFormatApplication = _sNameOfApp;}
-
- // get methods
- public XMultiServiceFactory getMultiServiceFactory()
- {
- XMultiServiceFactory xMSF = m_aCurrentParams.getMSF();
-
- // check if MultiServiceFactory is given
- if (getReferenceType().equalsIgnoreCase("pdf") ||
- getReferenceType().equalsIgnoreCase("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()
- {
- return !((getMaxPages() > 0) || (getOnlyPages().length() != 0));
- }
-
- /**
- * @return integer value, which contain resolution in DPI.
- */
- public int getResolutionInDPI() {return m_nResolutionInDPI;}
-
- private 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
-
- private String m_sImportFilterName = "";
- private 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;
- }
-
- private String m_sOfficeProgram = "";
- public void setOfficeProgram(String _sName)
- {
- m_sOfficeProgram = _sName;
- }
- public String getOfficeProgram()
- {
- return m_sOfficeProgram;
- }
-
- public boolean restartOffice()
- {
- return !m_bResuseOffice;
- }
-
- private String m_sHTMLOutputPrefix = "";
- public String getHTMLOutputPrefix()
- {
- return m_sHTMLOutputPrefix;
- }
-
- private TriState m_tWithBorderMove = TriState.UNSET;
- public TriState getBorderMove()
- {
- return m_tWithBorderMove;
- }
- public void setBorderMove(TriState _tBorderMove)
- {
- m_tWithBorderMove = _tBorderMove;
- }
-
- private String m_sDocumentType = "";
- public void setDocumentType(String _sName)
- {
- m_sDocumentType = _sName;
- }
- public String getDocumentType()
- {
- return m_sDocumentType;
- }
-
- /*
- helper class for performance analyser features
- */
- private 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
deleted file mode 100644
index 9f5b650ea757..000000000000
--- a/qadevOOo/runner/convwatch/HTMLOutputter.java
+++ /dev/null
@@ -1,178 +0,0 @@
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-package convwatch;
-
-import java.io.File;
-import java.io.FileWriter;
-import helper.OSHelper;
-
-public class HTMLOutputter {
- private FileWriter m_aOut;
- private String m_sFilename;
-
- /**
- * ls is the current line separator (carridge return)
- */
- private String ls;
-
- HTMLOutputter() {
- }
-
- public static HTMLOutputter create(String _sOutputPath,
- String _sHTMLFilename) {
- 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;
- 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) {
- }
- }
-
- private final static String TEST_TABLETITLE = "Test";
- private final static String VISUAL_STATUS_TABLETITLE = "Visual status";
- private 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) {
- }
- }
-
- private String getHREF(String _sHREF, String _sPathInfo) {
- StringBuffer a = new StringBuffer();
- if (!OSHelper.isWindows()) {
- a.append("<A HREF=\"");
- a.append(_sHREF);
- a.append("\">");
- a.append(_sPathInfo);
- a.append("</A>");
- } else {
- // ! 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("</A>");
-
- }
- return a.toString();
- }
-
- private String tableDataCell(String _sValue) {
- StringBuffer a = new StringBuffer();
- a.append("<TD>");
- a.append(_sValue);
- a.append("</TD>");
- return a.toString();
- }
-
- private String tableHeaderCell(String _sValue) {
- StringBuffer a = new StringBuffer();
- a.append("<TH>");
- a.append(_sValue);
- a.append("</TH>");
- return a.toString();
- }
-
- public void indexLine(String _sHTMLFile, String _sHTMLName,
- String _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) {
- }
- }
-
- private String stronghtml(String _sValue) {
- StringBuffer a = new StringBuffer();
- a.append("<STRONG>");
- a.append(_sValue);
- a.append("</STRONG>");
- return a.toString();
- }
-
- private final static String FIRSTGFX_TABLETITLE = "Original print file as jpeg";
-
-}
diff --git a/qadevOOo/runner/convwatch/INIOutputter.java b/qadevOOo/runner/convwatch/INIOutputter.java
deleted file mode 100644
index 63a6eecd8335..000000000000
--- a/qadevOOo/runner/convwatch/INIOutputter.java
+++ /dev/null
@@ -1,190 +0,0 @@
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-package convwatch;
-
-import java.io.File;
-import java.io.FileWriter;
-
-public class INIOutputter
-{
- private FileWriter m_aOut;
- private String m_sFilename;
-
-
- /**
- * ls is the current line separator (carriage return)
- */
- private String ls;
-
- public static INIOutputter create( String _sOutputPath, String _sHTMLFilename )
- {
- 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;
-
- 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 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 = _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 = _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)
- {
- }
- }
-
- private 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 = _aStatus.nPercent + "%";
- 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
deleted file mode 100644
index 5723c3fc85fb..000000000000
--- a/qadevOOo/runner/convwatch/ImageHelper.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-package convwatch;
-
-import java.awt.Image;
-import java.awt.image.PixelGrabber;
-import java.awt.image.ImageObserver;
-import java.io.File;
-import java.lang.reflect.Method;
-
-class ImageHelper
-{
- private final Image m_aImage;
- private final int[] m_aPixels;
- private final int m_w;
-
-
- private ImageHelper(Image _aImage)
- {
- m_aImage = _aImage;
-
- // grab all (consume much memory)
- m_w = getWidth();
- int h = getHeight();
- int x = 0;
- int y = 0;
- m_aPixels = new int[m_w * h];
- PixelGrabber pg = new PixelGrabber(m_aImage, x, y, m_w, 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;
- }
- }
- 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];
- }
-
- 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());
- }
- return new ImageHelper(aImage);
- }
-}
diff --git a/qadevOOo/runner/convwatch/IniFile.java b/qadevOOo/runner/convwatch/IniFile.java
deleted file mode 100644
index ddab207d1769..000000000000
--- a/qadevOOo/runner/convwatch/IniFile.java
+++ /dev/null
@@ -1,238 +0,0 @@
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-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.
- */
- private final String m_sFilename;
- private final ArrayList<String> m_aList;
-
- /**
- open a ini file by its 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();
- }
-
- private ArrayList<String> loadLines()
- {
- File aFile = new File(m_sFilename);
- ArrayList<String> aLines = new ArrayList<String>();
- if (! aFile.exists())
- {
- GlobalLogWriter.get().println("couldn't find file " + m_sFilename);
- 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());
- }
- catch (java.io.IOException ie)
- {
- GlobalLogWriter.get().println("Exception occurs while reading from file " + m_sFilename);
- GlobalLogWriter.get().println("Message: " + 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());
- }
- return aLines;
- }
-
- /**
- * @return true, if the ini file contain some readable data
- */
- public boolean is()
- {
- return m_aList.size() > 1;
- }
-
-
-
- private boolean isRemark(String _sLine)
- {
- return _sLine.length() < 2 ||
- _sLine.startsWith("#") ||
- _sLine.startsWith(";");
- }
-
- private String getItem(int i)
- {
- return m_aList.get(i);
- }
-
- private String buildSectionName(String _sSectionName)
- {
- String sFindSection = "[" + _sSectionName + "]";
- return sFindSection;
- }
- private String toLowerIfNeed(String _sName)
- {
- return _sName.toLowerCase();
- }
-
- // return the number where this section starts
- private int findSection(String _sSection)
- {
- String sFindSection = toLowerIfNeed(buildSectionName(_sSection));
- // ----------- find _sSection ---------------
- int i;
- for (i=0; i<m_aList.size();i++)
- {
- String sLine = toLowerIfNeed(getItem(i).trim());
- if (isRemark(sLine))
- {
- continue;
- }
- if (sFindSection.equals("[]"))
- {
- // special case, empty Section.
- return i - 1;
- }
- if (sLine.startsWith(sFindSection))
- {
- return i;
- }
- }
- return -1;
- }
-
- // return the line number, where the key is found.
- private int findKey(String _sSection, String _sKey)
- {
- int i = findSection(_sSection);
- if (i == -1)
- {
- // Section not found, therefore the value can't exist
- return -1;
- }
- return findKeyFromKnownSection(i, _sKey);
- }
-
- // i must be the index in the list, where the well known section starts
- private int findKeyFromKnownSection(int _nSectionIndex, String _sKey)
- {
- _sKey = toLowerIfNeed(_sKey);
- for (int j=_nSectionIndex + 1; j<m_aList.size();j++)
- {
- String sLine = getItem(j).trim();
-
- if (isRemark(sLine))
- {
- continue;
- }
-
- if (sLine.startsWith("["))
- {
- // 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;
- }
-
- private String getValue(int _nIndex)
- {
- String sLine = getItem(_nIndex).trim();
- if (isRemark(sLine))
- {
- return "";
- }
- int nEqual = sLine.indexOf('=');
- if (nEqual >= 0)
- {
- 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;
- }
-
-
-
-
-
-
-
-}
diff --git a/qadevOOo/runner/convwatch/LISTOutputter.java b/qadevOOo/runner/convwatch/LISTOutputter.java
deleted file mode 100644
index 175b32d3b2a6..000000000000
--- a/qadevOOo/runner/convwatch/LISTOutputter.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-package convwatch;
-
-import java.io.File;
-import java.io.FileWriter;
-
-public class LISTOutputter
-{
- private FileWriter m_aOut;
- private String m_sFilename;
-
- /**
- * ls is the current line separator (carridge return)
- */
- private 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 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
deleted file mode 100644
index e6235bed9716..000000000000
--- a/qadevOOo/runner/convwatch/MSOfficePrint.java
+++ /dev/null
@@ -1,867 +0,0 @@
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-package convwatch;
-
-import java.io.File;
-import java.io.FileWriter;
-import java.io.RandomAccessFile;
-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<String> m_aArray;
-}
-
-public class MSOfficePrint
-{
- private String m_sPrinterName; // within Windows the tools need a printer name;
-
- private void setPrinterName(String _s) {m_sPrinterName = _s;}
-
-
- private static boolean isWordDocument(String _sSuffix)
- {
- return _sSuffix.toLowerCase().endsWith(".doc") ||
- _sSuffix.toLowerCase().endsWith(".rtf") ||
- _sSuffix.toLowerCase().endsWith(".dot");
- }
-
- private 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;
- }
-
- private static boolean isPowerPointDocument(String _sSuffix)
- {
- return _sSuffix.toLowerCase().endsWith(".pps") ||
- _sSuffix.toLowerCase().endsWith(".ppt");
- }
-
- /**
- * 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<String> aStartCommand = new ArrayList<String>();
- if (isWordDocument(sDocumentSuffix))
- {
- aStartCommand = createWordStoreHelper();
- }
- else if (isExcelDocument(sDocumentSuffix))
- {
- aStartCommand = createExcelStoreHelper();
- }
- else if (isPowerPointDocument(sDocumentSuffix))
- {
- }
- else if (sDocumentSuffix.equalsIgnoreCase(".xml"))
- {
- // special case, if xml we prefer word, but with DEFAULT_XML_FORMAT_APP=excel it's changeable.
- if (_aGTA.getDefaultXMLFormatApp().equalsIgnoreCase("excel"))
- {
- aStartCommand = createExcelStoreHelper();
- }
- }
- 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";
- }
-
- 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<String> aStartCommand = new ArrayList<String>();
- if (isWordDocument(sDocumentSuffix))
- {
- aStartCommand = createWordPrintHelper();
- }
- else if (isExcelDocument(sDocumentSuffix))
- {
- aStartCommand = createExcelPrintHelper();
- }
- else if (isPowerPointDocument(sDocumentSuffix))
- {
- aStartCommand = createPowerPointPrintHelper();
- }
- else if (sDocumentSuffix.equalsIgnoreCase(".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 (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())
- {
- String sPrinterName = m_sPrinterName;
- if (sPrinterName == null)
- {
- sPrinterName = "";
- }
-
- 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.");
- }
-
- private void realStartCommand(ArrayList<String> _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 = _aStartCommand.get(i);
- if (aStr == null)
- {
- aStr = "";
- }
- if (aStr.length() == 0)
- {
- aStr = "\"\"";
- }
- aList[i] = 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 don't work within windows environment.");
- }
-
-
- ProcessHandler aHandler = new ProcessHandler(aList);
- aHandler.executeSynchronously();
- }
- catch (IndexOutOfBoundsException e)
- {
- throw new ConvWatchCancelException/*WrongEnvironmentException*/("Given list is too short.", e);
- }
-
- // return aHandler.getExitCode();
- }
-
-
- private ArrayList<String> createWordPrintHelper() throws java.io.IOException
- {
- // create a program in tmp file
- String sTmpPath = util.utils.getUsersTempDir();
- String ls = System.getProperty("line.separator");
- String fs = System.getProperty("file.separator");
-
- String sPrintViaWord = "printViaWord.pl";
-
- ArrayList<String> aList = searchLocalFile(sPrintViaWord);
- if (!aList.isEmpty())
- {
- return aList;
- }
-
- String sName = sTmpPath + fs + sPrintViaWord;
- File aFile = new File(sName);
- FileWriter out = null;
- try
- {
- 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 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);
- }
- finally
- {
- if (out != null)
- out.close();
- }
-
- aList.add("perl");
- aList.add(sName);
- return aList;
- }
-
- // TODO: Maybe give a possibility to say where search the script from outside
-
- private ArrayList<String> searchLocalFile(String _sScriptName)
- {
- String userdir = System.getProperty("user.dir");
- String fs = System.getProperty("file.separator");
-
- ArrayList<String> aList = new ArrayList<String>();
- File aPerlScript = new File(userdir + fs + _sScriptName);
- if (FileHelper.isDebugEnabled())
- {
- GlobalLogWriter.get().println("Search for local existence 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();
- aList.add("perl");
- aList.add(sName);
- return aList;
- }
- return aList;
- }
-
- private ArrayList<String> createWordStoreHelper() throws java.io.IOException
- {
- // create a program in tmp file
- String sTmpPath = util.utils.getUsersTempDir();
- String ls = System.getProperty("line.separator");
- String fs = System.getProperty("file.separator");
-
- String sSaveViaWord = "saveViaWord.pl";
-
- ArrayList<String> aList = searchLocalFile(sSaveViaWord);
- if (!aList.isEmpty())
- {
- 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 = null;
- try
- {
- 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 );
- }
- finally
- {
- if (out != null)
- out.close();
- }
-
- aList.add("perl");
- aList.add(sName);
- return aList;
- }
-
-
- private ArrayList<String> createExcelPrintHelper() throws java.io.IOException
- {
- // create a program in tmp file
- String sTmpPath = util.utils.getUsersTempDir();
- String ls = System.getProperty("line.separator");
- String fs = System.getProperty("file.separator");
-
- String sPrintViaExcel = "printViaExcel.pl";
-
- ArrayList<String> aList = searchLocalFile(sPrintViaExcel);
- if (!aList.isEmpty())
- {
- 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 = null;
- try
- {
- 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 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( " close(FILE);" + ls);
- out.write( "}" + ls);
- }
- finally
- {
- if (out != null)
- out.close();
- }
-
- aList.add("perl");
- aList.add(sName);
- return aList;
- }
-
- private ArrayList<String> createExcelStoreHelper() throws java.io.IOException
- {
- // create a program in tmp file
- String sTmpPath = util.utils.getUsersTempDir();
- String ls = System.getProperty("line.separator");
- String fs = System.getProperty("file.separator");
-
- String sSaveViaExcel = "saveViaExcel.pl";
-
- ArrayList<String> aList = searchLocalFile(sSaveViaExcel);
- if (!aList.isEmpty())
- {
- 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 = null;
- try
- {
- 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 );
- }
- finally
- {
- if (out != null)
- out.close();
- }
-
- aList.add("perl");
- aList.add(sName);
- return aList;
- }
-
- private ArrayList<String> createPowerPointPrintHelper() throws java.io.IOException
- {
- // create a program in tmp file
- String sTmpPath = util.utils.getUsersTempDir();
- String ls = System.getProperty("line.separator");
- String fs = System.getProperty("file.separator");
-
- String sPrintViaPowerPoint = "printViaPowerPoint.pl";
-
- ArrayList<String> aList = searchLocalFile(sPrintViaPowerPoint);
- if (!aList.isEmpty())
- {
- 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 = null;
- try
- {
- 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 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( " close(FILE);" + ls);
- out.write( "}" + ls);
- }
- finally
- {
- if (out != null)
- 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
- */
- private 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
deleted file mode 100644
index cade9b55360f..000000000000
--- a/qadevOOo/runner/convwatch/NameHelper.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-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/OfficePrint.java b/qadevOOo/runner/convwatch/OfficePrint.java
deleted file mode 100644
index ada4cb917e91..000000000000
--- a/qadevOOo/runner/convwatch/OfficePrint.java
+++ /dev/null
@@ -1,1162 +0,0 @@
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-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;
-
-/**
- * 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 {
-
-
- 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
- */
- private 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];
- if (aValue.Name.equals("FilterName") ||
- aValue.Name.equals("MediaType"))
- {
- String sNameValue = "'" + aValue.Name + "' := '" + aValue.Value + "'";
- return sNameValue;
- }
- }
- return "";
- }
-
- private 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.
- */
- private 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.");
-
-
- // 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>();
-
- // 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");
-
- XComponentLoader aCompLoader = UnoRuntime.queryInterface( XComponentLoader.class, aDesktop);
-
- _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 occurs.FAILED
- GlobalLogWriter.get().println("UNO Exception caught.");
- GlobalLogWriter.get().println("Message: " + e.getMessage());
- e.printStackTrace();
- }
- return aDoc;
- }
-
- private 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;
- }
-
- private 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;
- }
-
-
-
- private 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;
- }
-
- private 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.
- *
- * @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 existence of _sPrintFileURL
- */
-
- private static boolean printToFileWithOOo(GraphicalTestArguments _aGTA,
- String _sInputURL,
- String _sOutputURL,
- String _sPrintFileURL)
- {
- 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;
- }
-
-
- private 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 = "";
-
- FileWriter out = null;
- try
- {
- try
- {
- 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);
- }
- out.write(ls);
- out.write("# resolution given in DPI" + ls);
- out.write("resolution=" + _aGTA.getResolutionInDPI() + ls);
- }
- else
- {
- out.write("buildid=" + _sSpecial + 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();
- }
- finally
- {
- if (out != null)
- 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 occurs.FAILED
- GlobalLogWriter.get().println("UNO Exception caught.");
- GlobalLogWriter.get().println("Message: " + e.getMessage());
-
- e.printStackTrace();
- bBack = false;
- }
-
- try
- {
-
- // Change Pagesettings to DIN A4
-
- GlobalLogWriter.get().println(DateHelper.getDateTimeForHumanreadableLog() + " Print document.");
- XPrintable aPrintable = UnoRuntime.queryInterface( XPrintable.class, _aDoc);
- if (aPrintable != null)
- {
- // configure Office to allow to execute macos
-
-// TODO: We need a possibility to set the printer name also for StarOffice/OpenOffice
- if (OSHelper.isWindows())
- {
- if (_aGTA.getPrinterName() != null)
- {
- ArrayList<PropertyValue> aPropertyList = new ArrayList<PropertyValue>();
- PropertyValue Arg = new PropertyValue();
- Arg.Name = "Name";
- Arg.Value = _aGTA.getPrinterName();
- aPropertyList.add(Arg);
- showProperty(Arg);
- aPrintable.setPrinter(PropertyHelper.createPropertyValueArrayFormArrayList(aPropertyList));
- }
- }
-
- // set property values for XPrintable.print()
- // more can be found at "http://api.libreoffice.org/docs/common/ref/com/sun/star/view/PrintOptions.html"
-
- // 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", Boolean.TRUE );
- GlobalLogWriter.get().println("PrintAllSheets := true");
- }
- }
-
- ArrayList<PropertyValue> aPrintProps = new ArrayList<PropertyValue>();
-
- PropertyValue Arg = new PropertyValue();
- Arg.Name = "FileName";
- Arg.Value = _sPrintFileURL;
- aPrintProps.add(Arg);
- showProperty(Arg);
-
- if (!_aGTA.printAllPages())
- {
- String sPages = "";
- if (_aGTA.getMaxPages() > 0)
- {
- sPages = "1-" + _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);
- }
-
- _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))
- {
- nPropIndex++;
- }
- isBusy = aPrinterProps[nPropIndex].Value.equals(Boolean.TRUE);
- 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 occurs.FAILED
- GlobalLogWriter.get().println("UNO Exception caught.");
- GlobalLogWriter.get().println("Message: " + e.getMessage());
-
- e.printStackTrace();
- bBack = false;
- }
-
- if (bFailed)
- {
- GlobalLogWriter.get().println("convwatch.OfficePrint: FAILED");
- }
- else
- {
- GlobalLogWriter.get().println("convwatch.OfficePrint: OK");
- }
- return bBack;
- }
-
-
- /**
- * @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))
- {
- return false;
- }
-
- String fs = System.getProperty("file.separator");
-
- String sInputFileBasename = FileHelper.getBasename(_sAbsoluteInputFile);
- String sOutputPath;
- if (_sAbsoluteOutputPath != null)
- {
- sOutputPath = _sAbsoluteOutputPath;
- }
- else
- {
- String sInputPath = FileHelper.getPath(_sAbsoluteInputFile);
- sOutputPath = sInputPath;
- }
-
- String sPrintFilename = FileHelper.getNameNoSuffix(sInputFileBasename);
-
- String sAbsolutePrintFilename = sOutputPath + fs + sPrintFilename + ".prn";
- if (FileHelper.exists(sAbsolutePrintFilename) && !_aGTA.getOverwrite())
- {
- 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
- */
- 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;
- }
-
- String sPrintFilename = FileHelper.getNameNoSuffix(sInputFileBasename);
- String sPrintFileURL;
-
- String sAbsolutePrintFilename = sOutputPath + fs + sPrintFilename + ".prn";
- if (FileHelper.exists(sAbsolutePrintFilename) && !_aGTA.getOverwrite())
- {
- GlobalLogWriter.get().println("Reference already exist, don't overwrite. Set " + PropertyName.DOC_COMPARATOR_OVERWRITE_REFERENCE + "=true to force overwrite.");
- return true;
- }
-
- if (_aGTA.getReferenceType().equalsIgnoreCase("msoffice"))
- {
- sPrintFileURL = URLHelper.getFileURLFromSystemPath(sAbsolutePrintFilename);
- }
- else if (_aGTA.getReferenceType().equalsIgnoreCase("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().equalsIgnoreCase("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;
- // 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;
- }
-
-
- if (_aGTA.getReferenceType().equalsIgnoreCase("ooo"))
- {
- bBack = printToFileWithOOo(_aGTA, _sInputFileURL, _sOutputFileURL, _sPrintFileURL);
- }
- else if (_aGTA.getReferenceType().equalsIgnoreCase("pdf"))
- {
- GlobalLogWriter.get().println("USE PDF AS EXPORT FORMAT.");
- bBack = storeAsPDF(_aGTA, _sInputFileURL, _sPrintFileURL);
- }
- else if (_aGTA.getReferenceType().equalsIgnoreCase("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)
- {
- GlobalLogWriter.get().println(e.getMessage());
- throw new ConvWatchCancelException("Exception caught. Problem with MSOffice printer methods.", e);
- }
- catch(java.io.IOException e)
- {
- GlobalLogWriter.get().println(e.getMessage());
- throw new ConvWatchCancelException("IOException caught. Problem with MSOffice printer methods.", e);
- }
- 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
- {
- throw new ConvWatchCancelException("OfficePrint.printToFile(): Unknown print type.");
- }
- return bBack;
- }
-
-
- // TODO: move this away!
-
-
-
-
-
- private static String getInternalFilterName(String _sFilterName, XMultiServiceFactory _xMSF)
- {
- if (_sFilterName.length() == 0)
- {
- return null;
- }
-
- if (_xMSF == null)
- {
- GlobalLogWriter.get().println("MultiServiceFactory not set.");
- return null;
- }
- Object aObj = null;
- try
- {
- aObj = _xMSF.createInstance("com.sun.star.document.FilterFactory");
- }
- catch(com.sun.star.uno.Exception e)
- {
- GlobalLogWriter.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;
- try
- {
- aElements = (Object[]) aNameAccess.getByName(_sFilterName);
- if (aElements != null)
- {
- String sInternalFilterName = null;
- for (int i=0;i<aElements.length; i++)
- {
- PropertyValue aPropertyValue = (PropertyValue)aElements[i];
- if (aPropertyValue.Name.equals("Type"))
- {
- String sValue = (String)aPropertyValue.Value;
- sInternalFilterName = sValue;
- }
- }
- return sInternalFilterName;
- }
- else
- {
- GlobalLogWriter.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;
- }
-
-
-
- private static String getServiceNameFromFilterName(String _sFilterName, XMultiServiceFactory _xMSF)
- {
- if (_sFilterName.length() == 0)
- {
- 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;
- try
- {
- aElements = (Object[]) aNameAccess.getByName(_sFilterName);
- if (aElements != null)
- {
- String sServiceName = null;
- for (int i=0;i<aElements.length; i++)
- {
- PropertyValue aPropertyValue = (PropertyValue)aElements[i];
- if (aPropertyValue.Name.equals("DocumentService"))
- {
- String sValue = (String)aPropertyValue.Value;
- sServiceName = sValue;
- break;
- }
- }
- return sServiceName;
- }
- else
- {
- GlobalLogWriter.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;
- }
-
-
- private static String getFileExtension(String _sInternalFilterName, XMultiServiceFactory _xMSF)
- {
- if (_sInternalFilterName.length() == 0)
- {
- 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)
- {
-
- 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;
- for (int i=0;i<aElements.length; i++)
- {
- PropertyValue aPropertyValue = (PropertyValue)aElements[i];
- 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)
- {
- XMultiServiceFactory xMSF = _aGTA.getMultiServiceFactory();
- if (xMSF == null)
- {
- GlobalLogWriter.get().println("MultiServiceFactory in GraphicalTestArgument not set.");
- return;
- }
-
- String sInputURL = URLHelper.getFileURLFromSystemPath(_sInputFile);
- 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 );
-
- // 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();
-
- 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)
- {
- 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;
- 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);
- String sInputFileNameNoSuffix = FileHelper.getNameNoSuffix(sInputFileBasename);
- 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())
- {
- 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
deleted file mode 100644
index 1dac4c8eed97..000000000000
--- a/qadevOOo/runner/convwatch/PRNCompare.java
+++ /dev/null
@@ -1,504 +0,0 @@
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-package convwatch;
-
-
-import helper.ProcessHandler;
-import java.io.File;
-import helper.OSHelper;
-import helper.StringHelper;
-import java.util.ArrayList;
-
-
-// --------------------------------- PRNCompare ---------------------------------
-
-public class PRNCompare
-{
- private final String fs;
-
- public PRNCompare()
- {
- fs = System.getProperty("file.separator");
- }
-
- private int getMaxNumOfFileEntry(String _sDirectory, String _sBasename)
- {
-// TODO: check if directory exist should be done earlier
- File aDirectory = new File(_sDirectory);
- File[] aDirList = aDirectory.listFiles(
- );
-
- 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))
- {
- int nJpgIdx = sDirEntry.lastIndexOf(".jpg");
- String sValue = sDirEntry.substring(_sBasename.length(), nJpgIdx);
- int nValue = 0;
- try
- {
- nValue = Integer.parseInt(sValue);
- }
- catch(java.lang.NumberFormatException e)
- {
- }
-
- nNum = nValue;
- }
-
- if (nNum > nMaxNumber)
- {
- nMaxNumber = nNum;
- }
- }
- }
- return nMaxNumber;
- }
-
-
- private String m_sReferencePath;
- private String m_sOutputPath;
-
- private String m_sReferenceFile;
- private String m_sPostScriptFile;
- private int m_nMaxPages = 0;
- private int m_nResolutionInDPI = 0;
- private TriState m_tUseBorderMove;
- private String m_sDocumentType;
-
- public void setReferencePath(String _sReferencePath) { m_sReferencePath = _sReferencePath; }
-
- public void setOutputPath(String _sOutPath) { m_sOutputPath = _sOutPath; }
-
- 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 setMaxPages(int _n) {m_nMaxPages = _n;}
- private int getMaxPages() {return m_nMaxPages;}
-
- public void setResolutionInDPI(int _n) {m_nResolutionInDPI = _n;}
- private 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;
- }
-
-
-
- private 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";
-
- 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 sGS = "gs";
- if (OSHelper.isWindows())
- {
- sGS = "gswin32c.exe";
- }
-
- String[] sCommandArray =
- {
- sGS,
- "-dNOPROMPT",
- "-dBATCH",
- "-sDEVICE=jpeg",
- "-r" + _nResolutionInDPI,
- "-dNOPAUSE",
- "-sOutputFile=" + sJPGFilename,
- sOriginalFile
- };
-
- ProcessHandler aHandler = new ProcessHandler(sCommandArray);
- 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<String> aFileList = new ArrayList<String>();
- for (int i=1;i<9999;i++)
- {
- String sNewJPEGFilename = sJPGFilename.replace(sGS_PageOutput, StringHelper.createValueString(i, 4));
- if (FileHelper.exists(sNewJPEGFilename))
- {
- aFileList.add(sNewJPEGFilename); // as long as the files exist, fill the array
- }
- else
- {
- break; // stop file check
- }
- }
- String[] aList = new String[aFileList.size()];
- aList = 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
- */
- private 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);
-
- // 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
-
- 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 (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;
-
-// 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 (sDiff_BM_Gfx.length() > 0)
- {
- nResult = identify(sDiff_BM_Gfx);
- if (nResult == 1)
- {
- aStatus.nDiffStatus = StatusHelper.DIFF_AFTER_MOVE_DONE_NO_PROBLEMS;
- aStatus.nPercent2 = 0;
- }
- else
- {
- nPercent = estimateGfx(sOld_BM_Gfx, sNew_BM_Gfx, sDiff_BM_Gfx);
- aStatus.nDiffStatus = StatusHelper.DIFF_AFTER_MOVE_DONE_DIFFERENCES_FOUND;
- aStatus.nPercent2 = nPercent;
- }
- }
- else
- {
- }
- }
- catch(java.io.IOException e)
- {
- GlobalLogWriter.get().println("Exception caught. At border remove: " + e.getMessage());
- }
- }
-
-
- }
- catch (java.io.IOException e)
- {
- GlobalLogWriter.get().println(e.getMessage());
- }
- }
-
- }
- aList[nStatusIndex ++] = aStatus;
- }
- return aList;
- }
-
-
- public static String compareJPEGs(String _sOldGfx, String _sNewGfx)
- {
- String sBasename1 = FileHelper.getBasename(_sOldGfx);
- 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);
- }
-
- private static String compareJPEGs(String _sOldGfx, String _sNewGfx, String _sDiffGfx)
- {
- String sComposite = "composite";
- if (OSHelper.isWindows())
- {
- sComposite = "composite.exe";
- }
-
- String[] sCommandArray =
- {
- sComposite,
- "-compose",
- "difference",
- _sOldGfx,
- _sNewGfx,
- _sDiffGfx
- };
-
- ProcessHandler aHandler = new ProcessHandler(sCommandArray);
- aHandler.executeSynchronously();
-
- String sBack = aHandler.getOutputText();
- GlobalLogWriter.get().println("'" + sBack + "'");
-
- 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.
- */
- private 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";
-
- String sIdentify = "identify";
- if (OSHelper.isWindows())
- {
- sIdentify = "identify.exe";
- }
-
- String[] sCommandArray =
- {
- sIdentify,
- "-format",
- sIM_Format,
- _sDiffGfx
- };
- ProcessHandler aHandler = new ProcessHandler(sCommandArray);
- 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.parseInt(sBack);
- }
- 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);
-
- 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;
- }
- }
- }
- 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 than 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.
- *
- */
- private 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:" + nPercent + "% pixel differ ");
- return nPercent;
- }
-
-}
diff --git a/qadevOOo/runner/convwatch/PerformanceContainer.java b/qadevOOo/runner/convwatch/PerformanceContainer.java
deleted file mode 100644
index 2f32bdeaeb06..000000000000
--- a/qadevOOo/runner/convwatch/PerformanceContainer.java
+++ /dev/null
@@ -1,221 +0,0 @@
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-package convwatch;
-
-import java.io.File;
-import java.io.FileWriter;
-import java.io.RandomAccessFile;
-
-public class PerformanceContainer {
- /*
- simple helper functions to start/stop a timer, to know how long a process need in milliseconds
- */
- private long getStartTime()
- {
- return System.currentTimeMillis();
- }
- public void setStartTime(long _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=" + (m_nTime[ Load ]) + ls);
- out.write("storetime=" + (m_nTime[ Store ]) + ls);
- out.write("printtime=" + (m_nTime[ Print ]) + ls);
- out.write("officestarttime=" + (m_nTime[ OfficeStart ]) + ls);
- out.write("storeaspdftime=" + (m_nTime[ StoreAsPDF ]) + ls);
- }
-
- private 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;
- }
-
- private 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());
- }
- }
-
-}
diff --git a/qadevOOo/runner/convwatch/PixelCounter.java b/qadevOOo/runner/convwatch/PixelCounter.java
deleted file mode 100644
index 5a8f805db2fe..000000000000
--- a/qadevOOo/runner/convwatch/PixelCounter.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-package convwatch;
-
-abstract class CountPixel
-{
- int m_nCount = 0;
- public int getCount() {return m_nCount;}
- public abstract void count(int _nRGB);
-}
-
-
-class CountNotWhite extends CountPixel
-{
- @Override
- public void count(int pixel)
- {
- int red = (pixel >> 16) & 0xff;
- int green = (pixel >> 8) & 0xff;
- int blue = (pixel ) & 0xff;
-
- if (red == 0xff && green == 0xff && blue == 0xff)
- {
- return;
- }
- m_nCount++;
- }
-}
-
-
-class CountNotBlack extends CountPixel
-{
- @Override
- public void count(int pixel)
- {
- 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
-{
-
-
- private static void countPixel(ImageHelper img, int _w, int _h, CountPixel _aPixelCounter)
- {
- for (int y = 0; y < _h; y++) {
- for (int x = 0; x < _w; x++) {
- _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, 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, w, h, aCountNotBlack);
- return aCountNotBlack.getCount();
- }
-}
-
-
-
-public class PixelCounter {
- private ImageHelper m_aImage;
-
-
- private int countNotWhitePixel(String _sFile)
- throws java.io.IOException
- {
- m_aImage = ImageHelper.createImageHelper(_sFile);
- int nw = graphics_stuff.countNotWhitePixel(m_aImage);
- return nw;
- }
-
- private 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);
- }
-
-
-
-}
-
-
diff --git a/qadevOOo/runner/convwatch/PropertyName.java b/qadevOOo/runner/convwatch/PropertyName.java
deleted file mode 100644
index 88269954c977..000000000000
--- a/qadevOOo/runner/convwatch/PropertyName.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-package convwatch;
-
-public interface PropertyName
-{
- String DOC_COMPARATOR_INPUT_PATH = "DOC_COMPARATOR_INPUT_PATH";
- String DOC_COMPARATOR_OUTPUT_PATH = "DOC_COMPARATOR_OUTPUT_PATH";
- String DOC_COMPARATOR_DIFF_PATH = "DOC_COMPARATOR_DIFF_PATH";
- String DOC_COMPARATOR_REFERENCE_PATH = "DOC_COMPARATOR_REFERENCE_PATH";
- String DOC_COMPARATOR_REFERENCE_INPUT_PATH = "DOC_COMPARATOR_REFERENCE_INPUT_PATH";
- String DOC_COMPARATOR_REFERENCE_TYPE = "DOC_COMPARATOR_REFERENCE_CREATOR_TYPE";
- String DOC_COMPARATOR_PRINTER_NAME = "DOC_COMPARATOR_PRINTER_NAME";
- String DOC_COMPARATOR_DEFAULT_XML_FORMAT_APP = "DOC_COMPARATOR_DEFAULT_XML_FORMAT_APP";
- String DOC_COMPARATOR_INCLUDE_SUBDIRS = "DOC_COMPARATOR_INCLUDE_SUBDIRS";
- String DOC_COMPARATOR_PRINT_MAX_PAGE = "DOC_COMPARATOR_PRINT_MAX_PAGE";
- String DOC_COMPARATOR_PRINT_ONLY_PAGE = "DOC_COMPARATOR_PRINT_ONLY_PAGE";
- String DOC_COMPARATOR_GFX_OUTPUT_DPI_RESOLUTION = "DOC_COMPARATOR_GFX_OUTPUT_DPI_RESOLUTION";
- String DOC_COMPARATOR_OVERWRITE_REFERENCE = "DOC_COMPARATOR_OVERWRITE_REFERENCE";
-
- String DOC_COMPARATOR_HTML_OUTPUT_PREFIX = "DOC_COMPARATOR_HTML_OUTPUT_PREFIX";
- String DOC_COMPARATOR_GFXCMP_WITH_BORDERMOVE = "DOC_COMPARATOR_GFXCMP_WITH_BORDERMOVE";
-
- String DOC_CONVERTER_IMPORT_FILTER_NAME = "DOC_CONVERTER_IMPORT_FILTER_NAME";
- String DOC_CONVERTER_EXPORT_FILTER_NAME = "DOC_CONVERTER_EXPORT_FILTER_NAME";
- String DOC_CONVERTER_OFFICE_PROGRAM = "DOC_CONVERTER_OFFICE_PROGRAM";
- String DOC_CONVERTER_REUSE_OFFICE = "DOC_CONVERTER_REUSE_OFFICE";
-
- String DOC_COMPARATOR_LEAVE_OUT_FILES = "DOC_COMPARATOR_LEAVE_OUT_FILES";
-
- String DOC_COMPARATOR_DB_INFO_STRING = "DOC_COMPARATOR_DB_INFO_STRING";
-
- String TEMPPATH = "TEMPPATH";
-
- // set this variable to "true" or "yes" and loadComponentFromURL works with property Hidden=false
- String OFFICE_VIEWABLE = "OFFICE_VIEWABLE";
-
- String DB_CONNECTION_STRING = "DB_CONNECTION_STRING";
- String CHECK_NEED_TOOLS = "CHECK_NEED_TOOLS";
- String CREATE_DEFAULT = "CREATE_DEFAULT_REFERENCE";
-
-}
diff --git a/qadevOOo/runner/convwatch/ReferenceBuilder.java b/qadevOOo/runner/convwatch/ReferenceBuilder.java
deleted file mode 100644
index 2c4bc37a64cd..000000000000
--- a/qadevOOo/runner/convwatch/ReferenceBuilder.java
+++ /dev/null
@@ -1,257 +0,0 @@
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-package convwatch;
-
-import java.io.File;
-import java.io.FileFilter;
-import com.sun.star.lang.XMultiServiceFactory;
-
-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 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.
- */
- @Override
- 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.
- */
- @Override
- 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()
- {
- }
-
- public void after()
- {
- }
-
- // The test method itself.
- private String m_sInputPath = "";
- private String m_sReferencePath = "";
- private void initMember()
- {
- // MUST PARAMETER
- // INPUT_PATH ----------
- 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 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)
- {
- 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 accessible as an external executable
- */
- @Override
- protected String[] mustInstalledSoftware()
- {
- return new String[] { "perl -version" };
- }
-
- // 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 accessible
- checkEnvironment(mustInstalledSoftware());
-
- 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");
-
- aInputPath.getAbsolutePath();
- // a whole directory
- FileFilter aFileFilter = FileHelper.getFileFilter();
-
- Object[] aList = DirectoryHelper.traverse(m_sInputPath, aFileFilter, aGTA.includeSubDirectories());
-
- // 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
- {
- if (aGTA.checkIfUsableDocumentType(m_sInputPath))
- {
- runGDC(m_sInputPath, m_sReferencePath);
- }
- }
- }
-
- private 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))
- {
- // start a fresh Office
- OfficeProvider aProvider = null;
- // SimpleFileSemaphore aSemaphore = new SimpleFileSemaphore();
- if (aGTA.shouldOfficeStart())
- {
- 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);
-
- 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);
- }
- }
- 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
deleted file mode 100644
index 204f8d9c70f3..000000000000
--- a/qadevOOo/runner/convwatch/ReportDesignerTest.java
+++ /dev/null
@@ -1,535 +0,0 @@
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-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 complexlib.ComplexTestCase;
-import helper.OfficeProvider;
-import helper.URLHelper;
-import helper.OfficeWatcher;
-
-class PropertySetHelper
-{
- XPropertySet m_xPropertySet;
- public PropertySetHelper(Object _aObj)
- {
- m_xPropertySet = UnoRuntime.queryInterface(XPropertySet.class, _aObj);
- }
-
- /**
- get a property and don't convert it
- @param _sName the string name of the property
- @return the object value of the property without any conversion
- */
- public Object getPropertyValueAsObject(String _sName)
- {
- Object aObject = null;
-
- if (m_xPropertySet != null)
- {
- try
- {
- aObject = m_xPropertySet.getPropertyValue(_sName);
- }
- catch (com.sun.star.beans.UnknownPropertyException e)
- {
- System.out.println("ERROR: UnknownPropertyException caught. '" + _sName + "'");
- System.out.println("Message: " + e.getMessage());
- }
- catch (com.sun.star.lang.WrappedTargetException e)
- {
- System.out.println("ERROR: WrappedTargetException caught.");
- System.out.println("Message: " + e.getMessage());
- }
- }
- return aObject;
- }
-}
-
-class PropertyHelper
-{
- /**
- Create a PropertyValue[] from a ArrayList
- @return a PropertyValue[]
- */
- public static PropertyValue[] createPropertyValueArrayFormArrayList(ArrayList<PropertyValue> _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] = _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.
- */
- @Override
- 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);
- }
- }
-
- 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 = 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()
- {
- param.put("TimeOut", Integer.valueOf(300000));
- System.out.println("TimeOut: " + param.getInt("TimeOut"));
- System.out.println("ThreadTimeOut: " + param.getInt("ThreadTimeOut"));
-
- 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 static String m_sSourceVersion;
- private static String m_sDestinationVersion;
- private static String m_sSourceName;
- private static String m_sDestinationName;
-
- /**
- * 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 + "'");
-
- 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");
-
- 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
-
- checkIfOfficeExists(sAppExecutionCommand);
- param.put("AppExecutionCommand", sAppExecutionCommand);
-
- // --------------------------- Start the given Office ---------------------------
-
- startOffice();
-
- // ------------------------------ Start a test run ------------------------------
-
- String sDocument = (String) param.get(convwatch.PropertyName.DOC_COMPARATOR_INPUT_PATH);
- sDocument = helper.StringHelper.removeQuoteIfExists( sDocument );
- startTestForFile(sDocument);
- }
- catch (AssureException e)
- {
- stopOffice();
- throw new AssureException(e);
- }
-
- // ------------------------------ 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");
-
- 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 = UnoRuntime.queryInterface(XNameAccess.class, x);
- showElements(xNameAccess);
- Object aObj = xNameAccess.getByName(sFileURL);
-
- XDocumentDataSource xDataSource = UnoRuntime.queryInterface(XDocumentDataSource.class, aObj);
- XOfficeDatabaseDocument xOfficeDBDoc = xDataSource.getDatabaseDocument();
-
- assure("can't access DatabaseDocument", xOfficeDBDoc != null);
-
- XModel xDBSource = UnoRuntime.queryInterface(XModel.class, xOfficeDBDoc);
- Object aController = xDBSource.getCurrentController();
- assure("Controller of xOfficeDatabaseDocument is empty!", aController != null);
-
- XDatabaseDocumentUI aDBDocUI = UnoRuntime.queryInterface(XDatabaseDocumentUI.class, aController);
- aDBDocUI.connect();
-
- Object aActiveConnectionObj = aDBDocUI.getActiveConnection();
- assure("ActiveConnection is empty", aActiveConnectionObj != null);
-
- XReportDocumentsSupplier xSupplier = UnoRuntime.queryInterface(XReportDocumentsSupplier.class, xOfficeDBDoc);
- xNameAccess = xSupplier.getReportDocuments();
- assure("xOfficeDatabaseDocument returns no Report Document", xNameAccess != null);
-
- showElements(xNameAccess);
-
- ArrayList<PropertyValue> aPropertyList = new ArrayList<PropertyValue>();
-
- 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());
- }
-
- // Close the document
- closeComponent(xDocComponent);
- }
-
- private String getDocumentPoolName(/*int _nType*/)
- {
- return "AutogenReportDesignTest";
- }
-
-
- 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 sSourceVersion = m_sSourceVersion;
- String sSourceName = m_sSourceName;
- String sSourceCreatorType = "";
- 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.");
- }
-
- private void loadAndStoreReports(XNameAccess _xNameAccess, ArrayList<PropertyValue> _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 = 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;
- }
-
- 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 += DateHelper.getDateTimeForFilename();
- 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<PropertyValue> aPropertyList = new ArrayList<PropertyValue>(); // set some properties for storeAsURL
-
- PropertyValue aOverwrite = new PropertyValue(); // always overwrite already exist files
- aOverwrite.Name = "Overwrite";
- aOverwrite.Value = Boolean.TRUE;
- aPropertyList.add(aOverwrite);
-
- // store the document in an other directory
- XStorable aStorable = UnoRuntime.queryInterface( XStorable.class, _xComponent);
- if (aStorable != null)
- {
- 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<PropertyValue> _aPropertyList)
- {
- XComponent xDocComponent = null;
- 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 = UnoRuntime.queryInterface(XCloseable.class, _xDoc);
- try
- {
- xCloseable.close(true);
- }
- catch (com.sun.star.util.CloseVetoException e)
- {
- log.println("ERROR: CloseVetoException caught");
- log.println("CloseVetoException occurred Can't close document.");
- log.println("Message: " + e.getMessage());
- }
- }
-
-}
diff --git a/qadevOOo/runner/convwatch/SimpleFileSemaphore.java b/qadevOOo/runner/convwatch/SimpleFileSemaphore.java
deleted file mode 100644
index 0fd9882604c2..000000000000
--- a/qadevOOo/runner/convwatch/SimpleFileSemaphore.java
+++ /dev/null
@@ -1,180 +0,0 @@
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-package convwatch;
-
-import java.io.File;
-import java.io.RandomAccessFile;
-import helper.OSHelper;
-
-public class SimpleFileSemaphore
-{
- String m_sInternSemaphoreFile;
- File m_aInternSemaphoreFile;
- GlobalLogWriter m_aLog;
-
- public static void sleep( int _nSeconds)
- {
- // wait a second here
- try
- {
- java.lang.Thread.sleep(1000L * _nSeconds);
- }
- catch (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() )
- {
- GlobalLogWriter.get().println( "Active wait since " + nCount + "sec..");
- nCount ++;
- sleep( 1 );
- }
- else
- {
- sleep( 1 );
- if ( _aSemaphore.exists() )
- {
- // ups
- GlobalLogWriter.get().println( "ups...");
- }
- else
- {
- nCheckLoop = 0;
- }
- }
- }
-
- // block resource by ourself
- try
- {
- RandomAccessFile aWriter = new RandomAccessFile(_aSemaphore, "rw");
- aWriter.writeByte(1);
- aWriter.close();
- }
-
- catch (java.io.FileNotFoundException fne)
- {
- GlobalLogWriter.get().println( "caught: FileNotFoundException");
- }
- catch(java.io.IOException ie)
- {
- GlobalLogWriter.get().println( "caught: IOException");
- }
- }
-
-
-// block a resource
- public void V(File _aSemaphore)
- {
-
- if ( _aSemaphore.exists() )
- {
- _aSemaphore.delete();
- }
- else
- {
- GlobalLogWriter.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
deleted file mode 100644
index ea3241f55011..000000000000
--- a/qadevOOo/runner/convwatch/StatusHelper.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-package convwatch;
-
-public class StatusHelper
-{
- final static private 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_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 " + 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 " + nPercent2 + " old was " + nPercent + "%");
- }
- else
- {
- GlobalLogWriter.get().println("Unknown DIFF_ values used, not handles yet.");
- }
- }
-
-}
diff --git a/qadevOOo/runner/convwatch/TimeHelper.java b/qadevOOo/runner/convwatch/TimeHelper.java
deleted file mode 100644
index 8d5d79252d1f..000000000000
--- a/qadevOOo/runner/convwatch/TimeHelper.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-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 " + _nSeconds + " sec. Reason: " + _sReason);
- try {
- java.lang.Thread.sleep(1000L * _nSeconds);
- } catch (InterruptedException e2) {}
- }
-}
diff --git a/qadevOOo/runner/convwatch/TriState.java b/qadevOOo/runner/convwatch/TriState.java
deleted file mode 100644
index ec9dfd194336..000000000000
--- a/qadevOOo/runner/convwatch/TriState.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-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);
-
- private final int m_nValue;
-
- /**
- Allocates a <code>TriState</code> object representing the
- <code>value</code> argument.
-
- @param value the value of the <code>TriState</code>.
- */
- private 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.
- */
- private 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.
- */
-
- @Override
- 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
deleted file mode 100644
index 4892e1545f47..000000000000
--- a/qadevOOo/runner/convwatch/ValueNotFoundException.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-package convwatch;
-
-class ValueNotFoundException extends Exception
-{
- ValueNotFoundException(String _sMessage)
- {
- super(_sMessage);
- }
-}