summaryrefslogtreecommitdiff
path: root/qadevOOo/runner
diff options
context:
space:
mode:
Diffstat (limited to 'qadevOOo/runner')
-rw-r--r--qadevOOo/runner/base/TestBase.java39
-rw-r--r--qadevOOo/runner/base/basic_fat.java457
-rw-r--r--qadevOOo/runner/base/java_cmp.java83
-rw-r--r--qadevOOo/runner/base/java_complex.java170
-rw-r--r--qadevOOo/runner/base/java_fat.java602
-rw-r--r--qadevOOo/runner/base/java_fat_service.java267
-rw-r--r--qadevOOo/runner/base/makefile.mk52
-rw-r--r--qadevOOo/runner/basicrunner/BasicException.java42
-rw-r--r--qadevOOo/runner/basicrunner/BasicHandler.java612
-rw-r--r--qadevOOo/runner/basicrunner/BasicHandlerProvider.java153
-rw-r--r--qadevOOo/runner/basicrunner/BasicIfcTest.java169
-rw-r--r--qadevOOo/runner/basicrunner/BasicTestCase.java178
-rw-r--r--qadevOOo/runner/basicrunner/basichelper/AttributeList.java138
-rw-r--r--qadevOOo/runner/basicrunner/basichelper/Connector.java272
-rw-r--r--qadevOOo/runner/basicrunner/basichelper/DispatchProviderInterceptor.java194
-rw-r--r--qadevOOo/runner/basicrunner/basichelper/DocumentHandler.java344
-rw-r--r--qadevOOo/runner/basicrunner/basichelper/Filter.java269
-rw-r--r--qadevOOo/runner/basicrunner/basichelper/ThreadRunner.java254
-rw-r--r--qadevOOo/runner/basicrunner/basichelper/makefile.mk47
-rw-r--r--qadevOOo/runner/basicrunner/makefile.mk46
-rw-r--r--qadevOOo/runner/complexlib/Assurance.java407
-rw-r--r--qadevOOo/runner/complexlib/ComplexTestCase.java315
-rw-r--r--qadevOOo/runner/complexlib/MethodThread.java112
-rw-r--r--qadevOOo/runner/complexlib/ShowTargets.java138
-rw-r--r--qadevOOo/runner/complexlib/makefile.mk49
-rw-r--r--qadevOOo/runner/convwatch/Basename.java61
-rw-r--r--qadevOOo/runner/convwatch/BorderRemover.java319
-rw-r--r--qadevOOo/runner/convwatch/BuildID.java163
-rw-r--r--qadevOOo/runner/convwatch/ConvWatch.java432
-rw-r--r--qadevOOo/runner/convwatch/ConvWatchCancelException.java38
-rw-r--r--qadevOOo/runner/convwatch/ConvWatchException.java37
-rw-r--r--qadevOOo/runner/convwatch/ConvWatchStarter.java445
-rw-r--r--qadevOOo/runner/convwatch/CrashLoopTest.java57
-rw-r--r--qadevOOo/runner/convwatch/DB.java541
-rw-r--r--qadevOOo/runner/convwatch/DBHelper.java316
-rwxr-xr-xqadevOOo/runner/convwatch/DateHelper.java58
-rw-r--r--qadevOOo/runner/convwatch/DirectoryHelper.java156
-rw-r--r--qadevOOo/runner/convwatch/DocumentConverter.java277
-rw-r--r--qadevOOo/runner/convwatch/EnhancedComplexTestCase.java130
-rw-r--r--qadevOOo/runner/convwatch/FileHelper.java405
-rw-r--r--qadevOOo/runner/convwatch/FilenameHelper.java398
-rw-r--r--qadevOOo/runner/convwatch/GfxCompare.java196
-rw-r--r--qadevOOo/runner/convwatch/GlobalLogWriter.java57
-rw-r--r--qadevOOo/runner/convwatch/GraphicalDifferenceCheck.java410
-rw-r--r--qadevOOo/runner/convwatch/GraphicalTestArguments.java744
-rw-r--r--qadevOOo/runner/convwatch/HTMLOutputter.java418
-rw-r--r--qadevOOo/runner/convwatch/INIOutputter.java207
-rw-r--r--qadevOOo/runner/convwatch/ImageHelper.java116
-rw-r--r--qadevOOo/runner/convwatch/IniFile.java452
-rw-r--r--qadevOOo/runner/convwatch/LISTOutputter.java104
-rw-r--r--qadevOOo/runner/convwatch/MSOfficePrint.java870
-rw-r--r--qadevOOo/runner/convwatch/NameHelper.java89
-rw-r--r--qadevOOo/runner/convwatch/OSHelper.java84
-rw-r--r--qadevOOo/runner/convwatch/OfficePrint.java1377
-rw-r--r--qadevOOo/runner/convwatch/PRNCompare.java805
-rw-r--r--qadevOOo/runner/convwatch/PerformanceContainer.java250
-rw-r--r--qadevOOo/runner/convwatch/PixelCounter.java206
-rw-r--r--qadevOOo/runner/convwatch/PropertyName.java67
-rw-r--r--qadevOOo/runner/convwatch/ReferenceBuilder.java304
-rwxr-xr-xqadevOOo/runner/convwatch/ReportDesignerTest.java694
-rw-r--r--qadevOOo/runner/convwatch/SimpleFileSemaphore.java189
-rw-r--r--qadevOOo/runner/convwatch/StatusHelper.java108
-rw-r--r--qadevOOo/runner/convwatch/StringHelper.java103
-rwxr-xr-xqadevOOo/runner/convwatch/TimeHelper.java44
-rw-r--r--qadevOOo/runner/convwatch/TriState.java76
-rw-r--r--qadevOOo/runner/convwatch/ValueNotFoundException.java36
-rw-r--r--qadevOOo/runner/convwatch/makefile.mk86
-rw-r--r--qadevOOo/runner/graphical/BuildID.java226
-rw-r--r--qadevOOo/runner/graphical/DateHelper.java58
-rw-r--r--qadevOOo/runner/graphical/DirectoryHelper.java160
-rw-r--r--qadevOOo/runner/graphical/EnhancedComplexTestCase.java519
-rw-r--r--qadevOOo/runner/graphical/FileHelper.java767
-rw-r--r--qadevOOo/runner/graphical/GlobalLogWriter.java72
-rw-r--r--qadevOOo/runner/graphical/GraphicalComparator.java31
-rw-r--r--qadevOOo/runner/graphical/HTMLResult.java212
-rw-r--r--qadevOOo/runner/graphical/IDocument.java46
-rw-r--r--qadevOOo/runner/graphical/IOffice.java63
-rw-r--r--qadevOOo/runner/graphical/ImageHelper.java120
-rw-r--r--qadevOOo/runner/graphical/IniFile.java693
-rw-r--r--qadevOOo/runner/graphical/JPEGComparator.java816
-rw-r--r--qadevOOo/runner/graphical/JPEGCreator.java475
-rw-r--r--qadevOOo/runner/graphical/JPEGEvaluator.java163
-rw-r--r--qadevOOo/runner/graphical/MSOfficePostscriptCreator.java1004
-rw-r--r--qadevOOo/runner/graphical/Office.java170
-rw-r--r--qadevOOo/runner/graphical/OfficeException.java45
-rw-r--r--qadevOOo/runner/graphical/OpenOfficeDatabaseReportExtractor.java560
-rw-r--r--qadevOOo/runner/graphical/OpenOfficePostscriptCreator.java1427
-rw-r--r--qadevOOo/runner/graphical/ParameterHelper.java433
-rw-r--r--qadevOOo/runner/graphical/PerformanceContainer.java271
-rw-r--r--qadevOOo/runner/graphical/PixelCounter.java247
-rw-r--r--qadevOOo/runner/graphical/PostscriptCreator.java137
-rw-r--r--qadevOOo/runner/graphical/PropertyName.java73
-rw-r--r--qadevOOo/runner/graphical/TimeHelper.java91
-rw-r--r--qadevOOo/runner/graphical/Tolerance.java23
-rw-r--r--qadevOOo/runner/graphical/WrongEnvironmentException.java42
-rw-r--r--qadevOOo/runner/graphical/WrongSuffixException.java42
-rw-r--r--qadevOOo/runner/graphical/makefile.mk76
-rw-r--r--qadevOOo/runner/helper/APIDescGetter.java985
-rw-r--r--qadevOOo/runner/helper/AppProvider.java55
-rw-r--r--qadevOOo/runner/helper/BuildEnvTools.java195
-rw-r--r--qadevOOo/runner/helper/CfgParser.java192
-rw-r--r--qadevOOo/runner/helper/ClParser.java193
-rw-r--r--qadevOOo/runner/helper/ComplexDescGetter.java194
-rw-r--r--qadevOOo/runner/helper/ConfigHelper.java348
-rw-r--r--qadevOOo/runner/helper/ConfigurationRead.java141
-rw-r--r--qadevOOo/runner/helper/ContextMenuInterceptor.java140
-rw-r--r--qadevOOo/runner/helper/CwsDataExchangeImpl.java157
-rw-r--r--qadevOOo/runner/helper/FileTools.java160
-rw-r--r--qadevOOo/runner/helper/InetTools.java88
-rw-r--r--qadevOOo/runner/helper/LoggingThread.java96
-rw-r--r--qadevOOo/runner/helper/OSHelper.java88
-rw-r--r--qadevOOo/runner/helper/ObjectInspectorModelImpl.java145
-rw-r--r--qadevOOo/runner/helper/OfficeProvider.java833
-rw-r--r--qadevOOo/runner/helper/OfficeWatcher.java132
-rw-r--r--qadevOOo/runner/helper/ParameterNotFoundException.java39
-rw-r--r--qadevOOo/runner/helper/ProcessHandler.java824
-rw-r--r--qadevOOo/runner/helper/PropertyHandlerFactroy.java49
-rw-r--r--qadevOOo/runner/helper/PropertyHandlerImpl.java258
-rwxr-xr-xqadevOOo/runner/helper/PropertyHelper.java81
-rw-r--r--qadevOOo/runner/helper/SimpleMailSender.java171
-rw-r--r--qadevOOo/runner/helper/StreamSimulator.java533
-rw-r--r--qadevOOo/runner/helper/StringHelper.java125
-rw-r--r--qadevOOo/runner/helper/URLHelper.java292
-rw-r--r--qadevOOo/runner/helper/UnoProvider.java165
-rw-r--r--qadevOOo/runner/helper/WindowListener.java78
-rw-r--r--qadevOOo/runner/helper/makefile.mk65
-rw-r--r--qadevOOo/runner/lib/DynamicClassLoader.java94
-rw-r--r--qadevOOo/runner/lib/ExceptionStatus.java48
-rw-r--r--qadevOOo/runner/lib/MultiMethodTest.java511
-rw-r--r--qadevOOo/runner/lib/MultiPropertyTest.java608
-rw-r--r--qadevOOo/runner/lib/Parameters.java233
-rw-r--r--qadevOOo/runner/lib/SimpleStatus.java149
-rw-r--r--qadevOOo/runner/lib/Status.java173
-rw-r--r--qadevOOo/runner/lib/StatusException.java81
-rw-r--r--qadevOOo/runner/lib/TestCase.java182
-rw-r--r--qadevOOo/runner/lib/TestEnvironment.java153
-rw-r--r--qadevOOo/runner/lib/TestParameters.java343
-rw-r--r--qadevOOo/runner/lib/TestResult.java106
-rw-r--r--qadevOOo/runner/lib/makefile.mk58
-rw-r--r--qadevOOo/runner/makefile.mk60
-rw-r--r--qadevOOo/runner/manifest3
-rw-r--r--qadevOOo/runner/org/openoffice/Runner.java261
-rw-r--r--qadevOOo/runner/org/openoffice/RunnerService.java397
-rw-r--r--qadevOOo/runner/org/openoffice/makefile.mk46
-rw-r--r--qadevOOo/runner/share/ComplexTest.java39
-rw-r--r--qadevOOo/runner/share/CwsDataExchange.java51
-rw-r--r--qadevOOo/runner/share/DescEntry.java97
-rw-r--r--qadevOOo/runner/share/DescGetter.java197
-rw-r--r--qadevOOo/runner/share/LogWriter.java68
-rw-r--r--qadevOOo/runner/share/Watcher.java42
-rw-r--r--qadevOOo/runner/share/makefile.mk52
-rw-r--r--qadevOOo/runner/stats/ComplexDataBaseOutProducer.java181
-rw-r--r--qadevOOo/runner/stats/DataBaseOutProducer.java207
-rw-r--r--qadevOOo/runner/stats/FatDataBaseOutProducer.java147
-rw-r--r--qadevOOo/runner/stats/FileLogWriter.java141
-rw-r--r--qadevOOo/runner/stats/InternalLogWriter.java124
-rw-r--r--qadevOOo/runner/stats/OutProducerFactory.java137
-rw-r--r--qadevOOo/runner/stats/SQLExecution.java337
-rw-r--r--qadevOOo/runner/stats/SimpleFileOutProducer.java114
-rw-r--r--qadevOOo/runner/stats/SimpleLogWriter.java111
-rw-r--r--qadevOOo/runner/stats/SimpleOutProducer.java77
-rw-r--r--qadevOOo/runner/stats/Summarizer.java114
-rw-r--r--qadevOOo/runner/stats/makefile.mk59
-rw-r--r--qadevOOo/runner/util/AccessibilityTools.java461
-rw-r--r--qadevOOo/runner/util/BasicMacroTools.java261
-rw-r--r--qadevOOo/runner/util/BookmarkDsc.java84
-rw-r--r--qadevOOo/runner/util/CalcTools.java160
-rw-r--r--qadevOOo/runner/util/ControlDsc.java80
-rw-r--r--qadevOOo/runner/util/DBTools.java824
-rw-r--r--qadevOOo/runner/util/DefaultDsc.java81
-rw-r--r--qadevOOo/runner/util/DesktopTools.java515
-rw-r--r--qadevOOo/runner/util/DrawTools.java162
-rw-r--r--qadevOOo/runner/util/DynamicClassLoader.java123
-rw-r--r--qadevOOo/runner/util/FootnoteDsc.java84
-rw-r--r--qadevOOo/runner/util/FormTools.java349
-rw-r--r--qadevOOo/runner/util/FrameDsc.java126
-rw-r--r--qadevOOo/runner/util/InstCreator.java122
-rw-r--r--qadevOOo/runner/util/InstDescr.java53
-rw-r--r--qadevOOo/runner/util/ParagraphDsc.java85
-rw-r--r--qadevOOo/runner/util/PropertyName.java169
-rw-r--r--qadevOOo/runner/util/ReferenceMarkDsc.java84
-rw-r--r--qadevOOo/runner/util/RegistryTools.java370
-rw-r--r--qadevOOo/runner/util/SOfficeFactory.java629
-rw-r--r--qadevOOo/runner/util/ShapeDsc.java101
-rw-r--r--qadevOOo/runner/util/StyleFamilyDsc.java80
-rw-r--r--qadevOOo/runner/util/SysUtils.java153
-rw-r--r--qadevOOo/runner/util/TableDsc.java96
-rw-r--r--qadevOOo/runner/util/TextSectionDsc.java84
-rw-r--r--qadevOOo/runner/util/UITools.java814
-rw-r--r--qadevOOo/runner/util/ValueChanger.java994
-rw-r--r--qadevOOo/runner/util/ValueComparer.java266
-rw-r--r--qadevOOo/runner/util/WaitUnreachable.java127
-rw-r--r--qadevOOo/runner/util/WriterTools.java121
-rw-r--r--qadevOOo/runner/util/XInstCreator.java38
-rw-r--r--qadevOOo/runner/util/XLayerHandlerImpl.java119
-rw-r--r--qadevOOo/runner/util/XLayerImpl.java45
-rw-r--r--qadevOOo/runner/util/XMLTools.java939
-rw-r--r--qadevOOo/runner/util/XSchemaHandlerImpl.java137
-rw-r--r--qadevOOo/runner/util/compare/DocComparator.java52
-rw-r--r--qadevOOo/runner/util/compare/DocComparatorFactory.java64
-rw-r--r--qadevOOo/runner/util/compare/GraphicalComparator.java260
-rw-r--r--qadevOOo/runner/util/compare/PDFComparator.java62
-rw-r--r--qadevOOo/runner/util/compare/XMLComparator.java58
-rw-r--r--qadevOOo/runner/util/compare/makefile.mk54
-rw-r--r--qadevOOo/runner/util/db/DataSource.java163
-rw-r--r--qadevOOo/runner/util/db/DataSourceDescriptor.java74
-rw-r--r--qadevOOo/runner/util/db/DatabaseDocument.java90
-rw-r--r--qadevOOo/runner/util/dbg.java347
-rw-r--r--qadevOOo/runner/util/makefile.mk87
-rw-r--r--qadevOOo/runner/util/utils.java1020
210 files changed, 50286 insertions, 0 deletions
diff --git a/qadevOOo/runner/base/TestBase.java b/qadevOOo/runner/base/TestBase.java
new file mode 100644
index 000000000000..d09f28721ab0
--- /dev/null
+++ b/qadevOOo/runner/base/TestBase.java
@@ -0,0 +1,39 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package base;
+
+import lib.TestParameters;
+/**
+ *
+ * Base Interface to execute a given TestJob
+ */
+public interface TestBase {
+
+ public boolean executeTest(TestParameters param);
+
+}
diff --git a/qadevOOo/runner/base/basic_fat.java b/qadevOOo/runner/base/basic_fat.java
new file mode 100644
index 000000000000..74a6708cf801
--- /dev/null
+++ b/qadevOOo/runner/base/basic_fat.java
@@ -0,0 +1,457 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package base;
+
+
+import basicrunner.BasicIfcTest;
+import basicrunner.BasicTestCase;
+
+import com.sun.star.lang.XMultiServiceFactory;
+
+import helper.APIDescGetter;
+import helper.AppProvider;
+import helper.OfficeProvider;
+import helper.OfficeWatcher;
+
+import java.io.BufferedReader;
+import java.io.FileReader;
+import java.io.PrintWriter;
+
+import java.util.Vector;
+
+import lib.TestCase;
+import lib.TestEnvironment;
+import lib.TestParameters;
+
+import share.DescEntry;
+import share.DescGetter;
+import share.LogWriter;
+
+import stats.OutProducerFactory;
+import stats.Summarizer;
+
+import util.DynamicClassLoader;
+
+/**
+ * The testbase for executing basic tests.
+ * @see lib.TestBase
+ */
+public class basic_fat implements TestBase
+{
+
+ public static boolean debug = false;
+
+ /**
+ * Execute a test.
+ * @param param The test parameters.
+ * @return True, if the test was executed.
+ */
+ public boolean executeTest(TestParameters param)
+ {
+ DescGetter dg = new APIDescGetter();
+ String job = (String) param.get("TestJob");
+ OfficeProvider office = null;
+ debug = param.getBool("DebugIsActive");
+
+
+ //get Job-Descriptions
+ System.out.print("Getting Descriptions for Job: " + job + " from ");
+
+ DescEntry[] entries = dg.getDescriptionFor(job,
+ (String) param.get(
+ "DescriptionPath"),
+ debug);
+
+ if (entries == null)
+ {
+ System.out.println("Couldn't get Description for Job");
+
+ return false;
+ }
+
+ String ExclusionFile = (String) param.get("ExclusionList");
+ Vector exclusions = null;
+
+ if (ExclusionFile != null)
+ {
+ exclusions = getExclusionList(ExclusionFile, debug);
+ }
+
+ String conStr = (String) param.get("ConnectionString");
+ System.out.println("");
+ System.out.print("> Connecting the Office ");
+ System.out.println("With " + conStr);
+
+ for (int l = 0; l < entries.length; l++)
+ {
+ if (entries[l].hasErrorMsg)
+ {
+ System.out.println(entries[l].ErrorMsg);
+
+ continue;
+ }
+
+ office = new OfficeProvider();
+
+ XMultiServiceFactory msf = (XMultiServiceFactory) office.getManager(
+ param);
+
+ if (msf == null)
+ {
+ return false;
+ }
+
+ param.put("ServiceFactory", msf);
+
+ DescEntry entry = entries[l];
+
+ //get some helper classes
+ Summarizer sumIt = new Summarizer();
+ DynamicClassLoader dcl = new DynamicClassLoader();
+
+ TestCase tCase = null;
+
+ tCase = (TestCase) new BasicTestCase(entry);
+
+ if (tCase == null)
+ {
+ sumIt.summarizeDown(entry, entry.ErrorMsg);
+
+ LogWriter sumObj = OutProducerFactory.createOutProducer(param);
+ sumObj.initialize(entry, true);
+ sumObj.summary(entry);
+
+ continue;
+ }
+
+ System.out.println("Creating: " + tCase.getObjectName());
+
+ LogWriter log = (LogWriter) dcl.getInstance(
+ (String) param.get("LogWriter"));
+ log.initialize(entry, true);
+ entry.UserDefinedParams = param;
+ tCase.setLogWriter((PrintWriter) log);
+
+ try
+ {
+ tCase.initializeTestCase(param);
+ }
+ catch (RuntimeException e)
+ {
+ helper.ProcessHandler ph = (helper.ProcessHandler) param.get(
+ "AppProvider");
+
+ if (ph != null)
+ {
+ OfficeWatcher ow = (OfficeWatcher) param.get("Watcher");
+
+ if ((ow != null) && ow.isAlive())
+ {
+ ow.finish = true;
+ }
+
+ ph.kill();
+ shortWait(5000);
+ }
+
+ continue;
+ }
+
+ TestEnvironment tEnv = tCase.getTestEnvironment(param);
+
+ if (tEnv == null)
+ {
+ sumIt.summarizeDown(entry, "Unable to create testcase");
+
+ LogWriter sumObj = OutProducerFactory.createOutProducer(param);
+ sumObj.initialize(entry, true);
+ sumObj.summary(entry);
+
+ helper.ProcessHandler ph = (helper.ProcessHandler) param.get(
+ "AppProvider");
+
+ if (ph != null)
+ {
+ OfficeWatcher ow = (OfficeWatcher) param.get("Watcher");
+
+ if ((ow != null) && ow.isAlive())
+ {
+ ow.finish = true;
+ }
+
+ ph.kill();
+ shortWait(5000);
+ }
+
+ continue;
+ }
+
+ System.out.println("created " + tCase.getObjectName());
+
+ for (int j = 0; j < entry.SubEntryCount; j++)
+ {
+ if (!entry.SubEntries[j].isToTest)
+ {
+ Summarizer.summarizeDown(entry.SubEntries[j],
+ "not part of the job");
+
+ continue;
+ }
+
+ if ((exclusions != null) &&
+ (exclusions.contains(entry.SubEntries[j].longName)))
+ {
+ Summarizer.summarizeDown(entry.SubEntries[j],
+ "known issue");
+
+ continue;
+ }
+
+ System.out.println("running: " +
+ entry.SubEntries[j].entryName);
+
+ LogWriter ifclog = (LogWriter) dcl.getInstance(
+ (String) param.get("LogWriter"));
+ ifclog.initialize(entry.SubEntries[j], true);
+ entry.SubEntries[j].UserDefinedParams = param;
+ entry.SubEntries[j].Logger = ifclog;
+
+ if ((tEnv == null) || tEnv.isDisposed())
+ {
+ helper.ProcessHandler ph = (helper.ProcessHandler) param.get(
+ "AppProvider");
+
+ if (ph != null)
+ {
+ office.closeExistingOffice(param, true);
+ shortWait(5000);
+ }
+
+ tEnv = getEnv(entry, param);
+ }
+
+ BasicIfcTest ifc = null;
+ lib.TestResult res = null;
+ ifc = new BasicIfcTest(entry.SubEntries[j].longName);
+ res = ifc.run(entry.SubEntries[j], tEnv, param);
+
+ sumIt.summarizeUp(entry.SubEntries[j]);
+
+ LogWriter sumIfc = OutProducerFactory.createOutProducer(param);
+
+ sumIfc.initialize(entry.SubEntries[j], true);
+ sumIfc.summary(entry.SubEntries[j]);
+ }
+
+ try
+ {
+ tCase.cleanupTestCase(param);
+ }
+ catch (Exception e)
+ {
+ log.println("TestCase already gone");
+
+ helper.ProcessHandler ph = (helper.ProcessHandler) param.get(
+ "AppProvider");
+
+ if (ph != null)
+ {
+ office.closeExistingOffice(param, true);
+ shortWait(5000);
+ }
+ }
+
+ sumIt.summarizeUp(entry);
+
+ LogWriter sumObj = OutProducerFactory.createOutProducer(param);
+ sumObj.initialize(entry, true);
+ sumObj.summary(entry);
+ }
+
+ if (entries.length > 1)
+ {
+ System.out.println();
+
+ int counter = 0;
+ System.out.println(
+ "Failures that appeared during scenario execution:");
+
+ for (int i = 0; i < entries.length; i++)
+ {
+ if (!entries[i].State.endsWith("OK"))
+ {
+ System.out.println("\t " + entries[i].longName);
+ counter++;
+ }
+ }
+
+ System.out.println(counter + " of " + entries.length +
+ " tests failed");
+ }
+
+ helper.ProcessHandler ph = (helper.ProcessHandler) param.get(
+ "AppProvider");
+
+ if (ph != null)
+ {
+ office.closeExistingOffice(param, true);
+ }
+
+ return true;
+ }
+
+ protected TestEnvironment getEnv(DescEntry entry, TestParameters param)
+ {
+ DynamicClassLoader dcl = new DynamicClassLoader();
+ String officeProviderName = (String) param.get("OfficeProvider");
+ AppProvider office = (AppProvider) dcl.getInstance(officeProviderName);
+
+ if (office == null)
+ {
+ System.out.println("ERROR: Wrong parameter 'OfficeProvider', " +
+ " it cannot be instantiated.");
+ System.exit(-1);
+ }
+
+ XMultiServiceFactory msf = (XMultiServiceFactory) office.getManager(
+ param);
+
+ if (msf == null)
+ {
+ return null;
+ }
+
+ param.put("ServiceFactory", msf);
+
+ TestCase tCase = (TestCase) new BasicTestCase(entry);
+
+ System.out.println("Creating: " + tCase.getObjectName());
+
+ LogWriter log = (LogWriter) dcl.getInstance(
+ (String) param.get("LogWriter"));
+ log.initialize(entry, true);
+ entry.UserDefinedParams = param;
+ tCase.setLogWriter((PrintWriter) log);
+
+ TestEnvironment tEnv = null;
+
+ try
+ {
+ tCase.initializeTestCase(param);
+ tEnv = tCase.getTestEnvironment(param);
+ }
+ catch (java.lang.RuntimeException e)
+ {
+ System.out.println(e.getMessage());
+
+ helper.ProcessHandler ph = (helper.ProcessHandler) param.get(
+ "AppProvider");
+
+ if (ph != null)
+ {
+ office.closeExistingOffice(param, true);
+ shortWait(5000);
+ }
+
+ entry.ErrorMsg = e.getMessage();
+ entry.hasErrorMsg = true;
+ }
+
+ return tEnv;
+ }
+
+ protected void shortWait(int millis)
+ {
+ try
+ {
+ Thread.sleep(millis);
+ }
+ catch (java.lang.InterruptedException ie)
+ {
+ }
+ }
+
+ protected Vector getExclusionList(String url, boolean debug)
+ {
+ Vector entryList = new Vector();
+ String line = "#";
+ BufferedReader exclusion = null;
+
+ try
+ {
+ exclusion = new BufferedReader(new FileReader(url));
+ }
+ catch (java.io.FileNotFoundException fnfe)
+ {
+ if (debug)
+ {
+ System.out.println("Couldn't find file " + url);
+ }
+
+ return entryList;
+ }
+
+ while (line != null)
+ {
+ try
+ {
+ if (!line.startsWith("#"))
+ {
+ entryList.add(line);
+ }
+
+ line = exclusion.readLine();
+ }
+ catch (java.io.IOException ioe)
+ {
+ if (debug)
+ {
+ System.out.println(
+ "Exception while reading exclusion list");
+ }
+
+ return entryList;
+ }
+ }
+
+ try
+ {
+ exclusion.close();
+ }
+ catch (java.io.IOException ioe)
+ {
+ if (debug)
+ {
+ System.out.println("Couldn't close file " + url);
+ }
+
+ return entryList;
+ }
+
+ return entryList;
+ }
+}
diff --git a/qadevOOo/runner/base/java_cmp.java b/qadevOOo/runner/base/java_cmp.java
new file mode 100644
index 000000000000..c25de6efc4a9
--- /dev/null
+++ b/qadevOOo/runner/base/java_cmp.java
@@ -0,0 +1,83 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package base;
+
+
+
+
+/**
+ *
+ * this class handles tests written in java without running an Office with
+ * own bootstrapping of UNO
+ */
+public class java_cmp implements TestBase {
+
+ private TestBase mWrappedTestBase = new java_fat();
+
+ public boolean executeTest(lib.TestParameters param) {
+ param.put("OfficeProvider", "helper.UnoProvider");
+ return mWrappedTestBase.executeTest(param);
+ }
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/qadevOOo/runner/base/java_complex.java b/qadevOOo/runner/base/java_complex.java
new file mode 100644
index 000000000000..946e14b42934
--- /dev/null
+++ b/qadevOOo/runner/base/java_complex.java
@@ -0,0 +1,170 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package base;
+
+import complexlib.ComplexTestCase;
+import util.DynamicClassLoader;
+import share.DescGetter;
+import stats.OutProducerFactory;
+import helper.ComplexDescGetter;
+import helper.AppProvider;
+import helper.CfgParser;
+import share.DescEntry;
+import share.LogWriter;
+import stats.Summarizer;
+import lib.TestParameters;
+import util.PropertyName;
+
+/**
+ * Test base for executing a java complex test.
+ * @see base.TestBase
+ */
+public class java_complex implements TestBase
+{
+
+ /**
+ * This function executes the complex tests given as parameter "-o" or "TestJob". It querys for the correspond class
+ * and crates the JobDescription.
+ * @param param
+ * @return true of all tests run successfuly, esle false
+ */
+ public boolean executeTest(TestParameters param)
+ {
+
+ // is there an ini file for the complex tests defined?
+ String complexIniFileName = ((String) param.get("ComplexIni"));
+ if (complexIniFileName != null)
+ {
+ CfgParser ini = new CfgParser(complexIniFileName);
+ ini.getIniParameters(param);
+ }
+
+ // get the test job
+ String testJob = ((String) param.get("TestJob"));
+
+ DescGetter descGetter = new ComplexDescGetter();
+ // get the test jobs
+ DescEntry[] entries = descGetter.getDescriptionFor(testJob, null, true);
+ return executeTest(param, entries);
+
+ }
+
+ /**
+ * This function run the given DescEntry[] as ComplexTest
+ * @param param
+ * @param entries
+ * @return true of all tests run successfuly, esle false
+ */
+ public boolean executeTest(TestParameters param, DescEntry[] entries)
+ {
+ // is there an ini file for the complex tests defined?
+ String complexIniFileName = ((String) param.get("ComplexIni"));
+ if (complexIniFileName != null)
+ {
+ CfgParser ini = new CfgParser(complexIniFileName);
+ ini.getIniParameters(param);
+ }
+
+ DynamicClassLoader dcl = new DynamicClassLoader();
+ ComplexTestCase testClass = null;
+ boolean returnVal = true;
+
+// the concept of the TimeOut depends on runner logs. If the runner log,
+// for exmaple to start a test method, the timeout was restet. This is not
+// while the test itself log something like "open docuent...".
+// An property of complex test could be that it have only one test method
+// which works for serveral minutes. Ih this case the TimeOut get not trigger
+// and the office was killed.
+// In complex tests just use "ThreadTimeOut" as timout.
+
+ // param.put("TimeOut", new Integer(0));
+
+ for (int i = 0; i < entries.length; i++)
+ {
+
+ if (entries[i] == null)
+ {
+ continue;
+ }
+ String iniName = entries[i].longName;
+ iniName = iniName.replace('.', '/');
+ CfgParser ini = new CfgParser(iniName + ".props");
+ ini.getIniParameters(param);
+
+ LogWriter log = (LogWriter) dcl.getInstance((String) param.get("LogWriter"));
+
+ AppProvider office = null;
+ if (!param.getBool("NoOffice"))
+ {
+ try
+ {
+ office = (AppProvider) dcl.getInstance("helper.OfficeProvider");
+ Object msf = office.getManager(param);
+ if (msf == null)
+ {
+ returnVal = false;
+ continue;
+ }
+ param.put("ServiceFactory", msf);
+ }
+ catch (IllegalArgumentException e)
+ {
+ office = null;
+ }
+ }
+ log.initialize(entries[i], param.getBool(PropertyName.LOGGING_IS_ACTIVE));
+ entries[i].Logger = log;
+
+ // create an instance
+ try
+ {
+ testClass = (ComplexTestCase) dcl.getInstance(entries[i].longName);
+ }
+ catch (java.lang.Exception e)
+ {
+ e.printStackTrace();
+ return false;
+ }
+ testClass.executeMethods(entries[i], param);
+
+ Summarizer sum = new Summarizer();
+ sum.summarizeUp(entries[i]);
+
+ if (office != null)
+ {
+ office.closeExistingOffice(param, false);
+ }
+
+ LogWriter out = OutProducerFactory.createOutProducer(param);
+
+ out.initialize(entries[i], true);
+ out.summary(entries[i]);
+ returnVal &= entries[i].State.endsWith("OK");
+ }
+ return returnVal;
+ }
+}
diff --git a/qadevOOo/runner/base/java_fat.java b/qadevOOo/runner/base/java_fat.java
new file mode 100644
index 000000000000..4dd3ad51a817
--- /dev/null
+++ b/qadevOOo/runner/base/java_fat.java
@@ -0,0 +1,602 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package base;
+
+import com.sun.star.lang.XMultiServiceFactory;
+
+import helper.APIDescGetter;
+import helper.AppProvider;
+
+import java.io.BufferedReader;
+import java.io.FileReader;
+import java.io.PrintWriter;
+
+import java.util.Vector;
+
+import lib.MultiMethodTest;
+import lib.TestCase;
+import lib.TestEnvironment;
+import lib.TestParameters;
+import lib.TestResult;
+
+import share.DescEntry;
+import share.DescGetter;
+import share.LogWriter;
+
+import stats.OutProducerFactory;
+import stats.Summarizer;
+
+import util.DynamicClassLoader;
+
+/**
+ *
+ * this class handles tests written in java and running on a fat Office
+ */
+public class java_fat implements TestBase
+{
+
+ private static boolean m_isDebug = false;
+ private static boolean keepdocument = false;
+ private static boolean logging = true;
+ private static boolean newOffice = false;
+ private DynamicClassLoader m_aDynamicClassLoader = null;
+
+ private lib.TestParameters m_aParams;
+ private AppProvider m_aOffice;
+
+ public boolean executeTest(lib.TestParameters _aParams)
+ {
+ m_aParams = _aParams;
+
+ m_aDynamicClassLoader = new DynamicClassLoader();
+
+ DescGetter dg = new APIDescGetter();
+ String job = (String) m_aParams.get("TestJob");
+ String ExclusionFile = (String) m_aParams.get("ExclusionList");
+ Vector exclusions = null;
+ boolean retValue = true;
+ m_isDebug = m_aParams.getBool("DebugIsActive");
+ logging = m_aParams.getBool("LoggingIsActive");
+ keepdocument = m_aParams.getBool("KeepDocument");
+ newOffice = m_aParams.getBool(util.PropertyName.NEW_OFFICE_INSTANCE);
+ if (keepdocument)
+ {
+ System.setProperty("KeepDocument", "true");
+ }
+ if (ExclusionFile != null)
+ {
+ exclusions = getExclusionList(ExclusionFile, m_isDebug);
+ }
+ //get Job-Descriptions
+ // System.out.println("Getting Descriptions for Job: " + job);
+
+ String sDescriptionPath = (String) m_aParams.get("DescriptionPath");
+ DescEntry[] entries = dg.getDescriptionFor(job, sDescriptionPath, m_isDebug);
+
+ // System.out.println();
+
+ if (entries == null)
+ {
+ System.out.println("Couldn't get Description for Job: " + job);
+
+ return false;
+ }
+
+// String officeProviderName = (String) m_aParams.get("OfficeProvider");
+// AppProvider office = (AppProvider) m_aDynamicClassLoader.getInstance(officeProviderName);
+//
+// if (office == null) {
+// System.out.println("ERROR: Wrong parameter 'OfficeProvider', " +
+// " it cannot be instantiated.");
+// System.exit(-1);
+// }
+
+ m_aOffice = startOffice(m_aParams);
+
+ boolean firstRun = true;
+
+ // Run through all entries (e.g. sw.SwXBookmark.*)
+
+ for (int l = 0; l < entries.length; l++)
+ {
+ DescEntry entry = entries[l];
+
+ if (entry == null)
+ {
+ continue;
+ }
+
+ if (entry.hasErrorMsg)
+ {
+ System.out.println(entries[l].ErrorMsg);
+ retValue = false;
+ continue;
+ }
+
+ if (!firstRun && newOffice)
+ {
+ if (!m_aOffice.closeExistingOffice(m_aParams, true))
+ {
+ m_aOffice.disposeManager(m_aParams);
+ }
+ startOffice(m_aParams);
+ }
+ firstRun = false;
+
+ XMultiServiceFactory msf = (XMultiServiceFactory) m_aParams.getMSF();
+
+ if (msf == null)
+ {
+ retValue = false;
+ continue;
+ }
+
+ //get some helper classes
+ Summarizer sumIt = new Summarizer();
+ TestCase tCase = getTestCase(entry);
+ if (tCase == null)
+ {
+ continue;
+ }
+
+// if (m_isDebug)
+// {
+// System.out.println("sleeping 2 seconds..");
+// }
+ util.utils.shortWait(2000);
+
+ System.out.println("Creating: " + entry.entryName);
+
+ LogWriter log = (LogWriter) m_aDynamicClassLoader.getInstance((String) m_aParams.get("LogWriter"));
+ log.initialize(entry, logging);
+ entry.UserDefinedParams = m_aParams;
+
+ tCase.setLogWriter((PrintWriter) log);
+ tCase.initializeTestCase(m_aParams);
+
+ TestEnvironment tEnv = getTestEnvironment(tCase, entry);
+ if (tEnv == null)
+ {
+ continue;
+ }
+
+ final String sObjectName = tCase.getObjectName();
+ // System.out.println(sObjectName + " recreated ");
+
+ for (int j = 0; j < entry.SubEntryCount; j++)
+ {
+ DescEntry aSubEntry = entry.SubEntries[j];
+ final boolean bIsToTest = aSubEntry.isToTest;
+ if (!bIsToTest)
+ {
+ Summarizer.summarizeDown(aSubEntry, "not part of the job");
+ continue;
+ }
+
+ // final String sEntryName = aSubEntry.entryName;
+ final String sLongEntryName = aSubEntry.longName;
+
+ if ((exclusions != null) && (exclusions.contains(sLongEntryName)))
+ {
+ Summarizer.summarizeDown(aSubEntry, "known issue");
+ continue;
+ }
+
+ // System.out.println("running: '" + sLongEntryName + "' testcode: [" + sEntryName + "]");
+ // this will shown in test itself
+
+ LogWriter ifclog = (LogWriter) m_aDynamicClassLoader.getInstance( (String) m_aParams.get("LogWriter"));
+
+ ifclog.initialize(aSubEntry, logging);
+ aSubEntry.UserDefinedParams = m_aParams;
+ aSubEntry.Logger = ifclog;
+
+ if ((tEnv == null) || tEnv.isDisposed())
+ {
+ closeExistingOffice();
+ tEnv = getEnv(entry, m_aParams);
+ tCase = tEnv.getTestCase();
+ }
+
+ // MultiMethodTest ifc = null;
+ lib.TestResult res = null;
+
+ // run the interface test twice if it failed.
+ int countInterfaceTestRun = 0;
+ boolean finished = false;
+ while (!finished)
+ {
+ try
+ {
+ countInterfaceTestRun++;
+ finished = true;
+ res = executeInterfaceTest(aSubEntry, tEnv, m_aParams);
+ }
+ catch (IllegalArgumentException iae)
+ {
+ System.out.println("Couldn't load class " + aSubEntry.entryName);
+ System.out.println("**** " + iae.getMessage() + " ****");
+ Summarizer.summarizeDown(aSubEntry, iae.getMessage());
+ }
+ catch (java.lang.NoClassDefFoundError iae)
+ {
+ System.out.println("Couldn't load class " + aSubEntry.entryName);
+ System.out.println("**** " + iae.getMessage() + " ****");
+ Summarizer.summarizeDown(aSubEntry, iae.getMessage());
+ }
+ catch (java.lang.RuntimeException e)
+ {
+ closeExistingOffice();
+ tEnv = getEnv(entry, m_aParams);
+ tCase = tEnv.getTestCase();
+ if (countInterfaceTestRun < 2)
+ {
+ finished = false;
+ }
+ else
+ {
+ Summarizer.summarizeDown(aSubEntry, e.toString() + ".FAILED");
+ }
+ }
+ }
+ setState(aSubEntry, res);
+
+ sumIt.summarizeUp(aSubEntry);
+
+ LogWriter sumIfc = OutProducerFactory.createOutProducer(m_aParams);
+ aSubEntry.UserDefinedParams = m_aParams;
+ sumIfc.initialize(aSubEntry, logging);
+ sumIfc.summary(aSubEntry);
+ }
+
+ try
+ {
+ if (!keepdocument)
+ {
+ tCase.cleanupTestCase(m_aParams);
+ }
+ }
+ catch (Exception e)
+ {
+ System.err.println( "couldn't cleanup:" + e.toString() );
+ }
+ catch (java.lang.NoClassDefFoundError e)
+ {
+ System.err.println( "couldn't cleanup:" + e.toString() );
+ }
+
+ sumIt.summarizeUp(entry);
+
+ LogWriter sumObj = OutProducerFactory.createOutProducer(m_aParams);
+
+ sumObj.initialize(entry, logging);
+ sumObj.summary(entry);
+ }
+
+ if (entries.length > 0)
+ {
+ System.out.println();
+
+ int counter = 0;
+ System.out.println("Failures that appeared during scenario execution:");
+
+ for (int i = 0; i < entries.length; i++)
+ {
+ final String sState = entries[i].State;
+ if (!sState.endsWith("OK"))
+ {
+ System.out.println("\t " + entries[i].longName);
+ counter++;
+ }
+ }
+
+ System.out.println(counter + " of " + entries.length + " tests failed");
+ if (counter != 0) {
+ retValue = false;
+ }
+ }
+
+ closeExistingOffice();
+ return retValue;
+ }
+
+//
+ private TestEnvironment getTestEnvironment(TestCase tCase, DescEntry entry)
+ {
+ TestEnvironment tEnv = null;
+
+ try
+ {
+ tEnv = tCase.getTestEnvironment(m_aParams);
+ }
+ catch (Exception e)
+ {
+ System.out.println("Exception while creating " + tCase.getObjectName());
+ System.out.println("Message " + e.getMessage());
+ e.printStackTrace();
+ tEnv = null;
+ }
+ catch (java.lang.UnsatisfiedLinkError e)
+ {
+ System.out.println("Exception while creating " + tCase.getObjectName());
+ System.out.println("Message " + e.getMessage());
+ tEnv = null;
+ }
+ catch (java.lang.NoClassDefFoundError e)
+ {
+ System.out.println("Exception while creating " + tCase.getObjectName());
+ System.out.println("Message " + e.getMessage());
+ tEnv = null;
+ }
+
+ if (tEnv == null)
+ {
+ Summarizer.summarizeDown(entry, "Couldn't create " + tCase.getObjectName());
+
+ LogWriter sumObj = OutProducerFactory.createOutProducer(m_aParams);
+ entry.UserDefinedParams = m_aParams;
+ sumObj.initialize(entry, logging);
+ sumObj.summary(entry);
+ }
+ return tEnv;
+ }
+ // -------------------------------------------------------------------------
+ private TestCase getTestCase(DescEntry _aEntry)
+ {
+ TestCase tCase = null;
+
+ try
+ {
+ tCase = (TestCase) m_aDynamicClassLoader.getInstance("mod._" + _aEntry.entryName);
+ }
+ catch (java.lang.IllegalArgumentException ie)
+ {
+ _aEntry.ErrorMsg = ie.getMessage();
+ _aEntry.hasErrorMsg = true;
+ }
+ catch (java.lang.NoClassDefFoundError ie)
+ {
+ _aEntry.ErrorMsg = ie.getMessage();
+ _aEntry.hasErrorMsg = true;
+ }
+
+ if (tCase == null)
+ {
+ Summarizer.summarizeDown(_aEntry, _aEntry.ErrorMsg);
+
+ LogWriter sumObj = OutProducerFactory.createOutProducer(m_aParams);
+ _aEntry.UserDefinedParams = m_aParams;
+ sumObj.initialize(_aEntry, logging);
+ sumObj.summary(_aEntry);
+ }
+ return tCase;
+}
+
+ private void setState(DescEntry aSubEntry, lib.TestResult res)
+ {
+ if (res != null)
+ {
+ for (int k = 0; k < aSubEntry.SubEntryCount; k++)
+ {
+ DescEntry aSubSubEntry = aSubEntry.SubEntries[k];
+ if (res.hasMethod( aSubSubEntry.entryName))
+ {
+ aSubSubEntry.State = res.getStatusFor(aSubSubEntry.entryName).toString();
+ }
+ }
+ }
+ }
+
+ private TestEnvironment getEnv(DescEntry entry, TestParameters param)
+ {
+// if (m_aDynamicClassLoader == null)
+// m_aDynamicClassLoader = new DynamicClassLoader();
+// String officeProviderName = (String) m_aParams.get("OfficeProvider");
+// AppProvider office = (AppProvider) m_aDynamicClassLoader.getInstance(officeProviderName);
+//
+// if (office == null) {
+// System.out.println("ERROR: Wrong parameter 'OfficeProvider', " +
+// " it cannot be instantiated.");
+// System.exit(-1);
+// }
+//
+// XMultiServiceFactory msf = (XMultiServiceFactory) office.getManager(
+// m_aParams);
+//
+// if (msf == null) {
+// return null;
+// }
+//
+// m_aParams.put("ServiceFactory", msf);
+
+ // AppProvider office = startOffice(m_aParams);
+
+ TestCase tCase = null;
+
+ try
+ {
+ tCase = (TestCase) m_aDynamicClassLoader.getInstance("mod._" + entry.entryName);
+ }
+ catch (java.lang.IllegalArgumentException ie)
+ {
+ entry.ErrorMsg = ie.getMessage();
+ entry.hasErrorMsg = true;
+ }
+ catch (java.lang.NoClassDefFoundError ie)
+ {
+ entry.ErrorMsg = ie.getMessage();
+ entry.hasErrorMsg = true;
+ }
+
+ System.out.println("Creating: " + entry.entryName);
+
+ entry.UserDefinedParams = param;
+
+ LogWriter log = (LogWriter) m_aDynamicClassLoader.getInstance((String) param.get("LogWriter"));
+ log.initialize(entry, logging);
+ tCase.setLogWriter((PrintWriter) log);
+
+ try
+ {
+ tCase.initializeTestCase(param);
+ return tCase.getTestEnvironment(param);
+ }
+ catch (com.sun.star.lang.DisposedException de)
+ {
+ System.out.println("Office disposed");
+ closeExistingOffice();
+ throw de;
+ }
+ catch (lib.StatusException e)
+ {
+ System.out.println(e.getMessage());
+
+ closeExistingOffice();
+
+ entry.ErrorMsg = e.getMessage();
+ entry.hasErrorMsg = true;
+ throw e;
+ }
+ }
+
+ private void closeExistingOffice()
+ {
+ helper.ProcessHandler ph = (helper.ProcessHandler) m_aParams.get("AppProvider");
+
+ if (ph != null)
+ {
+ m_aOffice.closeExistingOffice(m_aParams, true);
+ util.utils.shortWait(5000);
+ }
+
+ }
+
+// private void shortWait(int millis)
+// {
+// try
+// {
+// Thread.sleep(millis);
+// }
+// catch (java.lang.InterruptedException ie)
+// {
+// }
+// }
+
+ private Vector getExclusionList(String url, boolean debug)
+ {
+ Vector entryList = new Vector();
+ String line = "#";
+ BufferedReader exclusion = null;
+
+ try
+ {
+ exclusion = new BufferedReader(new FileReader(url));
+ }
+ catch (java.io.FileNotFoundException fnfe)
+ {
+ if (debug)
+ {
+ System.out.println("Couldn't find file " + url);
+ }
+
+ return entryList;
+ }
+
+ while (line != null)
+ {
+ try
+ {
+ if (!line.startsWith("#") && (line.length() > 1))
+ {
+ entryList.add(line.trim());
+ }
+
+ line = exclusion.readLine();
+ }
+ catch (java.io.IOException ioe)
+ {
+ if (debug)
+ {
+ System.out.println("Exception while reading exclusion list");
+ }
+
+ return entryList;
+ }
+ }
+
+ try
+ {
+ exclusion.close();
+ }
+ catch (java.io.IOException ioe)
+ {
+ if (debug)
+ {
+ System.out.println("Couldn't close file " + url);
+ }
+
+ return entryList;
+ }
+
+ return entryList;
+ }
+
+ private TestResult executeInterfaceTest(
+ DescEntry entry, TestEnvironment tEnv, TestParameters param)
+ throws IllegalArgumentException, java.lang.NoClassDefFoundError
+ {
+ MultiMethodTest ifc = (MultiMethodTest) m_aDynamicClassLoader.getInstance(entry.entryName);
+ return ifc.run(entry, tEnv, param);
+ }
+
+ private AppProvider startOffice(lib.TestParameters param)
+ {
+
+ if (m_aDynamicClassLoader == null)
+ {
+ m_aDynamicClassLoader = new DynamicClassLoader();
+ }
+
+ String officeProviderName = (String) param.get("OfficeProvider");
+ AppProvider office = (AppProvider) m_aDynamicClassLoader.getInstance(officeProviderName);
+
+ if (office == null)
+ {
+ System.out.println("ERROR: Wrong parameter 'OfficeProvider', " + " it cannot be instantiated.");
+ System.exit(-1);
+ }
+
+ XMultiServiceFactory msf = (XMultiServiceFactory) office.getManager(param);
+
+ if (msf != null)
+ {
+ param.put("ServiceFactory", msf);
+ }
+
+ return office;
+ }
+}
diff --git a/qadevOOo/runner/base/java_fat_service.java b/qadevOOo/runner/base/java_fat_service.java
new file mode 100644
index 000000000000..0c8fd17e43ec
--- /dev/null
+++ b/qadevOOo/runner/base/java_fat_service.java
@@ -0,0 +1,267 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package base;
+
+
+import java.io.PrintWriter;
+
+import lib.TestParameters;
+import lib.TestCase;
+import lib.MultiMethodTest;
+import lib.TestEnvironment;
+import util.DynamicClassLoader;
+
+import com.sun.star.lang.XMultiServiceFactory;
+
+import share.DescEntry;
+import share.DescGetter;
+import helper.APIDescGetter;
+
+import share.LogWriter;
+import stats.Summarizer;
+
+/**
+ * this class handles tests written in java and running on a fat Office
+ * with the runner as a service.
+ */
+public class java_fat_service implements TestBase {
+
+ static protected boolean debug = false;
+ protected LogWriter log = null;
+
+ public boolean executeTest(lib.TestParameters param) {
+ DynamicClassLoader dcl = new DynamicClassLoader();
+ log = (LogWriter)dcl.getInstance((String)param.get("LogWriter"));
+ debug = ((Boolean) param.get("DebugIsActive")).booleanValue();
+
+ DescGetter dg = new APIDescGetter();
+ String job = (String) param.get("TestJob");
+ boolean retValue = true;
+
+ //get Job-Descriptions
+ log.println("Getting Descriptions for Job: "+job);
+ DescEntry[] entries = dg.getDescriptionFor(job,
+ (String) param.get("DescriptionPath"),debug);
+
+ if (entries == null ) {
+ log.println("Couldn't get Description for Job");
+ return false;
+ }
+
+ String conStr = (String) param.get("ConnectionString");
+
+ XMultiServiceFactory msf = (XMultiServiceFactory)param.getMSF();
+
+ for (int l=0;l<entries.length;l++) {
+
+ if (entries[l] == null ) {
+ continue;
+ }
+
+ if (entries[l].hasErrorMsg) {
+ log.println(entries[l].ErrorMsg);
+ continue;
+ }
+
+ DescEntry entry = entries[l];
+
+ //get some helper classes
+ Summarizer sumIt = new Summarizer();
+
+ TestCase tCase = null;
+ try {
+ tCase = (TestCase)
+ dcl.getInstance("mod._"+entry.entryName);
+ } catch (java.lang.IllegalArgumentException ie) {
+ entry.ErrorMsg=ie.getMessage();
+ entry.hasErrorMsg=true;
+ }
+
+ if (tCase == null) {
+ sumIt.summarizeDown(entry,entry.ErrorMsg);
+ LogWriter sumObj = (LogWriter)dcl.getInstance(
+ (String)param.get("OutProducer"));
+ sumObj.initialize(entry,true);
+ entry.UserDefinedParams = param;
+ sumObj.summary(entry);
+ continue;
+ }
+
+ log.println("Creating: "+tCase.getObjectName());
+
+ log.initialize(entry,true);
+ entry.UserDefinedParams = param;
+ TestEnvironment tEnv = null;
+ try {
+ tCase.setLogWriter((PrintWriter) log);
+ tCase.initializeTestCase(param);
+ tEnv = tCase.getTestEnvironment(param);
+ } catch (Exception e) {
+ log.println("Exception while creating "+tCase.getObjectName());
+ log.println("Exception: " + e);
+ log.println("Message "+e.getMessage());
+ tEnv = null;
+ }
+ if (tEnv == null) {
+ sumIt.summarizeDown(entry,"Couldn't create "+tCase.getObjectName());
+ LogWriter sumObj = (LogWriter)dcl.getInstance(
+ (String)param.get("OutProducer"));
+ sumObj.initialize(entry,true);
+ entry.UserDefinedParams = param;
+ sumObj.summary(entry);
+ continue;
+ }
+ log.println("Created "+tCase.getObjectName()+"\n");
+
+ for (int j=0;j<entry.SubEntryCount;j++) {
+ if (!entry.SubEntries[j].isToTest) {
+ Summarizer.summarizeDown(entry.SubEntries[j],"not part of the job");
+ continue;
+ }
+
+ log.println("running: "+entry.SubEntries[j].entryName);
+
+ LogWriter ifclog = (LogWriter)dcl.getInstance(
+ (String)param.get("LogWriter"));
+
+ ifclog.initialize(entry.SubEntries[j],true);
+ entry.SubEntries[j].UserDefinedParams = param;
+ entry.SubEntries[j].Logger = ifclog;
+
+ if (tEnv == null || tEnv.isDisposed()) {
+ tEnv = getEnv(entry,param);
+ }
+
+ MultiMethodTest ifc = null;
+ lib.TestResult res = null;
+ try {
+ ifc = (MultiMethodTest) dcl.getInstance(
+ entry.SubEntries[j].entryName);
+ res = ifc.run(entry.SubEntries[j],tEnv,param);
+ } catch (IllegalArgumentException iae) {
+ log.println("Couldn't load class "+entry.SubEntries[j].entryName);
+ log.println("**** "+iae.getMessage()+" ****");
+ Summarizer.summarizeDown(entry.SubEntries[j],iae.getMessage());
+ } catch (java.lang.RuntimeException e) {
+ tEnv = getEnv(entry,param);
+ ifc = (MultiMethodTest) dcl.getInstance(
+ entry.SubEntries[j].entryName);
+ if ((tEnv != null) && (ifc != null)) {
+ res = ifc.run(entry.SubEntries[j],tEnv,param);
+ }
+ else
+ {
+ res = null;
+ }
+ }
+ if (res != null) {
+ for (int k=0;k<entry.SubEntries[j].SubEntryCount;k++) {
+ if (res.hasMethod(entry.SubEntries[j].SubEntries[k].entryName)) {
+ entry.SubEntries[j].SubEntries[k].State=
+ res.getStatusFor(entry.SubEntries[j].SubEntries[k].entryName).toString();
+ }
+ }
+ }
+ sumIt.summarizeUp(entry.SubEntries[j]);
+
+ LogWriter sumIfc = (LogWriter)dcl.getInstance(
+ (String)param.get("OutProducer"));
+
+ sumIfc.initialize(entry.SubEntries[j],true);
+ entry.SubEntries[j].UserDefinedParams = param;
+ sumIfc.summary(entry.SubEntries[j]);
+ }
+ try {
+ tCase.cleanupTestCase(param);
+ } catch (Exception e) {
+ e.printStackTrace((PrintWriter)log);
+ }
+ sumIt.summarizeUp(entry);
+ LogWriter sumObj = (LogWriter)dcl.getInstance(
+ (String)param.get("OutProducer"));
+ sumObj.initialize(entry,true);
+ sumObj.summary(entry);
+ }
+ if (entries.length > 1) {
+ log.println("");
+ int counter = 0;
+ log.println("Failures that appeared during scenario execution:");
+ for (int i=0;i<entries.length;i++) {
+ if (! entries[i].State.endsWith("OK")) {
+ log.println("\t "+entries[i].longName);
+ counter++;
+ }
+ }
+ log.println(counter +" of "+entries.length + " tests failed" );
+ }
+
+ return retValue;
+ }
+
+ protected TestEnvironment getEnv(DescEntry entry, TestParameters param) {
+ DynamicClassLoader dcl = new DynamicClassLoader();
+ log = (LogWriter)dcl.getInstance((String)param.get("LogWriter"));
+ XMultiServiceFactory msf = (XMultiServiceFactory)param.getMSF();
+
+ TestCase tCase = null;
+
+ try
+ {
+ tCase = (TestCase) dcl.getInstance("mod._"+entry.entryName);
+ }
+ catch (java.lang.IllegalArgumentException ie)
+ {
+ entry.ErrorMsg=ie.getMessage();
+ entry.hasErrorMsg=true;
+ }
+
+ log.println("Creating: "+tCase.getObjectName());
+ // LogWriter log = (LogWriter)dcl.getInstance( (String)param.get("LogWriter"));
+ log.initialize(entry,true);
+ entry.UserDefinedParams = param;
+ tCase.setLogWriter((PrintWriter) log);
+ TestEnvironment tEnv = null;
+ try
+ {
+ tCase.initializeTestCase(param);
+ tEnv = tCase.getTestEnvironment(param);
+ }
+ catch (com.sun.star.lang.DisposedException de)
+ {
+ log.println("Office disposed");
+ }
+ return tEnv;
+ }
+
+// protected void shortWait(int millis) {
+// try {
+// Thread.sleep(millis);
+// } catch (java.lang.InterruptedException ie) {}
+// }
+
+}
diff --git a/qadevOOo/runner/base/makefile.mk b/qadevOOo/runner/base/makefile.mk
new file mode 100644
index 000000000000..17fb497c0c8b
--- /dev/null
+++ b/qadevOOo/runner/base/makefile.mk
@@ -0,0 +1,52 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..
+
+PRJNAME = OOoRunner
+PACKAGE = base
+TARGET = runner_base
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+# --- Files --------------------------------------------------------
+
+JARFILES = ridl.jar jurt.jar unoil.jar
+JAVAFILES = TestBase.java \
+ java_complex.java \
+ java_fat.java \
+ java_fat_service.java \
+ java_cmp.java \
+ basic_fat.java
+
+JAVACLASSFILES= $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class)
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
diff --git a/qadevOOo/runner/basicrunner/BasicException.java b/qadevOOo/runner/basicrunner/BasicException.java
new file mode 100644
index 000000000000..419e26461916
--- /dev/null
+++ b/qadevOOo/runner/basicrunner/BasicException.java
@@ -0,0 +1,42 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package basicrunner;
+
+/** An exception while executing a Basic test.
+ */
+public class BasicException extends Throwable {
+ /** Detailed information about the exception.
+ */
+ public String info;
+
+ /** Constructor with detailed information.
+ * @param info Information about the exception.
+ */
+ public BasicException(String info) {
+ this.info = info;
+ }
+} \ No newline at end of file
diff --git a/qadevOOo/runner/basicrunner/BasicHandler.java b/qadevOOo/runner/basicrunner/BasicHandler.java
new file mode 100644
index 000000000000..a0f5f5e405fc
--- /dev/null
+++ b/qadevOOo/runner/basicrunner/BasicHandler.java
@@ -0,0 +1,612 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package basicrunner;
+
+
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.connection.ConnectionSetupException;
+import com.sun.star.container.ContainerEvent;
+import com.sun.star.container.XContainer;
+import com.sun.star.container.XContainerListener;
+import com.sun.star.container.XNameContainer;
+import com.sun.star.frame.XComponentLoader;
+import com.sun.star.frame.XDesktop;
+import com.sun.star.lang.WrappedTargetException;
+import com.sun.star.lang.XComponent;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.lang.XServiceInfo;
+import com.sun.star.lang.XSingleServiceFactory;
+import com.sun.star.lang.XTypeProvider;
+import com.sun.star.uno.Type;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.util.XChangesBatch;
+import java.util.Hashtable;
+import lib.TestParameters;
+
+import share.LogWriter;
+
+
+/**
+ * This class is a java-part of BASIC-java interaction "driver"
+ * It is used to call Star-Basic's function from java using
+ * basic's part of "driver" where listeners are implemented.
+ * The instance of the BasicHandler should be added to the MSF that will be
+ * used for loading BASIC's part of "driver".<br>
+ * After opening basic's document it creates an instance of the
+ * HandlerContainer using BasicHandler. HandlerContainer is a UNO
+ * XContainer and XNameContainer.
+ * Only one instance of BasicHandler can be used at the moment.
+ * @see com.sun.star.lang.XServiceInfo
+ * @see com.sun.star.lang.XSingleServiceFactory
+ */
+public class BasicHandler implements XServiceInfo, XSingleServiceFactory {
+ /**
+ * serviceName is the name of service that can be created in BASIC.
+ */
+ static final String serviceName =
+ "com.sun.star.jsuite.basicrunner.BasicHandler";
+
+ /**
+ * <code>container</code> is a SHARED variable (between BASIC and Java).
+ * It is used for interacting.
+ */
+ static private HandlerContainer container = null;
+
+ /**
+ * Contains a writer to log an information about the interface testing, to
+ * allows for tests to access it.
+ */
+ static private LogWriter log;
+
+ /**
+ * <code>oHandlerDoc</code> is a referrence to BASIC's document.
+ */
+ static private XComponent oHandlerDoc = null;
+
+ /**
+ * <code>xMSF</code> is a MultiServiceFactory currently used by
+ * BasicHandler.
+ */
+ static private XMultiServiceFactory xMSF = null;
+
+ /**
+ * Interface being tested now.
+ */
+ static private BasicIfcTest TestedInterface = null;
+
+ /**
+ * Ab enhanced scheme of timeouts can be used with BASIC tests.
+ * A small timeout can be used zo wait for changes in the test status.
+ * <code>respFlag</code> is set to <code>true</code> when a BASIC test
+ * writes any log information.
+ */
+ static private boolean respFlag = false;
+
+ /**
+ * <code>iBasicTimeout</code> is the amount of milliseconds that
+ * the BasicHandler will wait for a response from tests
+ * (finish to execute a method or add log information)
+ * before it decides that SOffice is dead.
+ */
+ static private int iBasicTimeout = 10000;
+
+
+
+ /**
+ * Creates an instance of a HandlerContainer. This instance is used from
+ * BASIC.
+ * @param tParam The test parameters.
+ */
+ public BasicHandler(TestParameters tParam) {
+ if (tParam.get("soapi.test.basic.debugFile") != null) {
+ iBasicTimeout = 0; // Debug mode.
+ }
+ container = new HandlerContainer(this);
+ }
+
+ /**
+ * Set the tested interface and a log writer.
+ * @param ifc The test of an interface
+ * @param log A log writer.
+ */
+ public void setTestedInterface(BasicIfcTest ifc, LogWriter log) {
+ this.log = log;
+ TestedInterface = ifc;
+ }
+
+ /**
+ * Is called when BASIC signals that it has performed the test of a method.
+ * @param methodName The name of the method.
+ * @bResult The result of the test.
+ */
+ synchronized void methodTested(String methodName, boolean bResult) {
+ respFlag = true;
+ TestedInterface.methodTested(methodName, bResult);
+ notify() ;
+ }
+
+ /**
+ * Is called when BASIC sends a signal to write some log information.
+ * @param info The string to write.
+ */
+ synchronized public void Log(String info) {
+ respFlag = true;
+ log.println(info);
+ notify() ;
+ }
+
+ /**
+ * Is called by BasicIfcTest to find out if this BasicHandler uses the
+ * correct MultiServiceFactory.
+ * @param xMSF The MultiServiceFactory
+ * @see com.sun.star.lang.XMultiServiceFactory
+ * @return True, if xMSF is equal to the MultiServiceFactory of this class.
+ */
+ public boolean isUptodate(XMultiServiceFactory xMSF) {
+ return xMSF.equals(this.xMSF);
+ }
+
+
+ /**
+ * Establishes a connection between BASIC and Java.
+ * If required, hte BASIC part of the "driver" is loaded.
+ * @param sBasicBridgeURL The URL of the basic bridge document
+ * (BasicBridge.sxw)
+ * @param tParam The test parameters.
+ * @param xMSF The MultiServiceFactory
+ * @param log The log writer.
+ * @see com.sun.star.lang.XMultiServiceFactory
+ * @throws ConnectionSetupException Exception is thrown, if no connection could be made.
+ */
+ public synchronized void Connect(String sBasicBridgeURL,
+ TestParameters tParam, XMultiServiceFactory xMSF,
+ LogWriter log) throws ConnectionSetupException {
+ this.log = log;
+ try {
+ this.xMSF = xMSF;
+ Object oInterface = xMSF.createInstance(
+ "com.sun.star.frame.Desktop");
+ XDesktop oDesktop = (XDesktop) UnoRuntime.queryInterface(
+ XDesktop.class, oInterface);
+ XComponentLoader oCLoader = (XComponentLoader)
+ UnoRuntime.queryInterface(
+ XComponentLoader.class, oDesktop);
+
+ // load BasicBridge with MarcoEceutionMode = Always-no warn
+ //PropertyValue[] DocArgs = null;
+ PropertyValue[] DocArgs = new PropertyValue[1];
+ PropertyValue DocArg = new PropertyValue();
+ DocArg.Name = "MacroExecutionMode";
+ DocArg.Value = new Short(
+ com.sun.star.document.MacroExecMode.ALWAYS_EXECUTE_NO_WARN);
+ DocArgs[0] = DocArg;
+
+ // configure Office to allow to execute macos
+ PropertyValue [] ProvArgs = new PropertyValue [1];
+ PropertyValue Arg = new PropertyValue();
+ Arg.Name = "nodepath";
+ Arg.Value = "/org.openoffice.Office.Common/Security";
+ ProvArgs[0] = Arg;
+
+ Object oProvider = xMSF.createInstance(
+ "com.sun.star.configuration.ConfigurationProvider");
+
+ XMultiServiceFactory oProviderMSF = (XMultiServiceFactory)
+ UnoRuntime.queryInterface(
+ XMultiServiceFactory.class, oProvider);
+
+ Object oSecure = oProviderMSF.createInstanceWithArguments(
+ "com.sun.star.configuration.ConfigurationUpdateAccess",
+ ProvArgs);
+
+ XPropertySet oSecureProps = (XPropertySet)
+ UnoRuntime.queryInterface(XPropertySet.class, oSecure);
+
+ Object oScripting = oSecureProps.getPropertyValue("Scripting");
+ XPropertySet oScriptingSettings = (XPropertySet)
+ UnoRuntime.queryInterface(XPropertySet.class, oScripting);
+
+ oScriptingSettings.setPropertyValue("Warning", Boolean.FALSE);
+ oScriptingSettings.setPropertyValue("OfficeBasic", new Integer(2));
+
+ XChangesBatch oSecureChange = (XChangesBatch)
+ UnoRuntime.queryInterface(XChangesBatch.class, oSecure);
+ oSecureChange.commitChanges();
+
+ // As we want to have some information about a debugFile
+ // BEFORE connection is established
+ // we pass the information about it in frame name.
+ String sFrameName = (String)tParam.get(
+ "soapi.test.basic.debugFile");
+ if (sFrameName == null) sFrameName = "BasicRunner";
+
+ oHandlerDoc = oCLoader.loadComponentFromURL(sBasicBridgeURL,
+ sFrameName, 40, DocArgs);
+
+ do {
+ respFlag = false ;
+ wait(10000); // waiting for basic response for 10 seconds.
+ } while (respFlag && !container.hasByName("BASIC_Done")) ;
+
+ if (!container.hasByName("BASIC_Done")) {
+ throw new ConnectionSetupException("Connection timed out.");
+ }
+ } catch (Exception e) {
+ System.out.println("Exception: " + e.toString());
+ throw new ConnectionSetupException();
+ }
+
+ log.println("Java-BASIC connection established!");
+ }
+
+ /**
+ * Overloads perform(Strin fName, Object params) for convenience.
+ * @return A proprty value as result.
+ *
+ public synchronized PropertyValue perform(String fName)
+ throws BasicException {
+ return perform(fName, "");
+ }
+*/
+ /**
+ * Perform a test of a method.
+ * @param fName The name of the method to test.
+ * @param params The test parameters.
+ * @return A proprty value as result of the test.
+ * @throws BasicException The method could not be executed.
+ */
+ public synchronized PropertyValue perform(String fName, Object params)
+ throws BasicException {
+ try {
+ container.callBasicFunction(fName, params);
+
+ do {
+ respFlag = false;
+ // waiting for basic response for iBasicTimeout milliseconds.
+ wait(iBasicTimeout);
+ } while(respFlag && !container.hasByName("BASIC_Done"));
+
+ } catch (InterruptedException e) {
+ System.out.println("The operation " + fName + " was interrupted.");
+ } catch (com.sun.star.lang.DisposedException de) {
+ System.out.println("## Office is disposed");
+ }
+
+ if (!container.hasByName("BASIC_Done")) {
+ System.out.println("Operation timed out.");
+ throw new BasicException(
+ "Operation timed out.");
+ }
+
+ Object res = container.getByName("BASIC_Done") ;
+ container.removeByName("BASIC_Done");
+
+ if (!(res instanceof PropertyValue)) {
+ if (res == null) {
+ System.out.println(
+ "BasicBridge returns null");
+ throw new BasicException(
+ "BasicBridge returns null");
+ } else {
+ System.out.println(
+ "BasicBridge returns wrong type: " + res.getClass());
+ throw new BasicException(
+ "BasicBridge returns wrong type: " + res.getClass());
+ }
+ }
+
+ PropertyValue result = (PropertyValue) res ;
+
+ if ((result.Value instanceof String) && (((String)result.Value)).startsWith("Exception")) {
+ throw new BasicException((String)result.Value);
+ }
+
+ return result;
+ }
+
+ /**
+ * Returns true, if name is a supported service of this class.
+ * @param name The service name.
+ * @return True, if the service is supported.
+ */
+ public boolean supportsService(String name) {
+ return serviceName.equals(name);
+ }
+
+ /**
+ * Return all supported service names.
+ * @return All supported services.
+ */
+ public String[] getSupportedServiceNames() {
+ return new String[] {serviceName};
+ }
+
+ /**
+ * Get the implementation name.
+ * @return Implementation name.
+ */
+ public String getImplementationName() {
+ return getClass().getName();
+ }
+
+ /**
+ * Create an instance of HandlerContainer.
+ * Arguments are not supported here, so they will be ignored.
+ * @param args The arguments.
+ * @return The instance.
+ */
+ public Object createInstanceWithArguments(Object[] args) {
+ return container;
+ }
+
+ /**
+ * Create an instance of HandlerContainer.
+ * @return The instance.
+ */
+ public Object createInstance() {
+ return createInstanceWithArguments(null);
+ }
+
+ /**
+ * Dispose the BASIC document.
+ */
+ public synchronized void dispose() {
+ try {
+ if (oHandlerDoc != null) {
+ //oHandlerDoc.dispose();
+ util.DesktopTools.closeDoc(oHandlerDoc);
+ wait(1000);
+ }
+ } catch (Exception e) {
+ System.out.println("Exception: " + e.toString());
+ }
+ }
+}
+
+
+/**
+ * This class handles the communication between Java and BASIC.
+ * @see com.sun.star.container.XContainer
+ * @see com.sun.star.container.XNameContainer
+ * @see com.sun.star.lang.XTypeProvider
+ */
+class HandlerContainer implements XContainer, XNameContainer, XTypeProvider{
+
+ /** Container for parameters.
+ **/
+ Hashtable container = new Hashtable(20);
+ /**
+ * An array of listeners for container events.
+ * @see com.sun.star.container.XContainerListener
+ */
+ static XContainerListener[] listener = null;
+
+ /** The BasicHandler belonging to this handler. **/
+ BasicHandler parent = null;
+
+ /**
+ * Constructor with the parent BasicHandler.
+ * @param par The BasicHandler.
+ */
+ public HandlerContainer(BasicHandler par) {
+ parent = par;
+ }
+
+ /**
+ * Call a BASIC function, meaning a test method.
+ * @param fName The method name.
+ * @param args Arguments for the method.
+ */
+ public void callBasicFunction(String fName, Object args) {
+ // BASIC's listener should be called ONLY in this case.
+ if (container.containsKey(fName)) {
+ container.remove(fName);
+ }
+ container.put(fName, args);
+ if (listener != null) {
+ ContainerEvent event = new ContainerEvent();
+ event.Element = fName;
+ for (int i=0; i<listener.length; i++){
+ if (listener[i] != null) {
+ listener[i].elementInserted(event);
+ }
+ }
+ }
+ }
+
+ /**
+ * Insert an object into the container.
+ * @param name The key for the object.
+ * @param object The object to insert.
+ * @throws IllegalArgumentException Throws this exception when trying to insert null.
+ */
+ public void insertByName(String name, Object object) throws com.sun.star.lang.IllegalArgumentException, com.sun.star.container.ElementExistException, com.sun.star.lang.WrappedTargetException {
+
+ // BASIC and Java can insert into the container.
+ if (container.containsKey(name)) {
+ container.remove(name);
+ }
+ container.put(name, object);
+
+ PropertyValue result = null ;
+
+ if (object instanceof PropertyValue) {
+ result = (PropertyValue)object;
+ if (name.equals("BASIC_Done")) {
+ synchronized (parent) {
+ parent.notify();
+ }
+ } else if (name.equals("BASIC_MethodTested")) {
+ parent.methodTested(result.Name,
+ ((Boolean)result.Value).booleanValue());
+ }
+ } else if (name.equals("BASIC_Log")) {
+ parent.Log(object.toString());
+ }
+ }
+
+ /**
+ * Remove the object with this name from the container.
+ * @param name The key.
+ */
+ public void removeByName(String name) {
+ container.remove(name) ;
+ }
+
+ /**
+ * Unsupported method.
+ * @param name The name of the key.
+ * @param value The value.
+ * @throws WrappedTargetException Throws this exception when called falsely.
+ */
+ public void replaceByName(String name, Object value)
+ throws WrappedTargetException {
+ throw new WrappedTargetException("Unsupported");
+ }
+
+ /**
+ * Has a value for this key.
+ * @param name The name of a key.
+ * @return True, if name exists as key in the container.
+ */
+ public boolean hasByName(String name) {
+ return container.containsKey(name);
+ }
+
+ /**
+ * Get an object by its key.
+ * @param name The name of the key.
+ * @return The object of this key.
+ */
+ public Object getByName(String name) {
+ return container.get(name);
+ }
+
+ /**
+ * Get all key names.
+ * @return All names of keys.
+ */
+ public String[] getElementNames() {
+ String[] res = new String[container.size()];
+ return (String[])container.keySet().toArray(res);
+ }
+
+ /**
+ * Is the xcontainer empty?
+ * @return True, if the container has elements.
+ */
+ public boolean hasElements() {
+ return !container.isEmpty();
+ }
+
+ /**
+ * Get the type of this class.
+ * @return The type of this class.
+ */
+ public Type getElementType() {
+ try {
+ return new Type(String.class);
+ } catch (Exception e) {
+ return null;
+ }
+ }
+
+ /**
+ * Get the implementation id of this class.
+ * @return A unique id for this class
+ * @see com.sun.star.lang.XTypeProvider
+ */
+ public byte[] getImplementationId() {
+ return toString().getBytes();
+ }
+
+ /**
+ * Get all types of this class.
+ * @return All implemented UNO types.
+ */
+ public Type[] getTypes() {
+ Class interfaces[] = getClass().getInterfaces();
+ Type types[] = new Type[interfaces.length];
+ for(int i = 0; i < interfaces.length; ++ i) {
+ types[i] = new Type(interfaces[i]);
+ }
+ return types;
+ }
+
+ /**
+ * Add a listener
+ * @param xListener The listener.
+ */
+ public void addContainerListener(XContainerListener xListener){
+ int length = 0;
+ if (listener != null)
+ length = listener.length;
+
+ XContainerListener[] mListener =
+ new XContainerListener[length+1];
+ for (int i=0; i<length-1; i++) {
+ mListener[i] = listener[i];
+ // listener already added
+ if (((Object)xListener).equals(listener[i]))
+ return;
+ }
+ mListener[length] = xListener;
+ listener = mListener;
+ }
+
+ /**
+ * Remove a listener
+ * @param xListener The listener.
+ */
+ public void removeContainerListener(XContainerListener xListener){
+ if (listener != null && listener.length != 0) {
+ int length = listener.length;
+ XContainerListener[] mListener =
+ new XContainerListener[length-1];
+ boolean found = false;
+ int j=0;
+ for (int i=0; i<length-1; i++) {
+ if (!((Object)xListener).equals(listener[j])) {
+ mListener[i] = listener[j];
+ }
+ else {
+ j++;
+ found = true;
+ }
+ j++;
+ }
+ if (!found) {
+ if (((Object)xListener).equals(listener[length-1]))
+ listener = mListener;
+ }
+ else
+ listener = mListener;
+
+ }
+ }
+}
diff --git a/qadevOOo/runner/basicrunner/BasicHandlerProvider.java b/qadevOOo/runner/basicrunner/BasicHandlerProvider.java
new file mode 100644
index 000000000000..9a6479d50f1d
--- /dev/null
+++ b/qadevOOo/runner/basicrunner/BasicHandlerProvider.java
@@ -0,0 +1,153 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package basicrunner;
+
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.container.XSet;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.container.ElementExistException;
+import com.sun.star.lang.IllegalArgumentException;
+import com.sun.star.connection.ConnectionSetupException;
+import lib.TestParameters;
+import share.LogWriter;
+import basicrunner.basichelper.Connector;
+import basicrunner.basichelper.DocumentHandler;
+import basicrunner.basichelper.ThreadRunner;
+import basicrunner.basichelper.AttributeList;
+import basicrunner.basichelper.Filter;
+import basicrunner.basichelper.DispatchProviderInterceptor;
+
+/**
+ * This class provides a BasicHandler. All classes for the communication with
+ * and handling of the BASIC tests are instantiated and inserted int the
+ * MultiServiceFactory of StarOffice.
+ */
+public class BasicHandlerProvider {
+
+ /** The BassicHandler **/
+ static BasicHandler oHandler = null;
+ /** The Connector **/
+ static Connector oConnector = null;
+ /** The DocumentHandler **/
+ static DocumentHandler oDocumentHandler = null;
+ /** The Thread Runner **/
+ static ThreadRunner oThreadRunner = null;
+ /** The AttributeList **/
+ static AttributeList oAttributeList = null;
+ /** The Filter **/
+ static Filter oFilter = null;
+ /** The DispatchProviderInterceptor **/
+ static DispatchProviderInterceptor oCeptor = null ;
+ /** The MultiServiceFactory from StarOffice **/
+ static XMultiServiceFactory MSF = null;
+ /** IS this a new connection or an existing one? **/
+ static boolean bIsNewConnection = true;
+
+ /**
+ * Get a BasicHandler
+ * @param tParam Test parameters.
+ * @param log A log writer
+ * @return An instance of BasicHandler
+ */
+ static public BasicHandler getHandler(TestParameters tParam, LogWriter log) {
+
+ XMultiServiceFactory xMSF = (XMultiServiceFactory)tParam.getMSF();
+
+ if (!xMSF.equals(MSF)) {
+ MSF = xMSF;
+ oHandler = new BasicHandler(tParam);
+ oConnector = new Connector();
+ oFilter = new Filter();
+ oDocumentHandler = new DocumentHandler();
+ oThreadRunner = new ThreadRunner(xMSF);
+ oCeptor = new DispatchProviderInterceptor() ;
+ oAttributeList = new AttributeList();
+ XSet xMSFSet = (XSet)UnoRuntime.queryInterface(XSet.class, xMSF);
+
+ try {
+ xMSFSet.insert(oHandler);
+ xMSFSet.insert(oConnector);
+ xMSFSet.insert(oFilter);
+ xMSFSet.insert(oDocumentHandler);
+ xMSFSet.insert(oThreadRunner);
+ xMSFSet.insert(oCeptor);
+ xMSFSet.insert(oAttributeList);
+ } catch (ElementExistException e) {
+ System.out.println(e.toString());
+ } catch (IllegalArgumentException e) {
+ System.out.println(e.toString());
+ }
+
+ try {
+ oHandler.Connect(util.utils.getFullURL((String)tParam.get("BASICBRIDGE")),
+ tParam, xMSF, log);
+ } catch (ConnectionSetupException e) {
+ System.out.println("Can't connect to BASIC !");
+ }
+
+ bIsNewConnection = true;
+ } else {
+ bIsNewConnection = false;
+ }
+
+ return oHandler;
+ }
+
+ /**
+ * Is this a new connection?
+ * @return True, if the connection did not exist before.
+ */
+ static public boolean isNewConnection() {
+ return bIsNewConnection;
+ }
+
+ /**
+ * Dispose the BasicHandler
+ */
+ static public void disposeHandler() {
+
+ try {
+ if (oHandler != null) {
+ oHandler.dispose();
+ }
+ if (MSF != null) {
+ XSet xMSFSet = (XSet)UnoRuntime.queryInterface(XSet.class, MSF);
+ xMSFSet.remove(oHandler);
+ xMSFSet.remove(oFilter);
+ xMSFSet.remove(oConnector);
+ xMSFSet.remove(oDocumentHandler);
+ xMSFSet.remove(oThreadRunner);
+ xMSFSet.remove(oAttributeList);
+ }
+ } catch (Exception e){
+ System.out.println(e.toString());
+ }
+
+ MSF = null;
+ oHandler = null;
+ }
+}
diff --git a/qadevOOo/runner/basicrunner/BasicIfcTest.java b/qadevOOo/runner/basicrunner/BasicIfcTest.java
new file mode 100644
index 000000000000..8c75f8ff94f0
--- /dev/null
+++ b/qadevOOo/runner/basicrunner/BasicIfcTest.java
@@ -0,0 +1,169 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package basicrunner;
+
+import lib.TestResult;
+import lib.TestEnvironment;
+import lib.TestParameters;
+import share.DescEntry;
+import share.LogWriter;
+
+import com.sun.star.lang.XMultiServiceFactory;
+
+import com.sun.star.beans.PropertyValue;
+
+
+/**
+ * The BASIC interface test
+ */
+public class BasicIfcTest {
+ /** The BasicHandler **/
+ static BasicHandler oBasicHandler = null;
+ /** The result orf the test **/
+ protected TestResult tRes;
+ /** the name of the test **/
+ protected String testName;
+
+ /** Constructor with test name.
+ * @param name The name of the test.
+ */
+ public BasicIfcTest(String name) {
+ testName = name;
+ }
+
+ /**
+ * Let the test run.
+ * @param xTestedEntry Informaton about the interface to test.
+ * @param tEnv The environment of the test.
+ * @param tParam The test parameters.
+ * @return A result of the test.
+ */
+ public TestResult run(DescEntry xTestedEntry, TestEnvironment tEnv,
+ TestParameters tParam) {
+
+ String sResult = "";
+
+ this.tRes = new TestResult();
+ LogWriter log = xTestedEntry.Logger;
+
+ // Get Handler, that was created during object creation.
+ try {
+ oBasicHandler = (BasicHandler)tEnv.getObjRelation("BasicHandler");
+ } catch (java.lang.NullPointerException e) {
+ log.println("No Component created");
+ return null;
+ }
+
+ if (!oBasicHandler.isUptodate((XMultiServiceFactory)tParam.getMSF())) {
+ // If Handler uses old MSF (in case of Office's GPF) then don't test
+ // interface.
+ return null;
+ }
+
+ boolean objectWasCreated = ((Boolean)tEnv.getObjRelation("objectCreated")).booleanValue();
+
+ if (objectWasCreated) {
+ oBasicHandler.setTestedInterface(this, log);
+
+ DescEntry methods[] = xTestedEntry.SubEntries;
+
+ String names[] = new String[methods.length + 1];
+ boolean isOpt[] = new boolean[methods.length + 1];
+ String other[] = new String[1];
+
+ String aName = xTestedEntry.longName;
+ aName = aName.substring(aName.indexOf("::")+2);
+ int oldIndex = 0;
+ int index = aName.indexOf("::");
+ names[0] = "";
+ while(index!=-1) {
+ names[0] += aName.substring(oldIndex,index) + ".";
+ oldIndex=index+2;
+ index=aName.indexOf("::", oldIndex);
+ }
+ names[0] += aName.substring(oldIndex);
+ isOpt[0] = xTestedEntry.isOptional;
+
+ for (int i = 1; i < names.length; i++) {
+ names[i] = methods[i - 1].entryName;
+ isOpt[i] = methods[i - 1].isOptional;
+ }
+
+ // for reasons of compatibility with JSuite we change the first
+ // character of EntryType to upper case.
+ String eType = xTestedEntry.EntryType;
+ other[0] = eType.toUpperCase().charAt(0)+eType.substring(1);
+
+ Object params[] = {names, isOpt, other};
+
+ try {
+ PropertyValue Res = oBasicHandler.perform("testInterface", params);
+ sResult = (String)Res.Value;
+ } catch (BasicException e) {
+ log.println(e.info);
+ sResult = "SKIPPED.FAILED";
+ }
+ } else { // if object was not created...
+ sResult = "SKIPPED.FAILED";
+ }
+
+ // now tRes has all substates: collect them
+ DescEntry[] subs = xTestedEntry.SubEntries;
+ for (int i = 0; i < subs.length ; i++) {
+ if (sResult.equals("SKIPPED.FAILED"))
+ subs[i].State = "SKIPPED.FAILED";
+ else if (sResult.equals("SKIPPED.OK"))
+ subs[i].State = "SKIPPED.OK";
+ else
+ if (tRes.getStatusFor(subs[i].entryName) == null) {
+ subs[i].State = "SKIPPED.FAILED";
+ } else {
+ subs[i].State = tRes.getStatusFor(
+ subs[i].entryName).toString();
+ }
+ }
+
+ xTestedEntry.State = sResult;
+ return null;
+ }
+
+ /**
+ * Set the result of the method that is tested.
+ * @param methodName The name of the method.
+ * @param bResult The result of the test.
+ */
+ public void methodTested(String methodName, boolean bResult) {
+ tRes.tested(methodName, bResult);
+ }
+
+ /**
+ * @return The name of the interface or the service tested.
+ */
+ String getTestedClassName() {
+ return testName;
+ }
+}
diff --git a/qadevOOo/runner/basicrunner/BasicTestCase.java b/qadevOOo/runner/basicrunner/BasicTestCase.java
new file mode 100644
index 000000000000..1356badc12d7
--- /dev/null
+++ b/qadevOOo/runner/basicrunner/BasicTestCase.java
@@ -0,0 +1,178 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package basicrunner;
+
+import lib.TestCase;
+import lib.TestParameters;
+import lib.TestEnvironment;
+import share.DescEntry;
+import share.LogWriter;
+
+import com.sun.star.uno.XInterface;
+
+import java.io.PrintWriter;
+
+import com.sun.star.beans.PropertyValue;
+
+
+/**
+ * The basic test case.
+ */
+public class BasicTestCase extends TestCase {
+
+ /**
+ * Specifies the PrintWriter to log information.
+ */
+ public PrintWriter oLog;
+
+ /** The name of the test object **/
+ protected String objName;
+ /** The implementation name of the test object **/
+ protected String implName;
+ /** A BasicHandler **/
+ static BasicHandler oBasicHandler = null;
+
+ /**
+ * Constructor with the entry which is to test.
+ * @param entry The description entry.
+ */
+ public BasicTestCase(DescEntry entry) {
+ this.objName = entry.entryName;
+ this.implName = entry.longName;
+ }
+
+
+ /**
+ * Initialize the test case.
+ * The BasicHandler is talken from the test parameters and several
+ * parameters are initialized.
+ * @param tParam The test parameters.
+ * @param pLog A log writer.
+ */
+ protected void initialize(TestParameters tParam, PrintWriter pLog) {
+ // Create Handler ONLY here. If SOffice crashes,
+ // no new Handler will be created until new object's initialization.
+ this.oLog = pLog;
+ LogWriter log = (LogWriter)pLog;
+ oBasicHandler = BasicHandlerProvider.getHandler(tParam, log);
+ try {
+ oBasicHandler.perform("setValue",
+ "cBASPath = \"" + tParam.get("BASICRESPTH") + "/\"");
+ oBasicHandler.perform("setValue",
+ "cTestDocsDir = \"" + tParam.get("DOCPTH") + "/\"");
+ oBasicHandler.perform("setValue",
+ "CNCSTR = \"" + tParam.get("CNCSTR") + "\"");
+ if (tParam.get("soapi.test.hidewindows") != null) {
+ oBasicHandler.perform("setValue",
+ "soapi_test_hidewindows = true");
+ } else {
+ oBasicHandler.perform("setValue",
+ "soapi_test_hidewindows = false");
+ }
+ //this parameters are used by testcases of db-driver components
+ oBasicHandler.perform("setValue", "dbaseUrl = \"sdbc:dbase:" +
+ tParam.get("dbase.url") + "\"");
+ oBasicHandler.perform("setValue", "flatUrl = \"sdbc:flat:" +
+ tParam.get("flat.url") + "\"");
+ oBasicHandler.perform("setValue", "calcUrl = \"sdbc:calc:" +
+ tParam.get("calc.url") + "\"");
+ oBasicHandler.perform("setValue", "odbcUrl = \"sdbc:odbc:" +
+ tParam.get("odbc.url") + "\"");
+ oBasicHandler.perform("setValue", "jdbcUrl = \"jdbc:" +
+ tParam.get("jdbc.url") + "\"");
+ oBasicHandler.perform("setValue", "jdbcUser = \"" +
+ tParam.get("jdbc.user") + "\"");
+ oBasicHandler.perform("setValue", "jdbcPassword = \"" +
+ tParam.get("jdbc.password") + "\"");
+ oBasicHandler.perform("setValue", "adabasUrl = \"sdbc:adabas:" +
+ tParam.get("adabas.url") + "\"");
+ oBasicHandler.perform("setValue", "adabasUser = \"" +
+ tParam.get("adabas.user") + "\"");
+ oBasicHandler.perform("setValue", "adabasPassword = \"" +
+ tParam.get("adabas.password") + "\"");
+ oBasicHandler.perform("setValue", "adoUrl = \"sdbc:ado:" +
+ tParam.get("ado.url") + "\"");
+ oBasicHandler.perform("setValue", "mozabUrl = \"sdbc:address:" +
+ tParam.get("mozab.url") + "\"");
+ } catch (BasicException e) {
+ log.println(e.info);
+ throw new RuntimeException(e.info);
+ }
+ }
+
+ /**
+ * Create the environment for the test. This is done by BASIC.
+ * @param tParam The test parameters.
+ * @param log A log writer.
+ * @return The test environment
+ */
+ protected TestEnvironment createTestEnvironment(TestParameters tParam,
+ PrintWriter log) {
+
+ PropertyValue Res;
+ boolean bObjectWasCreated = false;
+
+ try {
+ oBasicHandler.perform("setValue",
+ "cObjectImplementationName = \"" + implName + "\"");
+ Res = oBasicHandler.perform("createObject", objName);
+ bObjectWasCreated = ((Boolean)Res.Value).booleanValue();
+
+ if (!bObjectWasCreated) {
+ log.println("Couldn't create object");
+ throw new RuntimeException("Couldn't create object");
+ }
+
+ } catch (BasicException e) {
+ log.println(e.info);
+ bObjectWasCreated = false;
+ throw new RuntimeException(e.info);
+ }
+
+ TestEnvironment tEnv = new TestEnvironment(new XInterface(){});
+ tEnv.addObjRelation("objectCreated", new Boolean(bObjectWasCreated));
+ tEnv.addObjRelation("BasicHandler", oBasicHandler);
+ return tEnv;
+ }
+
+ /**
+ * BASIC is told to dispose the test object.
+ * @param tParam The test parameters.
+ */
+
+ public void cleanupTestCase(TestParameters tParam) {
+ PropertyValue Res;
+ oLog.println("Cleaning up testcase");
+ try {
+ Res = oBasicHandler.perform("disposeObject", objName);
+ } catch (BasicException e) {
+ oLog.println(e.info);
+ throw new RuntimeException(e.info);
+ }
+ }
+
+}
diff --git a/qadevOOo/runner/basicrunner/basichelper/AttributeList.java b/qadevOOo/runner/basicrunner/basichelper/AttributeList.java
new file mode 100644
index 000000000000..cdcba0f6f956
--- /dev/null
+++ b/qadevOOo/runner/basicrunner/basichelper/AttributeList.java
@@ -0,0 +1,138 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package basicrunner.basichelper;
+
+import com.sun.star.lang.XInitialization;
+import com.sun.star.lang.XSingleServiceFactory;
+import com.sun.star.lang.XServiceInfo;
+import com.sun.star.uno.Type;
+import com.sun.star.lang.XTypeProvider;
+import util.XMLTools;
+
+/**
+* The class provides an implementation of the service
+* <code>com.sun.star.xml.sax.XAttributeList</code>.
+* @see com.sun.star.xml.sax.XAttributeList
+* @see com.sun.star.lang.XServiceInfo
+* @see com.sun.star.lang.XSingleServiceFactory
+*/
+public class AttributeList implements XServiceInfo, XSingleServiceFactory {
+ /** The service name of this class **/
+ static final String __serviceName = "basichelper.AttributeList";
+
+ /**
+ * Returns True, of the service is supported.
+ * @param name The service name.
+ * @return True, if the service is supported.
+ */
+ public boolean supportsService(String name) {
+ return __serviceName.equals(name);
+ }
+
+ /**
+ * Get all supported services.
+ * @return The supported services.
+ */
+ public String[] getSupportedServiceNames() {
+ return new String[] {__serviceName};
+ }
+
+ /**
+ * Ask for the implementation name.
+ * @return The implementation name.
+ */
+ public String getImplementationName() {
+ return getClass().getName();
+ }
+
+ /**
+ * Create an instance of the actual implementation of the AttributeList.
+ * Arguments are not supported, so they will bge ignored.
+ * @param args The arguments.
+ * @return A new instance of this class.
+ */
+ public Object createInstanceWithArguments(Object[] args) {
+ return new AttributeListImpl();
+ }
+
+ /**
+ * Create an instance of this class.
+ * @return A new instance of this class.
+ */
+ public Object createInstance() {
+ return createInstanceWithArguments(null);
+ }
+}
+
+/**
+ * The actual implementation of the service
+ * <code>com.sun.star.xml.sax.XAttributeList</code>.
+ * Extends the class util.XMLTools.AttributeList.
+ * @see util.XMLTools.AttributeList
+ * @see com.sun.star.xml.sax.XAttributeList
+ * @see com.sun.star.lang.XTypeProvider
+ * @see com.sun.star.lang.XInitialization
+ */
+class AttributeListImpl extends XMLTools.AttributeList
+ implements XTypeProvider, XInitialization {
+
+ /**
+ * Initialize this class.
+ * @param p0 An array of XML attributes that are added to the list.
+ * @throws Exception Initialize failed.
+ */
+ public void initialize(Object[] p0) throws com.sun.star.uno.Exception {
+ for(int i = 0; i + 2 < p0.length; i += 3) {
+ add((String)p0[i], (String)p0[i + 1], (String)p0[i + 2]);
+ }
+ }
+
+ /**
+ * Return all implemented types of this class.
+ * @return All UNO types of this class.
+ */
+ public Type[] getTypes() {
+ Class interfaces[] = getClass().getInterfaces();
+ Class superInterfaces[] = getClass().getSuperclass().getInterfaces();
+
+ Type types[] = new Type[interfaces.length + superInterfaces.length];
+ int i = 0;
+ for(; i < interfaces.length; ++ i)
+ types[i] = new Type(interfaces[i]);
+ for(; i < interfaces.length + superInterfaces.length; ++ i)
+ types[i] = new Type(superInterfaces[i - interfaces.length]);
+ return types;
+ }
+
+ /**
+ * Get a unique id for this class
+ * @return The id.
+ */
+ public byte[] getImplementationId() {
+ return toString().getBytes();
+ }
+}
diff --git a/qadevOOo/runner/basicrunner/basichelper/Connector.java b/qadevOOo/runner/basicrunner/basichelper/Connector.java
new file mode 100644
index 000000000000..cc219ac9f416
--- /dev/null
+++ b/qadevOOo/runner/basicrunner/basichelper/Connector.java
@@ -0,0 +1,272 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package basicrunner.basichelper;
+
+import com.sun.star.lang.XInitialization;
+import com.sun.star.lang.XServiceInfo;
+import com.sun.star.lang.XTypeProvider;
+import com.sun.star.uno.Type;
+import com.sun.star.connection.XConnector;
+import com.sun.star.connection.XConnection;
+import com.sun.star.connection.ConnectionSetupException;
+import com.sun.star.connection.NoConnectException;
+import com.sun.star.container.XNameAccess;
+import com.sun.star.container.NoSuchElementException;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.lang.XSingleServiceFactory;
+
+/**
+ * This is a special service that is used in testing Acceptor
+ * component in BASIC. This componennt creates a separate thread
+ * that tries to connect to BASIC's acceptor. After successfull
+ * connection it writes a connectionString to XConnection.
+ */
+ public class Connector implements XServiceInfo, XSingleServiceFactory {
+ /** The service name of this class **/
+ static final String __serviceName = "basichelper.Connector";
+ /** The Connector implementation **/
+ static ConnectorImpl oConnector = null;
+
+ /** Create a connector.
+ */
+ public Connector() {
+ oConnector = new ConnectorImpl();
+ }
+
+ /**
+ * Returns an instance of the connector.
+ * Arguments are not supported here and will be ignored.
+ * @param args The arguments.
+ * @return The connector.
+ */
+ public Object createInstanceWithArguments(Object[] args) {
+ return oConnector;
+ }
+
+ /**
+ * Returns an instance of the connector.
+ * @return The connector.
+ */
+ public Object createInstance() {
+ return createInstanceWithArguments(null);
+ }
+
+ /**
+ * Get a unique id for this implementation.
+ * @return The id.
+ */
+ public byte[] getImplementationId() {
+ return toString().getBytes();
+ }
+
+ /**
+ * Return all implemented types of this class.
+ * @return The implemented UNO types.
+ */
+ public Type[] getTypes() {
+ Class interfaces[] = getClass().getInterfaces();
+
+ Type types[] = new Type[interfaces.length];
+ for(int i = 0; i < interfaces.length; ++ i)
+ types[i] = new Type(interfaces[i]);
+
+ return types;
+ }
+
+ /** Is this servioce supported?
+ * @param name The service name.
+ * @return True, if the service is supported.
+ */
+ public boolean supportsService(String name) {
+ return __serviceName.equals(name);
+ }
+
+ /**
+ * Get all supported service names.
+ * @return All supported servcices.
+ */
+ public String[] getSupportedServiceNames() {
+ return new String[] {__serviceName};
+ }
+
+ /**
+ * Get the implementation name of this class.
+ * @return The implementation name.
+ */
+ public String getImplementationName() {
+ return getClass().getName();
+ }
+}
+
+/**
+ * The actual implementation of the connector
+ * @see com.sun.star.lang.XInitialization
+ * @see com.sun.star.lang.XTypeProvider
+ * @see com.sun.star.container.XNameAccess
+ */
+class ConnectorImpl implements XInitialization, XTypeProvider, XNameAccess {
+ static String aState;
+ static Integer iTimeout;
+
+ /**
+ * Construct a new connector.
+ */
+ public ConnectorImpl() {
+ aState = "just created";
+ iTimeout = new Integer(3000);
+ }
+
+ /**
+ * Method initialize() creates a new thread that will try to connect to
+ * Acceptor for a few seconds. One should pass as parameters an array,
+ * where element 0 is an instance of Connector and element 1 is a
+ * connection string (the same as in Acceptor)
+ * @param parm1 An instance of XConnector.
+ * @see com.sun.star.connection.XConnector
+ * @throws Exception Is thrown, when initialize fails.
+ */
+ public void initialize(Object[] parm1) throws com.sun.star.uno.Exception {
+ aState = "just initialized";
+ XConnector cntr = (XConnector)UnoRuntime.queryInterface(
+ XConnector.class, parm1[0]);
+ ConnThread aThread = new ConnThread(cntr, (String)parm1[1]);
+ aThread.start();
+ }
+
+ /**
+ * Get the element names
+ * @return All element names.
+ */
+ public String[] getElementNames() {
+ return new String[]{"State", "Timeout"};
+ }
+
+ /**
+ * Does this element exist?
+ * @param name The element name.
+ * @return True, if the name exists.
+ */
+ public boolean hasByName(String name) {
+ return (name.equals("State") || name.equals("Timeout"));
+ }
+
+ /**
+ * Get an element by its name.
+ * @param name The name of the element.
+ * @return The value of the element.
+ * @throws NoSuchElementException The element does not exist.
+ */
+ public Object getByName(String name) throws NoSuchElementException{
+ if (name.equals("State"))
+ return aState;
+ else if (name.equals("Timeout"))
+ return iTimeout;
+ else
+ throw new NoSuchElementException();
+ }
+
+ /**
+ * Are there elements
+ * @return Always true.
+ */
+ public boolean hasElements() {
+ return true;
+ }
+
+ /**
+ * Get element type.
+ * @return null.
+ */
+ public Type getElementType() {
+ return null;
+ }
+
+ /**
+ * Get a unique id for this implementation.
+ * @return The id.
+ */
+ public byte[] getImplementationId() {
+ return toString().getBytes();
+ }
+
+ /**
+ * Return all implemented types of this class.
+ * @return The implemented UNO types.
+ */
+ public Type[] getTypes() {
+ Class interfaces[] = getClass().getInterfaces();
+
+ Type types[] = new Type[interfaces.length];
+ for(int i = 0; i < interfaces.length; ++ i)
+ types[i] = new Type(interfaces[i]);
+
+ return types;
+ }
+}
+
+/**
+ * A connector thread
+ */
+class ConnThread extends Thread {
+ String connStr;
+ XConnector oConnector;
+
+ /**Construct the thread.
+ * @param oCntr A connector.
+ * @param cStr The conection string.
+ */
+ public ConnThread(XConnector oCntr, String cStr){
+ connStr = cStr;
+ oConnector = oCntr;
+ }
+
+ /**
+ * Run the thread.
+ */
+ public void run(){
+ try {
+ Thread.sleep(ConnectorImpl.iTimeout.intValue());
+ ConnectorImpl.aState = "before connection";
+ XConnection oConnection = oConnector.connect(connStr);
+ if (oConnection != null) {
+ ConnectorImpl.aState = "connected";
+ oConnection.write(connStr.getBytes());
+ oConnection.write(new byte[]{0});
+ } else
+ ConnectorImpl.aState = "XConnection is null";
+ } catch (ConnectionSetupException e) {
+ ConnectorImpl.aState = "ConnectionSetupException";
+ throw new RuntimeException(e.toString());
+ } catch (NoConnectException e) {
+ ConnectorImpl.aState = "NoConnectException";
+ throw new RuntimeException(e.toString());
+ } catch (Exception e) {
+ ConnectorImpl.aState = "error";
+ throw new RuntimeException("Can't sleep exception");
+ }
+ }
+}
diff --git a/qadevOOo/runner/basicrunner/basichelper/DispatchProviderInterceptor.java b/qadevOOo/runner/basicrunner/basichelper/DispatchProviderInterceptor.java
new file mode 100644
index 000000000000..f50a7d2eb470
--- /dev/null
+++ b/qadevOOo/runner/basicrunner/basichelper/DispatchProviderInterceptor.java
@@ -0,0 +1,194 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package basicrunner.basichelper;
+
+import com.sun.star.lang.XSingleServiceFactory;
+import com.sun.star.lang.XServiceInfo;
+import com.sun.star.lang.XTypeProvider;
+import com.sun.star.uno.Type;
+import com.sun.star.frame.XDispatchProviderInterceptor;
+import com.sun.star.frame.XDispatchProvider;
+import com.sun.star.frame.XDispatch;
+import com.sun.star.frame.DispatchDescriptor;
+import com.sun.star.util.URL;
+
+/**
+ * This implementation provides an implementation of an interceptor.
+ * @see com.sun.star.lang.XSingleServiceFactory
+ * @see com.sun.star.lang.XServiceInfo
+ */
+public class DispatchProviderInterceptor implements XServiceInfo,
+ XSingleServiceFactory {
+ /** The service name **/
+ static final String __serviceName =
+ "basichelper.DispatchProviderInterceptor";
+
+ /** Create an instance of the interceptor
+ * Arguments are not supported here, so they will be ignored.
+ * @param args The arguments.
+ * @return A new instance of the interceptor.
+ **/
+ public Object createInstanceWithArguments(Object[] args) {
+ return new InterceptorImpl();
+ }
+
+ /** Create an instance of the interceptor
+ * @return A new instance of the interceptor.
+ **/
+ public Object createInstance() {
+ return createInstanceWithArguments(null);
+ }
+
+ /** Get the unique id for this implementation
+ * @return The id.
+ */
+ public byte[] getImplementationId() {
+ return toString().getBytes();
+ }
+
+ /** Get all implemented types.
+ * @return The implemented UNO types.
+ */
+ public Type[] getTypes() {
+ Class interfaces[] = getClass().getInterfaces();
+
+ Type types[] = new Type[interfaces.length];
+ for(int i = 0; i < interfaces.length; ++ i)
+ types[i] = new Type(interfaces[i]);
+
+ return types;
+ }
+
+ /**
+ * Is this service supported?
+ * @param name The name of a service.
+ * @return True, if the service is supported.
+ */
+ public boolean supportsService(String name) {
+ return __serviceName.equals(name);
+ }
+
+ /**
+ * Get all supported service names.
+ * @return All service names.
+ */
+ public String[] getSupportedServiceNames() {
+ return new String[] {__serviceName};
+ }
+
+ /**
+ * Get the implementation name of this class.
+ * @return The name.
+ */
+ public String getImplementationName() {
+ return getClass().getName();
+ }
+}
+
+/**
+ * The actual implementation of the interceptor.
+ * @see com.sun.star.lang.XTypeProvider
+ * @see com.sun.star.frame.XDispatchProviderInterceptor
+ * @see com.sun.star.frame.XDispatchProvider
+ */
+class InterceptorImpl implements XDispatchProvider,
+ XDispatchProviderInterceptor, XTypeProvider {
+
+ /** A master dispatch provider **/
+ public XDispatchProvider master = null;
+ /** A slave dispatch provider **/
+ public XDispatchProvider slave = null;
+
+ /** Get the slave dispatch provider
+ * @return The slave.
+ */
+ public XDispatchProvider getSlaveDispatchProvider() {
+ return slave;
+ }
+ /** Get the master dispatch provider
+ * @return The master.
+ */
+ public XDispatchProvider getMasterDispatchProvider() {
+ return master;
+ }
+
+ /** Set the slave dispatch provider
+ * @param prov The new slave.
+ */
+ public void setSlaveDispatchProvider(XDispatchProvider prov) {
+ slave = prov ;
+ }
+
+ /** Set the master dispatch provider
+ * @param prov The new master.
+ */
+ public void setMasterDispatchProvider(XDispatchProvider prov) {
+ master = prov ;
+ }
+
+ /** Searches for an <type>XDispatch</type> for the specified URL within
+ * the specified target frame.
+ * @param url The URL.
+ * @param frame The target frame
+ * @param flags Optional search flags.
+ * @return The dispatch object which provides the queried functionality
+ * or null if no dispatch object is available.
+ * @see com.sun.star.frame.XDispatch
+ */
+ public XDispatch queryDispatch(URL url, String frame, int flags) {
+ return master.queryDispatch(url, frame, flags) ;
+ }
+
+ /**
+ * Query for an array of <type>XDispatch</type>.
+ * @param desc A list of dipatch requests.
+ * @return A list of dispatch objects.
+ */
+ public XDispatch[] queryDispatches(DispatchDescriptor[] desc) {
+ return master.queryDispatches(desc) ;
+ }
+
+ /** Get the unique id for this implementation
+ * @return The id.
+ */
+ public byte[] getImplementationId() {
+ return toString().getBytes();
+ }
+
+ /** Get all implemented types.
+ * @return The implemented UNO types.
+ */
+ public Type[] getTypes() {
+ Class interfaces[] = getClass().getInterfaces();
+
+ Type types[] = new Type[interfaces.length];
+ for(int i = 0; i < interfaces.length; ++ i)
+ types[i] = new Type(interfaces[i]);
+
+ return types;
+ }
+}
diff --git a/qadevOOo/runner/basicrunner/basichelper/DocumentHandler.java b/qadevOOo/runner/basicrunner/basichelper/DocumentHandler.java
new file mode 100644
index 000000000000..62909f16dd4f
--- /dev/null
+++ b/qadevOOo/runner/basicrunner/basichelper/DocumentHandler.java
@@ -0,0 +1,344 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package basicrunner.basichelper;
+
+import com.sun.star.lang.XInitialization;
+import com.sun.star.lang.XSingleServiceFactory;
+import com.sun.star.lang.XServiceInfo;
+import com.sun.star.lang.XTypeProvider;
+import com.sun.star.uno.Type;
+import com.sun.star.xml.sax.XDocumentHandler;
+import com.sun.star.container.XNameAccess;
+import com.sun.star.container.NoSuchElementException;
+import java.util.Vector;
+import util.XMLTools.Tag;
+import util.XMLTools;
+import java.io.StringWriter;
+import java.io.PrintWriter;
+
+/**
+ * This class provides a handler of the BASIC test document.
+ * @see com.sun.star.lang.XSingleServiceFactory
+ * @see com.sun.star.lang.XServiceInfo
+ */
+public class DocumentHandler implements XServiceInfo, XSingleServiceFactory {
+ /** The service name of this class **/
+ static final String __serviceName = "basichelper.DocumentHandler";
+ /** The actual handler of the document **/
+ static DocumentHandlerImpl oDocumentHandler = null;
+ /** A string writer **/
+ private StringWriter writer;
+ /** The log writer (just a wrapper around <code>writer</code>) **/
+ private PrintWriter log;
+
+ /**
+ * Create an instance of the document handler.
+ * @param args A boolean value as <codde>args[0]</code> determines,
+ * if checked XML data is printed to the log.
+ * Default is false.
+ * @return The document handler
+ */
+ public Object createInstanceWithArguments(Object[] args) {
+ boolean printXML = false;
+ if (args != null && args.length!=0 && args[0] instanceof Boolean)
+ printXML = ((Boolean)args[0]).booleanValue();
+ writer = new StringWriter();
+ log = new PrintWriter(writer);
+ oDocumentHandler = new DocumentHandlerImpl(log, printXML, writer);
+ return oDocumentHandler;
+ }
+
+ /**
+ * Create an instance of the document handler.
+ * @return The document handler
+ */
+ public Object createInstance() {
+ return createInstanceWithArguments(null);
+ }
+
+ /** Get the unique id for this implementation
+ * @return The id.
+ */
+ public byte[] getImplementationId() {
+ return toString().getBytes();
+ }
+
+ /** Get all implemented types.
+ * @return The implemented UNO types.
+ */
+ public Type[] getTypes() {
+ Class interfaces[] = getClass().getInterfaces();
+ Type types[] = new Type[interfaces.length];
+ for(int i = 0; i < interfaces.length; ++ i)
+ types[i] = new Type(interfaces[i]);
+ return types;
+ }
+
+ /** Is this servioce supported?
+ * @param name The service name.
+ * @return True, if the service is supported.
+ */
+ public boolean supportsService(String name) {
+ return __serviceName.equals(name);
+ }
+
+ /**
+ * Get all supported service names.
+ * @return All supported servcices.
+ */
+ public String[] getSupportedServiceNames() {
+ return new String[] {__serviceName};
+ }
+
+ /**
+ * Get the implementation name of this class.
+ * @return The implementation name.
+ */
+ public String getImplementationName() {
+ return getClass().getName();
+ }
+}
+
+/**
+ * The actual implementation of the document handler
+ * @see util.XMLTools.XMLChecker
+ * @see com.sun.star.lang.XInitialization
+ * @see com.sun.star.xml.sax.XDocumentHandler
+ * @see com.sun.star.container.XNameAccess
+ * @see com.sun.star.lang.XTypeProvider
+ */
+class DocumentHandlerImpl extends XMLTools.XMLChecker
+ implements XInitialization, XDocumentHandler,
+ XNameAccess, XTypeProvider {
+ /** A string writer **/
+ private StringWriter writer;
+
+ /**
+ * Constructor
+ * @param log_ A log writer.
+ * @param printXML Should XML data be printed to the log?
+ * @param logWriter A wrapper around <code>log_</code> for convenience.
+ */
+ public DocumentHandlerImpl(PrintWriter log_,
+ boolean printXML, StringWriter logWriter) {
+ super(log_, printXML);
+ writer = logWriter;
+ }
+
+ /**
+ * Initialize this class with rules.
+ * @param parm1 An array of filter rules:
+ * <code>processAction()</code> is called for every rule.
+ * @throws com.sun.star.uno.Exception for an incorrect rule.
+ */
+ public void initialize(Object[] parm1) throws com.sun.star.uno.Exception {
+ if (!(parm1[0] instanceof Object[])) return;
+ for (int i=0; i<parm1.length; i++) {
+ processActionForXMLChecker((Object[])parm1[i]);
+ }
+ }
+
+ /**
+ * Method processes all filters received from basic tests.
+ * Called by initialize().
+ * @param filterRule An array building one filter rule.
+ * @throws com.sun.star.uno.Exception for an incorrect rule.
+ */
+ private void processActionForXMLChecker(Object[] filterRule)
+ throws com.sun.star.uno.Exception {
+ int arrLen = filterRule.length;
+ String oTagName;
+ Object[] oTags;
+ Object[] oTag;
+ int tagsNum = arrLen-1;
+ Vector allTags = new Vector();
+ String CDATA = "";
+ String action = "";
+
+ // First element of rule is RuleName and should be String
+ if (!(filterRule[0] instanceof String)) {
+ throw new com.sun.star.uno.Exception("Error: incorrect filter rule "+
+ "received from basic test! Rule name must be a String.");
+ } else {
+ action = (String) filterRule[0];
+ }
+
+ // Searching for character data and defining amount of tags received.
+ for (int j=1; j<arrLen; j++) {
+ if ( (filterRule[j] instanceof String) && (j != 1) ) {
+ CDATA = (String) filterRule[j];
+ tagsNum--;
+ }
+ }
+
+ // Adding received tags to internal array.
+ oTags = new Object[tagsNum];
+ for (int j=1; j<=tagsNum; j++) {
+ if (filterRule[j] instanceof Object[]) {
+ oTags[j-1] = (Object[]) filterRule[j];
+ }
+ }
+
+ // Process all received tags for a given filter rule
+ for (int i=0; i<oTags.length; i++) {
+ if (oTags[i] instanceof Object[]) {
+ oTag = (Object[]) oTags[i];
+ oTagName = (String) oTag[0];
+ } else if (oTags[i] instanceof Object) {
+ oTag = new Object[1];
+ oTag[0] = (Object) oTags[i];
+ oTagName = (String) oTag[0];
+ } else {
+ throw new com.sun.star.uno.Exception("Error: invalid tag "+
+ "received from basic test! Check tag "
+ +i+" in rule '"+action+"'.");
+ }
+
+ // Action for constructor Tag(TagName, attrName, attrValue)
+ if (oTag.length == 3) {
+ if ((oTag[1] instanceof String)&&(oTag[2] instanceof String)) {
+ allTags.add(new Tag(oTagName,
+ (String) oTag[1], (String) oTag[2]));
+ } else {
+ throw new com.sun.star.uno.Exception("Error: invalid tag '"+
+ oTagName+"' received from basic test!");
+ }
+
+ // Action for constructors:
+ // Tag(TagName, String[][] attrValues )
+ // Tag(TagName, String[] attrNames)
+ // Tag(TagName, String attrName)
+ //
+ } else if (oTag.length == 2) {
+ if (oTag[1] instanceof String[][]) {
+ allTags.add(new Tag(oTagName, (String[][]) oTag[1]));
+ } else if (oTag[1] instanceof String[]) {
+ allTags.add(new Tag(oTagName, (String[]) oTag[1]));
+ } else if (oTag[1] instanceof String) {
+ allTags.add(new Tag(oTagName, (String) oTag[1]));
+ } else {
+ throw new com.sun.star.uno.Exception("Error: invalid tag '"+
+ oTagName+"' received from basic test!");
+ }
+
+ // Action for constructor Tag(TagName)
+ } else if (oTag.length == 1) {
+ if (oTag[0] instanceof String) {
+ allTags.add(new Tag(oTagName));
+ } else {
+ throw new com.sun.star.uno.Exception("Error: invalid tag '"+
+ oTagName+"' received from basic test!");
+ }
+ } else {
+ throw new com.sun.star.uno.Exception("Error: invalid tag '"+
+ oTagName+"' received from basic test!");
+ }
+ }
+
+ // Adding tags to XMLChecker
+ if ( action.equals((String)"TagExists") ) {
+ for (int i=0; i<allTags.size(); i++) {
+ addTag((Tag)allTags.get(i));
+ }
+ } else if (action.equals((String)"TagEnclosed")) {
+ addTagEnclosed((Tag) allTags.get(0), (Tag) allTags.get(1));
+ } else if (action.equals((String)"CharsEnclosed")) {
+ addCharactersEnclosed(CDATA, (Tag) allTags.get(0));
+ } else {
+ throw new com.sun.star.uno.Exception("Error: incorrect rule name '"+
+ action+"' received from basic test!");
+ }
+ }
+
+ /**
+ * Get the names of the elements.
+ * @return element names.
+ */
+ public String[] getElementNames() {
+ return new String[]{"XMLCode", "XMLIsCorrect"};
+ }
+
+ /**
+ * Is this an element?
+ * @param name Element name.
+ * @return true, if <code>name>/code> is the name of an element.
+ */
+ public boolean hasByName(String name) {
+ return (name.equals("XMLCode") || name.equals("XMLIsCorrect"));
+ }
+
+ /**
+ * Get an element by its name.
+ * @param name The element name.
+ * @return The element with the specified <code>name</code>.
+ * @throws NoSuchElementException Is thrown, if name does not exist.
+ */
+ public Object getByName(String name) throws NoSuchElementException{
+ if (name.equals("XMLIsCorrect"))
+ return new Boolean(this.check());
+ else if (name.equals("XMLCode")) {
+ return writer.getBuffer().toString();
+ } else
+ throw new NoSuchElementException();
+ }
+
+ /**
+ * Are there any elements?
+ * @return Always true.
+ */
+ public boolean hasElements() {
+ return true;
+ }
+
+ /**
+ * Get the element type.
+ * @return The type.
+ */
+ public Type getElementType() {
+ return new Type(Object.class);
+ }
+
+ /**
+ * Get a unique id for this implementation.
+ * @return The id.
+ */
+ public byte[] getImplementationId() {
+ return toString().getBytes();
+ }
+
+ /**
+ * Return all implemented types of this class.
+ * @return The implemented UNO types.
+ */
+ public Type[] getTypes() {
+ Class interfaces[] = getClass().getInterfaces();
+ Type types[] = new Type[interfaces.length];
+ for(int i = 0; i < interfaces.length; ++ i)
+ types[i] = new Type(interfaces[i]);
+ return types;
+ }
+}
diff --git a/qadevOOo/runner/basicrunner/basichelper/Filter.java b/qadevOOo/runner/basicrunner/basichelper/Filter.java
new file mode 100644
index 000000000000..d9616d30e5b2
--- /dev/null
+++ b/qadevOOo/runner/basicrunner/basichelper/Filter.java
@@ -0,0 +1,269 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package basicrunner.basichelper;
+
+import com.sun.star.lang.XInitialization;
+import com.sun.star.lang.XServiceInfo;
+import com.sun.star.lang.XTypeProvider;
+import com.sun.star.uno.Type;
+import com.sun.star.container.XNameAccess;
+import com.sun.star.container.NoSuchElementException;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.lang.XSingleServiceFactory;
+import com.sun.star.document.XFilter;
+import com.sun.star.beans.PropertyValue;
+
+
+/**
+ * Provides an implementation of XFilter.
+ * @see com.sun.star.document.XFilter
+ * @see com.sun.star.lang.XServiceInfo
+ * @see com.sun.star.lang.XSingleServiceFactory
+ */
+public class Filter implements XServiceInfo, XSingleServiceFactory {
+ /** The service name of this class **/
+ static final String __serviceName = "basichelper.Filter";
+ /** The actual filter **/
+ static FilterImpl oFilter = null;
+
+ /**
+ * Construct a new filter
+ */
+ public Filter() {
+ oFilter = new FilterImpl();
+ }
+
+ /**
+ * Returns an instance of the filter.
+ * Arguments are not supported here and will be ignored.
+ * @param args The arguments.
+ * @return The filter.
+ */
+ public Object createInstanceWithArguments(Object[] args) {
+ return oFilter;
+ }
+
+ /**
+ * Returns an instance of the filter.
+ * @return The filter.
+ */
+ public Object createInstance() {
+ return createInstanceWithArguments(null);
+ }
+
+ /**
+ * Get a unique id for this implementation.
+ * @return The id.
+ */
+ public byte[] getImplementationId() {
+ return toString().getBytes();
+ }
+
+ /**
+ * Return all implemented types of this class.
+ * @return The implemented UNO types.
+ */
+ public Type[] getTypes() {
+ Class interfaces[] = getClass().getInterfaces();
+
+ Type types[] = new Type[interfaces.length];
+ for(int i = 0; i < interfaces.length; ++ i)
+ types[i] = new Type(interfaces[i]);
+
+ return types;
+ }
+
+ /** Is this servioce supported?
+ * @param name The service name.
+ * @return True, if the service is supported.
+ */
+ public boolean supportsService(String name) {
+ return __serviceName.equals(name);
+ }
+
+ /**
+ * Get all supported service names.
+ * @return All supported servcices.
+ */
+ public String[] getSupportedServiceNames() {
+ return new String[] {__serviceName};
+ }
+
+ /**
+ * Get the implementation name of this class.
+ * @return The implementation name.
+ */
+ public String getImplementationName() {
+ return getClass().getName();
+ }
+}
+
+/**
+ * The actual filter implementation
+ * @see com.sun.star.lang.XInitialization;
+ * @see com.sun.star.lang.XTypeProvider;
+ * @see com.sun.star.container.XNameAccess;
+ */
+class FilterImpl implements XInitialization, XTypeProvider, XNameAccess {
+ /** A state **/
+ static String aState;
+ /** A result **/
+ static boolean bResult;
+
+ /**
+ * Constructs a new filter.
+ */
+ public FilterImpl() {
+ aState = "just created";
+ bResult = false;
+ }
+
+ /**
+ * Get the element names
+ * @return All element names.
+ */
+ public String[] getElementNames() {
+ return new String[]{"State", "Result"};
+ }
+
+ /**
+ * Does this element exist?
+ * @param name The element name.
+ * @return True, if the name exists.
+ */
+ public boolean hasByName(String name) {
+ return (name.equals("State") || name.equals("Result"));
+ }
+
+ /**
+ * Get an element by its name.
+ * @param name The name of the element.
+ * @return The value of the element.
+ * @throws NoSuchElementException The element does not exist.
+ */
+ public Object getByName(String name) throws NoSuchElementException{
+ if (name.equals("State"))
+ return aState;
+ else if (name.equals("Result"))
+ return new Boolean(bResult);
+ else
+ throw new NoSuchElementException();
+ }
+
+ /**
+ * Are there elements
+ * @return Always true.
+ */
+ public boolean hasElements() {
+ return true;
+ }
+
+ /**
+ * Get element type.
+ * @return null.
+ */
+ public Type getElementType() {
+ return null;
+ }
+
+ /**
+ * Get a unique id for this implementation.
+ * @return The id.
+ */
+ public byte[] getImplementationId() {
+ return toString().getBytes();
+ }
+
+ /**
+ * Return all implemented types of this class.
+ * @return The implemented UNO types.
+ */
+ public Type[] getTypes() {
+ Class interfaces[] = getClass().getInterfaces();
+
+ Type types[] = new Type[interfaces.length];
+ for(int i = 0; i < interfaces.length; ++ i)
+ types[i] = new Type(interfaces[i]);
+
+ return types;
+ }
+
+
+ /**
+ * Method initialize() creates a new thread that will try to start
+ * filtering
+ * @param parm1 An instance of XFilter
+ * @see com.sun.star.document.XFilter
+ * @throws Exception Is thrown, when initialize fails.
+ */
+ public void initialize(Object[] parm1) throws com.sun.star.uno.Exception {
+ XFilter oFilter = (XFilter)UnoRuntime.queryInterface(
+ XFilter.class, parm1[0]);
+//? PropertyValue[] FilterDesc = (PropertyValue[])AnyConverter.toArray(parm1[1]);
+ PropertyValue[] FilterDesc = (PropertyValue[])UnoRuntime.queryInterface(PropertyValue[].class, parm1[1]);
+ aState = "just initialized";
+ FilterThread aThread = new FilterThread(oFilter, FilterDesc);
+ aThread.start();
+ }
+}
+
+/**
+ * A thread for filtering.
+ */
+class FilterThread extends Thread {
+ /** The filter that is used **/
+ XFilter oFilter = null;
+ /** Filter descriptions **/
+ PropertyValue[] FilterDesc = null;
+
+ /**
+ * Construct the thread.
+ * @param oObj The filter.
+ * @param Desc The descriptions.
+ */
+ public FilterThread(XFilter oObj, PropertyValue[] Desc){
+ oFilter = oObj;
+ FilterDesc = Desc;
+ }
+
+ /**
+ * Let the thread run
+ */
+ public void run(){
+ boolean bOK;
+ try {
+ FilterImpl.aState = "before filtering";
+ bOK = oFilter.filter(FilterDesc);
+ FilterImpl.aState = "filtering finished";
+ FilterImpl.bResult = bOK;
+ } catch (Exception e) {
+ ConnectorImpl.aState = "error";
+ throw new RuntimeException("Can't filtering exception"
+ + e.toString());
+ }
+ }
+}
diff --git a/qadevOOo/runner/basicrunner/basichelper/ThreadRunner.java b/qadevOOo/runner/basicrunner/basichelper/ThreadRunner.java
new file mode 100644
index 000000000000..ec8957e01a6f
--- /dev/null
+++ b/qadevOOo/runner/basicrunner/basichelper/ThreadRunner.java
@@ -0,0 +1,254 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package basicrunner.basichelper;
+
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.lang.XInitialization;
+import com.sun.star.lang.XSingleServiceFactory;
+import com.sun.star.lang.XServiceInfo;
+import com.sun.star.lang.XTypeProvider;
+import com.sun.star.uno.Type;
+import com.sun.star.frame.XDispatch;
+import com.sun.star.frame.XDispatchProvider;
+import com.sun.star.frame.XModel;
+import com.sun.star.util.XURLTransformer;
+import com.sun.star.frame.XController;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.util.URL;
+import com.sun.star.lang.XMultiServiceFactory;
+import util.utils;
+import com.sun.star.lang.XComponent;
+import lib.StatusException;
+import lib.Status;
+import util.SOfficeFactory;
+import com.sun.star.ui.dialogs.XExecutableDialog;
+
+
+public class ThreadRunner implements XServiceInfo, XSingleServiceFactory {
+ static final String __serviceName = "basichelper.ThreadRunner";
+ static ThreadRunnerImpl oThreadRunner = null;
+
+ public ThreadRunner(XMultiServiceFactory xMSF) {
+ oThreadRunner = new ThreadRunnerImpl(xMSF);
+ }
+
+ public Object createInstanceWithArguments(Object[] args) {
+ return oThreadRunner;
+ }
+
+ public Object createInstance() {
+ return createInstanceWithArguments(null);
+ }
+
+ public byte[] getImplementationId() {
+ return toString().getBytes();
+ }
+
+ public Type[] getTypes() {
+ Class interfaces[] = getClass().getInterfaces();
+ Type types[] = new Type[interfaces.length];
+ for(int i = 0; i < interfaces.length; ++ i)
+ types[i] = new Type(interfaces[i]);
+ return types;
+ }
+
+ public boolean supportsService(String name) {
+ return __serviceName.equals(name);
+ }
+
+ public String[] getSupportedServiceNames() {
+ return new String[] {__serviceName};
+ }
+
+ public String getImplementationName() {
+ return getClass().getName();
+ }
+}
+
+
+class ThreadRunnerImpl implements XInitialization, XTypeProvider {
+ Object oDoc = null;
+ String actionType = null;
+ String actionParm = null;
+ XMultiServiceFactory oMSF = null;
+
+ public ThreadRunnerImpl(XMultiServiceFactory MSF) {
+ oMSF = MSF;
+ }
+
+ public void initialize(Object[] params) throws com.sun.star.uno.Exception {
+ boolean parmsOK = false;
+
+ if (!(params[0] instanceof String)) {
+ throw new StatusException(Status.failed(
+ "Wrong first parameter for ThreadRunner, allowed values:" +
+ "'OpenToolkitDialog', 'OpenDialogFromFile', 'ExecuteDialog'"));
+ }
+
+ actionType = (String) params[0];
+
+ if (actionType.equals("OpenToolkitDialog")) {
+ if (params.length != 3 || !(params[2] instanceof Object) ||
+ !(params[1] instanceof String) ) {
+ throw new StatusException(Status.failed("Expected the " +
+ "following type of parameters for 'OpenToolkitDialog': " +
+ "String, Object"));
+ }
+ actionParm = (String)params[1];
+ oDoc = (Object)params[2];
+ ToolkitDialogThread aThread =
+ new ToolkitDialogThread(oMSF, oDoc, actionParm);
+ aThread.start();
+ } else if (actionType.equals("OpenDialogFromFile")) {
+ if (params.length != 2 || !(params[1] instanceof String) ) {
+ throw new StatusException(Status.failed("Expected the " +
+ "following type of parameters for 'OpenDialogFromFile': " +
+ "String"));
+ }
+ actionParm = (String)params[1];
+ DialogFromFileThread bThread =
+ new DialogFromFileThread(oMSF, actionParm);
+ bThread.start();
+ } else if ( actionType.equals("ExecuteDialog")) {
+ if (params.length != 2 || !(params[1] instanceof String)) {
+ throw new StatusException(Status.failed("Expected the " +
+ "following type of parameters for 'ExecuteDialog': " +
+ "String"));
+ }
+ ExecuteDialogThread cThread =
+ new ExecuteDialogThread(oMSF, (String)params[1]);
+ cThread.start();
+ } else {
+ System.out.println("Error! ThreadRunnerImpl.initialize(): " +
+ "Incorrect parameters!");
+ }
+ }
+
+ public byte[] getImplementationId() {
+ return toString().getBytes();
+ }
+
+ public Type[] getTypes() {
+ Class interfaces[] = getClass().getInterfaces();
+ Type types[] = new Type[interfaces.length];
+ for(int i = 0; i < interfaces.length; ++ i)
+ types[i] = new Type(interfaces[i]);
+ return types;
+ }
+}
+
+
+class ToolkitDialogThread extends Thread {
+ Object oDoc = null;
+ String url = null;
+ XMultiServiceFactory msf = null;
+
+ public ToolkitDialogThread(XMultiServiceFactory xMSF, Object doc, String sUrl) {
+ oDoc = doc;
+ url = sUrl;
+ msf = xMSF;
+ }
+
+ public void run() {
+ XModel aModel = (XModel) UnoRuntime.queryInterface(XModel.class, oDoc);
+ XController xController = aModel.getCurrentController();
+ try {
+ XDispatchProvider xDispProv = (XDispatchProvider)
+ UnoRuntime.queryInterface( XDispatchProvider.class, xController );
+ XURLTransformer xParser = (com.sun.star.util.XURLTransformer)
+ UnoRuntime.queryInterface(XURLTransformer.class,
+ msf.createInstance("com.sun.star.util.URLTransformer"));
+ URL[] aParseURL = new URL[1];
+ aParseURL[0] = new URL();
+ aParseURL[0].Complete = url;
+ xParser.parseStrict(aParseURL);
+ URL aURL = aParseURL[0];
+ XDispatch xDispatcher = xDispProv.queryDispatch( aURL,"",0);
+ if( xDispatcher != null )
+ xDispatcher.dispatch( aURL, null );
+ } catch (com.sun.star.uno.Exception e) {
+ System.out.println("Couldn't open dialog!!!");
+ throw new StatusException( "Couldn't open dialog!!!", e );
+ }
+ }
+}
+
+
+class DialogFromFileThread extends Thread {
+ String url = null;
+ SOfficeFactory SOF = null;
+ XMultiServiceFactory myMSF = null;
+
+ public DialogFromFileThread(XMultiServiceFactory xMSF, String sUrl) {
+ url = sUrl;
+ SOF = SOfficeFactory.getFactory(xMSF);
+ myMSF = xMSF;
+ }
+
+ public void run() {
+ try {
+ PropertyValue[] args = new PropertyValue[1];
+ args[0] = new PropertyValue();
+ args[0].Name = "InteractionHandler";
+ args[0].Value = myMSF.createInstance(
+ "com.sun.star.comp.uui.UUIInteractionHandler");
+
+ String testUrl= utils.getFullTestURL(url);
+ System.out.println("loading "+testUrl);
+ XComponent xDoc = SOF.loadDocument(testUrl, args);
+ } catch (com.sun.star.uno.Exception e) {
+ System.out.println("Couldn't create document!!!");
+ throw new StatusException( "Couldn't create document!!!", e );
+ }
+ }
+
+}
+
+class ExecuteDialogThread extends Thread {
+ XMultiServiceFactory xMSF = null;
+ String serviceName = null;
+
+ public ExecuteDialogThread(XMultiServiceFactory xMSF, String serviceName) {
+ this.xMSF = xMSF;
+ this.serviceName = serviceName;
+ }
+
+ public void run() {
+ Object dlg = null;
+ try {
+ dlg = xMSF.createInstance(serviceName);
+ } catch(com.sun.star.uno.Exception e) {
+ throw new StatusException(Status.failed("Couldn't create service"));
+ }
+ XExecutableDialog execDlg = (XExecutableDialog)UnoRuntime.queryInterface
+ (XExecutableDialog.class, dlg);
+ execDlg.execute();
+ }
+}
+
+
diff --git a/qadevOOo/runner/basicrunner/basichelper/makefile.mk b/qadevOOo/runner/basicrunner/basichelper/makefile.mk
new file mode 100644
index 000000000000..cc45b0014fb9
--- /dev/null
+++ b/qadevOOo/runner/basicrunner/basichelper/makefile.mk
@@ -0,0 +1,47 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+
+PRJNAME = OOoRunner
+PACKAGE = basicrunner$/basichelper
+TARGET = runner_basichelper
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+# --- Files --------------------------------------------------------
+
+JARFILES = ridl.jar jurt.jar unoil.jar
+JAVAFILES = AttributeList.java DocumentHandler.java Filter.java \
+ Connector.java DispatchProviderInterceptor.java \
+ ThreadRunner.java
+JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class)
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
diff --git a/qadevOOo/runner/basicrunner/makefile.mk b/qadevOOo/runner/basicrunner/makefile.mk
new file mode 100644
index 000000000000..54874a77ef48
--- /dev/null
+++ b/qadevOOo/runner/basicrunner/makefile.mk
@@ -0,0 +1,46 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..
+
+PRJNAME = OOoRunner
+PACKAGE = basicrunner
+TARGET = runner_basicrunner
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+# --- Files --------------------------------------------------------
+
+JARFILES = ridl.jar jurt.jar unoil.jar
+JAVAFILES = BasicException.java BasicIfcTest.java BasicHandler.java BasicTestCase.java BasicHandlerProvider.java
+JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class)
+#SUBDIRS = basichelper
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
diff --git a/qadevOOo/runner/complexlib/Assurance.java b/qadevOOo/runner/complexlib/Assurance.java
new file mode 100644
index 000000000000..665980d792ab
--- /dev/null
+++ b/qadevOOo/runner/complexlib/Assurance.java
@@ -0,0 +1,407 @@
+/*
+ * ************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ * ***********************************************************************
+ */
+
+package complexlib;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+/**
+ *
+ * @author ll93751
+ *
+ * I have removed the assure(...) functions from ComplexTestCase due to the fact now I can
+ * use the functions every where and don't need to be a ComplexTestCase any longer.
+ */
+public class Assurance
+{
+ public static final boolean CONTINUE = true;
+
+ /** State of the current test method **/
+ protected boolean state = true;
+
+ /** The message if the test did fail **/
+ protected String message = null;
+
+
+ /**
+ * Assure that s is true.
+ * This function generates "Assure failed." as standard message.
+ * @param s The condition that should be true.
+ */
+ protected void assure(boolean s) {
+ assure("Assure failed.", s, false);
+ }
+
+ /**
+ * Assure that s is true.
+ * The given message will be only evaluated, if s is false.
+ * @param msg The message that is evaluated.
+ * @param s The condition that should be true.
+ */
+ protected void assure(String msg, boolean s) {
+ assure(msg, s, false);
+ }
+
+ /**
+ * Assure that two boolean values are equal
+ * @param expected specifies the expected boolean value
+ * @param actual specifies the actual boolean value
+ */
+ protected void assureEquals( boolean expected, boolean actual ) {
+ assureEquals( "Equality test failed", new Boolean( expected ), new Boolean( actual ), false );
+ }
+
+ /**
+ * Assure that two boolean values are equal
+ * @param message the message to print when the equality test fails
+ * @param expected specifies the expected boolean value
+ * @param actual specifies the actual boolean value
+ */
+ protected void assureEquals( String message, boolean expected, boolean actual ) {
+ assureEquals( message, new Boolean( expected ), new Boolean( actual ), false );
+ }
+
+ /**
+ * Assure that two byte values are equal
+ * @param expected specifies the expected byte value
+ * @param actual specifies the actual byte value
+ */
+ protected void assureEquals( byte expected, byte actual ) {
+ assureEquals( "Equality test failed", new Byte( expected ), new Byte( actual ), false );
+ }
+
+ /**
+ * Assure that two byte values are equal
+ * @param message the message to print when the equality test fails
+ * @param expected specifies the expected byte value
+ * @param actual specifies the actual byte value
+ */
+ protected void assureEquals( String message, byte expected, byte actual ) {
+ assureEquals( message, new Byte( expected ), new Byte( actual ), false );
+ }
+
+ /**
+ * Assure that two double values are equal
+ * @param expected specifies the expected double value
+ * @param actual specifies the actual double value
+ */
+ protected void assureEquals( double expected, double actual ) {
+ assureEquals( "Equality test failed", new Double( expected ), new Double( actual ), false );
+ }
+
+ /**
+ * Assure that two double values are equal
+ * @param message the message to print when the equality test fails
+ * @param expected specifies the expected double value
+ * @param actual specifies the actual double value
+ */
+ protected void assureEquals( String message, double expected, double actual ) {
+ assureEquals( message, new Double( expected ), new Double( actual ), false );
+ }
+
+ /**
+ * Assure that two float values are equal
+ * @param expected specifies the expected float value
+ * @param actual specifies the actual float value
+ */
+ protected void assureEquals( float expected, float actual ) {
+ assureEquals( "Equality test failed", new Float( expected ), new Float( actual ), false );
+ }
+
+ /**
+ * Assure that two float values are equal
+ * @param message the message to print when the equality test fails
+ * @param expected specifies the expected float value
+ * @param actual specifies the actual float value
+ */
+ protected void assureEquals( String message, float expected, float actual ) {
+ assureEquals( message, new Float( expected ), new Float( actual ), false );
+ }
+
+ /**
+ * Assure that two short values are equal
+ * @param expected specifies the expected short value
+ * @param actual specifies the actual short value
+ */
+ protected void assureEquals( short expected, short actual ) {
+ assureEquals( "Equality test failed", new Short( expected ), new Short( actual ), false );
+ }
+
+ /**
+ * Assure that two short values are equal
+ * @param message the message to print when the equality test fails
+ * @param expected specifies the expected short value
+ * @param actual specifies the actual short value
+ */
+ protected void assureEquals( String message, short expected, short actual ) {
+ assureEquals( message, new Short( expected ), new Short( actual ), false );
+ }
+
+ /**
+ * Assure that two int values are equal
+ * @param expected specifies the expected int value
+ * @param actual specifies the actual int value
+ */
+ protected void assureEquals( int expected, int actual ) {
+ assureEquals( "Equality test failed", new Integer( expected ), new Integer( actual ), false );
+ }
+
+ /**
+ * Assure that two int values are equal
+ * @param message the message to print when the equality test fails
+ * @param expected specifies the expected int value
+ * @param actual specifies the actual int value
+ */
+ protected void assureEquals( String message, int expected, int actual ) {
+ assureEquals( message, new Integer( expected ), new Integer( actual ), false );
+ }
+
+ /**
+ * Assure that two long values are equal
+ * @param expected specifies the expected long value
+ * @param actual specifies the actual long value
+ */
+ protected void assureEquals( long expected, long actual ) {
+ assureEquals( "Equality test failed", new Long( expected ), new Long( actual ), false );
+ }
+
+ /**
+ * Assure that two long values are equal
+ * @param message the message to print when the equality test fails
+ * @param expected specifies the expected long value
+ * @param actual specifies the actual long value
+ */
+ protected void assureEquals( String message, long expected, long actual ) {
+ assureEquals( message, new Long( expected ), new Long( actual ), false );
+ }
+
+ /**
+ * Assure that two string values are equal
+ * @param expected specifies the expected string value
+ * @param actual specifies the actual string value
+ */
+ protected void assureEquals( String expected, String actual ) {
+ assureEquals( "Equality test failed", expected, actual, false );
+ }
+
+ /**
+ * Assure that two string values are equal
+ * @param message the message to print when the equality test fails
+ * @param expected specifies the expected string value
+ * @param actual specifies the actual string value
+ */
+ protected void assureEquals( String message, String expected, String actual ) {
+ assureEquals( message, expected, actual, false );
+ }
+
+ /**
+ * Assure that two object are equal
+ * @param expected specifies the expected object value
+ * @param actual specifies the actual object value
+ */
+ protected void assureEquals( Object expected, Object actual ) {
+ assureEquals( "Equality test failed", expected, actual, false );
+ }
+
+ /**
+ * Assure that two objects are equal
+ * @param message the message to print when the equality test fails
+ * @param expected specifies the expected object value
+ * @param actual specifies the actual object value
+ */
+ protected void assureEquals( String message, Object expected, Object actual ) {
+ assureEquals( message, expected, actual, false );
+ }
+
+ /** invokes a given method on a given object, and assures a certain exception is caught
+ * @param _message is the message to print when the check fails
+ * @param _object is the object to invoke the method on
+ * @param _methodName is the name of the method to invoke
+ * @param _methodArgs are the arguments to pass to the method.
+ * @param _argClasses are the classes to assume for the arguments of the methods
+ * @param _expectedExceptionClass is the class of the exception to be caught. If this is null,
+ * it means that <em>no</em> exception must be throw by invoking the method.
+ */
+ protected void assureException( final String _message, final Object _object, final String _methodName,
+ final Class[] _argClasses, final Object[] _methodArgs, final Class _expectedExceptionClass )
+ {
+ Class objectClass = _object.getClass();
+
+ boolean noExceptionAllowed = ( _expectedExceptionClass == null );
+
+ boolean caughtExpected = noExceptionAllowed ? true : false;
+ try
+ {
+ Method method = objectClass.getMethod( _methodName, _argClasses );
+ method.invoke(_object, _methodArgs );
+ }
+ catch ( InvocationTargetException e )
+ {
+ caughtExpected = noExceptionAllowed
+ ? false
+ : ( e.getTargetException().getClass().equals( _expectedExceptionClass ) );
+ }
+ catch( Exception e )
+ {
+ caughtExpected = false;
+ }
+
+ assure( _message, caughtExpected );
+ }
+
+ /** invokes a given method on a given object, and assures a certain exception is caught
+ * @param _message is the message to print when the check fails
+ * @param _object is the object to invoke the method on
+ * @param _methodName is the name of the method to invoke
+ * @param _methodArgs are the arguments to pass to the method. Those implicitly define
+ * the classes of the arguments of the method which is called.
+ * @param _expectedExceptionClass is the class of the exception to be caught. If this is null,
+ * it means that <em>no</em> exception must be throw by invoking the method.
+ */
+ protected void assureException( final String _message, final Object _object, final String _methodName,
+ final Object[] _methodArgs, final Class _expectedExceptionClass )
+ {
+ Class[] argClasses = new Class[ _methodArgs.length ];
+ for ( int i=0; i<_methodArgs.length; ++i )
+ argClasses[i] = _methodArgs[i].getClass();
+ assureException( _message, _object, _methodName, argClasses, _methodArgs, _expectedExceptionClass );
+ }
+
+ /** invokes a given method on a given object, and assures a certain exception is caught
+ * @param _object is the object to invoke the method on
+ * @param _methodName is the name of the method to invoke
+ * @param _methodArgs are the arguments to pass to the method. Those implicitly define
+ * the classes of the arguments of the method which is called.
+ * @param _expectedExceptionClass is the class of the exception to be caught. If this is null,
+ * it means that <em>no</em> exception must be throw by invoking the method.
+ */
+ protected void assureException( final Object _object, final String _methodName, final Object[] _methodArgs,
+ final Class _expectedExceptionClass )
+ {
+ assureException(
+ "did not catch the expected exception (" +
+ ( ( _expectedExceptionClass == null ) ? "none" : _expectedExceptionClass.getName() ) +
+ ") while calling " + _object.getClass().getName() + "." + _methodName,
+ _object, _methodName, _methodArgs, _expectedExceptionClass );
+ }
+
+ /** invokes a given method on a given object, and assures a certain exception is caught
+ * @param _object is the object to invoke the method on
+ * @param _methodName is the name of the method to invoke
+ * @param _methodArgs are the arguments to pass to the method
+ * @param _argClasses are the classes to assume for the arguments of the methods
+ * @param _expectedExceptionClass is the class of the exception to be caught. If this is null,
+ * it means that <em>no</em> exception must be throw by invoking the method.
+ */
+ protected void assureException( final Object _object, final String _methodName, final Class[] _argClasses,
+ final Object[] _methodArgs, final Class _expectedExceptionClass )
+ {
+ assureException(
+ "did not catch the expected exception (" +
+ ( ( _expectedExceptionClass == null ) ? "none" : _expectedExceptionClass.getName() ) +
+ ") while calling " + _object.getClass().getName() + "." + _methodName,
+ _object, _methodName, _argClasses, _methodArgs, _expectedExceptionClass );
+ }
+
+ /**
+ * Mark the currently executed method as failed.
+ * This function generates "Test did fail." as standard message.
+ */
+ protected void failed() {
+ assure("Test did fail.", false, false);
+ }
+
+ /**
+ * Mark the currently executed method as failed.
+ * with the given message.
+ * @param msg The message of the failure.
+ */
+ protected void failed(String msg) {
+ assure(msg, false, false);
+ }
+
+ /**
+ * Assure that s is true.
+ * The given message will be only evaluated, if s is false.
+ * Normally, assure() leaves the current test method, and the next one
+ * is executed. With the parameter 'cont' set to true, the current test
+ * method will continue.<br>
+ * The current method will of course marked as failed.
+ * @param msg The message that is evaluated.
+ * @param s The condition that should be true.
+ * @param cont Continue with test method, even if s is false.
+ */
+ protected void assure(String msg, boolean s, boolean cont) {
+ state &= s;
+ if (!s) {
+ message += msg + "\r\n";
+ // log.println(msg);
+ if (!cont) {
+ throw new AssureException(msg);
+ }
+ }
+ }
+
+ protected void assureEquals( String message, Object expected, Object actual, boolean cont ) {
+ assure( message + " (expected: " + expected.toString() + ", actual: " + actual.toString() + ")",
+ expected.equals( actual ), cont );
+ }
+
+ /**
+ * Mark the currently executed method as failed.
+ * with the given message.
+ * The given message will be only evaluated, if s is false.
+ * With the parameter 'cont' set to true, the current test
+ * method will continue.<br>
+ * The current method will of course marked as failed.
+ * @param msg The message that is evaluated.
+ * @param cont Continue with test method, even if s is false.
+ */
+ protected void failed(String msg, boolean cont) {
+ assure(msg, false, cont);
+ }
+
+ /**
+ * @deprecated
+ */
+// protected void addResult(String message, boolean state) {
+// String msg = message + " - " + state;
+// this.state &= state;
+// this.message += msg + "\r\n";
+// log.println(msg);
+// }
+
+ public class AssureException extends RuntimeException {
+
+ public AssureException(String msg) {
+ super(msg);
+ }
+ }
+}
diff --git a/qadevOOo/runner/complexlib/ComplexTestCase.java b/qadevOOo/runner/complexlib/ComplexTestCase.java
new file mode 100644
index 000000000000..b15224bc503f
--- /dev/null
+++ b/qadevOOo/runner/complexlib/ComplexTestCase.java
@@ -0,0 +1,315 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package complexlib;
+
+import java.lang.reflect.Method;
+import share.DescEntry;
+import lib.TestParameters;
+import lib.StatusException;
+import share.LogWriter;
+import share.ComplexTest;
+import java.io.PrintWriter;
+
+/**
+ * Base class for all complex tests.
+ */
+public abstract class ComplexTestCase extends Assurance implements ComplexTest
+{
+
+ /** The test parameters **/
+ protected static TestParameters param = null;
+ /** Log writer **/
+ protected static LogWriter log = null;
+ /**
+ * The method name which will be written into f.e. the data base
+ **/
+ protected String mTestMethodName = null;
+ /** Maximal time one method is allowed to execute
+ * Can be set with parameter 'ThreadTimeOut'
+ **/
+ protected int m_nThreadTimeOut = 0;
+ /** Continue a test even if it did fail **/
+ // public static final boolean CONTINUE = true;
+
+ /** End a test if it did fail **/
+ public static final boolean BREAK = true;
+
+ private boolean m_bBeforeCalled;
+
+ /**
+ * is called before the real test starts
+ */
+ private void before()
+ {
+ try
+ {
+ Method before = this.getClass().getMethod("before", new Class[] {} );
+ before.invoke(this, new Object[] {} );
+
+ // beforeWorked = false;
+ m_bBeforeCalled = true;
+ }
+ catch (java.lang.NoSuchMethodException e)
+ {
+ // simply ignore
+ int dummy = 0;
+ m_bBeforeCalled = true;
+ }
+ catch (java.lang.IllegalAccessException e)
+ {
+ log.println("Cannot access the 'before()' method, although it" + " is there. Is this ok?");
+ }
+ catch (java.lang.reflect.InvocationTargetException e)
+ {
+ Throwable t = e.getTargetException();
+ if (!(t instanceof RuntimeException) || state)
+ {
+ log.println(t.toString());
+ if (message == null)
+ {
+ message = "Exception in before() method.\n\r" + t.getMessage();
+ }
+ state = false;
+ t.printStackTrace((PrintWriter) log);
+ }
+ }
+
+ }
+
+ /** Description entry **/
+ // protected DescEntry subEntry = null;
+
+ private void test_method(DescEntry _entry)
+ {
+
+ m_nThreadTimeOut = param.getInt("ThreadTimeOut");
+ if (m_nThreadTimeOut == 0)
+ {
+ m_nThreadTimeOut = 300000;
+ }
+
+ for (int i = 0; i < _entry.SubEntries.length; i++)
+ {
+
+ DescEntry subEntry = _entry.SubEntries[i];
+ if (m_bBeforeCalled)
+ {
+ state = true;
+ message = "";
+ }
+ else
+ {
+ // set all test methods on failed, if 'before()' did not work.
+ subEntry.State = message;
+ subEntry.hasErrorMsg = true;
+ subEntry.ErrorMsg = message;
+ continue;
+ }
+ Method testMethod = null;
+ try
+ {
+ String entryName = subEntry.entryName;
+ Object[] parameter = null;
+
+ if (entryName.indexOf("(") != -1)
+ {
+ String sParameter = (entryName.substring(entryName.indexOf("(") + 1, entryName.indexOf(")")));
+ mTestMethodName = entryName;
+ parameter = new String[] { sParameter };
+ entryName = entryName.substring(0, entryName.indexOf("("));
+ testMethod = this.getClass().getMethod(entryName, new Class[] { String.class });
+ }
+ else
+ {
+ testMethod = this.getClass().getMethod(entryName, new Class[] {} );
+ mTestMethodName = entryName;
+ }
+
+ MethodThread th = new MethodThread(testMethod, this, parameter, (java.io.PrintWriter) log);
+ log.println("Starting " + mTestMethodName);
+ th.start();
+
+ try
+ {
+ // some tests are very dynamic in its exceution time so that
+ // a threadTimeOut fials. In this cases the logging mechanisim
+ // is a usefull way to detect that a office respective a test
+ // is running and not death.
+ // But way ThreadTimeOut?
+ // There exeitsts a complex test which uses no office. Therefore
+ // a logging mechanisim to detect a stalled test.
+ int lastPing = -1;
+ int newPing = 0;
+
+ int sleepingStep = 1000;
+ int factor = 0;
+
+ while (th.isAlive() && (lastPing != newPing || factor * sleepingStep < m_nThreadTimeOut))
+ {
+ Thread.sleep(sleepingStep);
+ factor++;
+ // if a test starts the office itself it the watcher is a
+ // new one.
+ share.Watcher ow = (share.Watcher) param.get("Watcher");
+ if (ow != null)
+ {
+ lastPing = newPing;
+ newPing = ow.getPing();
+ //System.out.println("lastPing: '" + lastPing + "' newPing '" + newPing + "'");
+ factor = 0;
+ }
+ }
+ }
+ catch (InterruptedException e)
+ {
+ }
+ if (th.isAlive())
+ {
+ log.println("Destroy " + mTestMethodName);
+ th.destroy();
+ subEntry.State = "Test did sleep for " + (m_nThreadTimeOut / 1000) + " seconds and has been killed!";
+ subEntry.hasErrorMsg = true;
+ subEntry.ErrorMsg = subEntry.State;
+ continue;
+ }
+ else
+ {
+ log.println("Finished " + mTestMethodName);
+ if (th.hasErrorMessage())
+ {
+ subEntry.State = th.getErrorMessage();
+ subEntry.hasErrorMsg = true;
+ subEntry.ErrorMsg = subEntry.State;
+ continue;
+ }
+ }
+ }
+ catch (java.lang.Exception e)
+ {
+ log.println(e.getClass().getName());
+ String msg = e.getMessage();
+ log.println("Message: " + msg);
+ e.printStackTrace((PrintWriter) log);
+ subEntry.State = "SKIPPED.FAILED";
+ subEntry.hasErrorMsg = true;
+ subEntry.ErrorMsg = (msg == null ? "" : msg);
+ continue;
+ }
+ subEntry.State = (state ? "PASSED.OK" : message);
+ subEntry.hasErrorMsg = !state;
+ subEntry.ErrorMsg = message;
+ }
+ }
+
+ /**
+ * after() is called after the test is done
+ */
+ private void after()
+ {
+ if (m_bBeforeCalled)
+ {
+ // the after() method
+ try
+ {
+ Method after = this.getClass().getMethod("after", new Class[] {});
+ after.invoke(this, new Object[] {} );
+ }
+ catch (java.lang.NoSuchMethodException e)
+ {
+ // simply ignore
+ }
+ catch (java.lang.IllegalAccessException e)
+ {
+ // simply ignore
+ }
+ catch (java.lang.reflect.InvocationTargetException e)
+ {
+ Throwable t = e.getTargetException();
+ if (!(t instanceof StatusException))
+ {
+ log.println(t.toString());
+ if (message == null)
+ {
+ message = "Exception in after() method.\n\r" + t.getMessage();
+ }
+ else
+ {
+ message += "Exception in \'after()\' method.\n\r" + t.getMessage();
+ }
+ log.println("Message: " + message);
+ t.printStackTrace((PrintWriter) log);
+ }
+ }
+ }
+
+ }
+
+
+
+ /**
+ * Call test. It is expected, that an environment is
+ * given to this test.
+ *
+ * @param entry The name of the test method that should be called.
+ * @param environment The environment for the test.
+ */
+ public void executeMethods(DescEntry entry, TestParameters environment)
+ {
+ m_bBeforeCalled = false;
+
+ // get the environment
+ param = environment;
+ log = entry.Logger;
+
+
+ // start with the before() method
+ before();
+
+ //executeMethodTests
+ test_method(entry);
+
+ // cleanup
+ after();
+ }
+
+
+ /**
+ * Implement this method in the Complex test.
+ * @return All test method names.
+ */
+ public abstract String[] getTestMethodNames();
+
+ /**
+ * Return a name for the test or tested object.
+ * Override to give an own name.
+ * @return As default, the name of this class.
+ */
+ public String getTestObjectName()
+ {
+ return this.getClass().getName();
+ }
+}
diff --git a/qadevOOo/runner/complexlib/MethodThread.java b/qadevOOo/runner/complexlib/MethodThread.java
new file mode 100644
index 000000000000..e068323fd41e
--- /dev/null
+++ b/qadevOOo/runner/complexlib/MethodThread.java
@@ -0,0 +1,112 @@
+package complexlib;
+
+import java.io.PrintWriter;
+import java.lang.reflect.Method;
+
+/**
+ * Invoke a method of a class in an own thread. Provide a method to end
+ * the thread.
+ */
+public class MethodThread extends Thread
+{
+
+ /** The method that should be executed **/
+ private Method mTestMethod = null;
+ /** The object that implements the method **/
+ private Object mInvokeClass = null;
+ /** A PrintWriter for debug Output **/
+ private PrintWriter mLog = null;
+ /** An Error String **/
+ private String mErrMessage = null;
+ /** Did an Exception happen? **/
+ private boolean mExceptionHappened = false;
+ private Object[] mParameter = null;
+
+ /**
+ * Constructor.
+ * @param testMethod The method that will be invoked.
+ * @param invokeClass The class where the method is invoked.
+ * @param log The logging mechanism.
+ */
+ public MethodThread(Method testMethod, Object invokeClass, PrintWriter log)
+ {
+ mTestMethod = testMethod;
+ mInvokeClass = invokeClass;
+ mLog = log;
+ }
+
+ public MethodThread(Method testMethod, Object invokeClass, Object[] parameter, PrintWriter log)
+ {
+ mTestMethod = testMethod;
+ mInvokeClass = invokeClass;
+ mParameter = parameter;
+ mLog = log;
+ }
+
+ /**
+ * Invoke the method.
+ */
+ public void run()
+ {
+ try
+ {
+ mTestMethod.invoke(mInvokeClass, mParameter);
+ }
+ catch (IllegalAccessException e)
+ {
+ e.printStackTrace(mLog);
+ mErrMessage = e.getMessage();
+ mExceptionHappened = true;
+ }
+ catch (java.lang.reflect.InvocationTargetException e)
+ {
+ Throwable t = e.getTargetException();
+ if (!(t instanceof ComplexTestCase.AssureException))
+ {
+ t.printStackTrace(mLog);
+ mErrMessage = t.getMessage();
+ if (mErrMessage == null)
+ {
+ mErrMessage = t.toString();
+ }
+ mExceptionHappened = true;
+ }
+
+ }
+ }
+
+ /**
+ * Get the error message
+ * @return The error message.
+ */
+ public String getErrorMessage()
+ {
+ return mErrMessage;
+ }
+
+ /**
+ * Is there an error message?
+ * @return True, if an error did happen.
+ */
+ public boolean hasErrorMessage()
+ {
+ return mExceptionHappened;
+ }
+
+ /**
+ * Stop the running method.
+ */
+ public void destroy()
+ {
+ try
+ {
+ interrupt();
+ }
+ catch (SecurityException e)
+ {
+ e.printStackTrace(mLog);
+ mErrMessage = e.getMessage();
+ mExceptionHappened = true;
+ }
+ }
+}
diff --git a/qadevOOo/runner/complexlib/ShowTargets.java b/qadevOOo/runner/complexlib/ShowTargets.java
new file mode 100644
index 000000000000..6f46a389d14b
--- /dev/null
+++ b/qadevOOo/runner/complexlib/ShowTargets.java
@@ -0,0 +1,138 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package complexlib;
+
+/**
+ *
+ * @author fs93730
+ */
+public class ShowTargets
+{
+ /** Creates a new instance of ShowTargets */
+ public ShowTargets()
+ {
+ }
+
+ public static void main( String[] args )
+ {
+ java.util.Vector targets = new java.util.Vector();
+ java.util.Vector descs = new java.util.Vector();
+
+ targets.add( "run" );
+ descs.add( "runs all complex tests in this module" );
+
+ int maxTargetLength = 3;
+
+ for ( int i = 0; i < args.length; ++i )
+ {
+ String completePotentialClassName = args[i].replace( '/', '.' );
+
+ // filter
+ if ( completePotentialClassName.endsWith( ".TestCase" ) )
+ continue;
+ if ( completePotentialClassName.endsWith( ".TestSkeleton" ) )
+ continue;
+
+ // get the class
+ Class potentialTestClass = null;
+ try { potentialTestClass = Class.forName( completePotentialClassName ); }
+ catch( java.lang.ClassNotFoundException e )
+ {
+ continue;
+ }
+
+ // see if it is derived from complexlib.ComplexTestCase
+ Class superClass = potentialTestClass.getSuperclass();
+ while ( superClass != null )
+ {
+ if ( superClass.getName().equals( "complexlib.ComplexTestCase" ) )
+ {
+ String bareClassName = completePotentialClassName.substring( completePotentialClassName.lastIndexOf( '.' ) + 1 );
+ String target = "run_" + bareClassName;
+ targets.add( target );
+ descs.add( getShortTestDescription( potentialTestClass ) );
+
+ if ( maxTargetLength < target.length() )
+ maxTargetLength = target.length();
+ break;
+ }
+ superClass = superClass.getSuperclass();
+ }
+ }
+
+ System.out.println( "possible targets:" );
+ for ( int i=0; i<targets.size(); ++i )
+ {
+ // target
+ String target = (String)targets.get(i);
+ // 'tab'
+ System.out.print( " " + target );
+ for ( int s = maxTargetLength - target.length(); s>0; --s )
+ System.out.print( " " );
+ // description
+ System.out.println( " (" + (String)descs.get(i) + ")" );
+ }
+ }
+
+ /** determines if the test denoted by a given Class is an interactive test
+ */
+ static private boolean isInteractiveTest( Class testClass )
+ {
+ java.lang.reflect.Method interactiveTestMethod = null;
+ try { interactiveTestMethod = testClass.getMethod( "isInteractiveTest", new Class[]{} ); }
+ catch( Exception e ) { }
+
+ if ( interactiveTestMethod != null )
+ {
+ try
+ {
+ Boolean result = (Boolean)interactiveTestMethod.invoke( null, new Object[]{} );
+ return result.booleanValue();
+ }
+ catch( Exception e ) { }
+ }
+ return false;
+ }
+
+ static private String getShortTestDescription( Class _testClass )
+ {
+ java.lang.reflect.Method getShortDescriptionMethod = null;
+ try { getShortDescriptionMethod = _testClass.getMethod( "getShortTestDescription", new Class[]{} ); }
+ catch( Exception e ) { }
+
+ if ( getShortDescriptionMethod != null )
+ {
+ try
+ {
+ return (String)getShortDescriptionMethod.invoke( null, new Object[]{} );
+ }
+ catch( Exception e ) { }
+ }
+ return "no description provided by the test";
+ }
+}
diff --git a/qadevOOo/runner/complexlib/makefile.mk b/qadevOOo/runner/complexlib/makefile.mk
new file mode 100644
index 000000000000..7af514193c12
--- /dev/null
+++ b/qadevOOo/runner/complexlib/makefile.mk
@@ -0,0 +1,49 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..
+
+PRJNAME = OOoRunner
+PACKAGE = complexlib
+TARGET = runner_complexlib
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+
+# --- Files --------------------------------------------------------
+
+JARFILES = ridl.jar jurt.jar unoil.jar
+
+JAVAFILES = ComplexTestCase.java MethodThread.java ShowTargets.java
+
+JAVACLASSFILES= $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class)
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
diff --git a/qadevOOo/runner/convwatch/Basename.java b/qadevOOo/runner/convwatch/Basename.java
new file mode 100644
index 000000000000..05381e841eed
--- /dev/null
+++ b/qadevOOo/runner/convwatch/Basename.java
@@ -0,0 +1,61 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package convwatch;
+
+// -----------------------------------------------------------------------------
+// Helper stuff to
+// abstract class Name
+// {
+// abstract public String getName();
+// }
+// class PRN extends Name
+// {
+// public String getName() {return "-ref";}
+// }
+// class PS extends Name
+// {
+// public String getName() {return "-test";}
+// }
+//
+// public class Basename /* extends *//* implements */ {
+// String fs;
+// Basename()
+// {
+// fs = System.getProperty("file.separator");
+// }
+// String getJPEGName(String _sOutputPath, String _sBasename, String _sGS_PageOutput, Name _aPostNameAdd)
+// {
+// String sBaseNameNoSuffix = FileHelper.getNameNoSuffix(_sBasename);
+// String sJPEGName = _sOutputPath + fs + sBaseNameNoSuffix + "-" + _sGS_PageOutput + _aPostNameAdd.getName() + ".jpg";
+// return sJPEGName;
+// }
+//
+// public static void main( String[] argv ) {
+//
+// }
+// }
diff --git a/qadevOOo/runner/convwatch/BorderRemover.java b/qadevOOo/runner/convwatch/BorderRemover.java
new file mode 100644
index 000000000000..986f6ff6582b
--- /dev/null
+++ b/qadevOOo/runner/convwatch/BorderRemover.java
@@ -0,0 +1,319 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package convwatch;
+
+import convwatch.ImageHelper;
+import java.io.File;
+import java.awt.image.RenderedImage;
+import java.awt.image.BufferedImage;
+import java.lang.reflect.Method;
+
+// -----------------------------------------------------------------------------
+class Rect
+{
+ int x;
+ int y;
+ int w;
+ int h;
+
+ public Rect(int _x, int _y, int _w, int _h)
+ {
+ x = _x;
+ y = _y;
+ w = _w;
+ h = _h;
+ }
+ public int getX() {return x;}
+ public int getY() {return y;}
+ public int getWidth() {return w;}
+ public int getHeight() {return h;}
+}
+
+class BorderRemover
+{
+ ImageHelper m_aImage;
+
+ // Helper values, filled after find Border
+
+ // --------------------------------- test mode ---------------------------------
+
+ // void pixelValue(int pixel)
+ // {
+ // int alpha = (pixel >> 24) & 0xff;
+ // int red = (pixel >> 16) & 0xff;
+ // int green = (pixel >> 8) & 0xff;
+ // int blue = (pixel ) & 0xff;
+ // int dummy = 0;
+ // }
+
+ /*
+ * compares 2 colors with a given tolerance. So it's possible to check differences approximate.
+ * @param _nColor1
+ * @param _nColor2
+ * @param _nTolerance is a percentage value how strong the colors could be differ
+
+ */
+ boolean compareColorWithTolerance(int _nColor1, int _nColor2, int _nTolerance)
+ {
+ // int alpha1 = (_nColor1 >> 24) & 0xff;
+ int red1 = (_nColor1 >> 16) & 0xff;
+ int green1 = (_nColor1 >> 8) & 0xff;
+ int blue1 = (_nColor1 ) & 0xff;
+
+ // int alpha2 = (_nColor2 >> 24) & 0xff;
+ int red2 = (_nColor2 >> 16) & 0xff;
+ int green2 = (_nColor2 >> 8) & 0xff;
+ int blue2 = (_nColor2 ) & 0xff;
+
+ if (_nTolerance > 100)
+ {
+ _nTolerance = 100;
+ }
+
+ // calculate tolerance halve
+ double nTolerable = (_nTolerance * 256 / 100);
+ if (nTolerable < 0)
+ {
+ nTolerable = 0;
+ }
+
+ // X - th < Y < X + th
+ // if ((red1 - nTolerable) < red2 && red2 < (red1 + nTolerable))
+ // is the same
+ // abs (X - Y) < th
+ if (Math.abs(red1 - red2) < nTolerable)
+ {
+ if (Math.abs(green1 - green2) < nTolerable)
+ {
+ if (Math.abs(blue1 - blue2) < nTolerable)
+ {
+ return true;
+ }
+ else
+ {
+ // blue differ
+ }
+ }
+ else
+ {
+ // green differ
+ }
+ }
+ else
+ {
+ // red differ
+ }
+
+ return false;
+ }
+
+ /**
+ * create a new image from an exist one without it's borders
+ * open the file (_sFilenameFrom) as an image, check if it contains any borders and remove
+ * the borders.
+ */
+ public boolean createNewImageWithoutBorder(String _sFilenameFrom, String _sFilenameTo)
+ throws java.io.IOException
+ {
+ // System.out.println("load image: " + fileName);
+ m_aImage = ImageHelper.createImageHelper(_sFilenameFrom);
+
+ // System.out.println("image width:" + String.valueOf(m_aImage.getWidth()));
+ // System.out.println("image height:" + String.valueOf(m_aImage.getHeight()));
+
+ // int nw = graphics_stuff.countNotWhitePixel(m_aImage);
+ // System.out.println("not white pixels:" + String.valueOf(nw));
+
+ // int nb = graphics_stuff.countNotBlackPixel(m_aImage);
+ // System.out.println("not black pixels:" + String.valueOf(nb));
+
+ int nBorderColor = m_aImage.getPixel(0,0);
+ Rect aInnerRect = findBorder(m_aImage, nBorderColor);
+
+ RenderedImage aImage = createImage(m_aImage, aInnerRect);
+
+ File aWriteFile = new File(_sFilenameTo);
+ // GlobalLogWriter.get().println("Hello World: File to: " + _sFilenameTo);
+
+ Exception ex = null;
+ try
+ {
+ Class imageIOClass = Class.forName("javax.imageio.ImageIO");
+ // GlobalLogWriter.get().println("Hello World: get Class");
+
+ Method getWriterMIMETypesMethod = imageIOClass.getDeclaredMethod("getWriterMIMETypes", new Class[]{ });
+ // GlobalLogWriter.get().println("Hello World: get Methode");
+
+ Object aObj = getWriterMIMETypesMethod.invoke(imageIOClass, new Object[]{ });
+ String[] types = (String[])aObj;
+ // GlobalLogWriter.get().println("Hello World: types: " + Arrays.asList(types) );
+
+ Method writeMethod = imageIOClass.getDeclaredMethod("write", new Class[]{ java.awt.image.RenderedImage.class,
+ java.lang.String.class,
+ java.io.File.class});
+ // GlobalLogWriter.get().println("Hello World: get Methode");
+ writeMethod.invoke(imageIOClass, new Object[]{aImage, "image/jpeg", aWriteFile});
+ }
+ catch(java.lang.ClassNotFoundException e) {
+ e.printStackTrace();
+ ex = e;
+ }
+ catch(java.lang.NoSuchMethodException e) {
+ e.printStackTrace();
+ ex = e;
+ }
+ catch(java.lang.IllegalAccessException e) {
+ e.printStackTrace();
+ ex = e;
+ }
+ catch(java.lang.reflect.InvocationTargetException e) {
+ e.printStackTrace();
+ ex = e;
+ }
+
+ if (ex != null) {
+ // get Java version:
+ String javaVersion = System.getProperty("java.version");
+ throw new java.io.IOException(
+ "Cannot construct object with current Java version " +
+ javaVersion + ": " + ex.getMessage());
+ }
+// ImageIO.write(aImage, "jpg", aWriteFile);
+
+ return true;
+ }
+
+
+ /**
+ * runs through the image, pixel by pixel
+ * as long as found pixels like the color at (0,0) this is interpreted as border.
+ * as result it fills the m_nXMin, m_nXMax, m_nYMin, m_nYMax values.
+ */
+
+ Rect findBorder(ImageHelper _aImage, int _nBorderColor)
+ {
+ int h = _aImage.getHeight();
+ int w = _aImage.getWidth();
+ int nXMin = w;
+ int nXMax = 0;
+ int nYMin = h;
+ int nYMax = 0;
+
+ for (int y = 0; y < h; y++)
+ {
+ for (int x = 0; x < nXMin; x++)
+ {
+ // handlesinglepixel(x+i, y+j, pixels[j * w + i]);
+ int nCurrentColor = _aImage.getPixel(x, y);
+ if (! compareColorWithTolerance(nCurrentColor, _nBorderColor, 10))
+ {
+ // pixelValue(nCurrentColor);
+ // System.out.print("*");
+ nXMin = java.lang.Math.min(nXMin, x);
+ nYMin = java.lang.Math.min(nYMin, y);
+ }
+ // else
+ // {
+ // System.out.print(" ");
+ // }
+ }
+ }
+ for (int y = 0; y < h; y++)
+ {
+ for (int nx = w - 1; nx >= nXMax; --nx)
+ {
+ int ny = h - y - 1;
+ int nCurrentColor = _aImage.getPixel(nx, ny);
+ if (! compareColorWithTolerance(nCurrentColor, _nBorderColor, 10))
+ {
+ nXMax = java.lang.Math.max(nXMax, nx);
+ nYMax = java.lang.Math.max(nYMax, ny);
+ }
+ }
+ // System.out.println();
+ }
+ // System.out.println("xmin: " + String.valueOf(nXMin));
+ // System.out.println("xmax: " + String.valueOf(nXMax));
+ // System.out.println("ymin: " + String.valueOf(nYMin));
+ // System.out.println("ymax: " + String.valueOf(nYMax));
+
+ Rect aRect;
+ if (nXMin < nXMax && nYMin < nYMax)
+ {
+ int nw = nXMax - nXMin + 1;
+ int nh = nYMax - nYMin + 1;
+
+ // this is the rectangle around the image content.
+ aRect = new Rect(nXMin, nYMin, nw, nh );
+ }
+ else
+ {
+ // create the smalles possible image
+ aRect = new Rect(0,0,1,1);
+ }
+
+
+ // m_nXMin = nXMin;
+ // m_nXMax = nXMax;
+ // m_nYMin = nYMin;
+ // m_nYMax = nYMax;
+ return aRect;
+ }
+
+ RenderedImage createImage(ImageHelper _aImage, Rect _aRect) throws IllegalArgumentException
+ {
+// TODO: throw if w or h < 0
+ int w = _aRect.getWidth();
+ int h = _aRect.getHeight();
+
+ if (w <= 0 || h <= 0)
+ {
+ throw new IllegalArgumentException("width or height are too small or negative.");
+ }
+
+ BufferedImage aBI = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
+
+ int nXOffset = _aRect.getX();
+ int nYOffset = _aRect.getY();
+
+ // Memory Block move
+ for (int y = 0; y < h; y++)
+ {
+ for (int x = 0; x < w; x++)
+ {
+ // aPixels[y * w + x] = m_aImage.getPixel(m_nXMin + x, m_nYMin + y);
+ aBI.setRGB(x, y, _aImage.getPixel(x + nXOffset, y + nYOffset));
+ }
+ }
+ // java.awt.image.MemoryImageSource aSource = new java.awt.image.MemoryImageSource(w, h, aPixels, 0, w);
+// return java.awt.Component.createImage(aSource);
+ // return java.awt.Toolkit.getDefaultToolkit().createImage(aSource);
+ return aBI;
+ }
+
+}
diff --git a/qadevOOo/runner/convwatch/BuildID.java b/qadevOOo/runner/convwatch/BuildID.java
new file mode 100644
index 000000000000..efb091d160f9
--- /dev/null
+++ b/qadevOOo/runner/convwatch/BuildID.java
@@ -0,0 +1,163 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package convwatch;
+
+import java.io.File;
+import helper.OSHelper;
+import convwatch.IniFile;
+import java.util.Date;
+
+public class BuildID
+{
+ public static String getBuildID(String _sApp)
+ {
+ String sOfficePath = "";
+ if (_sApp.startsWith("\""))
+ {
+ int nIdx = _sApp.indexOf("\"", 1);
+ if (nIdx == -1)
+ {
+ }
+ else
+ {
+ // leave double qoute out.
+ sOfficePath = _sApp.substring(1, nIdx);
+ }
+ }
+ else
+ {
+ // check if a space exist, so we get all until space
+ int nIdx = _sApp.indexOf(" ", 1);
+ if (nIdx == -1)
+ {
+ sOfficePath = _sApp;
+ }
+ else
+ {
+ sOfficePath = _sApp.substring(0, nIdx);
+ }
+ }
+ GlobalLogWriter.get().println("Office path: " + sOfficePath);
+
+ String fs = System.getProperty("file.separator");
+ String sBuildID = "";
+ File aSOfficeFile = new File(sOfficePath);
+ if (aSOfficeFile.exists())
+ {
+ int nIdx = sOfficePath.lastIndexOf(fs);
+ sOfficePath = sOfficePath.substring(0, nIdx);
+ // ok. System.out.println("directory: " + sOfficePath);
+ sBuildID = getBuildIDFromBootstrap(sOfficePath);
+ if (sBuildID.length() == 0)
+ {
+ sBuildID = getBuildIDFromVersion(sOfficePath);
+ }
+ }
+ else
+ {
+ GlobalLogWriter.get().println("soffice executable not found.");
+ }
+
+ int dummy = 0;
+ return sBuildID;
+ }
+
+ private static String getBuildIDFromBootstrap(String _sOfficePath)
+ {
+ String fs = System.getProperty("file.separator");
+ String sBuildID = "";
+ String sOfficePath = _sOfficePath;
+ if (OSHelper.isWindows())
+ {
+ sOfficePath += fs + "bootstrap.ini";
+ }
+ else
+ {
+ sOfficePath += fs + "bootstraprc";
+ }
+ IniFile aIniFile = new IniFile(sOfficePath);
+ if (aIniFile.is())
+ {
+ sBuildID = aIniFile.getValue("Bootstrap", "buildid");
+ }
+ else
+ {
+ GlobalLogWriter.get().println("Property Build, can't open file '" + sOfficePath + "', please check.");
+ }
+ return sBuildID;
+ }
+
+ private static String getBuildIDFromVersion(String _sOfficePath)
+ {
+ String fs = System.getProperty("file.separator");
+ String sBuildID = "";
+ String sOfficePath = _sOfficePath;
+ if (OSHelper.isWindows())
+ {
+ sOfficePath += fs + "version.ini";
+ }
+ else
+ {
+ sOfficePath += fs + "versionrc";
+ }
+ IniFile aIniFile = new IniFile(sOfficePath);
+ if (aIniFile.is())
+ {
+ sBuildID = aIniFile.getValue("Version", "buildid");
+ }
+ else
+ {
+ GlobalLogWriter.get().println("Property Build, can't open file '" + sOfficePath + "', please check.");
+ }
+ return sBuildID;
+ }
+// public static void main(String[] args)
+// {
+// String sApp;
+// sApp = "/opt/staroffice8_m116/program/soffice -headless -accept=socket,host=localhost,port=8100;urp;";
+// String sBuildID;
+// sBuildID = getBuildID(sApp);
+// System.out.println("BuildID is: " + sBuildID);
+//
+// Date aDate = new Date();
+// long nStart = aDate.getTime();
+// System.out.println("Time:" + nStart);
+// // LLA: Just some more tests for getBuildID
+// // sApp = "/opt/staroffice8_net/program/soffice";
+// // sBuildID = getBuildID(sApp);
+// // System.out.println("BuildID is: " + sBuildID);
+// //
+// // sApp = "\"/opt/staroffice8_net/program/soffice\" test blah";
+// // sBuildID = getBuildID(sApp);
+// //
+// // System.out.println("BuildID is: " + sBuildID);
+// System.exit(1);
+// }
+
+}
+
diff --git a/qadevOOo/runner/convwatch/ConvWatch.java b/qadevOOo/runner/convwatch/ConvWatch.java
new file mode 100644
index 000000000000..76dc3522d2e0
--- /dev/null
+++ b/qadevOOo/runner/convwatch/ConvWatch.java
@@ -0,0 +1,432 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package convwatch;
+
+import convwatch.ConvWatchException;
+import convwatch.ConvWatchCancelException;
+import convwatch.FileHelper;
+import convwatch.OfficePrint;
+import convwatch.PRNCompare;
+import convwatch.StatusHelper;
+import helper.URLHelper;
+import java.io.File;
+
+public class ConvWatch
+{
+
+ String getBuildID_FromFile(String _sInfoFile)
+ {
+ String sBuildID = "";
+ IniFile aIniFile = new IniFile(_sInfoFile);
+ if (aIniFile.is())
+ {
+ sBuildID = aIniFile.getValue("", "buildid");
+ }
+ return sBuildID;
+ }
+ /**
+ * Check if given document (_sAbsoluteInputFile) and it's postscript representation (_sAbsoluteReferenceFile) produce
+ * the same output like the StarOffice / OpenOffice.org which is accessable with XMultiServiceFactory.
+ * Here a simple graphically difference check is run through.
+ *
+ * Hint: In the OutputPath all needed files will create, there must
+ * be very much space. It's not possible to say how much.
+ * One page need up to 800kb as jpeg.
+ * Sample: If a document contains 2 pages, we need 2*800kb for prn
+ * output and 2*800kb for ps output and 2*800kb for it's difference
+ * output. So up to 4800kb or 4.8mb.
+ *
+ * RAM is need least 300mb. Will say, it's tested on a pc with 128mb RAM and 256mb swap.
+ *
+ * It's also absolutlly impossible to say, how much time this functions consume.
+ */
+
+ StatusHelper[] createPostscriptStartCheck(GraphicalTestArguments _aGTA,
+ String _sOutputPath, String _sAbsoluteInputFile, String _sAbsoluteReferenceFile)
+ throws ConvWatchCancelException
+ {
+// TODO: some more checks
+
+ if (! FileHelper.exists(_sAbsoluteInputFile))
+ {
+ throw new ConvWatchCancelException("createPostscriptStartCheck: Input file: " + _sAbsoluteInputFile + " does not exist.");
+ }
+
+ if (_sAbsoluteReferenceFile == null)
+ {
+ // we assume, that the prn file is near the document
+ String sAbsoluteInputFileNoSuffix = FileHelper.getNameNoSuffix(_sAbsoluteInputFile);
+ _sAbsoluteReferenceFile = sAbsoluteInputFileNoSuffix + ".prn";
+ }
+
+ String fs = System.getProperty("file.separator");
+ File aAbsoluteReferenceFile = new File(_sAbsoluteReferenceFile);
+
+ if (aAbsoluteReferenceFile.isDirectory())
+ {
+ String sBasename = FileHelper.getBasename(_sAbsoluteInputFile);
+ String sNameNoSuffix = FileHelper.getNameNoSuffix(sBasename);
+ String sAbsoluteReferenceFileInfo = _sAbsoluteReferenceFile + fs + sNameNoSuffix + ".info";
+ _sAbsoluteReferenceFile = _sAbsoluteReferenceFile + fs + sNameNoSuffix + ".prn";
+
+ // Read the reference from the info file
+ String sRefBuildID = "";
+ if (FileHelper.exists(sAbsoluteReferenceFileInfo))
+ {
+ sRefBuildID = getBuildID_FromFile(sAbsoluteReferenceFileInfo);
+ }
+ _aGTA.setRefBuildID(sRefBuildID);
+
+ }
+ else
+ {
+ // java file has problems to check for directories, if the given directory doesn't exist.
+ String sName = FileHelper.getBasename(_sAbsoluteReferenceFile);
+ // thanks to Mircosoft, every document has a suffix, so if a name doesn't have a suffix, it must be a directory name
+ int nIdx = sName.indexOf('.');
+ if (nIdx == -1)
+ {
+ // must be a directory
+ throw new ConvWatchCancelException("createPostscriptStartCheck: Given reference directory: '" + _sAbsoluteReferenceFile + "' does not exist.");
+ }
+ }
+
+
+ boolean bAbsoluteReferenceFile = true;
+ if (! FileHelper.exists(_sAbsoluteReferenceFile))
+ {
+ if (_aGTA.createDefaultReference())
+ {
+ GlobalLogWriter.get().println("Reference File doesn't exist, will create a default");
+ bAbsoluteReferenceFile = false;
+ }
+ else
+ {
+ throw new ConvWatchCancelException("createPostscriptStartCheck: Given reference file: " + _sAbsoluteReferenceFile + " does not exist.");
+ }
+ }
+
+ FileHelper.makeDirectories("", _sOutputPath);
+
+ // runner.convwatch.compare();
+
+ String sAbsoluteInputFileURL = URLHelper.getFileURLFromSystemPath(_sAbsoluteInputFile);
+
+ String sInputFile = FileHelper.getBasename(_sAbsoluteInputFile);
+ // System.out.println("InputFile: " + sInputFile);
+
+ String sInputFileNoSuffix = FileHelper.getNameNoSuffix(sInputFile);
+ // System.out.println("BasenameNoSuffix: " + sInputFileNoSuffix);
+
+
+ String sAbsoluteOutputFile = _sOutputPath + fs + sInputFile;
+ String sAbsoluteOutputFileURL = URLHelper.getFileURLFromSystemPath(sAbsoluteOutputFile);
+
+ String sReferenceFile = FileHelper.getBasename(_sAbsoluteReferenceFile);
+ String sReferenceFileNoSuffix = FileHelper.getNameNoSuffix(sReferenceFile);
+ String sPostScriptFile = sReferenceFileNoSuffix + ".ps";
+ // System.out.println("PostscriptFile: " + sPostScriptFile);
+
+ String sAbsolutePrintFile = _sOutputPath + fs + sPostScriptFile;
+ String sAbsolutePrintFileURL = URLHelper.getFileURLFromSystemPath(sAbsolutePrintFile);
+
+ // System.out.println("AbsoluteInputFileURL: " + sAbsoluteInputFileURL);
+ // System.out.println("AbsoluteOutputFileURL: " + sAbsoluteOutputFileURL);
+ // System.out.println("AbsolutePrintFileURL: " + sAbsolutePrintFileURL);
+
+ // store and print the sAbsoluteInputFileURL file with StarOffice / OpenOffice.org
+ OfficePrint.printToFile(_aGTA, sAbsoluteInputFileURL, sAbsoluteOutputFileURL, sAbsolutePrintFileURL);
+
+ // wait(2);
+
+ if (! FileHelper.exists(sAbsolutePrintFile))
+ {
+ throw new ConvWatchCancelException("createPostscriptStartCheck: Printed file " + sAbsolutePrintFile + " does not exist.");
+ }
+
+ if (bAbsoluteReferenceFile == false)
+ {
+ // copy AbsolutePrintFile to AbsoluteReferenceFile
+ String sDestinationFile = sAbsolutePrintFile; // URLHelper.getSystemPathFromFileURL(...)
+ String sSourceFile = _sAbsoluteReferenceFile;
+ FileHelper.copy(sDestinationFile, sSourceFile);
+ // now the fix reference of the AbsoluteReferenceFile should exist.
+ if (! FileHelper.exists(_sAbsoluteReferenceFile))
+ {
+ throw new ConvWatchCancelException("createPostscriptStartCheck: Given reference file: " + _sAbsoluteReferenceFile + " does not exist, after try to copy.");
+ }
+ }
+
+ PRNCompare a = new PRNCompare();
+ String sInputPath = FileHelper.getPath(_sAbsoluteInputFile);
+ String sReferencePath = FileHelper.getPath(_sAbsoluteReferenceFile);
+ // String sReferenceFile = FileHelper.getBasename(sAbsoluteReferenceFile);
+
+ // System.out.println("InputPath: " + sInputPath);
+ // System.out.println("sReferencePath: " + sReferencePath);
+ // System.out.println("sReferenceFile: " + sReferenceFile);
+
+ a.setInputPath( sInputPath );
+ a.setReferencePath( sReferencePath );
+ a.setOutputPath( _sOutputPath );
+ // a.setDocFile( "1_Gov.ppt");
+ a.setReferenceFile( sReferenceFile );
+ a.setPostScriptFile(sPostScriptFile );
+ if (_aGTA.printAllPages() == true)
+ {
+ a.setMaxPages(9999);
+ }
+ else
+ {
+ if (_aGTA.getMaxPages() > 0)
+ {
+ a.setMaxPages(_aGTA.getMaxPages());
+ }
+ if (_aGTA.getOnlyPages().length() != 0)
+ {
+ // we can't interpret the string of getOnlyPages() right without much logic, so print all pages here!
+ a.setMaxPages(9999);
+ }
+ }
+
+ a.setResolutionInDPI(_aGTA.getResolutionInDPI());
+ a.setBorderMove(_aGTA.getBorderMove());
+ a.setDocumentType(_aGTA.getDocumentType());
+
+ StatusHelper[] aList = a.compare();
+
+ _aGTA.setBorderMove(a.getBorderMove());
+ return aList;
+ }
+
+ // -----------------------------------------------------------------------------
+ // This creates a status for exact on document
+ static boolean createINIStatus(StatusHelper[] aList, String _sFilenamePrefix, String _sOutputPath, String _sAbsoluteInputFile, String _sBuildID, String _sRefBuildID)
+ {
+ // Status
+ String fs = System.getProperty("file.separator");
+ String sBasename = FileHelper.getBasename(_sAbsoluteInputFile);
+ String sNameNoSuffix = FileHelper.getNameNoSuffix(sBasename);
+// String sHTMLFile = _sFilenamePrefix + sNameNoSuffix + ".html";
+// HTMLOutputter HTMLoutput = HTMLOutputter.create(_sOutputPath, sHTMLFile, "", "");
+// HTMLoutput.header(sNameNoSuffix);
+// TODO: version info was fine
+// HTMLoutput.checkSection(sBasename);
+ // Status end
+
+ String sINIFile = _sFilenamePrefix + sNameNoSuffix + ".ini";
+ INIOutputter INIoutput = INIOutputter.create(_sOutputPath, sINIFile, "", "");
+ INIoutput.createHeader();
+// TODO: version info was fine
+
+ INIoutput.writeSection("global");
+ INIoutput.writeValue("pages", String.valueOf(aList.length));
+ INIoutput.writeValue("buildid", _sBuildID);
+ INIoutput.writeValue("refbuildid", _sRefBuildID);
+ INIoutput.writeValue("diffdiff", "no");
+ INIoutput.writeValue("basename", sBasename);
+
+ boolean bResultIsOk = true; // result over all pages
+ for (int i=0;i<aList.length; i++)
+ {
+ INIoutput.writeSection("page" + String.valueOf(i + 1)); // list start at point 0, but this is page 1 and so on... current_page = (i + 1)
+ aList[i].printStatus();
+
+ boolean bCurrentResult = true; // result over exact one page
+
+ int nCurrentDiffStatus = aList[i].nDiffStatus;
+
+ // check if the status is in a defined range
+ if (nCurrentDiffStatus == StatusHelper.DIFF_NO_DIFFERENCES)
+ {
+ // ok.
+ }
+ else if (nCurrentDiffStatus == StatusHelper.DIFF_DIFFERENCES_FOUND && aList[i].nPercent < 5)
+ {
+ // ok.
+ }
+ else if (nCurrentDiffStatus == StatusHelper.DIFF_AFTER_MOVE_DONE_NO_PROBLEMS)
+ {
+ // ok.
+ }
+ else if (nCurrentDiffStatus == StatusHelper.DIFF_AFTER_MOVE_DONE_DIFFERENCES_FOUND && aList[i].nPercent2 < 5)
+ {
+ // ok.
+ }
+ else
+ {
+ // failed.
+ bCurrentResult = false; // logic: nDiff==0 = true if there is no difference
+ }
+
+ // Status
+// HTMLoutput.checkLine(aList[i], bCurrentResult);
+ INIoutput.checkLine(aList[i], bCurrentResult);
+ bResultIsOk &= bCurrentResult;
+ }
+ // Status
+// HTMLoutput.close();
+ INIoutput.close();
+ return bResultIsOk;
+ }
+
+ // -----------------------------------------------------------------------------
+
+ static void createINIStatus_DiffDiff(StatusHelper[] aDiffDiffList, String _sFilenamePrefix, String _sOutputPath, String _sAbsoluteInputFile, String _sBuildID)
+ {
+ // Status
+ String fs = System.getProperty("file.separator");
+ String sBasename = FileHelper.getBasename(_sAbsoluteInputFile);
+ String sNameNoSuffix = FileHelper.getNameNoSuffix(sBasename);
+ String sINIFile = _sFilenamePrefix + sNameNoSuffix + ".ini";
+
+// HTMLOutputter HTMLoutput = HTMLOutputter.create(_sOutputPath, sHTMLFile, _sFilenamePrefix, "");
+// HTMLoutput.header(sNameNoSuffix);
+// HTMLoutput.checkDiffDiffSection(sBasename);
+
+ INIOutputter INIoutput = INIOutputter.create(_sOutputPath, sINIFile, _sFilenamePrefix, "");
+ INIoutput.createHeader();
+ // LLA? what if the are no values in the list? true or false;
+ INIoutput.writeSection("global");
+ INIoutput.writeValue("pages", String.valueOf(aDiffDiffList.length));
+ INIoutput.writeValue("buildid", _sBuildID);
+ INIoutput.writeValue("diffdiff", "yes");
+ INIoutput.writeValue("basename", sBasename);
+
+ for (int i=0;i<aDiffDiffList.length; i++)
+ {
+ INIoutput.writeSection("page" + String.valueOf(i + 1)); // list start at point 0, but this is page 1 and so on... current_page = (i + 1)
+ boolean bCurrentResult = (aDiffDiffList[i].nDiffStatus == StatusHelper.DIFF_NO_DIFFERENCES); // logic: nDiff==0 = true if there is no difference
+
+// HTMLoutput.checkDiffDiffLine(aDiffDiffList[i], bCurrentResult);
+ INIoutput.checkDiffDiffLine(aDiffDiffList[i], bCurrentResult);
+ }
+ // Status
+// HTMLoutput.close();
+ INIoutput.close();
+ }
+
+
+ // -----------------------------------------------------------------------------
+
+ public static boolean check(GraphicalTestArguments _aGTA,
+ String _sOutputPath, String _sAbsoluteInputFile, String _sAbsoluteReferenceFile)
+ throws ConvWatchCancelException, ConvWatchException
+ {
+ ConvWatch a = new ConvWatch();
+ StatusHelper[] aList = a.createPostscriptStartCheck(_aGTA, _sOutputPath, _sAbsoluteInputFile, _sAbsoluteReferenceFile);
+ DB.writeNumberOfPages(aList.length);
+
+ boolean bResultIsOk = createINIStatus(aList, "", _sOutputPath, _sAbsoluteInputFile, _aGTA.getBuildID(), _aGTA.getRefBuildID());
+
+ if (! bResultIsOk)
+ {
+ // it could be that this will store in a DB, there are problems with '\'
+ String sErrorMessage = "Graphical compare failed with file ";
+ String sErrorFile = _sAbsoluteInputFile.replace('\\', '/');
+ sErrorMessage = sErrorMessage + "'" + sErrorFile + "'";
+ DB.writeErrorFile(sErrorFile);
+ throw new ConvWatchException(sErrorMessage);
+ }
+ return bResultIsOk;
+ }
+
+ // -----------------------------------------------------------------------------
+ public static boolean checkDiffDiff(GraphicalTestArguments _aGTA,
+ String _sOutputPath, String _sAbsoluteInputFile, String _sAbsoluteReferenceFile,
+ String _sAbsoluteDiffPath)
+ throws ConvWatchCancelException, ConvWatchException
+ {
+ ConvWatch a = new ConvWatch();
+ _aGTA.setBorderMove(TriState.FALSE);
+ StatusHelper[] aList = a.createPostscriptStartCheck(_aGTA, _sOutputPath, _sAbsoluteInputFile, _sAbsoluteReferenceFile);
+
+ // Status
+ boolean bResultIsOk = createINIStatus(aList, "", _sOutputPath, _sAbsoluteInputFile, _aGTA.getBuildID(), _aGTA.getRefBuildID());
+
+ StatusHelper[] aDiffDiffList = new StatusHelper[aList.length];
+
+ String fs = System.getProperty("file.separator");
+
+ boolean bDiffIsOk = true;
+ boolean bFoundAOldDiff = false;
+
+ PRNCompare aCompare = new PRNCompare();
+ // LLA? what if the are no values in the list? true or false;
+ for (int i=0;i<aList.length; i++)
+ {
+ String sOrigDiffName = aList[i].m_sDiffGfx;
+ String sDiffBasename = FileHelper.getBasename(sOrigDiffName);
+
+ String sNewDiffName = _sAbsoluteDiffPath + fs + sDiffBasename;
+ if (! FileHelper.exists(sNewDiffName))
+ {
+ GlobalLogWriter.get().println("checkDiffDiff: Old diff file: '" + sNewDiffName + "' does not exist." );
+ continue;
+ }
+ // String sNewDiffName = _sAbsoluteDiffPath + fs + sDiffBasename;
+
+ // make a simple difference between these both diff files.
+ String sSourcePath1 = FileHelper.getPath(sOrigDiffName);
+ String sSourceFile1 = sDiffBasename;
+ String sSourcePath2 = _sAbsoluteDiffPath;
+ String sSourceFile2 = sDiffBasename;
+
+ StatusHelper aCurrentStatus = aCompare.checkDiffDiff(_sOutputPath, sSourcePath1, sSourceFile1, sSourcePath2, sSourceFile2);
+ boolean bCurrentResult = (aCurrentStatus.nDiffStatus == StatusHelper.DIFF_NO_DIFFERENCES); // logic: nDiff==0 = true if there is no difference
+ bDiffIsOk &= bCurrentResult;
+ bFoundAOldDiff = true;
+
+ aDiffDiffList[i] = aCurrentStatus;
+ }
+
+ createINIStatus_DiffDiff(aDiffDiffList, "DiffDiff_", _sOutputPath, _sAbsoluteInputFile, _aGTA.getBuildID());
+
+ if (bFoundAOldDiff == false)
+ {
+ throw new ConvWatchCancelException("No old difference file found." );
+ }
+ if (! bDiffIsOk)
+ {
+ throw new ConvWatchException("Graphical difference compare failed with file '" + _sAbsoluteInputFile + "'");
+ }
+ return bDiffIsOk;
+ }
+
+ // public static void main( String[] argv )
+ // {
+ // PRNCompare a = new PRNCompare();
+ // a.setInputPath( "/cws/so-cwsserv06/qadev18/SRC680/src.m47/convwatch.keep/input/msoffice/xp/PowerPoint");
+ // a.setDocFile( "1_Gov.ppt");
+ // a.setReferencePath( "/cws/so-cwsserv06/qadev18/SRC680/src.m47/convwatch.keep/input/msoffice/xp/PowerPoint");
+ // a.setReferenceFile( "1_Gov.prn" );
+ //
+ // a.setOutputPath( "/tmp/convwatch_java");
+ // a.setPostScriptFile("1_Gov.ps" );
+ // }
+}
diff --git a/qadevOOo/runner/convwatch/ConvWatchCancelException.java b/qadevOOo/runner/convwatch/ConvWatchCancelException.java
new file mode 100644
index 000000000000..2042f600b4cc
--- /dev/null
+++ b/qadevOOo/runner/convwatch/ConvWatchCancelException.java
@@ -0,0 +1,38 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package convwatch;
+
+import convwatch.ConvWatchException;
+
+public class ConvWatchCancelException extends ConvWatchException
+{
+ public ConvWatchCancelException(String _aMessage)
+ {
+ super(_aMessage);
+ }
+}
diff --git a/qadevOOo/runner/convwatch/ConvWatchException.java b/qadevOOo/runner/convwatch/ConvWatchException.java
new file mode 100644
index 000000000000..f0fab0852deb
--- /dev/null
+++ b/qadevOOo/runner/convwatch/ConvWatchException.java
@@ -0,0 +1,37 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package convwatch;
+
+public class ConvWatchException extends Exception
+{
+ public ConvWatchException(String _aMessage)
+ {
+ super(_aMessage);
+ }
+}
+
diff --git a/qadevOOo/runner/convwatch/ConvWatchStarter.java b/qadevOOo/runner/convwatch/ConvWatchStarter.java
new file mode 100644
index 000000000000..c81ba3dfca85
--- /dev/null
+++ b/qadevOOo/runner/convwatch/ConvWatchStarter.java
@@ -0,0 +1,445 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package convwatch;
+
+// imports
+import java.util.ArrayList;
+import java.io.File;
+import java.io.FileFilter;
+
+import convwatch.EnhancedComplexTestCase;
+import com.sun.star.lang.XMultiServiceFactory;
+
+import convwatch.ConvWatchException;
+import convwatch.DirectoryHelper;
+import convwatch.GraphicalTestArguments;
+import convwatch.HTMLOutputter;
+import helper.OfficeProvider;
+import helper.OfficeWatcher;
+import helper.OSHelper;
+import convwatch.PerformanceContainer;
+
+/**
+ * The following Complex Test will test
+ * an already created document and it's postscript output (by an older office version)
+ * with a new office version.
+ * This test use Ghostscript for the jpeg export and graphically compare tools from ImageMagick.
+ * Read the manual for more information.
+ *
+ * this is only the starter program
+ * more is found in qadevOOo/runner/convwatch/*
+ */
+
+public class ConvWatchStarter extends EnhancedComplexTestCase
+{
+ // The first of the mandatory functions:
+ /**
+ * Return the name of the test.
+ * In this case it is the actual name of the service.
+ * @return The tested service.
+ */
+ // public String getTestObjectName() {
+ // return "ConvWatch runner";
+ // }
+
+ // The second of the mandatory functions: return all test methods as an
+ // array. There is only one test function in this example.
+ /**
+ * Return all test methods.
+ * @return The test methods.
+ */
+ public String[] getTestMethodNames() {
+ return new String[]{"compareGraphicalDiffs"};
+ }
+
+ String m_sInputPath = "";
+ String m_sReferencePath = "";
+ String m_sOutputPath = "";
+ String m_sDiffPath = null;
+
+ private void initMember()
+ {
+ // MUST PARAMETER
+ // INPUTFILE ----------
+ String sINPATH = (String)param.get( PropertyName.DOC_COMPARATOR_INPUT_PATH );
+ boolean bQuit = false;
+ if (sINPATH == null || sINPATH.length() == 0)
+ {
+ log.println("Please set input path (path to documents) " + PropertyName.DOC_COMPARATOR_INPUT_PATH + "=path.");
+ bQuit = true;
+ }
+ else
+ {
+ log.println("found " + PropertyName.DOC_COMPARATOR_INPUT_PATH + " " + sINPATH);
+ m_sInputPath = sINPATH;
+ }
+
+ // REFERENCE_PATH ----------
+ String sREF = (String)param.get( PropertyName.DOC_COMPARATOR_REFERENCE_PATH );
+ if (sREF == null || sREF.length() == 0)
+ {
+ // log.println("Please set reference file (path to good documents) REFERENCEFILE=path.");
+ log.println("Assumtion, reference directory and input directory are the same.");
+ m_sReferencePath = m_sInputPath;
+ }
+ else
+ {
+ log.println("found " + PropertyName.DOC_COMPARATOR_REFERENCE_PATH + " " + sREF);
+ m_sReferencePath = sREF;
+ }
+
+ // OUTPUT_PATH ----------
+ String sOUT = (String)param.get( PropertyName.DOC_COMPARATOR_OUTPUT_PATH );
+ if (sOUT == null || sOUT.length() == 0)
+ {
+ log.println("Please set output path (path to a temp directory) " + PropertyName.DOC_COMPARATOR_OUTPUT_PATH + "=path.");
+ bQuit = true;
+ }
+ else
+ {
+ log.println("found " + PropertyName.DOC_COMPARATOR_OUTPUT_PATH + " " + sOUT);
+ m_sOutputPath = sOUT;
+ }
+
+ if (bQuit == true)
+ {
+ // log.println("must quit.");
+ assure("Must quit", false);
+ }
+
+
+ // DIFF_PATH ----------
+ String sDIFF = (String)param.get( PropertyName.DOC_COMPARATOR_DIFF_PATH );
+ if (sDIFF == null || sDIFF.length() == 0)
+ {
+ }
+ else
+ {
+ log.println("found " + PropertyName.DOC_COMPARATOR_DIFF_PATH + " " + sDIFF);
+ m_sDiffPath = sDIFF;
+ }
+
+ if (m_sInputPath.startsWith("file:") ||
+ m_sReferencePath.startsWith("file:") ||
+ m_sOutputPath.startsWith("file:"))
+ {
+ assure("We can't handle file: URL right, use system path instead.", false);
+ }
+
+ }
+
+
+ /**
+ *
+ * @return a List of software which must accessable as an external executable
+ */
+ protected Object[] mustInstalledSoftware()
+ {
+ ArrayList aList = new ArrayList();
+ // Tools from ImageMagick
+ if (! OSHelper.isWindows())
+ {
+ aList.add( "composite -version" );
+ aList.add( "identify -version" );
+
+ // Ghostscript
+ aList.add( "gs -version" );
+ }
+ else
+ {
+ aList.add( "composite.exe -version" );
+ aList.add( "identify.exe -version" );
+
+ // Ghostscript
+ aList.add( "gswin32c.exe -version" );
+ }
+
+ return aList.toArray();
+ }
+
+
+ /**
+ * The test method itself.
+ * Don't try to call it from outside, it is started only from qadevOOo runner
+ */
+
+ /* protected */
+ public void compareGraphicalDiffs()
+ {
+ GlobalLogWriter.set(log);
+ String sDBConnection = (String)param.get( PropertyName.DB_CONNECTION_STRING );
+ // check if all need software is installed and accessable
+ checkEnvironment(mustInstalledSoftware());
+
+ GraphicalTestArguments aGTA = getGraphicalTestArguments();
+ if (aGTA == null)
+ {
+ assure("Must quit", false);
+ }
+ if (aGTA.cancelRequest())
+ {
+ return;
+ }
+
+ initMember();
+
+ aGTA.allowStore();
+
+ String sBuildID = aGTA.getBuildID();
+ log.println("Current Office has buildid: " + sBuildID);
+
+ // LLA: sample code, how to access all parameters
+ // for (Enumeration e = param.keys() ; e.hasMoreElements() ;)
+ // {
+ // System.out.println(e.nextElement());
+ // }
+
+ String fs = System.getProperty("file.separator");
+
+ String sHTMLName = "index.html";
+ File aInputPathTest = new File(m_sInputPath);
+ if (!aInputPathTest.isDirectory())
+ {
+ int n = m_sInputPath.lastIndexOf(fs);
+ sHTMLName = m_sInputPath.substring(n + 1);
+ sHTMLName += ".html";
+ }
+ HTMLOutputter HTMLoutput = HTMLOutputter.create(m_sOutputPath, sHTMLName, "", "");
+ HTMLoutput.header( m_sOutputPath );
+ HTMLoutput.indexSection( m_sOutputPath );
+ LISTOutputter LISToutput = LISTOutputter.create(m_sOutputPath, "allfiles.txt");
+
+ DB.init(aGTA.getDBInfoString() + "," + sDBConnection);
+
+ File aInputPath = new File(m_sInputPath);
+ if (aInputPath.isDirectory())
+ {
+ // check a whole directory
+ // a whole directory
+ FileFilter aFileFilter = FileHelper.getFileFilter();
+
+ Object[] aList = DirectoryHelper.traverse(m_sInputPath, aFileFilter, aGTA.includeSubDirectories());
+ if (aList.length == 0)
+ {
+ log.println("Nothing to do, there are no document files found.");
+ }
+ else
+ {
+ for (int i=0;i<aList.length;i++)
+ {
+ String sEntry = (String)aList[i];
+ log.println("- next file is: ------------------------------");
+ log.println(sEntry);
+
+ String sNewSubDir = FileHelper.removeFirstDirectorysAndBasenameFrom(sEntry, m_sInputPath);
+
+ String sNewReferencePath = m_sReferencePath;
+ String sNewOutputPath = m_sOutputPath;
+ String sNewDiffPath = m_sDiffPath;
+ if (sNewSubDir.length() > 0)
+ {
+ if (sNewReferencePath != null)
+ sNewReferencePath = sNewReferencePath + fs + sNewSubDir;
+ // String sNameNoSuffix = FileHelper.getNameNoSuffix(FileHelper.getBasename(sEntry));
+ // sNewReferenceFile = sNewReferencePath + fs + sNameNoSuffix + ".prn";
+
+ sNewOutputPath = sNewOutputPath + fs + sNewSubDir;
+ if (sNewDiffPath != null)
+ sNewDiffPath = sNewDiffPath + fs + sNewSubDir;
+ }
+
+ // NameHelper aNameContainer = new NameHelper(m_sOutputPath, sNewSubDir, FileHelper.getBasename(sEntry));
+ // aNameContainer.print();
+
+ if (aGTA.checkIfUsableDocumentType(sEntry))
+ {
+ runGDCWithStatus(HTMLoutput, LISToutput, sEntry, sNewOutputPath, sNewReferencePath, sNewDiffPath, sNewSubDir);
+ }
+ if (aGTA.cancelRequest())
+ {
+ break;
+ }
+ }
+ }
+ }
+ else
+ {
+ // check exact name
+ if (aGTA.checkIfUsableDocumentType(m_sInputPath))
+ {
+ runGDCWithStatus(HTMLoutput, LISToutput, m_sInputPath, m_sOutputPath, m_sReferencePath, m_sDiffPath, "");
+ }
+ }
+
+ LISToutput.close();
+ HTMLoutput.close();
+ log.println("The file '" + HTMLoutput.getFilename() + "' shows a html based status.");
+ DB.writeHTMLFile(HTMLoutput.getFilename());
+ }
+
+
+ // -----------------------------------------------------------------------------
+ void runGDCWithStatus(HTMLOutputter _aHTMLoutput, LISTOutputter _aLISToutput, String _sInputFile, String _sOutputPath, String _sReferencePath, String _sDiffPath, String _sNewSubDir )
+ {
+ // start a fresh Office
+ GraphicalTestArguments aGTA = getGraphicalTestArguments();
+
+ OfficeProvider aProvider = null;
+ // SimpleFileSemaphore aSemaphore = new SimpleFileSemaphore();
+ if (aGTA.shouldOfficeStart())
+ {
+ // if (OSHelper.isWindows())
+ // {
+ // aSemaphore.P(aSemaphore.getSemaphoreFile());
+ // }
+
+ aGTA.getPerformance().startTime(PerformanceContainer.OfficeStart);
+ aProvider = new OfficeProvider();
+ XMultiServiceFactory xMSF = (XMultiServiceFactory) aProvider.getManager(param);
+ param.put("ServiceFactory", xMSF);
+ aGTA.getPerformance().stopTime(PerformanceContainer.OfficeStart);
+
+ long nStartTime = aGTA.getPerformance().getTime(PerformanceContainer.OfficeStart);
+ aGTA = getGraphicalTestArguments(); // get new TestArguments
+ aGTA.getPerformance().setTime(PerformanceContainer.OfficeStart, nStartTime);
+ }
+
+ // Watcher Object is need in log object to give a simple way to say if a running office is alive.
+ // As long as a log comes, it pings the Watcher and says the office is alive, if not an
+ // internal counter increase and at a given point (300 seconds) the office is killed.
+ GlobalLogWriter.get().println("Set office watcher");
+ OfficeWatcher aWatcher = (OfficeWatcher)param.get("Watcher");
+ GlobalLogWriter.get().setWatcher(aWatcher);
+ // initializeWatcher(param);
+
+ String sStatusRunThrough = "";
+ String sStatusMessage = "";
+ try
+ {
+ DB.destination_start();
+ // better was:
+ // load document
+ // create postscript from document
+ // check file
+ GraphicalDifferenceCheck.checkOneFile(_sInputFile, _sOutputPath, _sReferencePath, _sDiffPath, aGTA);
+ sStatusRunThrough = "PASSED, OK";
+ DB.destination_finished();
+ }
+ catch(ConvWatchCancelException e)
+ {
+ assure(e.getMessage(), false, true);
+ sStatusRunThrough = "CANCELLED, FAILED";
+ sStatusMessage = e.getMessage();
+ DB.destination_failed(sStatusRunThrough, sStatusMessage);
+ }
+ catch(ConvWatchException e)
+ {
+ assure(e.getMessage(), false, true);
+ sStatusMessage = e.getMessage();
+ sStatusRunThrough = "PASSED, FAILED";
+ DB.destination_failed(sStatusRunThrough, sStatusMessage);
+ }
+ catch(com.sun.star.lang.DisposedException e)
+ {
+ assure(e.getMessage(), false, true);
+ sStatusMessage = e.getMessage();
+ sStatusRunThrough = "FAILED, FAILED";
+ DB.destination_failed(sStatusRunThrough, sStatusMessage);
+ }
+
+ GlobalLogWriter.get().println("Watcher count is: " + aWatcher.getPing());
+
+ // Office shutdown
+ if (aProvider != null)
+ {
+ aProvider.closeExistingOffice(param, true);
+ // if (OSHelper.isWindows())
+ // {
+ // aSemaphore.V(aSemaphore.getSemaphoreFile());
+ // aSemaphore.sleep(2);
+ // // wait some time maybe an other process will take the semaphore
+ // // I know, this is absolutly dirty, but the whole convwatch is dirty and need a big cleanup.
+ // }
+ }
+
+ // -------------------- Status --------------------
+ String fs = System.getProperty("file.separator");
+ String sBasename = FileHelper.getBasename(_sInputFile);
+ String sFilenameNoSuffix = FileHelper.getNameNoSuffix(sBasename);
+
+ // -------------------- List of all files -----------------
+ String sListFile;
+ if (_sNewSubDir.length() > 0)
+ {
+ sListFile = _sNewSubDir + fs + sFilenameNoSuffix + ".ini";
+ }
+ else
+ {
+ sListFile = sFilenameNoSuffix + ".ini";
+ }
+ _aLISToutput.writeValue(sListFile);
+
+ // -------------------- HTML --------------------
+ String sLink;
+ String sLinkDD;
+ String sLinkName;
+ String sLinkDDName;
+ String sHTMLPrefix = aGTA.getHTMLOutputPrefix();
+
+ GlobalLogWriter.get().println("----------------------------------------------------------------------");
+ GlobalLogWriter.get().println(" OutputPath: " + _sOutputPath);
+ GlobalLogWriter.get().println(" NewPath: " + _sNewSubDir);
+ GlobalLogWriter.get().println("----------------------------------------------------------------------");
+
+// if (_sNewSubDir.length() > 0)
+// {
+// sLink = sHTMLPrefix /* + "/cw.php?inifile=" */ + _sOutputPath + fs + _sNewSubDir + fs + sFilenameNoSuffix + ".ini";
+// sLinkDD = sHTMLPrefix /* + "/cw.php?inifile=" */ + _sOutputPath + fs + _sNewSubDir + fs + "DiffDiff_" + sFilenameNoSuffix + ".ini";
+// }
+// else
+// {
+ sLink = sHTMLPrefix /* + "/cw.php?inifile=" */ + _sOutputPath + fs + sFilenameNoSuffix + ".ini";
+ // sLinkDD = sHTMLPrefix /* + "/cw.php?inifile=" */ + _sOutputPath + fs + _sNewSubDir + fs + "DiffDiff_" + sFilenameNoSuffix + ".ini";
+ sLinkDD = sHTMLPrefix /* + "/cw.php?inifile=" */ + _sOutputPath + fs + "DiffDiff_" + sFilenameNoSuffix + ".ini";
+// }
+ sLinkName = sFilenameNoSuffix;
+ sLinkDDName = sFilenameNoSuffix + " (DiffDiff)";
+
+ if (_sDiffPath != null && _sDiffPath.length() > 0)
+ {
+ _aHTMLoutput.indexLine( sLinkDD, sLinkDDName, sLink, sLinkName, sStatusRunThrough, sStatusMessage );
+ }
+ else
+ {
+ _aHTMLoutput.indexLine( sLink, sLinkName, "", "", sStatusRunThrough, sStatusMessage );
+ }
+
+ }
+
+
+}
diff --git a/qadevOOo/runner/convwatch/CrashLoopTest.java b/qadevOOo/runner/convwatch/CrashLoopTest.java
new file mode 100644
index 000000000000..6eb7b35391b8
--- /dev/null
+++ b/qadevOOo/runner/convwatch/CrashLoopTest.java
@@ -0,0 +1,57 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package convwatch;
+
+public class CrashLoopTest extends ReferenceBuilder
+{
+ // The first of the mandatory functions:
+ /**
+ * Return the name of the test.
+ * In this case it is the actual name of the service.
+ * @return The tested service.
+ */
+ public String getTestObjectName() {
+ return "CrashLoopTest runner";
+ }
+
+ // The second of the mandatory functions: return all test methods as an
+ // array. There is only one test function in this example.
+ /**
+ * Return all test methods.
+ * @return The test methods.
+ */
+ public String[] getTestMethodNames() {
+ return new String[]{"testcrashandloops"};
+ }
+
+ public void testcrashandloops()
+ {
+ buildreference();
+ }
+
+}
diff --git a/qadevOOo/runner/convwatch/DB.java b/qadevOOo/runner/convwatch/DB.java
new file mode 100644
index 000000000000..4f6ab74a738b
--- /dev/null
+++ b/qadevOOo/runner/convwatch/DB.java
@@ -0,0 +1,541 @@
+package convwatch;
+
+import java.sql.Connection;
+import java.util.StringTokenizer;
+import java.util.ArrayList;
+import helper.OSHelper;
+
+// import convwatch.DBHelper;
+
+public class DB extends DBHelper
+{
+ private static DB m_aDB = null;
+
+ // private ctor
+ private DB()
+ {
+ }
+
+ private static synchronized DB getDB()
+ {
+ if (m_aDB == null)
+ {
+ m_aDB = new DB();
+ }
+ return m_aDB;
+ }
+
+ private String m_sSourceVersion;
+ private String m_sDestinationVersion;
+ private String m_sDocumentPool;
+ private String m_sEnvironment;
+ private String m_sDocID;
+ private String m_sDBDistinct;
+
+ public static void init(String _sDBInfoString)
+ {
+ if (_sDBInfoString == null) return;
+ getDB().fillVariables(_sDBInfoString);
+ getDB().updatestate_status("source started");
+ }
+
+ public static void test()
+ {
+ getDB().sql_test();
+ }
+
+ public static void source_start()
+ {
+ getDB().updatestate_status("source started");
+ }
+
+ public static void source_finished()
+ {
+ getDB().updatestate_status( "source finished");
+ }
+
+ public static void source_failed(String _sMessage)
+ {
+ getDB().updatestate_status("source failed");
+ getDB().updateinfo_status(_sMessage);
+ }
+
+ public static void destination_start()
+ {
+ getDB().updatestate_status("destination started");
+ }
+
+ public static void destination_finished()
+ {
+ getDB().updatestate_status("PASSED-OK");
+ }
+
+ public static void destination_failed(String _sStatus, String _sMessage)
+ {
+ getDB().updatestate_status(_sStatus);
+ getDB().updateinfo_status(_sMessage);
+ }
+ public static void writeNumberOfPages(int _nPages)
+ {
+ getDB().updatepagecount_documents(_nPages);
+ }
+ public static void writeErrorFile(String _sErrorFile)
+ {
+ getDB().updateerrorfile_status(_sErrorFile);
+ }
+ public static void writeHTMLFile(String _sHTMLFile)
+ {
+ getDB().updatehtmlfile_status(_sHTMLFile);
+ }
+
+ public static void writeToDB(String _sFilename,
+ String _sBasename,
+ String _sFileFormat,
+ String _sBuildID,
+ String _sSourceType,
+ int _nResolution )
+ {
+ GlobalLogWriter.get().println("DB: Filename:" + _sFilename);
+ GlobalLogWriter.get().println("DB: Basename:" + _sBasename);
+ GlobalLogWriter.get().println("DB: FileFormat:" + _sFileFormat);
+ GlobalLogWriter.get().println("DB: BuildID:" + _sBuildID);
+ GlobalLogWriter.get().println("DB: SourceType:" + _sSourceType);
+ GlobalLogWriter.get().println("DB: Resolution:" + _nResolution);
+ }
+
+ private String getEnvironment()
+ {
+ if (OSHelper.isWindows())
+ {
+ return "wntmsci";
+ }
+ else if ( OSHelper.isSolarisIntel())
+ {
+ return "unxsoli";
+ }
+ else if ( OSHelper.isSolarisSparc())
+ {
+ return "unxsols";
+ }
+ else if ( OSHelper.isLinuxIntel())
+ {
+ return "unxlngi";
+ }
+ else
+ {
+ GlobalLogWriter.get().println("DB: Unknown environment.");
+ GlobalLogWriter.get().println("DB: os.name := " + System.getProperty("os.name").toLowerCase());
+ GlobalLogWriter.get().println("DB: os.arch := " + System.getProperty("os.arch"));
+ return "";
+ }
+ }
+
+ // fill some db access important variables with values given out of a simple string
+ // DOC_COMPARATOR_DB_INFO_STRING=p:m220,c:m224,d:demo_lla,src:m220,dest:m224,doc:demo_lla,id:294,distinct:81
+
+ private void fillVariables(String _sInfo)
+ {
+ fillDBConnection(_sInfo);
+ m_sEnvironment = getEnvironment();
+
+ StringTokenizer aTokenizer = new StringTokenizer(_sInfo,",",false);
+ while (aTokenizer.hasMoreTokens())
+ {
+ String sPart = aTokenizer.nextToken();
+ if (sPart.startsWith("p:"))
+ {
+ m_sSourceVersion = sPart.substring(2);
+ GlobalLogWriter.get().println("DB: source version: " + m_sSourceVersion);
+ }
+ else if (sPart.startsWith("src:"))
+ {
+ m_sSourceVersion = sPart.substring(4);
+ GlobalLogWriter.get().println("DB: source version: " + m_sSourceVersion);
+ }
+ else if (sPart.startsWith("c:"))
+ {
+ m_sDestinationVersion = sPart.substring(2);
+ GlobalLogWriter.get().println("DB: destination version: " + m_sDestinationVersion);
+ }
+ else if (sPart.startsWith("dest:"))
+ {
+ m_sDestinationVersion = sPart.substring(5);
+ GlobalLogWriter.get().println("DB: destination version: " + m_sDestinationVersion);
+ }
+ else if (sPart.startsWith("d:"))
+ {
+ m_sDocumentPool = sPart.substring(2);
+ GlobalLogWriter.get().println("DB: documentpool version: " + m_sDocumentPool);
+ }
+ else if (sPart.startsWith("doc:"))
+ {
+ m_sDocumentPool = sPart.substring(4);
+ GlobalLogWriter.get().println("DB: documentpool version: " + m_sDocumentPool);
+ }
+ else if (sPart.startsWith("id:"))
+ {
+ m_sDocID = sPart.substring(3);
+ GlobalLogWriter.get().println("DB: docid: " + m_sDocID);
+ }
+ else if (sPart.startsWith("distinct:"))
+ {
+ m_sDBDistinct = sPart.substring(9);
+ GlobalLogWriter.get().println("DB: distinct: " + m_sDBDistinct);
+ }
+ else
+ {
+ }
+ }
+ }
+
+ // public static void insertinto_file(String _sFilename,
+ // String _sBasename,
+ // String _sFileFormat,
+ // String _sBuildID,
+ // String _sSourceType,
+ // int _nResolution )
+ // {
+ // Connection aCon = new ShareConnection().getConnection();
+ //
+ // String sFilename = _sFilename.replace('\\', '/');
+ //
+ // String sDeleteOld = "DELETE FROM file WHERE filename = " + Quote(sFilename);
+ // ExecSQL(aCon, sDeleteOld);
+ //
+ // String sValueLine = "type, filename, basename, fileformat, buildid, resolution, date";
+ // StringBuffer aDataLine = new StringBuffer();
+ // aDataLine.append( Quote(_sSourceType) ) . append( sComma ) .
+ // append( Quote( sFilename) ) . append( sComma ) .
+ // append( Quote( _sBasename) ) . append( sComma ) .
+ // append( Quote( _sFileFormat) ) . append( sComma ) .
+ // append( Quote( _sBuildID) ) . append( sComma ) .
+ // append( _nResolution) . append( sComma ) .
+ // append( Quote( today() ) );
+ //
+ // SQLinsertValues(aCon, "file", sValueLine, aDataLine.toString());
+ // }
+
+ // public static void updatestate_currentdocs(String _sFilename,
+ // String _sState)
+ // {
+ // Connection aCon = new ShareConnection().getConnection();
+ //
+ // String sFilename = _sFilename.replace('\\', '/');
+ //
+ // // String sDeleteOld = "DELETE FROM file WHERE filename = " + Quote(sFilename);
+ // // ExecSQL(aCon, sDeleteOld);
+ //
+ // String sSet = "state=" + Quote(_sState);
+ // String sWhere = getWhereClause() + sAND + "name=" + Quote(sFilename);
+ // SQLupdateValue( aCon, "currentdocs", sSet, sWhere );
+ // }
+
+ private void sql_test()
+ {
+ String sUUID = getDBDistinct();
+ System.out.println("UUID: " + sUUID);
+ }
+
+ public ArrayList QuerySQL(Connection _aCon, String _sSQL)
+ {
+ java.sql.Statement oStmt = null;
+ Connection oCon = null;
+ ArrayList aResultList = new ArrayList();
+ try
+ {
+ oStmt = _aCon.createStatement();
+
+ java.sql.ResultSet aResultSet = oStmt.executeQuery(_sSQL);
+ java.sql.ResultSetMetaData aResultSetMetaData = aResultSet.getMetaData();
+
+ int nColumnCount = aResultSetMetaData.getColumnCount(); // java sql starts with '1'
+ // String[] aColumnName = new String[nColumnCount];
+ // for(int i=1;i<nColumnCount;i++)
+ // {
+ // String aColumnName[i - 1] = aResultSetMetaData.getColumnName(i);
+ // }
+
+ while( aResultSet.next() )
+ {
+ StringBuffer aResult = new StringBuffer();
+ try
+ {
+ Object aObj = null;
+
+
+ aResult.append("sqlresult: ");
+ for (int i=1;i<=nColumnCount;i++)
+ {
+ String sColumnName = aResultSetMetaData.getColumnName(i);
+ aResult.append(sColumnName).append("=");
+ String sValue;
+ int nSQLType = aResultSetMetaData.getColumnType(i);
+ switch(nSQLType)
+ {
+ case java.sql.Types.VARCHAR:
+ sValue = "'" + aResultSet.getString(i) + "'";
+ break;
+ case java.sql.Types.INTEGER:
+ {
+ int nValue = aResultSet.getInt(i);
+ sValue = String.valueOf(nValue);
+ break;
+ }
+
+ default:
+ sValue = "UNSUPPORTED TYPE";
+ }
+ aResult.append(sValue).append(", ");
+ // String sName = aObj.getClass().getName();
+ // System.out.println("sqlresult: Class name: " + sName);
+ }
+ String sResult = aResult.toString();
+ aResultList.add(sResult);
+ // System.out.println(sResult);
+ }
+ catch (java.sql.SQLException e)
+ {
+ }
+ }
+ }
+ catch (java.sql.SQLException e)
+ {
+ String sError = e.getMessage();
+ GlobalLogWriter.get().println("DB: Original SQL error: " + sError);
+ // throw new ValueNotFoundException("Cant execute SQL: " + _sSQL);
+ }
+ return aResultList;
+ }
+
+ private void updatestate_status(String _sStatus)
+ {
+ Connection aCon = new ShareConnection().getConnection();
+
+ // String sInfo = _sInfo.replace('\\', '/');
+
+ // String sDeleteOld = "DELETE FROM file WHERE filename = " + Quote(sFilename);
+ // ExecSQL(aCon, sDeleteOld);
+
+ String sSet = "state=" + Quote(_sStatus);
+ String sWhere = getWhereClause();
+ if (sWhere.length() > 0)
+ {
+ SQLupdateValue( aCon, "status", sSet, sWhere );
+ }
+ }
+ private void updateinfo_status(String _sInfo)
+ {
+ Connection aCon = new ShareConnection().getConnection();
+
+ // String sInfo = _sInfo.replace('\\', '/');
+
+ // String sDeleteOld = "DELETE FROM file WHERE filename = " + Quote(sFilename);
+ // ExecSQL(aCon, sDeleteOld);
+
+ String sSet = "info=" + Quote(_sInfo);
+ String sWhere = getWhereClause();
+ SQLupdateValue( aCon, "status", sSet, sWhere );
+ }
+ private void updateerrorfile_status(String _sErrorFile)
+ {
+ Connection aCon = new ShareConnection().getConnection();
+
+ String sErrorFile = _sErrorFile.replace('\\', '/');
+
+ String sSet = "errorfile=" + Quote(sErrorFile);
+ String sWhere = getWhereClause();
+ SQLupdateValue( aCon, "status", sSet, sWhere );
+ }
+ private void updatehtmlfile_status(String _sHtmlFile)
+ {
+ Connection aCon = new ShareConnection().getConnection();
+
+ String sHtmlFile = _sHtmlFile.replace('\\', '/');
+
+ String sSet = "htmlfile=" + Quote(sHtmlFile);
+ String sWhere = getWhereClause();
+ SQLupdateValue( aCon, "status", sSet, sWhere );
+ }
+ private void updatepagecount_documents(int _nPageCount)
+ {
+ Connection aCon = new ShareConnection().getConnection();
+
+ String sSet = "pagecount=" + _nPageCount;
+ String sWhere = getWhereClause();
+ SQLupdateValue( aCon, "documents", sSet, sWhere );
+
+ }
+
+
+ private String getWhereClause()
+ {
+ StringBuffer aWhereClause = new StringBuffer();
+ // WHERE environment='' and referenceversion='' and currentversion='' and documentpool=''
+ // aWhere.append( "environment" ). append(sEqual) . append(Quote(m_sEnvironment)) .
+ // append(sAND) .
+ // append( "referenceversion" ). append(sEqual) . append(Quote(m_sSourceVersion)) .
+ // append(sAND) .
+ // append( "currentversion" ). append(sEqual) . append(Quote(m_sDestinationVersion)) .
+ // append(sAND) .
+ // append( "documentpool" ). append(sEqual) . append(Quote(m_sDocumentPool));
+ boolean bAND = false;
+ if (m_sDocID != null)
+ {
+ aWhereClause.append( "docid" ). append(sEqual) . append(m_sDocID);
+ bAND = true;
+ }
+ if (bAND)
+ {
+ aWhereClause.append(sAND);
+ }
+ if (m_sDBDistinct != null)
+ {
+ aWhereClause.append( "dbdistinct2" ). append(sEqual) . append(Quote(m_sDBDistinct));
+ }
+ return aWhereClause.toString();
+ }
+
+ private String getDBDistinct()
+ {
+ Connection aCon = new ShareConnection().getConnection();
+
+ String sSQL = "SELECT uuid()";
+ ArrayList aResultList = QuerySQL(aCon, sSQL);
+
+ for (int i=0;i<aResultList.size();i++)
+ {
+ String sResult = (String)aResultList.get(i);
+
+ StringTokenizer aTokenizer = new StringTokenizer(sResult,",",false);
+ while (aTokenizer.hasMoreTokens())
+ {
+ String sToken = aTokenizer.nextToken();
+ // System.out.println("PART: " + sToken);
+ int nIndex = sToken.indexOf("uuid()=");
+ // System.out.println("Index " + nIndex);
+ int nIndexTuettel = sToken.indexOf("'", nIndex);
+ // System.out.println("IndexTuettel " + nIndexTuettel);
+ int nIndexTuettel2 = sToken.lastIndexOf("'");
+ // System.out.println("IndexTuettel2 " + nIndexTuettel2);
+ String sUuid = sToken.substring(nIndexTuettel + 1, nIndexTuettel2);
+ // if (sPart.startsWith("p:"))
+ // {
+ // m_sSourceVersion = sPart.substring(2);
+ // GlobalLogWriter.get().println("DB: source version: " + m_sSourceVersion);
+ // }
+ return sUuid;
+ }
+ // System.out.println(sResult);
+ }
+
+ return "0";
+ }
+
+ public static void insertinto_documentcompare(String _sSourceVersion, String _sSourceName, String _sSourceCreatorType,
+ String _sDestinationVersion, String _sDestinationName, String _sDestinationCreatorType,
+ String _sDocumentPoolDir, String _sDocumentPoolName, String _sMailAddress,
+ String _sSpecial, String _sParentDistinct)
+ {
+ getDB().insertinto_documentcompare_impl( _sSourceVersion, _sSourceName, _sSourceCreatorType,
+ _sDestinationVersion, _sDestinationName, _sDestinationCreatorType,
+ _sDocumentPoolDir, _sDocumentPoolName, _sMailAddress,
+ _sSpecial, _sParentDistinct);
+ }
+
+ private void insertinto_documentcompare_impl(String _sSourceVersion, String _sSourceName, String _sSourceCreatorType,
+ String _sDestinationVersion, String _sDestinationName, String _sDestinationCreatorType,
+ String _sDocumentPoolDir, String _sDocumentPoolName, String _sMailAddress,
+ String _sSpecial, String _sParentDistinct)
+ {
+ // $sSQLInsert = "INSERT INTO documentcompare
+ if (_sParentDistinct == null)
+ {
+ _sParentDistinct = "";
+ }
+
+ Connection aCon = new ShareConnection().getConnection();
+
+ String sValueLine="dbdistinct2, environment, sourceversion, sourcename, sourcecreatortype, destinationversion, destinationname, destinationcreatortype, documentpoolpath, documentpool, mailfeedback, state, special, parentdistinct, startdate";
+ String sDocumentPoolDir = _sDocumentPoolDir.replace('\\', '/');
+ StringBuffer aDataLine = new StringBuffer();
+ aDataLine.append( Quote(getDBDistinct()) ) . append( sComma ) .
+ append( Quote( getEnvironment()) ) . append( sComma ) .
+ append( Quote( _sSourceVersion) ) . append( sComma ) .
+ append( Quote( _sSourceName) ) . append( sComma ) .
+ append( Quote( _sSourceCreatorType ) ) . append( sComma ) .
+ append( Quote( _sDestinationVersion) ) . append( sComma ) .
+ append( Quote( _sDestinationName) ) . append( sComma ) .
+ append( Quote( _sDestinationCreatorType ) ) . append( sComma ) .
+ append( Quote( sDocumentPoolDir) ) . append( sComma ) .
+ append( Quote( _sDocumentPoolName) ) . append( sComma ) .
+ append( Quote( _sMailAddress) ) . append( sComma ) .
+ append( Quote( "new" )) . append ( sComma ) .
+ append( Quote( _sSpecial ) ) . append( sComma ) .
+ append( Quote( _sParentDistinct ) ) . append( sComma ) .
+ append( Quote( today() ));
+
+ SQLinsertValues(aCon, "documentcompare", sValueLine, aDataLine.toString());
+ }
+
+ // public static void filesRemove(String _sDBInfoString)
+ // {
+ // if (_sDBInfoString == null) return;
+ // fillVariables(_sDBInfoString);
+ //
+ // Connection aCon = new ShareConnection().getConnection();
+ //
+ // String sDeleteSQL = "DELETE FROM currentdocs WHERE " + getWhereClause();
+ //
+ // ExecSQL(aCon, sDeleteSQL);
+ // }
+ //
+ // public static void fileInsert(String _sDBInfoString,
+ // String _sFilename,
+ // String _sRemovePath)
+ // {
+ // if (_sDBInfoString == null) return;
+ // fillVariables(_sDBInfoString);
+ //
+ // String sFilename = _sFilename.replace('\\', '/');
+ //
+ // Connection aCon = new ShareConnection().getConnection();
+ //
+ // String sValueLine = "environment, referenceversion, currentversion, documentpool, name, state";
+ // StringBuffer aDataLine = new StringBuffer();
+ // aDataLine.append( Quote(m_sEnvironment) ) . append( sComma ) .
+ // append( Quote( m_sSourceVersion) ) . append( sComma ) .
+ // append( Quote( m_sDestinationVersion) ) . append( sComma ) .
+ // append( Quote( m_sDocumentPool) ) . append( sComma ) .
+ // append( Quote( sFilename) ) . append( sComma ) .
+ // append( Quote( "undone"));
+ //
+ // SQLinsertValues(aCon, "currentdocs", sValueLine, aDataLine.toString());
+ // }
+
+
+ // public static void insertinto_file(String _sFilename, String _sFileFormat, String _sBuildID)
+ // {
+ // Connection aCon = new ShareConnection().getConnection();
+ //
+ // String sValueLine = "type, filename, fileformat, buildid, date";
+ // StringBuffer aDataLine = new StringBuffer();
+ // aDataLine.append( "1" ) . append( sComma ) .
+ // append( Quote( _sFilename) ) . append( sComma ) .
+ // append( Quote( _sFileFormat) ) . append( sComma ) .
+ // append( Quote( _sBuildID) ) . append( sComma ) .
+ // append( Quote( today() ) );
+ //
+ // SQLinsertValues(aCon, "file", sValueLine, aDataLine.toString());
+ // }
+
+ // public static void main( String[] args )
+ // {
+ //
+ // String _sFilename = "";
+ // String _sFileFormat = "";
+ // String _sBuildID = "";
+ //
+ // // insertinto_file("c:\temp\test.txt", "test", "txt", "nix", "", 0);
+ // fillVariables("p:m128,c:m134,d:demo");
+ // }
+}
diff --git a/qadevOOo/runner/convwatch/DBHelper.java b/qadevOOo/runner/convwatch/DBHelper.java
new file mode 100644
index 000000000000..e28fafb65ec4
--- /dev/null
+++ b/qadevOOo/runner/convwatch/DBHelper.java
@@ -0,0 +1,316 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package convwatch;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.Statement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+import java.lang.Thread;
+import java.util.StringTokenizer;
+
+class ShareConnection
+{
+ private Connection m_aConnection = null;
+ public ShareConnection()
+ {}
+
+ public Connection getConnection()
+ {
+ if (m_aConnection == null)
+ {
+ try
+ {
+ m_aConnection = DBHelper.getMySQLConnection();
+ }
+ catch(java.sql.SQLException e)
+ {
+ GlobalLogWriter.get().println("DB: ERROR: can't connect to DB.");
+ m_aConnection = null;
+ }
+ }
+ return m_aConnection;
+ }
+}
+
+ class MySQLThread extends Thread
+ {
+ Connection m_aCon = null;
+ String m_sSQL;
+ public MySQLThread(Connection _aCon, String _sSQL)
+ {
+ m_aCon = _aCon;
+ m_sSQL = _sSQL;
+ }
+
+ public void run()
+ {
+ Statement oStmt = null;
+ if (m_aCon == null)
+ {
+ GlobalLogWriter.get().println("DB: ERROR: in ExecSQL, connection not established.");
+ return;
+ }
+
+ // Connection oCon = null;
+ try
+ {
+ // oCon = getMySQLConnection();
+ oStmt = m_aCon.createStatement();
+
+ GlobalLogWriter.get().println("DB: " + m_sSQL);
+ /* ResultSet oResult = */
+ oStmt.executeUpdate(m_sSQL);
+ }
+ catch(Exception e)
+ {
+ GlobalLogWriter.get().println("DB: Couldn't execute sql string '" + m_sSQL + "'");
+ GlobalLogWriter.get().println("DB: Reason: " + e.getMessage());
+ }
+ }
+ }
+
+public class DBHelper
+{
+ /**
+ * This method inserts given values into<br>
+ * the table 'states'
+ * @param values a set of comma separated values to be inserted
+ */
+
+ public void SQLinsertValues(Connection _aCon, String _sTableName, String value_names, String values)
+ {
+ if (_aCon == null)
+ {
+ GlobalLogWriter.get().println("DB: ERROR: in SQLinsertValues, connection not established.");
+ return;
+ }
+
+ // String aInsertStr = "";
+ //
+ // aInsertStr = "INSERT INTO " + _sTableName + " (" + value_names + " ) VALUES (" + values + ")";
+ // ExecSQL(_aCon, aInsertStr);
+ StringBuffer aInsertStr = new StringBuffer();
+
+ aInsertStr.append( "INSERT INTO " ) . append( _sTableName );
+ aInsertStr.append( " (").append( value_names ).append ( ")" );
+ aInsertStr.append(" VALUES (" ).append( values ).append( ")" );
+ ExecSQL(_aCon, aInsertStr.toString() );
+ }
+
+ public void SQLupdateValue(Connection _aCon, String _sTableName, String _sSet, String _sWhere)
+ {
+ if (_aCon == null)
+ {
+ GlobalLogWriter.get().println("DB: ERROR: in SQLinsertValues, connection not established.");
+ return;
+ }
+
+ // String aUpdateStr = "";
+ //
+ // aUpdateStr = "UPDATE " + _sTableName + " SET " + _sSet + " WHERE " + _sWhere;
+ // ExecSQL( _aCon, aUpdateStr );
+ StringBuffer aUpdateStr = new StringBuffer();
+
+ aUpdateStr.append( "UPDATE " ).append( _sTableName )
+ .append( " SET " ).append( _sSet )
+ .append( " WHERE " ).append( _sWhere );
+ ExecSQL( _aCon, aUpdateStr.toString() );
+ }
+
+ private static String m_sDBServerName;
+ private static String m_sDBName;
+ private static String m_sDBUser;
+ private static String m_sDBPasswd;
+
+ protected synchronized void fillDBConnection(String _sInfo)
+ {
+ StringTokenizer aTokenizer = new StringTokenizer(_sInfo,",",false);
+ while (aTokenizer.hasMoreTokens())
+ {
+ String sPart = aTokenizer.nextToken();
+ if (sPart.startsWith("db:"))
+ {
+ m_sDBName = sPart.substring(3);
+ // GlobalLogWriter.get().println("DB: source version: " + m_sSourceVersion);
+ }
+ else if (sPart.startsWith("user:"))
+ {
+ m_sDBUser = sPart.substring(5);
+ }
+ else if (sPart.startsWith("passwd:"))
+ {
+ m_sDBPasswd = sPart.substring(7);
+ }
+ else if (sPart.startsWith("server:"))
+ {
+ m_sDBServerName = sPart.substring(7);
+ }
+ }
+ }
+
+ /**
+ * This method establishes a Connection<br>
+ * with the database 'module_unit' on jakobus
+ */
+
+ public static Connection getMySQLConnection() throws SQLException
+ {
+ try
+ {
+ Class.forName("org.gjt.mm.mysql.Driver");
+ String sConnection = "jdbc:mysql://" + m_sDBServerName + ":3306/" + m_sDBName;
+ // Connection mysql = DriverManager.getConnection(
+ // "jdbc:mysql://jakobus:3306/jobs_convwatch","admin","admin");
+ Connection mysql = DriverManager.getConnection(sConnection, m_sDBUser, m_sDBPasswd);
+ return mysql;
+ }
+ catch (ClassNotFoundException e)
+ {
+ GlobalLogWriter.get().println("DB: Class not found exception caught: " + e.getMessage());
+ GlobalLogWriter.get().println("DB: Maybe mysql.jar is not added to the classpath.");
+ }
+ return null;
+ }
+
+
+ /**
+ * This method removes all entries of the given<br>
+ * module/platform combination
+ * @param mdl the name of the module, e.g. sal
+ * @param os the name of the platform, e.g. unxsols
+ */
+ // LLA: public static void SQLdeleteValues(Connection _aCon, String _sEnvironment, String _sUnitName, String _sMethodName, String _sCWS, String _sDate)
+ // LLA: {
+ // LLA: String sSQL =
+ // LLA: "DELETE FROM states WHERE " +
+ // LLA: " unit=" + DatabaseEntry.Quote(_sUnitName) +
+ // LLA: " AND pf=" + DatabaseEntry.Quote (_sEnvironment) +
+ // LLA: " AND meth=" + DatabaseEntry.Quote (_sMethodName) +
+ // LLA: " AND cws=" + DatabaseEntry.Quote(_sCWS) +
+ // LLA: " AND dt=" + DatabaseEntry.Quote(_sDate);
+ // LLA:
+ // LLA: // ExecSQL(_aCon, sSQL);
+ // LLA: }
+
+ protected synchronized void ExecSQL(Connection _aCon, String _sSQL)
+ {
+ MySQLThread aSQLThread = new MySQLThread(_aCon, _sSQL);
+ aSQLThread.start();
+ }
+
+
+
+ // public static int QueryIntFromSQL(String _sSQL, String _sColumnName, String _sValue)
+ // {
+ // boolean bNeedSecondTry = false;
+ // int nValue = 0;
+ // do
+ // {
+ // try
+ // {
+ // nValue = QueryIntFromSQL(_sSQL, _sColumnName, _sValue);
+ // }
+ // catch (ValueNotFoundException e)
+ // {
+ // bNeedSecondTry = true;
+ // String sSQL = "INSERT INTO " + _sTable + "(" + _sColumnName + ") VALUES (" + _sValue + ")";
+ // ExecSQL(sSQL);
+ // }
+ // } while (bNeedSecondTry);
+ // return nValue;
+ // }
+
+ public int QueryIntFromSQL(Connection _aCon, String _sSQL, String _sColumnName)
+ throws ValueNotFoundException
+ {
+ Statement oStmt = null;
+ Connection oCon = null;
+ int nValue = 0;
+ try
+ {
+ // oCon = getMySQLConnection();
+ oStmt = _aCon.createStatement();
+
+ ResultSet oResult = oStmt.executeQuery(_sSQL);
+ oResult.next();
+
+ try
+ {
+ if (_sColumnName.length() == 0)
+ {
+ // take the first row value (started with 1)
+ nValue = oResult.getInt(1);
+ }
+ else
+ {
+ nValue = oResult.getInt(_sColumnName);
+ }
+ // System.out.println("value: " + String.valueOf(nValue));
+ }
+ catch (SQLException e)
+ {
+ String sError = e.getMessage();
+ GlobalLogWriter.get().println("DB: Original SQL error: " + sError);
+ throw new ValueNotFoundException("Cant execute SQL: " + _sSQL);
+ }
+ }
+ catch(SQLException e)
+ {
+ String sError = e.getMessage();
+ GlobalLogWriter.get().println("DB: Couldn't execute sql string " + _sSQL + "\n" + sError);
+ }
+ return nValue;
+ }
+
+ public String Quote(String _sToQuote)
+ {
+ String ts = "'";
+ String ds = "\"";
+ int nQuote = _sToQuote.indexOf(ts);
+ if (nQuote >= 0)
+ {
+ return ds + _sToQuote + ds;
+ }
+ return ts + _sToQuote + ts;
+ }
+
+/* default date format in the MySQL DB yyyy-MM-dd */
+ public static String today()
+ {
+ return DateHelper.getDateString("yyyy-MM-dd");
+ }
+
+ public static final String sComma = ",";
+ public static final String sEqual = "=";
+ public static final String sAND = " AND ";
+
+}
+
diff --git a/qadevOOo/runner/convwatch/DateHelper.java b/qadevOOo/runner/convwatch/DateHelper.java
new file mode 100755
index 000000000000..59207ea3ee3a
--- /dev/null
+++ b/qadevOOo/runner/convwatch/DateHelper.java
@@ -0,0 +1,58 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package convwatch;
+
+import java.text.SimpleDateFormat;
+import java.util.GregorianCalendar;
+import java.text.FieldPosition;
+import java.util.Locale;
+
+public class DateHelper
+{
+ public static String getDateTimeForFilename()
+ {
+ return getDateString("yyyyMMdd-HHmmss");
+ }
+
+ public static String getDateTimeForHumanreadableLog()
+ {
+ return getDateString("[yyyy/MM/dd hh:mm:ss]");
+ }
+
+ public static String getDateString(String _sFormat)
+ {
+ GregorianCalendar aCalendar = new GregorianCalendar();
+ StringBuffer aBuf = new StringBuffer();
+
+ Locale aLocale = new Locale("en","US");
+ SimpleDateFormat aFormat = new SimpleDateFormat(_sFormat, aLocale);
+ aBuf = aFormat.format(aCalendar.getTime(), aBuf, new FieldPosition(0) );
+ // DebugHelper.writeInfo("Date: " + aBuf.toString());
+ return aBuf.toString();
+ }
+}
diff --git a/qadevOOo/runner/convwatch/DirectoryHelper.java b/qadevOOo/runner/convwatch/DirectoryHelper.java
new file mode 100644
index 000000000000..a15d790b9c25
--- /dev/null
+++ b/qadevOOo/runner/convwatch/DirectoryHelper.java
@@ -0,0 +1,156 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package convwatch;
+
+import java.io.File;
+import java.io.FileFilter;
+import java.util.ArrayList;
+
+/**
+ * Helper for directory access
+ *
+ * @author Lars.Langhans@sun.com
+ */
+public class DirectoryHelper
+{
+ ArrayList m_aFileList = new ArrayList();
+ boolean m_bRecursiveIsAllowed = true;
+
+ void setRecursiveIsAllowed(boolean _bValue)
+ {
+ m_bRecursiveIsAllowed = _bValue;
+ }
+
+ /**
+ * Traverse over a given directory, and filter with a given FileFilter
+ * object and gives back the deep directory as a Object[] list, which
+ * contain a String object for every directory entry.
+ *
+ * <B>Example</B>
+ * List directory /bin, filter out all files which ends with '.prn'
+ *
+ * FileFilter aFileFilter = new FileFilter()
+ * {
+ * public boolean accept( File pathname )
+ * {
+ * if (pathname.getName().endsWith(".prn"))
+ * {
+ * return false;
+ * }
+ * return true;
+ * }
+ * };
+ *
+ * Object[] aList = DirectoryHelper.traverse("/bin", aFileFilter);
+ * for (int i=0;i<aList.length;i++)
+ * {
+ * String aEntry = (String)aList[i];
+ * System.out.println(aEntry);
+ * }
+ *
+ */
+ public static Object[] traverse( String _sDirectory, FileFilter _aFileFilter, boolean _bRecursiveIsAllowed )
+ {
+ DirectoryHelper a = new DirectoryHelper();
+ a.setRecursiveIsAllowed(_bRecursiveIsAllowed);
+ a.traverse_impl(_sDirectory, _aFileFilter);
+ return a.m_aFileList.toArray();
+ }
+
+ public static Object[] traverse( String _sDirectory, boolean _bRecursiveIsAllowed )
+ {
+ DirectoryHelper a = new DirectoryHelper();
+ a.setRecursiveIsAllowed(_bRecursiveIsAllowed);
+ a.traverse_impl(_sDirectory, null);
+ return a.m_aFileList.toArray();
+ }
+
+ void traverse_impl( String afileDirectory, FileFilter _aFileFilter )
+ {
+ File fileDirectory = new File(afileDirectory);
+ // Testing, if the file is a directory, and if so, it throws an exception
+ if ( !fileDirectory.isDirectory() )
+ {
+ throw new IllegalArgumentException( "not a directory: " + fileDirectory.getName() );
+ }
+
+ // Getting all files and directories in the current directory
+ File[] aDirEntries;
+ if (_aFileFilter != null)
+ {
+ aDirEntries = fileDirectory.listFiles(_aFileFilter);
+ }
+ else
+ {
+ aDirEntries = fileDirectory.listFiles();
+ }
+
+ // Iterating for each file and directory
+ for ( int i = 0; i < aDirEntries.length; ++i )
+ {
+ if ( aDirEntries[ i ].isDirectory() )
+ {
+ if (m_bRecursiveIsAllowed == true)
+ {
+ // Recursive call for the new directory
+ traverse_impl( aDirEntries[ i ].getAbsolutePath(), _aFileFilter );
+ }
+ }
+ else
+ {
+ // adding file to List
+ try
+ {
+ // Composing the URL by replacing all backslashs
+ // String stringUrl = "file:///" + aFileEntries[ i ].getAbsolutePath().replace( '\\', '/' );
+ String aStr = aDirEntries[ i ].getAbsolutePath();
+ m_aFileList.add(aStr);
+ }
+ catch( Exception exception )
+ {
+ exception.printStackTrace();
+ break;
+ }
+ }
+ }
+ }
+
+ // tests
+ // public static void main(String[] args)
+ // {
+ // String sDirectory = "/misc/convwatch/gfxcmp/data/doc-pool/demo";
+ // Object[] aDirectoryList = DirectoryHelper.traverse( sDirectory, false );
+ //
+ // for (int i=0;i<aDirectoryList.length;i++)
+ // {
+ // String sEntry = (String)aDirectoryList[i];
+ // System.out.println(sEntry);
+ // }
+ // }
+}
+
diff --git a/qadevOOo/runner/convwatch/DocumentConverter.java b/qadevOOo/runner/convwatch/DocumentConverter.java
new file mode 100644
index 000000000000..f6583dd5fdbc
--- /dev/null
+++ b/qadevOOo/runner/convwatch/DocumentConverter.java
@@ -0,0 +1,277 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package convwatch;
+
+// imports
+import java.io.File;
+import java.io.FileFilter;
+import java.util.ArrayList;
+
+import com.sun.star.lang.XMultiServiceFactory;
+
+import convwatch.DirectoryHelper;
+import convwatch.OfficePrint;
+import convwatch.ConvWatchException;
+import convwatch.EnhancedComplexTestCase;
+import convwatch.PropertyName;
+import helper.OfficeProvider;
+
+/**
+ * The following Complex Test will test
+ * an already created document and it's postscript output (by an older office version)
+ * with a new office version.
+ * This test use Ghostscript for the jpeg export and graphically compare tools from ImageMagick.
+ * Read the manual for more information.
+ *
+ * this is only the starter program
+ * more is found in qadevOOo/runner/convwatch/*
+ */
+
+public class DocumentConverter extends EnhancedComplexTestCase
+{
+ // The first of the mandatory functions:
+ /**
+ * Return the name of the test.
+ * In this case it is the actual name of the service.
+ * @return The tested service.
+ */
+ public String getTestObjectName() {
+ return "DocumentConverter runner";
+ }
+
+ // The second of the mandatory functions: return all test methods as an
+ // array. There is only one test function in this example.
+ /**
+ * Return all test methods.
+ * @return The test methods.
+ */
+ public String[] getTestMethodNames() {
+ return new String[]{"convert"};
+ }
+
+ // This test is fairly simple, so there is no need for before() or after()
+ // methods.
+
+ public void before()
+ {
+ // System.out.println("before()");
+ }
+
+ public void after()
+ {
+ // System.out.println("after()");
+ }
+
+ // The test method itself.
+ private String m_sInputPath = "";
+ private String m_sReferencePath = "";
+ private boolean m_bIncludeSubdirectories = true;
+
+ void initMember()
+ {
+ // MUST PARAMETER
+ // INPUT_PATH ----------
+ String sINPATH = (String)param.get( PropertyName.DOC_COMPARATOR_INPUT_PATH );
+ boolean bQuit = false;
+ String sError = "";
+ if (sINPATH == null || sINPATH.length() == 0)
+ {
+ log.println("Please set input path (path to documents) " + PropertyName.DOC_COMPARATOR_INPUT_PATH + "=path.");
+ bQuit = true;
+ }
+ else
+ {
+ log.println("found " + PropertyName.DOC_COMPARATOR_INPUT_PATH + " " + sINPATH);
+ m_sInputPath = sINPATH;
+ }
+
+ // REFERENCE_PATH ----------
+ String sREF = (String)param.get( PropertyName.DOC_COMPARATOR_REFERENCE_PATH );
+ if (sREF == null || sREF.length() == 0)
+ {
+ log.println("Please set output path (path to a directory, where the references should stay) " + PropertyName.DOC_COMPARATOR_REFERENCE_PATH + "=path.");
+ bQuit = true;
+ }
+ else
+ {
+ log.println("found " + PropertyName.DOC_COMPARATOR_REFERENCE_PATH + " " + sREF);
+ m_sReferencePath = sREF;
+ }
+
+ if (bQuit == true)
+ {
+ // log.println("must quit.");
+ assure("Must quit, Parameter problems.", false);
+ }
+
+ if (m_sInputPath.startsWith("file:") ||
+ m_sReferencePath.startsWith("file:"))
+ {
+ assure("We can't handle file: URL right, use system path instead.", false);
+ }
+
+ }
+
+ /**
+ * Function returns a List of software which must accessable as an external executable
+ */
+ protected Object[] mustInstalledSoftware()
+ {
+ ArrayList aList = new ArrayList();
+ // aList.add("perl -version");
+ return aList.toArray();
+ }
+
+ // the test ======================================================================
+ public void convert()
+ {
+ GlobalLogWriter.set(log);
+ // check if all need software is installed and accessable
+ checkEnvironment(mustInstalledSoftware());
+
+ // test_removeFirstDirectorysAndBasenameFrom();
+ // Get the MultiServiceFactory.
+ // XMultiServiceFactory xMSF = (XMultiServiceFactory)param.getMSF();
+ GraphicalTestArguments aGTA = getGraphicalTestArguments();
+ if (aGTA == null)
+ {
+ assure("Must quit", false);
+ }
+
+ initMember();
+
+ File aInputPath = new File(m_sInputPath);
+ if (aInputPath.isDirectory())
+ {
+ String fs = System.getProperty("file.separator");
+
+ String sRemovePath = aInputPath.getAbsolutePath();
+ // a whole directory
+ FileFilter aFileFilter = FileHelper.getFileFilter();
+
+ Object[] aList = DirectoryHelper.traverse(m_sInputPath, aFileFilter, aGTA.includeSubDirectories());
+ for (int i=0;i<aList.length;i++)
+ {
+ String sEntry = (String)aList[i];
+
+ String sNewReferencePath = m_sReferencePath + fs + FileHelper.removeFirstDirectorysAndBasenameFrom(sEntry, m_sInputPath);
+ log.println("- next file is: ------------------------------");
+ log.println(sEntry);
+
+ if (aGTA.checkIfUsableDocumentType(sEntry))
+ {
+ runGDC(sEntry, sNewReferencePath);
+ }
+ if (aGTA.cancelRequest())
+ {
+ break;
+ }
+ }
+ }
+ else
+ {
+ if (aGTA.checkIfUsableDocumentType(m_sInputPath))
+ {
+ runGDC(m_sInputPath, m_sReferencePath);
+ }
+ }
+ }
+
+ void runGDC(String _sInputFile, String _sReferencePath)
+ {
+ // first do a check if the reference not already exist, this is a big speedup, due to the fact,
+ // we don't need to start a new office.
+ GraphicalTestArguments aGTA_local = getGraphicalTestArguments();
+ // if (GraphicalDifferenceCheck.isReferenceExists(_sInputFile, _sReferencePath, aGTA_local) == false)
+ // {
+ // start a fresh Office
+ OfficeProvider aProvider = null;
+ if (aGTA_local.restartOffice())
+ {
+ aProvider = new OfficeProvider();
+ XMultiServiceFactory xMSF = (XMultiServiceFactory) aProvider.getManager(param);
+ param.put("ServiceFactory", xMSF);
+ }
+ GraphicalTestArguments aGTA = getGraphicalTestArguments();
+
+ if (aGTA.getOfficeProgram().toLowerCase().equals("msoffice"))
+ {
+ // ReferenceType is MSOffice
+ GlobalLogWriter.get().println("USE MSOFFICE AS EXPORT FORMAT.");
+ MSOfficePrint a = new MSOfficePrint();
+ try
+ {
+ String sInputFileBasename = FileHelper.getBasename(_sInputFile);
+ String fs = System.getProperty("file.separator");
+ FileHelper.makeDirectories("", _sReferencePath);
+ String sOutputFile = _sReferencePath;
+ if (sOutputFile.endsWith(fs))
+ {
+ sOutputFile += sInputFileBasename;
+ }
+ else
+ {
+ sOutputFile += fs + sInputFileBasename;
+ }
+
+ a.storeToFileWithMSOffice(aGTA, _sInputFile, sOutputFile);
+ }
+ catch(ConvWatchCancelException e)
+ {
+ GlobalLogWriter.get().println(e.getMessage());
+ }
+ catch(java.io.IOException e)
+ {
+ GlobalLogWriter.get().println(e.getMessage());
+ }
+ }
+ else
+ {
+ try
+ {
+ OfficePrint.convertDocument(_sInputFile, _sReferencePath, aGTA);
+ }
+ catch(ConvWatchCancelException e)
+ {
+ assure(e.getMessage(), false);
+ }
+ catch(ConvWatchException e)
+ {
+ assure(e.getMessage(), false);
+ }
+ }
+
+ if (aGTA.restartOffice())
+ {
+ // Office shutdown
+ aProvider.closeExistingOffice(param, true);
+ }
+ // }
+ }
+}
+
diff --git a/qadevOOo/runner/convwatch/EnhancedComplexTestCase.java b/qadevOOo/runner/convwatch/EnhancedComplexTestCase.java
new file mode 100644
index 000000000000..7c51940d7801
--- /dev/null
+++ b/qadevOOo/runner/convwatch/EnhancedComplexTestCase.java
@@ -0,0 +1,130 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package convwatch;
+
+import complexlib.ComplexTestCase;
+import helper.ProcessHandler;
+import convwatch.GraphicalTestArguments;
+
+/**
+ * Some Helperfunctions which are nice in ReferenceBuilder and ConvWatchTest
+ */
+
+public abstract class EnhancedComplexTestCase extends ComplexTestCase
+{
+ // public void before()
+ // {
+ // // System.out.println("before()");
+ // }
+ //
+ // public void after()
+ // {
+ // // System.out.println("after()");
+ // }
+
+ void checkExistance(String _sScriptFile, String _sName)
+ {
+ boolean bBackValue = false;
+ // Process testshl = Runtime.getRuntime().exec(scriptFile);
+ ProcessHandler aHandler = new ProcessHandler(_sScriptFile);
+ bBackValue = aHandler.executeSynchronously();
+ TimeHelper.waitInSeconds(1, "wait after ProcessHandler.executeSynchronously()");
+
+ StringBuffer aBuffer = new StringBuffer();
+ aBuffer.append(aHandler.getErrorText()).append(aHandler.getOutputText());
+ String sText = aBuffer.toString();
+
+ if (sText.length() == 0)
+ {
+ String sError = "Must quit. " + _sName + " may be not accessable.";
+ assure(sError, false);
+ // System.exit(1);
+ }
+ else
+ {
+ // System.out.println("Output from script:");
+ // System.out.println(sText);
+ }
+ }
+
+ // -----------------------------------------------------------------------------
+
+ protected void checkEnvironment(Object[] _aList)
+ {
+ // checks if some packages already installed,
+ // this function will not return if packages are not installed,
+ // it will call System.exit(1)!
+
+ if (needCheckForInstalledSoftware())
+ {
+ for (int i=0;i<_aList.length;i++)
+ {
+ String sCommand = (String)_aList[i];
+ // TODO: nice to have, a pair object
+ checkExistance(sCommand, sCommand);
+ }
+ }
+ }
+
+ // -----------------------------------------------------------------------------
+
+ protected abstract Object[] mustInstalledSoftware();
+ public boolean needCheckForInstalledSoftware()
+ {
+ String sNEEDCHECK = (String)param.get( PropertyName.CHECK_NEED_TOOLS );
+// TODO: I need to get the boolean value with get("name") because, if it is not given getBool() returns
+// with a default of 'false' which is not very helpful if the default should be 'true'
+// maybe a getBoolean("name", true) could be a better choise.
+ if (sNEEDCHECK == null)
+ {
+ sNEEDCHECK = "false";
+ }
+ if (sNEEDCHECK.toLowerCase().equals("yes") ||
+ sNEEDCHECK.toLowerCase().equals("true"))
+ {
+ return true;
+ }
+ return false;
+ }
+
+ // -----------------------------------------------------------------------------
+
+ public GraphicalTestArguments getGraphicalTestArguments()
+ {
+ GraphicalTestArguments aGTA = new GraphicalTestArguments(param);
+ if (aGTA.getImportFilterName() != null && aGTA.getImportFilterName().toLowerCase().equals("help"))
+ {
+ aGTA = null;
+ }
+ if (aGTA.getExportFilterName() != null && aGTA.getExportFilterName().toLowerCase().equals("help"))
+ {
+ aGTA = null;
+ }
+ return aGTA;
+ }
+}
diff --git a/qadevOOo/runner/convwatch/FileHelper.java b/qadevOOo/runner/convwatch/FileHelper.java
new file mode 100644
index 000000000000..2ff9ede2f8d4
--- /dev/null
+++ b/qadevOOo/runner/convwatch/FileHelper.java
@@ -0,0 +1,405 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package convwatch;
+
+import java.io.File;
+import java.io.FileFilter;
+import java.util.StringTokenizer;
+import helper.OSHelper;
+
+import javax.swing.JOptionPane;
+
+public class FileHelper
+{
+ public FileHelper()
+ {
+ // fs = System.getProperty("file.separator");
+
+
+ String sOSName = System.getProperty("os.name");
+ String sOSArch = System.getProperty("os.arch");
+ String sOSVersion = System.getProperty("os.version");
+
+ GlobalLogWriter.get().println(sOSName);
+ GlobalLogWriter.get().println(sOSArch);
+ GlobalLogWriter.get().println(sOSVersion);
+
+ }
+
+ public static void MessageBox(String _sStr)
+ {
+ String sVersion = System.getProperty("java.version");
+ String sOSName = System.getProperty("os.name");
+ JOptionPane.showMessageDialog( null, _sStr, sVersion + " " + sOSName + " Hello World Debugger", JOptionPane.INFORMATION_MESSAGE );
+ }
+
+ public static boolean exists(String _sFile)
+ {
+ if (_sFile == null) return false;
+
+ File aFile = new File(_sFile);
+ if (aFile.exists())
+ {
+ return true;
+ }
+ // This is just nice for DEBUG behaviour
+ // due to the fact this is absolutly context dependency no one should use it.
+ // else
+ // {
+ // System.out.println("FileHelper:exists() tell this path doesn't exists. Check it. path is:" );
+ // System.out.println( _sFile );
+ // System.out.println( aFile.getAbsolutePath() );
+ // MessageBox("Der JavaProzess wartet auf eine interaktion ihrerseits.");
+ //
+ // File aFile2 = new File(_sFile);
+ // if (aFile2.exists())
+ // {
+ // System.out.println("Thanks, file exists." );
+ // return true;
+ // }
+ // }
+ return false;
+ }
+
+ public static boolean isDir(String _sDir)
+ {
+ if (_sDir == null) return false;
+ try
+ {
+ File aFile = new File(_sDir);
+ if (aFile.exists() && aFile.isDirectory())
+ {
+ return true;
+ }
+ }
+ catch (NullPointerException e)
+ {
+ GlobalLogWriter.get().println("Exception caught. FileHelper.isDir('" + _sDir + "')");
+ e.printStackTrace();
+ }
+ return false;
+ }
+
+ public static String getBasename(String _sFilename)
+ {
+ if (_sFilename == null) return "";
+ String fs = System.getProperty("file.separator");
+
+ int nIdx = _sFilename.lastIndexOf(fs);
+ if (nIdx > 0)
+ {
+ return _sFilename.substring(nIdx + 1);
+ }
+ return _sFilename;
+ }
+
+ public static String getNameNoSuffix(String _sFilename)
+ {
+ if (_sFilename == null) return "";
+ int nIdx = _sFilename.lastIndexOf(".");
+ if (nIdx > 0)
+ {
+ return _sFilename.substring(0, nIdx);
+ }
+ return _sFilename;
+ }
+
+ public static String getSuffix(String _sFilename)
+ {
+ if (_sFilename == null) return "";
+ int nIdx = _sFilename.lastIndexOf(".");
+ if (nIdx > 0)
+ {
+ return _sFilename.substring(nIdx );
+ }
+ return "";
+ }
+
+ public static String getPath(String _sFilename)
+ {
+ if (_sFilename == null) return "";
+ String fs = System.getProperty("file.separator");
+
+ int nIdx = _sFilename.lastIndexOf(fs);
+ if (nIdx > 0)
+ {
+ return _sFilename.substring(0, nIdx);
+ }
+ return "";
+ }
+
+/*
+ static ArrayList files = new ArrayList();
+ public static Object[] traverse( String afileDirectory )
+ {
+
+ File fileDirectory = new File(afileDirectory);
+ // Testing, if the file is a directory, and if so, it throws an exception
+ if ( !fileDirectory.isDirectory() )
+ {
+ throw new IllegalArgumentException( "not a directory: " + fileDirectory.getName() );
+ }
+
+ // Getting all files and directories in the current directory
+ File[] entries = fileDirectory.listFiles();
+
+ // Iterating for each file and directory
+ for ( int i = 0; i < entries.length; ++i )
+ {
+ // adding file to List
+ try
+ {
+ // Composing the URL by replacing all backslashs
+ String stringUrl = "file:///"
+ + entries[ i ].getAbsolutePath().replace( '\\', '/' );
+ files.add(stringUrl);
+ }
+ catch( Exception exception )
+ {
+ exception.printStackTrace();
+ }
+ }
+ return files.toArray();
+ }
+*/
+
+ // makeDirectories("", "/tmp/a/b");
+ // creates all directories /tmp/a/b
+ //
+ public static void makeDirectories(String first, String path)
+ {
+ makeDirectories(first, path, "0777");
+ }
+
+ public static void makeDirectories(String first, String path, String _sMode)
+ {
+ String fs = System.getProperty("file.separator");
+ if (path.startsWith(fs + fs)) // starts with UNC Path
+ {
+ int n = path.indexOf(fs, 2);
+ n = path.indexOf(fs, n + 1);
+ first = path.substring(0, n);
+ path = path.substring(n + 1);
+ }
+
+ String already_done = null;
+ StringTokenizer path_tokenizer = new StringTokenizer(path,fs,false);
+ already_done = first;
+ while (path_tokenizer.hasMoreTokens())
+ {
+ String part = path_tokenizer.nextToken();
+ File new_dir = new File(already_done + File.separatorChar + part);
+ already_done = new_dir.toString();
+ // System.out.println(already_done);
+ //create the directory
+ new_dir.mkdirs();
+ if (OSHelper.isUnix() &&
+ _sMode.length() > 0)
+ {
+ try
+ {
+ chmod(new_dir, _sMode);
+ }
+ catch (java.io.IOException e)
+ {
+ GlobalLogWriter.get().println("Exception caught. FileHelper.makeDirectories('" + new_dir.getAbsolutePath() + "')");
+ }
+ }
+ }
+ // return;
+ }
+
+ public static void chmod(File file, String mode) throws java.io.IOException
+ {
+ Runtime.getRuntime().exec
+ (new String[]
+ {"chmod", mode, file.getAbsolutePath()});
+ }
+
+ public static String removeFirstDirectorysAndBasenameFrom(String _sName, String _sRemovePath)
+ {
+ // pre: _sName: /a/b/c/d/e/f.g _sRemovePath /a/b/c
+ // result: d/e
+ String fs = System.getProperty("file.separator");
+
+ String sBasename = FileHelper.getBasename(_sName);
+ String sSubDirs = "";
+ if (_sName.startsWith(_sRemovePath))
+ {
+ // if _sName starts with _sRemovePath
+ int nRemovePathIndex = _sRemovePath.length();
+ if (! _sRemovePath.endsWith(fs))
+ {
+ // add 1 if we not ends with file separator
+ nRemovePathIndex ++;
+ }
+ int nBasenameIndex = _sName.length() - sBasename.length() - 1;
+ if (nRemovePathIndex < nBasenameIndex)
+ {
+ sSubDirs = _sName.substring(nRemovePathIndex, nBasenameIndex);
+ }
+ }
+ else
+ {
+ // special case, the _sRemovePath is not part of _sName
+ sSubDirs = FileHelper.getPath(_sName);
+ if (sSubDirs.startsWith(fs))
+ {
+ // remove leading file separator
+ sSubDirs = sSubDirs.substring(1);
+ }
+ }
+
+ return sSubDirs;
+ }
+
+ public static void test_removeFirstDirectorysAndBasenameFrom()
+ {
+ String a = removeFirstDirectorysAndBasenameFrom("/a/b/c/d/e/f.g", "/a/b/c");
+ // assure("", a.equals("d/e"));
+ String b = removeFirstDirectorysAndBasenameFrom("/a/b/c/d/e/f.g", "/a/b/c/");
+ // assure("", b.equals("d/e"));
+ String c = removeFirstDirectorysAndBasenameFrom("/a/b/c/d/e/f.g", "/b/c");
+ // assure("", c.equals("a/b/c/d/e"));
+ }
+
+
+ public static String getSystemPathFromFileURL( String _sFileURL )
+ {
+ String sSystemFile = null;
+
+ if(_sFileURL.startsWith("file:///"))
+ {
+ if (OSHelper.isWindows())
+ {
+ sSystemFile = _sFileURL.substring(8);
+ }
+ else
+ {
+ sSystemFile = _sFileURL.substring(7);
+ }
+ }
+ else if (_sFileURL.startsWith("file://"))
+ {
+ sSystemFile = _sFileURL.substring(5);
+ }
+ String fs = System.getProperty("file.separator");
+ if (! fs.equals("/"))
+ {
+ sSystemFile = sSystemFile.replace ('/', fs.toCharArray ()[0]);
+ }
+// FEATURE FOR UNC NEED!!!
+ return sSystemFile;
+ }
+
+ private static boolean m_bDebugTextShown = false;
+ public static boolean isDebugEnabled()
+ {
+ boolean bDebug = false;
+ String sTmpPath = util.utils.getUsersTempDir();
+ //util.utils.getUsersTempDir();
+ String fs = System.getProperty("file.separator");
+ String sName = sTmpPath + fs + "DOC_COMPARATOR_DEBUG";
+ File aFile = new File(sName);
+ if (aFile.exists())
+ {
+ if (m_bDebugTextShown == false)
+ {
+ GlobalLogWriter.get().println("Found file: " + sName);
+ GlobalLogWriter.get().println("Activate debug mode.");
+ GlobalLogWriter.get().println("If debug mode is no longer necessary, remove the above file.");
+ m_bDebugTextShown = true;
+ }
+ bDebug = true;
+ }
+ return bDebug;
+ }
+
+ public static void copy(String _sSource, String _sDestination)
+ {
+ try
+ {
+ File inputFile = new File(_sSource);
+ File outputFile = new File(_sDestination);
+
+ java.io.FileReader in = new java.io.FileReader(inputFile);
+ java.io.FileWriter out = new java.io.FileWriter(outputFile);
+ int c;
+
+ while ((c = in.read()) != -1)
+ out.write(c);
+
+ in.close();
+ out.close();
+ }
+ catch (java.io.IOException e)
+ {
+ GlobalLogWriter.get().println("Exception caught. FileHelper.copy('" + _sSource + ", " + _sDestination + "')");
+ GlobalLogWriter.get().println("Message: " + e.getMessage());
+ }
+ }
+
+ /**
+ * Within the directory run through, it's possible to say which file extension types should not
+ * consider like '*.prn' because it's not a document.
+ *
+ * @return a FileFilter function
+ */
+ public static FileFilter getFileFilter()
+ {
+ FileFilter aFileFilter = new FileFilter()
+ {
+ public boolean accept( File pathname )
+ {
+ // leave out files which started by '~$' these are Microsoft Office temp files
+ if (pathname.getName().startsWith("~$"))
+ {
+ return false;
+ }
+
+ if (pathname.getName().endsWith(".prn"))
+ {
+ return false;
+ }
+ // This type of document no one would like to load.
+ if (pathname.getName().endsWith(".zip"))
+ {
+ return false;
+ }
+ // just a hack
+ if (pathname.getName().endsWith("_"))
+ {
+ return false;
+ }
+ return true;
+ }
+ };
+ return aFileFilter;
+ }
+}
+
diff --git a/qadevOOo/runner/convwatch/FilenameHelper.java b/qadevOOo/runner/convwatch/FilenameHelper.java
new file mode 100644
index 000000000000..3d49703dc995
--- /dev/null
+++ b/qadevOOo/runner/convwatch/FilenameHelper.java
@@ -0,0 +1,398 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+/**
+ * Helper class to hold a Filename or a FileURL
+ * Something like File in Java,
+ * with some more extensions direct to ConvWatch and it's name conventions
+ *
+ *
+ */
+package convwatch;
+
+import helper.URLHelper;
+import convwatch.FileHelper;
+import helper.StringHelper;
+import util.utils;
+
+interface Filenamer
+{
+ public String getSuffix();
+ public String getFileURL();
+ public String getAbsoluteSystemFilename();
+ public String getFilename();
+ public String getSystemPath();
+}
+
+// -----------------------------------------------------------------------------
+
+abstract class FilenameHelper_impl implements Filenamer
+{
+ String fs; // file separator like '/'
+ String m_sPath;
+ String m_sFilename;
+ String m_sSuffix;
+ int m_nNumber = 0;
+
+ public String getNumber()
+ {
+ return StringHelper.createValueString(m_nNumber, 4);
+ }
+ public void setNumber(int _n)
+ {
+ m_nNumber = _n;
+ }
+ void initMember()
+ {
+ fs = System.getProperty("file.separator");
+ }
+
+ /**
+ * initialise a FilenameHelper_impl with a complete filename.
+ * if the filename starts with 'file:///' it is interpret as a file URL
+ *
+ */
+ public FilenameHelper_impl()
+ {
+ initMember();
+ }
+
+ public void setCompleteFilename(String _sFilename)
+ {
+ if (_sFilename.startsWith("file:///"))
+ {
+ _sFilename = FileHelper.getSystemPathFromFileURL(_sFilename);
+ }
+ _sFilename = utils.replaceAll13(_sFilename, "\\\\", "/");
+
+ String sPath = checkPath(FileHelper.getPath(_sFilename));
+ String sFilenameWithSuffix = checkFilename(FileHelper.getBasename(_sFilename));
+ String sSuffix = splitSuffix(sFilenameWithSuffix);
+
+ m_sPath = sPath;
+ m_sFilename = FileHelper.getNameNoSuffix(sFilenameWithSuffix);
+ m_sSuffix = sSuffix;
+ }
+
+ /**
+ * initialise a FilenameHelper_impl with a path a name and a suffix separately
+ */
+ public FilenameHelper_impl(String _sPath, String _sName, String _sSuffix)
+ {
+ initMember();
+ _sPath = utils.replaceAll13(_sPath, "\\\\", "/");
+
+ String sPath = checkPath(_sPath);
+ String sFilename = checkFilename(_sName);
+ String sSuffix = checkSuffix(_sSuffix);
+
+ m_sPath = sPath;
+ m_sFilename = sFilename;
+ m_sSuffix = sSuffix;
+ }
+
+ /**
+ * @return the current path as a OOo path URL
+ */
+ public String getFileURL()
+ {
+ String sSystemPath = createAbsoluteFilename();
+ String sFileURL = URLHelper.getFileURLFromSystemPath(sSystemPath);
+ return sFileURL;
+ }
+
+
+ /**
+ * @return the current path as a system path
+ */
+ public String getAbsoluteSystemFilename()
+ {
+ String sSystemFilename = createAbsoluteFilename();
+ sSystemFilename = utils.replaceAll13(sSystemFilename, "/", fs);
+ return sSystemFilename;
+ }
+
+ /**
+ * @return the filename without it's suffix
+ */
+ public String getName()
+ {
+ return m_sFilename;
+ }
+ /**
+ * set only the filename, maybe it's is only a directory.
+ */
+ public void setName(String _sName)
+ {
+ m_sFilename = _sName;
+ }
+ public void setPath(String _sName)
+ {
+ m_sPath = _sName;
+ }
+
+ /**
+ * @return a created name
+ */
+ abstract public String buildName();
+ // {
+ // return getName();
+ // }
+
+ /**
+ * @return the complete filename with it's suffix
+ */
+ public String getFilename()
+ {
+ return buildName() + "." + getSuffix();
+ }
+
+ /**
+ * @return the path as system path
+ */
+ public String getSystemPath()
+ {
+ String sSystemPath = m_sPath;
+ sSystemPath = utils.replaceAll13(sSystemPath, "/", fs);
+ return sSystemPath;
+ }
+ /**
+ * @return true, if current SystemPath is a directory
+ */
+ public boolean isDirectory()
+ {
+ return FileHelper.isDir(getSystemPath());
+ }
+
+ /**
+ * @return true, if the file really exist.
+ */
+ public boolean exists()
+ {
+ return FileHelper.exists(createAbsoluteFilename());
+ }
+
+ /**
+ * @return the current suffix
+ */
+ public String getSuffix()
+ {
+ return m_sSuffix;
+ }
+ /**
+ * @return the complete name. Without convert the path separator!
+ */
+ String createAbsoluteFilename()
+ {
+ return m_sPath + fs + getFilename();
+ }
+
+ /*
+ * remove follows 'file separators'
+ */
+ String checkPath(String _sPath)
+ {
+ String sPath;
+ if (_sPath.endsWith("/") || _sPath.endsWith("\\"))
+ {
+ sPath = _sPath.substring(0, _sPath.length() - 1);
+ }
+ else
+ {
+ sPath = _sPath;
+ }
+ return sPath;
+ }
+
+ String checkFilename(String _sFilename)
+ {
+ String sFilename;
+ if (_sFilename.startsWith("/") || _sFilename.startsWith("\\"))
+ {
+ sFilename = _sFilename.substring(1);
+ }
+ else
+ {
+ sFilename = _sFilename;
+ }
+ return sFilename;
+ }
+
+ String checkSuffix(String _sSuffix)
+ {
+ String sSuffix;
+ if (_sSuffix.startsWith("."))
+ {
+ sSuffix = _sSuffix.substring(1);
+ }
+ else
+ {
+ sSuffix = _sSuffix;
+ }
+ return sSuffix;
+ }
+
+ String splitSuffix(String _sName)
+ {
+ String sSuffix = FileHelper.getSuffix(_sName);
+ return checkSuffix(sSuffix);
+ }
+
+ public boolean equals(FilenameHelper_impl _aOtherFN)
+ {
+ String sPath = createAbsoluteFilename();
+ String sPathOther = _aOtherFN.createAbsoluteFilename();
+ if (sPath.equals(sPathOther))
+ {
+ return true;
+ }
+ return false;
+ }
+
+}
+
+/**
+ * Original filename
+ */
+class OriginalFilename extends FilenameHelper_impl
+{
+ public String buildName()
+ {
+ return getName();
+ }
+
+ public OriginalFilename(){}
+ public OriginalFilename(String _path, String _filename, String _ext) { super(_path, _filename, _ext);}
+}
+
+/**
+ * Reference from original
+ */
+class OriginalReferenceFilename extends FilenameHelper_impl
+{
+ public String getSuffix()
+ {
+ return "prn";
+ }
+ public String buildName()
+ {
+ return getName();
+ }
+ public OriginalReferenceFilename(){}
+ public OriginalReferenceFilename(String _path, String _filename, String _ext) { super(_path, _filename, _ext);}
+}
+
+/**
+ * picture from reference from original
+ */
+class OriginalReferencePictureFilename extends FilenameHelper_impl
+{
+ public String getSuffix()
+ {
+ return "jpg";
+ }
+ public String buildName()
+ {
+ return getName() + "-" + getNumber() + "-ref";
+ }
+ public String getBuildString()
+ {
+ return getName() + "-" + "%04d" + "-ref";
+ }
+
+ public OriginalReferencePictureFilename(){}
+ public OriginalReferencePictureFilename(String _path, String _filename, String _ext) { super(_path, _filename, _ext);}
+}
+
+/**
+ * Reference from OpenOffice.org
+ */
+class CurrentReferenceFilename extends FilenameHelper_impl
+{
+ public String getSuffix()
+ {
+ return "ps";
+ }
+ public String buildName()
+ {
+ return getName();
+ }
+
+ public CurrentReferenceFilename(){}
+ public CurrentReferenceFilename(String _path, String _filename, String _ext) { super(_path, _filename, _ext);}
+}
+
+/**
+ * picture from reference from OpenOffice.org
+ */
+class CurrentReferencePictureFilename extends FilenameHelper_impl
+{
+ public String getSuffix()
+ {
+ return "jpg";
+ }
+ public String buildName()
+ {
+ return getName() + "-" + getNumber() + "-new-ref";
+ }
+ public String getBuildString()
+ {
+ return getName() + "-" + "%04d" + "-new-ref";
+ }
+
+ public CurrentReferencePictureFilename(){}
+ public CurrentReferencePictureFilename(String _path, String _filename, String _ext) { super(_path, _filename, _ext);}
+}
+
+
+public class FilenameHelper
+{
+
+ public static void main(String[] args)
+ {
+ OriginalReferenceFilename d = new OriginalReferenceFilename();
+ d.setCompleteFilename("c:\\dir1\\dir2\\name.ext");
+ System.out.println("Suffix: " + d.getSuffix());
+ System.out.println("Path: " + d.getSystemPath());
+ System.out.println("Absolute system path filename: " + d.getAbsoluteSystemFilename());
+ System.out.println("URL: " + d.getFileURL());
+ System.out.println("Filename: " + d.getFilename());
+
+ OriginalReferenceFilename a = new OriginalReferenceFilename("/dir1/dir2/", "name",".ext");
+ OriginalReferenceFilename a1 = new OriginalReferenceFilename("/dir1/dir2","name.ext","");
+ OriginalReferenceFilename a2 = new OriginalReferenceFilename("/dir1/dir2","/name.ext","");
+ OriginalReferenceFilename a3 = new OriginalReferenceFilename("/dir1/dir2","/name",".ext");
+ OriginalReferenceFilename a4 = new OriginalReferenceFilename("/dir1/dir2","name","ext");
+
+
+ // OriginalReferenceFilename b = new OriginalReferenceFilename("c:/dir1/dir2/name.ext");
+ // OriginalReferenceFilename c = new OriginalReferenceFilename("file:///dir1/dir2/name.ext");
+ // OriginalReferenceFilename e = new OriginalReferenceFilename("c:\\dir1\\dir2\\name");
+ // OriginalReferenceFilename f = new OriginalReferenceFilename("c:\\dir1\\dir2");
+ // OriginalReferenceFilename g = new OriginalReferenceFilename("c:\\dir1\\dir2\\");
+ }
+}
diff --git a/qadevOOo/runner/convwatch/GfxCompare.java b/qadevOOo/runner/convwatch/GfxCompare.java
new file mode 100644
index 000000000000..b45897475c23
--- /dev/null
+++ b/qadevOOo/runner/convwatch/GfxCompare.java
@@ -0,0 +1,196 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package convwatch;
+
+import java.util.ArrayList;
+import convwatch.EnhancedComplexTestCase;
+import convwatch.PRNCompare;
+import convwatch.GraphicalTestArguments;
+import helper.URLHelper;
+import convwatch.OfficePrint;
+import java.io.File;
+
+public class GfxCompare extends EnhancedComplexTestCase
+{
+ // The first of the mandatory functions:
+ /**
+ * Return the name of the test.
+ * In this case it is the actual name of the service.
+ * @return The tested service.
+ */
+ // public String getTestObjectName() {
+ // return "ConvWatch runner";
+ // }
+
+ // The second of the mandatory functions: return all test methods as an
+ // array. There is only one test function in this example.
+ /**
+ * Return all test methods.
+ * @return The test methods.
+ */
+
+ public String[] getTestMethodNames() {
+ return new String[]{"gfxcompare"};
+ }
+
+ /**
+ *
+ * @return a List of software which must accessable as an external executable
+ */
+ protected Object[] mustInstalledSoftware()
+ {
+ ArrayList aList = new ArrayList();
+ // Tools from ImageMagick
+ aList.add( "composite -version" );
+ aList.add( "identify -version" );
+
+ // Ghostscript
+ aList.add( "gs -version" );
+ return aList.toArray();
+ }
+
+
+ GraphicalTestArguments m_aArguments = null;
+ /**
+ * The test method itself.
+ * Don't try to call it from outside, it is started only from qadevOOo runner
+ */
+
+ /* protected */
+ public void gfxcompare()
+ {
+ GlobalLogWriter.set(log);
+
+ // check if all need software is installed and accessable
+ checkEnvironment(mustInstalledSoftware());
+
+ m_aArguments = getGraphicalTestArguments();
+
+ String sFile1 = (String)param.get("FILE1");
+ String sFile2 = (String)param.get("FILE2");
+ compare(sFile1, sFile2);
+ }
+
+ // -----------------------------------------------------------------------------
+
+ String createJPEG(String _sFile, String _sAdditional)
+ {
+ String sJPEGFile = "";
+ if (_sFile.startsWith("file:///"))
+ {
+ _sFile = FileHelper.getSystemPathFromFileURL(_sFile);
+ }
+ File aFile = new File(_sFile);
+ if (aFile.exists())
+ {
+ String sAbsFile = aFile.getAbsolutePath();
+ if (!sAbsFile.equals(_sFile))
+ {
+ _sFile = sAbsFile;
+ }
+ }
+ else
+ {
+ GlobalLogWriter.get().println("File: '" + _sFile + "' doesn't exist.");
+ return "";
+ }
+ String sFileDir = FileHelper.getPath(_sFile);
+ String sBasename = FileHelper.getBasename(_sFile);
+ String sNameNoSuffix = FileHelper.getNameNoSuffix(sBasename);
+
+ String fs = System.getProperty("file.separator");
+ String sTmpDir = util.utils.getUsersTempDir();
+ if (m_aArguments.getOutputPath() != null)
+ {
+ sTmpDir = m_aArguments.getOutputPath();
+ }
+
+ if (_sFile.toLowerCase().endsWith("ps") ||
+ _sFile.toLowerCase().endsWith("prn") ||
+ _sFile.toLowerCase().endsWith("pdf"))
+ {
+ // seems to be a Postscript of PDF file
+
+ String[] aList = PRNCompare.createJPEGFromPostscript(sTmpDir, sFileDir, sBasename, m_aArguments.getResolutionInDPI());
+ sJPEGFile = aList[0];
+ }
+ else if (_sFile.toLowerCase().endsWith("jpg") ||
+ _sFile.toLowerCase().endsWith("jpeg"))
+ {
+ // do nothing, it's already a picture.
+ return _sFile;
+ }
+ else
+ {
+ // we assume it's an office document.
+ String sInputURL;
+ String sOutputURL;
+ String sPrintFileURL;
+
+ String sInputFile = sFileDir + fs + sBasename;
+ sInputURL = URLHelper.getFileURLFromSystemPath(sInputFile);
+
+ String sOutputFile = sTmpDir + fs + sBasename;
+ sOutputURL = URLHelper.getFileURLFromSystemPath(sOutputFile);
+
+ String sPrintFile = sTmpDir + fs + sNameNoSuffix + _sAdditional + ".ps";
+ sPrintFileURL = URLHelper.getFileURLFromSystemPath(sPrintFile);
+
+ try
+ {
+ OfficePrint.printToFile(m_aArguments, sInputURL, sOutputURL, sPrintFileURL);
+ sJPEGFile = createJPEG(sPrintFile, _sAdditional);
+ }
+ catch (ConvWatchCancelException e)
+ {
+ GlobalLogWriter.get().println("Exception caught, can't create:" + sPrintFileURL);
+ }
+ }
+ return sJPEGFile;
+ }
+
+
+ public String compare(String _sFile1, String _sFile2)
+ {
+ String sJPEGFile1 = createJPEG(_sFile1, "-1");
+ String sJPEGFile2 = createJPEG(_sFile2, "-2");
+
+ if (sJPEGFile1.length() > 0 && sJPEGFile2.length() > 0)
+ {
+ String sDiffFile = PRNCompare.compareJPEGs(sJPEGFile1, sJPEGFile2);
+
+ if (sDiffFile.length() > 0)
+ {
+ GlobalLogWriter.get().println("Difference created: " + sDiffFile);
+ }
+ return sDiffFile;
+ }
+ return "";
+ }
+
+}
diff --git a/qadevOOo/runner/convwatch/GlobalLogWriter.java b/qadevOOo/runner/convwatch/GlobalLogWriter.java
new file mode 100644
index 000000000000..fe785915cc02
--- /dev/null
+++ b/qadevOOo/runner/convwatch/GlobalLogWriter.java
@@ -0,0 +1,57 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package convwatch;
+
+import share.LogWriter;
+import stats.SimpleLogWriter;
+
+public class GlobalLogWriter
+{
+ private static LogWriter m_aGlobalLogWriter = null;
+ public static synchronized LogWriter get()
+ {
+ if (m_aGlobalLogWriter == null)
+ {
+ SimpleLogWriter aLog = new SimpleLogWriter();
+ m_aGlobalLogWriter = aLog;
+ }
+ return m_aGlobalLogWriter;
+ }
+
+// public static synchronized void initialize()
+// {
+// get().initialize(null, true);
+// }
+
+ public static synchronized void set(LogWriter _aLog)
+ {
+ m_aGlobalLogWriter = _aLog;
+ }
+
+}
+
diff --git a/qadevOOo/runner/convwatch/GraphicalDifferenceCheck.java b/qadevOOo/runner/convwatch/GraphicalDifferenceCheck.java
new file mode 100644
index 000000000000..efce96c1c15b
--- /dev/null
+++ b/qadevOOo/runner/convwatch/GraphicalDifferenceCheck.java
@@ -0,0 +1,410 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package convwatch;
+
+import convwatch.GraphicalTestArguments;
+import convwatch.OfficePrint;
+import convwatch.ConvWatchCancelException;
+import convwatch.FileHelper;
+import java.io.File;
+
+import helper.URLHelper;
+import com.sun.star.lang.XComponent;
+import com.sun.star.frame.XStorable;
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.lang.XServiceInfo;
+import com.sun.star.uno.UnoRuntime;
+
+public class GraphicalDifferenceCheck
+{
+ private static void showVersion()
+ {
+ // DEBUG only
+ if (FileHelper.isDebugEnabled())
+ {
+ GlobalLogWriter.get().println("");
+ GlobalLogWriter.get().println("+##############################+");
+ GlobalLogWriter.get().println("##### THIS IS CONVWATCH #####");
+ GlobalLogWriter.get().println("##### Debug Version 1.0015 #####");
+ GlobalLogWriter.get().println("+##############################+");
+ GlobalLogWriter.get().println("");
+ }
+ }
+
+ /**
+ * Creates references form documents used by the graphical difference check
+ *
+ * @param _sInputPath the original document path
+ * @param _sReferencePath the directory where the document will print as file or export as pdf.
+ *
+ * @throws ConvWatchException if there are problems, see message
+ *
+ * Stops rest, if one creation of reference fails.
+ */
+ public static void createReferences(String _sInputPath, String _sReferencePath, GraphicalTestArguments _aGTA) throws ConvWatchException
+ {
+//!
+// System.out.println("createReferences() InputPath: " + _sInputPath + " refpath: " + _sReferencePath);
+ showVersion();
+ File aInputPath = new File(_sInputPath);
+
+// System.out.println("Inputpath in file: " + aInputPath.getAbsolutePath());
+//!
+// if (aInputPath.exists())
+// {
+// System.out.println("Inputpath exists");
+// }
+// else
+// {
+// System.out.println("Inputpath doesn't exists");
+// return;
+// }
+
+ if (aInputPath.isDirectory())
+ {
+ String fs = System.getProperty("file.separator");
+
+ String sRemovePath = aInputPath.getAbsolutePath();
+ // a whole directory
+
+ Object[] aList = DirectoryHelper.traverse(_sInputPath, FileHelper.getFileFilter(), _aGTA.includeSubDirectories());
+ for (int i=0;i<aList.length;i++)
+ {
+ String sEntry = (String)aList[i];
+ String sNewReferencePath = _sReferencePath + fs + FileHelper.removeFirstDirectorysAndBasenameFrom(sEntry, _sInputPath);
+ createOneReferenceFile(sEntry, sNewReferencePath, _aGTA);
+ }
+ }
+ else
+ {
+//!
+ // System.out.println("No directory.");
+ createOneReferenceFile(_sInputPath, _sReferencePath, _aGTA);
+ }
+ }
+
+
+ /**
+ * Creates a reference for a single document used by the graphical difference check
+ *
+ * @param _sInputFile the original document
+ * @param _sReferencePath the directory where the document will print as file or export as pdf.
+ *
+ * @throws ConvWatchException if the are problems, see containing message
+ */
+ public static boolean createOneReferenceFile(String _sInputFile, String _sReferencePath, GraphicalTestArguments _aGTA) throws ConvWatchException
+ {
+ showVersion();
+ if (_aGTA != null)
+ {
+ _aGTA.setInputFile(_sInputFile);
+ }
+ return OfficePrint.buildReference(_aGTA, _sReferencePath, _sInputFile);
+ }
+
+ /**
+ * Check if a reference exist
+ *
+ * @param _sInputFile the original document
+ * @param _sReferencePath the directory where the document will print as file or export as pdf.
+ *
+ * @throws ConvWatchException if the are problems, see containing message
+ */
+ public static boolean isReferenceExists(String _sInputFile, String _sReferencePath, GraphicalTestArguments _aGTA)
+ {
+ return OfficePrint.isReferenceExists(_aGTA, _sReferencePath, _sInputFile);
+ }
+
+
+ /**
+ * Used for the comparance of graphical differences.
+ * Method compares one document (_sInputFile) with an older document of the same name in the provided directory (_sReferencePath).
+ *
+ * @param _sInputPath the original document path
+ * @param _sOutputPath path where the same directory structure of the given input path will create. All the result documents
+ * needed very much disk space (up to 10MB per page).
+ * The path _sOutputPath must be writeable.
+ * @param _sReferencePath the directory where the document will print as file or export as pdf.
+ * @param _GTA Helper class for lot of parameter to control the office.
+ *
+ * Disadvantage: stops rest if one test file has a problem.
+ */
+ public static boolean check(String _sInputPath, String _sOutputPath, String _sReferencePath, GraphicalTestArguments _aGTA ) throws ConvWatchException
+ {
+ return check(_sInputPath, _sOutputPath, _sReferencePath, null, _aGTA);
+ }
+
+ /**
+ * Used for the comparance of graphical differences.
+ * Method compares one document (_sInputFile) with an older document of the same name in the provided directory (_sReferencePath).
+ *
+ * @param _sInputPath the original document path
+ * @param _sReferencePath the directory where the document will print as file or export as pdf.
+ * @param _sOutputPath path where the same directory structure of the given input path will create. All the result documents
+ * needed very much disk space (up to 10MB per page).
+ * The path _sOutputPath must be writeable.
+ * @param _sDiffPath Path to older differences.
+ * @param _GTA Helper class for lot of parameter to control the office.
+ *
+ *
+ * Stops all, if one creation of reference fails
+ */
+ public static boolean check(String _sInputPath, String _sOutputPath, String _sReferencePath, String _sDiffPath, GraphicalTestArguments _aGTA ) throws ConvWatchException
+ {
+ showVersion();
+
+ boolean bOk = true;
+
+ File aInputPath = new File(_sInputPath);
+ if (aInputPath.isDirectory())
+ {
+ String fs = System.getProperty("file.separator");
+ // a whole directory
+ Object[] aList = DirectoryHelper.traverse(_sInputPath, FileHelper.getFileFilter(), _aGTA.includeSubDirectories());
+ if (aList.length != 0)
+ {
+ for (int i=0;i<aList.length;i++)
+ {
+ String sEntry = (String)aList[i];
+ String sNewSubDir = FileHelper.removeFirstDirectorysAndBasenameFrom(sEntry, _sInputPath);
+ String sNewReferencePath = _sReferencePath;
+ String sNewOutputPath = _sOutputPath;
+ String sNewDiffPath = _sDiffPath;
+ if (sNewSubDir.length() > 0)
+ {
+ if (sNewReferencePath != null)
+ {
+ sNewReferencePath = sNewReferencePath + fs + sNewSubDir;
+ }
+
+ sNewOutputPath = sNewOutputPath + fs + sNewSubDir;
+ if (sNewDiffPath != null)
+ {
+ sNewDiffPath = sNewDiffPath + fs + sNewSubDir;
+ }
+ }
+ bOk &= checkOneFile(sEntry, sNewOutputPath, sNewReferencePath, sNewDiffPath, _aGTA);
+ }
+ }
+ }
+ else
+ {
+ bOk = /* GraphicalDifferenceCheck.*/ checkOneFile(_sInputPath, _sOutputPath, _sReferencePath, _sDiffPath, _aGTA);
+ }
+ return bOk;
+ }
+
+ /**
+ * Used for the comparance of graphical differences.
+ * Method compares one document (_sInputFile) with an older document of the same name in the provided directory (_sReferencePath).
+ *
+ * The path _sOutputPath must be writeable
+ */
+ public static boolean checkOneFile(String _sInputFile, String _sOutputPath, String _sReferencePath, GraphicalTestArguments _aGTA) throws ConvWatchException
+ {
+ return checkOneFile( _sInputFile, _sOutputPath, _sReferencePath, null, _aGTA);
+ }
+
+
+ /**
+ * Used for the comparance of graphical differences.
+ * Method compares one document (_sInputFile) with an older document of the same name in the provided directory (_sReferencePath).
+ *
+ * For scenarios, where a difference is known and further changes are of interest, differences itself can be compared.
+ * This functionality is provided by the difference path parameter (_sDiffPath). If set, the difference of the current comparance (between input and reference),
+ * will be compared with the (same named) difference document from a earlier comparance.
+ *
+ * The path _sOutputPath must be writeable
+ */
+ public static boolean checkOneFile(String _sInputFile, String _sOutputPath, String _sReferencePath, String _sDiffPath, GraphicalTestArguments _aGTA ) throws ConvWatchException
+ {
+ showVersion();
+ if (_aGTA != null)
+ {
+ _aGTA.setInputFile(_sInputFile);
+ }
+
+ boolean bOk = false;
+ if (_sDiffPath != null)
+ {
+ // check with an old diff
+ bOk = convwatch.ConvWatch.checkDiffDiff(_aGTA, _sOutputPath, _sInputFile, _sReferencePath, _sDiffPath);
+ }
+ else
+ {
+ // one file
+ bOk = convwatch.ConvWatch.check(_aGTA, _sOutputPath, _sInputFile, _sReferencePath);
+ }
+ return bOk;
+ }
+
+ /**
+ * Instead of providing a saved document for graphical comparance a StarOffice xComponent
+ * will be saved and afterwards compared.
+ *
+ * @param xComponent the test document to be compared as StarOffice component
+ * @param _sOutputPath Path where test results are supposed to been saved. The path _sOutputPath must be writeable.
+ * These documents need sufficient disk space (up to 10MB per page).
+ * A directory structure will be created, which is a mirrored from input path.
+ *
+ * @param resultDocName Name by which the xComponent shall be saved as OpenOffice.org XML document.
+ * If provided without suffix, the suffix will be derived from the export filter.
+ * @param _sReferencePath the directory where the document will print as file or export as pdf.
+ * @param _GTA Helper class for lot of parameter to control the office.
+ */
+ public static boolean checkOneFile(XComponent xComponent, String _sOutputPath, String _resultDocName, String _sReferencePath, GraphicalTestArguments _aGTA ) throws ConvWatchException
+ {
+ showVersion();
+
+ // one file
+ String sInputFile;
+ sInputFile = createInputFile(xComponent, _sOutputPath, _resultDocName);
+ sInputFile = FileHelper.getSystemPathFromFileURL(sInputFile);
+ return convwatch.ConvWatch.check(_aGTA, _sOutputPath, sInputFile, _sReferencePath);
+ }
+
+
+// LLA: old! /**
+// LLA: old! * Returns 'true' if a reference document on the specific output path exists.
+// LLA: old! * The name of the document is corresponding to the input document, which can be
+// LLA: old! * provided by a single name or path.
+// LLA: old! *
+// LLA: old! * @param inputPath the original document name (possibly including path)
+// LLA: old! * @param referencePath the directory where the reference document will be stored
+// LLA: old!
+// LLA: old! */
+// LLA: old! public static boolean isReferencExistent(String inputDocumentPath, String referencePath)
+// LLA: old! {
+// LLA: old! // isolate the document name
+// LLA: old! if(inputDocumentPath.indexOf(File.separator) != -1)
+// LLA: old! inputDocumentPath = inputDocumentPath.substring(inputDocumentPath.lastIndexOf(File.separator) + 1, inputDocumentPath.length());
+// LLA: old!
+// LLA: old! // exchange any arbitray suffix against the refence suffix (.prn)
+// LLA: old! if(inputDocumentPath.indexOf('.') != -1)
+// LLA: old! inputDocumentPath = inputDocumentPath.substring(0, inputDocumentPath.lastIndexOf('.'));
+// LLA: old! inputDocumentPath = inputDocumentPath + ".prn";
+// LLA: old! System.out.println("GraphicalDifference CheckReferenceDocument: " + inputDocumentPath);
+// LLA: old!
+// LLA: old! File refFile = new File(referencePath + inputDocumentPath);
+// LLA: old! if(refFile.exists()){
+// LLA: old! return true;
+// LLA: old! }else
+// LLA: old! return false;
+// LLA: old! }
+
+
+ private static String createInputFile(XComponent xComponent, String _sOutputPath, String resultDocName)
+ throws ConvWatchCancelException
+ {
+
+ // find the adequate XML StarOffice output filter to save the document and adequate suffix
+ StringBuffer suffix = new StringBuffer();
+ String exportFilter = getXMLOutputFilterforXComponent(xComponent, suffix);
+ if(resultDocName == null)
+ resultDocName = "OOoTestDocument";
+ if(resultDocName.indexOf('.') == -1)
+ resultDocName = suffix.insert(0, resultDocName).toString();
+
+ // create a result URL for storing the office document
+ String resultURL = URLHelper.getFileURLFromSystemPath(ensureEndingFileSep(_sOutputPath) + resultDocName);
+
+ XStorable xStorable = null;
+ xStorable = (com.sun.star.frame.XStorable)UnoRuntime.queryInterface(com.sun.star.frame.XStorable.class, xComponent);
+ if(xStorable == null)
+ {
+ throw new ConvWatchCancelException("com.sun.star.frame.XStorable could not be instantiated from the office.");
+ }
+
+ PropertyValue pvFilterName = new PropertyValue("FilterName", -1, exportFilter, com.sun.star.beans.PropertyState.getDefault());
+ PropertyValue pvOverwrite = new PropertyValue("Overwrite", -1, new Boolean(true), com.sun.star.beans.PropertyState.getDefault());
+
+ try
+ {
+ xStorable.storeAsURL(resultURL, new PropertyValue[]{pvFilterName, pvOverwrite});
+ }
+ catch (com.sun.star.io.IOException e)
+ {
+ // wrap IOException
+ throw new ConvWatchCancelException("Wrap IOException caught, " + e.getMessage());
+ }
+
+ GlobalLogWriter.get().println("Saving XComponent as " + resultURL);
+
+ return resultURL;
+ }
+
+
+ private static String getXMLOutputFilterforXComponent(XComponent xComponent, StringBuffer suffix){
+ XServiceInfo xSI = (XServiceInfo) UnoRuntime.queryInterface(XServiceInfo.class, xComponent);
+ if (xSI.supportsService("com.sun.star.text.TextDocument")){
+ resetBuffer(suffix, ".sxw");
+ return "swriter: StarOffice XML (Writer)";
+ }else if (xSI.supportsService("com.sun.star.sheet.SpreadsheetDocument")){
+ resetBuffer(suffix, ".sxc");
+ return "scalc: StarOffice XML (Calc)";
+ }else if (xSI.supportsService("com.sun.star.presentation.PresentationDocument")){
+ resetBuffer(suffix, ".sxi");
+ return "simpress: StarOffice XML (Impress)";
+ }else if(xSI.supportsService("com.sun.star.drawing.DrawingDocument")){
+ resetBuffer(suffix, ".sxd");
+ return "sdraw: StarOffice XML (Draw)";
+ }else if (xSI.supportsService("com.sun.star.formula.FormulaProperties")){
+ resetBuffer(suffix, ".sxm");
+ return "smath: StarOffice XML (Math)";
+ }
+ return null;
+ }
+
+ private static StringBuffer resetBuffer(StringBuffer sb, String suffix)
+ {
+ if(sb != null)
+ {
+ sb.replace(0, sb.length(), suffix);
+ }
+ return sb;
+ }
+
+ private static String ensureEndingFileSep(String s)
+ {
+ if(s != null && !s.equals("") && !s.endsWith(File.separator))
+ {
+ s = s.trim() + File.separator;
+ }
+ else
+ {
+ if(s == null)
+ {
+ s = "";
+ }
+ }
+
+ return s;
+ }
+
+
+}
diff --git a/qadevOOo/runner/convwatch/GraphicalTestArguments.java b/qadevOOo/runner/convwatch/GraphicalTestArguments.java
new file mode 100644
index 000000000000..72d732d3d8de
--- /dev/null
+++ b/qadevOOo/runner/convwatch/GraphicalTestArguments.java
@@ -0,0 +1,744 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package convwatch;
+
+import com.sun.star.lang.XMultiServiceFactory;
+import lib.TestParameters;
+import java.io.File;
+
+import com.sun.star.container.XNameAccess;
+import com.sun.star.uno.UnoRuntime;
+
+/**
+ * This class object is more a Helper or Controller.
+ * It stores information like:
+ * - How to create a document (with a OpenOffice.org method, or with MS Word, or with OpenOffice.org as pdf)
+ * - some more infos for OpenOffice.org method
+ * - a service factory pointer
+ * - if hidden mode should use
+ * - target name
+ *
+ * - printer name
+ *
+ * - how to handle .xml files, which in Microsoft could be Excel or Word documents
+ *
+ * HOWTO USE:
+ * For OOo,
+ * create an GraphicalTestArguments with a set of TestParameters
+ * GraphicalTestArguments a = new GraphicalTestArguments(params);
+ *
+ * If you wish to use pdf export instead of normal printer output, set also the reference type to 'pdf'
+ * a.setReferenceType("pdf");
+ *
+ *
+ * For MS Office:
+ * create an GraphicalTestArguments and set the reference type to 'msoffice'
+ * GraphicalTestArguments a = new GraphicalTestArguments(params);
+ * a.setReferenceType("msoffice");
+ *
+ * within windows it's better to set also a printer name so it's simply possible to use for normal work the default printer
+ * and for such tests with ConvWatch a extra printer.
+ * a.setPrinterName("CrossOffice Printer");
+ *
+ */
+
+public class GraphicalTestArguments
+{
+ /**
+ 2DO:
+ Possible reference types are currently
+ // ooo
+ // pdf
+ // msoffice
+ */
+ String m_sReferenceType = "OOo";
+
+ String m_sTargetFrameName = "_blank";
+
+ String m_sPrinterName = null;
+
+ // Hidden = true hiddes a used OpenOffice.org, all code is executed in the background
+ // This parameter is not used for RefType: msoffice
+ boolean m_bHidden = true;
+
+ String m_sDefaultXMLFormatApplication = null;
+
+ boolean m_bIncludeSubdirectories;
+
+ TestParameters m_aCurrentParams;
+
+ int m_nMaxPages = 0; // default is 0 (print all pages)
+ String m_sOnlyPage = ""; // default is "", there is no page which we want to print only.
+
+ int m_nResolutionInDPI = 0;
+
+ boolean m_bStoreFile = true;
+ boolean m_bResuseOffice = false;
+
+ boolean m_bDebugMode = false;
+
+ String m_sLeaveOutNames = null;
+
+ String m_sDistinct = null;
+
+ boolean m_bCreateDefaultReference = false;
+
+ // CONSTRUCTOR
+ private GraphicalTestArguments(){}
+
+ public GraphicalTestArguments(TestParameters param)
+ {
+ m_aCurrentParams = param;
+ // collect interesting information from the ComplexTestCase
+ // ....
+
+ // REFERENCE_TYPE ----------
+ String sReferenceType = (String)param.get( PropertyName.DOC_COMPARATOR_REFERENCE_TYPE );
+ if (sReferenceType == null || sReferenceType.length() == 0)
+ {
+ }
+ else
+ {
+ // log.println("found REFERENCE_TYPE " + sReferenceType );
+ setReferenceType(sReferenceType);
+ }
+
+ // PRINTER_NAME ----------
+ String sPrinterName = (String)param.get( PropertyName.DOC_COMPARATOR_PRINTER_NAME );
+ if (sPrinterName == null || sPrinterName.length() == 0)
+ {
+ }
+ else
+ {
+ // log.println("found PRINTER_NAME " + sPrinterName );
+ setPrinterName(sPrinterName);
+ }
+ // DEFAULT_XML_FORMAT_APP ------
+ String sDefaultXMLFormatApp = (String)param.get( PropertyName.DOC_COMPARATOR_DEFAULT_XML_FORMAT_APP );
+ if (sDefaultXMLFormatApp == null || sDefaultXMLFormatApp.length() == 0)
+ {
+ }
+ else
+ {
+ setDefaultXMLFormatApp(sDefaultXMLFormatApp);
+ }
+
+ m_bIncludeSubdirectories = true;
+ String sRECURSIVE = (String)param.get( PropertyName.DOC_COMPARATOR_INCLUDE_SUBDIRS );
+// TODO: I need to get the boolean value with get("name") because, if it is not given getBool() returns
+// with a default of 'false' which is not very helpful if the default should be 'true'
+// maybe a getBoolean("name", true) could be a better choise.
+ if (sRECURSIVE == null)
+ {
+ sRECURSIVE = "true";
+ }
+ if (sRECURSIVE.toLowerCase().equals("no") ||
+ sRECURSIVE.toLowerCase().equals("false"))
+ {
+ m_bIncludeSubdirectories = false;
+ }
+
+ // ----------------------------------------
+ m_nMaxPages = param.getInt( PropertyName.DOC_COMPARATOR_PRINT_MAX_PAGE );
+ m_sOnlyPage = (String)param.get(PropertyName.DOC_COMPARATOR_PRINT_ONLY_PAGE);
+
+ m_nResolutionInDPI = param.getInt( PropertyName.DOC_COMPARATOR_GFX_OUTPUT_DPI_RESOLUTION );
+ if (m_nResolutionInDPI == 0)
+ {
+ // 212 DPI is 1754 x 2474 pixel for DIN A4
+ m_nResolutionInDPI = 212;
+ }
+
+ // ----------------------------------------
+ String sImportFilterName = (String)param.get(PropertyName.DOC_CONVERTER_IMPORT_FILTER_NAME);
+ if (sImportFilterName != null && sImportFilterName.length() > 0)
+ {
+ // System.out.println("found " + PropertyName.DOC_CONVERTER_IMPORT_FILTER_NAME + " " + sImportFilterName );
+ m_sImportFilterName = sImportFilterName;
+
+ if (sImportFilterName.toLowerCase().equals("help"))
+ {
+ showInternalFilterName(sImportFilterName, getMultiServiceFactory() );
+ GlobalLogWriter.get().println("Must quit.");
+ }
+ }
+ // ----------------------------------------
+ String sExportFilterName = (String)param.get(PropertyName.DOC_CONVERTER_EXPORT_FILTER_NAME);
+ if (sExportFilterName != null && sExportFilterName.length() > 0)
+ {
+ // System.out.println("found " + PropertyName.DOC_CONVERTER_EXPORT_FILTER_NAME + " " + sExportFilterName );
+ m_sExportFilterName = sExportFilterName;
+ if (sExportFilterName.toLowerCase().equals("help"))
+ {
+ showInternalFilterName(sExportFilterName, getMultiServiceFactory() );
+ GlobalLogWriter.get().println("Must quit.");
+ }
+ }
+
+ // ----------------------------------------
+ String sOfficeProgram = (String)param.get(PropertyName.DOC_CONVERTER_OFFICE_PROGRAM);
+ if (sOfficeProgram != null && sOfficeProgram.length() > 0)
+ {
+ m_sOfficeProgram = sOfficeProgram;
+ }
+ // ----------------------------------------
+ String sREUSE_OFFICE = (String)param.get( PropertyName.DOC_CONVERTER_REUSE_OFFICE);
+ if (sREUSE_OFFICE == null)
+ {
+ sREUSE_OFFICE = "false";
+ }
+ if (sREUSE_OFFICE.toLowerCase().equals("yes") ||
+ sREUSE_OFFICE.toLowerCase().equals("true"))
+ {
+ m_bResuseOffice = true;
+ }
+ else
+ {
+ m_bResuseOffice = false;
+ }
+
+
+ String sHTMLOutputPrefix = (String)param.get( PropertyName.DOC_COMPARATOR_HTML_OUTPUT_PREFIX);
+ if (sHTMLOutputPrefix == null)
+ {
+ m_sHTMLOutputPrefix = "";
+ }
+ else
+ {
+ m_sHTMLOutputPrefix = sHTMLOutputPrefix;
+ }
+
+ String sWithBorderMove = (String)param.get( PropertyName.DOC_COMPARATOR_GFXCMP_WITH_BORDERMOVE);
+ if (sWithBorderMove == null)
+ {
+ sWithBorderMove = "";
+ // m_tWithBorderMove = TriState.UNSET;
+ m_tWithBorderMove = TriState.FALSE;
+ }
+ if (sWithBorderMove.toLowerCase().equals("yes") ||
+ sWithBorderMove.toLowerCase().equals("true"))
+ {
+ m_tWithBorderMove = TriState.TRUE;
+ }
+ else if (sWithBorderMove.toLowerCase().equals("no") ||
+ sWithBorderMove.toLowerCase().equals("false"))
+ {
+ m_tWithBorderMove = TriState.FALSE;
+ }
+ else
+ {
+ m_tWithBorderMove = TriState.FALSE;
+ // m_tWithBorderMove = TriState.UNSET;
+ }
+
+ String sLeaveOutNames = (String)param.get(PropertyName.DOC_COMPARATOR_LEAVE_OUT_FILES);
+ if (sLeaveOutNames != null)
+ {
+ m_sLeaveOutNames = sLeaveOutNames;
+ }
+
+ String sDBInfoString = (String)param.get(PropertyName.DOC_COMPARATOR_DB_INFO_STRING);
+ if (sDBInfoString != null)
+ {
+ m_sDBInfoString = sDBInfoString;
+ }
+
+ // DISTINCT ----------
+ String sDistinct = (String)param.get( "DISTINCT" );
+ if (sDistinct == null || sDistinct.length() == 0)
+ {
+ sDistinct = "";
+ }
+ else
+ {
+ m_sDistinct = sDistinct;
+ }
+ // HIDDEN
+ String sOfficeViewable = (String)param.get(PropertyName.OFFICE_VIEWABLE);
+ if (sOfficeViewable != null)
+ {
+ if (sOfficeViewable.toLowerCase().equals("yes") ||
+ sOfficeViewable.toLowerCase().equals("true"))
+ {
+ setViewable();
+ }
+ else
+ {
+ setHidden();
+ }
+ }
+ // CREATE_DEFAULT
+ String sCreateDefault = (String)param.get(PropertyName.CREATE_DEFAULT);
+ if (sCreateDefault != null)
+ {
+ if (sCreateDefault.toLowerCase().equals("yes") ||
+ sCreateDefault.toLowerCase().equals("true"))
+ {
+ m_bCreateDefaultReference = true;
+ }
+ else
+ {
+ m_bCreateDefaultReference = false;
+ }
+ }
+
+ }
+
+ public boolean checkIfUsableDocumentType(String _sName)
+ {
+ // @todo
+ // check if the name is in the leave out list and then return 'false'
+ if (_sName.toLowerCase().endsWith(".jpg") ||
+ _sName.toLowerCase().endsWith(".png") ||
+ _sName.toLowerCase().endsWith(".gif") ||
+ _sName.toLowerCase().endsWith(".bmp") ||
+ _sName.toLowerCase().endsWith(".prn") ||
+ _sName.toLowerCase().endsWith(".ps"))
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ static void showInternalFilterName(String _sFilterName, XMultiServiceFactory _xMSF)
+ {
+ if (_sFilterName.length() == 0)
+ {
+ // System.out.println("No FilterName set.");
+ return;
+ }
+
+ if (_xMSF == null)
+ {
+ GlobalLogWriter.get().println("MultiServiceFactory not set.");
+ return;
+ }
+ // XFilterFactory aFilterFactory = null;
+ Object aObj = null;
+ try
+ {
+ aObj = _xMSF.createInstance("com.sun.star.document.FilterFactory");
+ }
+ catch(com.sun.star.uno.Exception e)
+ {
+ GlobalLogWriter.get().println("Can't get com.sun.star.document.FilterFactory.");
+ return;
+ }
+ if (aObj != null)
+ {
+ XNameAccess aNameAccess = (XNameAccess)UnoRuntime.queryInterface(XNameAccess.class, aObj);
+ if (aNameAccess != null)
+ {
+
+ if (_sFilterName.toLowerCase().equals("help"))
+ {
+ GlobalLogWriter.get().println("Show all possible ElementNames from current version." );
+ String[] aElementNames = aNameAccess.getElementNames();
+ for (int i = 0; i<aElementNames.length; i++)
+ {
+ GlobalLogWriter.get().println(aElementNames[i]);
+ }
+ }
+ }
+ }
+ }
+
+ /*
+ public GraphicalTestArguments(TestParameters param, Log xxx)
+ {
+ // collect interesting information from the ComplexTestCase
+ // ....
+ }
+ */
+
+ // set methods
+ public void setReferenceType(String _sType)
+ {
+ // special casse, null is not allowed, set to default.
+ if (_sType == null)
+ {
+ m_sReferenceType = "OOo";
+ }
+ else
+ {
+ m_sReferenceType = _sType;
+ }
+ }
+ public void setTargetFrameName(String _sTargetFrameName) {m_sTargetFrameName = _sTargetFrameName;}
+ public void setPrinterName(String _sName) {m_sPrinterName = _sName;}
+ public void setHidden() { m_bHidden = true;}
+ public void setViewable() {m_bHidden = false;}
+ public void setDefaultXMLFormatApp(String _sNameOfApp) {m_sDefaultXMLFormatApplication = _sNameOfApp;}
+
+ // get methods
+ public XMultiServiceFactory getMultiServiceFactory()
+ {
+ XMultiServiceFactory xMSF = (XMultiServiceFactory)m_aCurrentParams.getMSF();
+
+ // check if MultiServiceFactory is given
+ if (getReferenceType().toLowerCase().equals("pdf") ||
+ getReferenceType().toLowerCase().equals("ooo"))
+ {
+ if (xMSF == null)
+ {
+ GlobalLogWriter.get().println("ERROR! MultiServiceFactory not given.");
+ }
+ }
+ return xMSF;
+ }
+
+ public String getReferenceType() {return m_sReferenceType;}
+ public String getTargetFrameName() {return m_sTargetFrameName;}
+ public String getPrinterName() {return m_sPrinterName;}
+ public boolean isHidden() {return m_bHidden;}
+ public String getDefaultXMLFormatApp() {return m_sDefaultXMLFormatApplication;}
+
+
+ /**
+ * @return true, if subdirectories should run through
+ */
+ public boolean includeSubDirectories() {return m_bIncludeSubdirectories;}
+
+ /**
+ * @return the number of pages to be print
+ */
+ public int getMaxPages() {return m_nMaxPages;}
+
+ /**
+ * @return as string, which pages should be print, e.g. '1-4;6' here, page 1 to 4 and page 6.
+ */
+ public String getOnlyPages()
+ {
+ if (m_sOnlyPage == null)
+ {
+ return "";
+ }
+ return m_sOnlyPage;
+ }
+
+ /**
+ * @return true, if there should not print all pages at all, use getMaxPages() and or getOnlyPages() to get which pages to print
+ */
+ public boolean printAllPages()
+ {
+ if ( (getMaxPages() > 0) ||
+ (getOnlyPages().length() != 0))
+ {
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * @return integer value, which contain resolution in DPI.
+ */
+ public int getResolutionInDPI() {return m_nResolutionInDPI;}
+
+ public static void checkIfMSWindowsConformPath(String _sPath)
+ {
+ if (_sPath != null && _sPath.length() > 1)
+ {
+ if (_sPath.charAt(1) == ':')
+ {
+ if (_sPath.charAt(2) != '\\')
+ {
+ GlobalLogWriter.get().println("This is not a Microsoft Windows conform path: '" + _sPath + "' please fix.");
+ System.exit(1);
+ }
+ }
+ }
+ }
+
+
+ /**
+ * @return the INPUT_PATH out of the TestParameters
+ */
+ public String getInputPath()
+ {
+ String sInputPath;
+ sInputPath = (String)m_aCurrentParams.get(PropertyName.DOC_COMPARATOR_INPUT_PATH);
+ checkIfMSWindowsConformPath(sInputPath);
+ return sInputPath;
+ }
+ /**
+ * @return the OUTPUT_PATH out of the TestParameters
+ */
+ public String getOutputPath()
+ {
+ String sOutputPath;
+ sOutputPath = (String)m_aCurrentParams.get(PropertyName.DOC_COMPARATOR_OUTPUT_PATH);
+ checkIfMSWindowsConformPath(sOutputPath);
+ return sOutputPath;
+ }
+ /**
+ * @return the REFERENCE_PATH out of the TestParameters
+ */
+ public String getReferencePath()
+ {
+ String sReferencePath;
+ sReferencePath = (String)m_aCurrentParams.get(PropertyName.DOC_COMPARATOR_REFERENCE_PATH);
+ checkIfMSWindowsConformPath(sReferencePath);
+ return sReferencePath;
+ }
+ /**
+ * @return the DIFF_PATH out of the TestParameters
+ */
+ public String getDiffPath()
+ {
+ String sDiffPath;
+ sDiffPath = (String)m_aCurrentParams.get(PropertyName.DOC_COMPARATOR_DIFF_PATH);
+ checkIfMSWindowsConformPath(sDiffPath);
+ return sDiffPath;
+ }
+
+ public boolean getOverwrite()
+ {
+ boolean bOverwrite = m_aCurrentParams.getBool( PropertyName.DOC_COMPARATOR_OVERWRITE_REFERENCE);
+ return bOverwrite;
+ }
+ public String getReferenceInputPath()
+ {
+ String sReferenceInputPath;
+ sReferenceInputPath = (String)m_aCurrentParams.get(PropertyName.DOC_COMPARATOR_REFERENCE_INPUT_PATH);
+ return sReferenceInputPath;
+ }
+
+ /**
+ * Helper function to get the buildid of the current used OpenOffice.org
+ * out of the AppExecutionCommand the build ID
+ */
+ public String getBuildID()
+ {
+ String sAPP = (String)m_aCurrentParams.get(util.PropertyName.APP_EXECUTION_COMMAND);
+ // return getBuildID(sAPP);
+// TODO: here we need the getBuildID(string) method
+ String sBuildID = convwatch.BuildID.getBuildID(sAPP);
+ return sBuildID;
+ }
+
+ public boolean shouldOfficeStart()
+ {
+ String sNoOffice = (String)m_aCurrentParams.get( "NoOffice" );
+ if (sNoOffice != null)
+ {
+ if (sNoOffice.toLowerCase().startsWith("t") || sNoOffice.toLowerCase().startsWith("y"))
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ // Handle for Reference Build ID, is set in ConvWatch.createPostscriptStartCheck()
+ private String m_sRefBuildID;
+
+ public void setRefBuildID(String _sRef)
+ {
+ m_sRefBuildID = _sRef;
+ }
+ public String getRefBuildID()
+ {
+ return m_sRefBuildID;
+ }
+
+ public void disallowStore()
+ {
+ m_bStoreFile = false;
+ }
+ public void allowStore()
+ {
+ m_bStoreFile = true;
+ }
+ public boolean isStoreAllowed()
+ {
+ return m_bStoreFile;
+ }
+ public boolean createDefaultReference()
+ {
+ return m_bCreateDefaultReference;
+ }
+
+
+ // get/set for FilterName
+ // get the right Filtername (internal Name) from
+ // http://framework.openoffice.org/files/documents/25/897/filter_description.html
+
+ String m_sImportFilterName = "";
+ String m_sExportFilterName = "";
+ public void setImportFilterName(String _sImportFilterName)
+ {
+ m_sImportFilterName = _sImportFilterName;
+ }
+ public String getImportFilterName()
+ {
+ return m_sImportFilterName;
+ }
+ public void setExportFilterName(String _sExportFilterName)
+ {
+ m_sExportFilterName = _sExportFilterName;
+ }
+ public String getExportFilterName()
+ {
+ return m_sExportFilterName;
+ }
+
+ String m_sOfficeProgram = "";
+ public void setOfficeProgram(String _sName)
+ {
+ m_sOfficeProgram = _sName;
+ }
+ public String getOfficeProgram()
+ {
+ return m_sOfficeProgram;
+ }
+
+ public boolean restartOffice()
+ {
+ if (m_bResuseOffice == false)
+ {
+ return true;
+ }
+ return false;
+ }
+
+ String m_sHTMLOutputPrefix = "";
+ public String getHTMLOutputPrefix()
+ {
+ return m_sHTMLOutputPrefix;
+ }
+
+ TriState m_tWithBorderMove = TriState.UNSET;
+ // public TriState isBorderMove()
+ // {
+ // return m_tWithBorderMove;
+ // }
+ public TriState getBorderMove()
+ {
+ return m_tWithBorderMove;
+ }
+ public void setBorderMove(TriState _tBorderMove)
+ {
+ m_tWithBorderMove = _tBorderMove;
+ }
+
+ String m_sDocumentType = "";
+ public void setDocumentType(String _sName)
+ {
+ m_sDocumentType = _sName;
+ }
+ public String getDocumentType()
+ {
+ return m_sDocumentType;
+ }
+
+ /*
+ helper class for performance analyser features
+ */
+ PerformanceContainer m_aPerformanceContainer = null;
+ public PerformanceContainer getPerformance()
+ {
+ if (m_aPerformanceContainer == null)
+ {
+ m_aPerformanceContainer = new PerformanceContainer();
+ }
+ return m_aPerformanceContainer;
+ }
+
+ private String m_aInputFile;
+ public void setInputFile(String _sInputFile)
+ {
+ m_aInputFile = _sInputFile;
+ }
+ public String getInputFile()
+ {
+ return m_aInputFile;
+ }
+
+ private String m_sDBInfoString;
+ public String getDBInfoString()
+ {
+ if (m_sDBInfoString != null)
+ {
+ if (m_sDBInfoString.length() == 0)
+ {
+ return null;
+ }
+ }
+
+ return m_sDBInfoString;
+ }
+
+ public boolean cancelRequest()
+ {
+ File aCancelFile = null;
+ String fs;
+ fs = System.getProperty("file.separator");
+ String sTempPath = (String)m_aCurrentParams.get( PropertyName.TEMPPATH );
+ if (sTempPath != null)
+ {
+ String sGDC_Dir = sTempPath;
+
+ if (m_sDistinct.length() > 0)
+ {
+ sGDC_Dir = sGDC_Dir + fs + m_sDistinct;
+ }
+
+ String sCancelFile = sGDC_Dir + fs + "cancel_compare.txt";
+ aCancelFile = new File(sCancelFile);
+
+ if (aCancelFile.exists())
+ {
+ GlobalLogWriter.get().println("ATTENTION: Found file: '" + sCancelFile + "'.");
+ GlobalLogWriter.get().println("User has canceled the program flow.");
+ return true;
+ }
+ }
+ return false;
+ }
+
+}
+
+
+/*
+public class MSGraphicalTestArguments extends GraphicalTestArguments
+{
+ MSGraphicalTestArguments()
+ {
+ setReferenceType("msoffice");
+ }
+}
+
+public class OOoGraphicalTestArguments extends GraphicalTestArguments
+{
+ OOoGraphicalTestArguments(XMultiServiceFactory _aFactory)
+ {
+ setMultiServiceFactory(_aFactory);
+ }
+}
+*/
diff --git a/qadevOOo/runner/convwatch/HTMLOutputter.java b/qadevOOo/runner/convwatch/HTMLOutputter.java
new file mode 100644
index 000000000000..49edb2c25ac0
--- /dev/null
+++ b/qadevOOo/runner/convwatch/HTMLOutputter.java
@@ -0,0 +1,418 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package convwatch;
+
+import java.io.File;
+import java.io.FileWriter;
+import helper.OSHelper;
+
+public class HTMLOutputter
+{
+ FileWriter m_aOut;
+ String m_sFilename;
+ String m_sNamePrefix; // the HTML files used a suffix to build it's right name
+
+ /**
+ * ls is the current line separator (carridge return)
+ */
+ String ls;
+
+ HTMLOutputter() {}
+ public static HTMLOutputter create( String _sOutputPath, String _sHTMLFilename, String _sNamePrefix, String _sTitle )
+ {
+ FileHelper.makeDirectories("", _sOutputPath);
+ HTMLOutputter a = new HTMLOutputter();
+ String fs = System.getProperty("file.separator");
+ String sFilename = _sOutputPath + fs + _sHTMLFilename;
+
+ try
+ {
+ File outputFile = new File(sFilename);
+ a.m_aOut = new FileWriter(outputFile.toString());
+ a.ls = System.getProperty("line.separator");
+ }
+ catch (java.io.IOException e)
+ {
+ e.printStackTrace();
+ GlobalLogWriter.get().println("ERROR: Can't create HTML Outputter");
+ return null;
+ }
+ a.m_sFilename = sFilename;
+ a.m_sNamePrefix = _sNamePrefix;
+ return a;
+ }
+ public String getFilename() {return m_sFilename;}
+
+ public void header(String _sTitle)
+ {
+ try
+ {
+ m_aOut.write( "<html>" + ls);
+ m_aOut.write( "<head>" + ls);
+ m_aOut.write( "<title>" + _sTitle + "</title>" + ls);
+ m_aOut.write( "<link rel=\"stylesheet\" type=\"text/css\" href=\"/gfxcmp_ui/xmloff.css\" media=\"screen\" />" + ls);
+ m_aOut.write( "<link rel=\"stylesheet\" type=\"text/css\" href=\"/gfxcmp_ui/style.css\" media=\"screen\" />" + ls);
+ m_aOut.write( "</head>" + ls);
+ m_aOut.write( "<body bgcolor=white>" + ls);
+ m_aOut.flush();
+ }
+ catch (java.io.IOException e)
+ {
+ }
+ }
+
+ final static String TEST_TABLETITLE = "Test";
+ final static String VISUAL_STATUS_TABLETITLE = "Visual status";
+ final static String VISUAL_STATUS_MESSAGE_TABLETITLE = "Message";
+
+ public void indexSection(String _sOfficeInfo)
+ {
+ try
+ {
+ m_aOut.write( "<h2>Results for " + _sOfficeInfo + "</h2>" + ls);
+ m_aOut.write( "<p>Legend:<br>");
+ m_aOut.write( stronghtml(FIRSTGFX_TABLETITLE) + " contains the output printed via 'ghostscript' as a jpeg picture.<br>");
+
+ m_aOut.write( "<table class=\"infotable\">" + ls);
+ m_aOut.write( "<TR>");
+ m_aOut.write( tableHeaderCell(TEST_TABLETITLE));
+ m_aOut.write( tableHeaderCell(TEST_TABLETITLE));
+ m_aOut.write( tableHeaderCell(VISUAL_STATUS_TABLETITLE));
+ m_aOut.write( tableHeaderCell(VISUAL_STATUS_MESSAGE_TABLETITLE));
+ m_aOut.write( "</TR>" + ls);
+ m_aOut.flush();
+ }
+ catch (java.io.IOException e)
+ {
+ }
+ }
+
+ String getHREF(String _sHREF, String _sPathInfo)
+ {
+ StringBuffer a = new StringBuffer();
+ if (! OSHelper.isWindows())
+ {
+ // System.out.println("Tu'nix system.");
+ a.append("<A HREF=\"");
+ a.append(_sHREF);
+ a.append("\">");
+ a.append(_sPathInfo);
+ a.append("</A>");
+ }
+ else
+ {
+ // System.out.println("Windows system.");
+ //! this should be replaced by a better method
+ //! name(WIN|UNIX)
+ a.append("<A HREF=\"");
+ a.append(_sHREF);
+ a.append("\">");
+ a.append(_sPathInfo);
+ // a.append("(first)");
+ a.append("</A>");
+ // if (_sHREF.charAt(1) == ':' && (_sHREF.charAt(0) == 'x' || _sHREF.charAt(0) == 'X'))
+ // int index = 0;
+ // index = _sHREF.indexOf("X:");
+ // if (index == -1)
+ // {
+ // index = _sHREF.indexOf("x:");
+ // }
+ // if (index >= 0)
+ // {
+ // // int index = 0;
+ // // remove "X:" and insert "/tausch"
+ // StringBuffer sbUNIXPath = new StringBuffer( _sHREF.substring(0, index) );
+ // sbUNIXPath.append("/tausch");
+ // sbUNIXPath.append(_sHREF.substring(index + 2));
+ // String sUNIXPath = sbUNIXPath.toString();
+ // sUNIXPath = utils.replaceAll13(sUNIXPath, "\\", "/");
+ //
+ // a.append("<A HREF=\"");
+ // a.append(sUNIXPath);
+ // a.append("\">");
+ // a.append("(second)");
+ // a.append("</A>");
+ // }
+ // else
+ // {
+ // System.out.println("Path is '" + _sHREF + "'");
+ // }
+
+ }
+ return a.toString();
+ }
+
+ String tableDataCell(String _sValue)
+ {
+ StringBuffer a = new StringBuffer();
+ a.append("<TD>");
+ a.append(_sValue);
+ a.append("</TD>");
+ return a.toString();
+ }
+
+ String tableHeaderCell(String _sValue)
+ {
+ StringBuffer a = new StringBuffer();
+ a.append("<TH>");
+ a.append(_sValue);
+ a.append("</TH>");
+ return a.toString();
+ }
+
+ public void indexLine(String _sHTMLFile, String _sHTMLName, String _sHTMLFile2, String _sHTMLName2, String _sStatusRunThrough, String _sStatusMessage)
+ {
+ try
+ {
+ m_aOut.write( "<TR>");
+ m_aOut.write(tableDataCell( getHREF(_sHTMLFile, _sHTMLName) ) );
+ if (_sHTMLFile2.length() > 0)
+ {
+ m_aOut.write(tableDataCell( getHREF(_sHTMLFile2, _sHTMLName2) ) );
+ }
+ else
+ {
+ m_aOut.write(tableDataCell( "" ) );
+ }
+
+ m_aOut.write( tableDataCell(_sStatusRunThrough) );
+ m_aOut.write( tableDataCell(_sStatusMessage) );
+ m_aOut.write( "</TR>" + ls);
+
+ m_aOut.flush();
+ }
+ catch (java.io.IOException e)
+ {
+ }
+ }
+
+ public void close()
+ {
+ try
+ {
+ m_aOut.write( "</TABLE>" + ls);
+ m_aOut.write( "</BODY></HTML>" + ls);
+ m_aOut.flush();
+ m_aOut.close();
+ }
+ catch (java.io.IOException e)
+ {
+ }
+ }
+
+// -----------------------------------------------------------------------------
+ String stronghtml(String _sValue)
+ {
+ StringBuffer a = new StringBuffer();
+ a.append("<STRONG>");
+ a.append(_sValue);
+ a.append("</STRONG>");
+ return a.toString();
+ }
+
+ final static String FIRSTGFX_TABLETITLE = "Original print file as jpeg";
+ final static String SECONDGFX_TABLETITLE = "New print file as jpeg";
+ final static String DIFFER_TABLETITLE = "Difference file";
+ final static String STATUS_TABLETITLE = "Status";
+ final static String PIXELDIFF_TABLETITLE = "Pixel difference in %";
+
+ final static String PIXELDIFF_BM_TABLETITLE = "P.diff. in % after remove border";
+ final static String DIFFER_BM_TABLETITLE = "Diff file (RB)";
+
+ final static String OK_TABLETITLE = "OK?";
+ public void checkSection(String _sDocumentName)
+ {
+ try
+ {
+ m_aOut.write( "<H2>Results for the document " + _sDocumentName + "</H2>" + ls);
+
+ m_aOut.write( "<p>Legend:<br>");
+ m_aOut.write( stronghtml(FIRSTGFX_TABLETITLE) + " contains the output printed via 'ghostscript' as a jpeg picture.<br>");
+ m_aOut.write( stronghtml(SECONDGFX_TABLETITLE) + " contains the same document opened within OpenOffice.org also printed via ghostscript as jpeg.<br>");
+ m_aOut.write( stronghtml(DIFFER_TABLETITLE)+" is build via composite from original and new picture. The result should be a whole black picture, if there are no differences.<br>At the moment "+stronghtml(STATUS_TABLETITLE)+" is only ok, if the difference file contains only one color (black).</p>" );
+ m_aOut.write( stronghtml(DIFFER_BM_TABLETITLE) + " is build via composite from original and new picture after the border of both pictures are removed, so differences based on center problems may solved here");
+ m_aOut.write( "</p>");
+ m_aOut.write( "<p>Some words about the percentage value<br>");
+ m_aOut.write( "If a character is on the original page (a) and on the new page this character is moved to an other position only (b) , this means the difference is 100%.<br>");
+ m_aOut.write( "If character (b) is also bigger than character (a) the percentage is grow over the 100% mark.<br>");
+ m_aOut.write( "This tool count only the pixels which are differ to it's background color. It makes no sense to count all pixels, or the difference percentage will most the time in a very low percentage range.");
+ m_aOut.write( "</p>");
+
+ m_aOut.write( "<table class=\"infotable\">" + ls);
+
+ m_aOut.write( "<TR>" + ls);
+ m_aOut.write( tableHeaderCell( FIRSTGFX_TABLETITLE) );
+ m_aOut.write( tableHeaderCell( SECONDGFX_TABLETITLE ) );
+ m_aOut.write( tableHeaderCell(DIFFER_TABLETITLE ) );
+ m_aOut.write( tableHeaderCell(PIXELDIFF_TABLETITLE ) );
+
+ m_aOut.write( tableHeaderCell(DIFFER_BM_TABLETITLE) );
+ m_aOut.write( tableHeaderCell(PIXELDIFF_BM_TABLETITLE ) );
+
+ m_aOut.write( tableHeaderCell( OK_TABLETITLE) );
+
+ m_aOut.write( "</TR>" + ls);
+ m_aOut.flush();
+ }
+ catch (java.io.IOException e)
+ {
+ }
+ }
+
+ public void checkLine(StatusHelper _aStatus, boolean _bCurrentResult)
+ {
+ try
+ {
+ m_aOut.write( "<TR>" + ls);
+ String sLink = getHREF(FileHelper.getBasename(_aStatus.m_sOldGfx), FileHelper.getBasename(_aStatus.m_sOldGfx));
+ m_aOut.write( tableDataCell(sLink) );
+
+ sLink = getHREF(FileHelper.getBasename(_aStatus.m_sNewGfx), FileHelper.getBasename(_aStatus.m_sNewGfx));
+ m_aOut.write( tableDataCell(sLink) );
+
+ sLink = getHREF(FileHelper.getBasename(_aStatus.m_sDiffGfx), FileHelper.getBasename(_aStatus.m_sDiffGfx));
+ m_aOut.write( tableDataCell(sLink) );
+
+ String sPercent = String.valueOf(_aStatus.nPercent) + "%";
+ if (_aStatus.nPercent > 0 && _aStatus.nPercent < 5)
+ {
+ sPercent += " (less 5% is ok)";
+ }
+ m_aOut.write(tableDataCell( sPercent ) );
+
+ if (_aStatus.m_sDiff_BM_Gfx == null)
+ {
+ sLink = "No diffs, therefore no moves";
+ m_aOut.write( tableDataCell(sLink) );
+ m_aOut.write(tableDataCell( "" ) );
+ }
+ else
+ {
+ sLink = getHREF(FileHelper.getBasename(_aStatus.m_sDiff_BM_Gfx), FileHelper.getBasename(_aStatus.m_sDiff_BM_Gfx));
+ m_aOut.write( tableDataCell(sLink) );
+
+ String sPercent2 = String.valueOf(_aStatus.nPercent2) + "%";
+ if (_aStatus.nPercent2 > 0 && _aStatus.nPercent2 < 5)
+ {
+ sPercent2 += " (less 5% is ok)";
+ }
+ m_aOut.write(tableDataCell( sPercent2 ) );
+ }
+
+ // is the check positiv, in a defined range
+ if (_bCurrentResult)
+ {
+ m_aOut.write(tableDataCell( "YES" ) );
+ }
+ else
+ {
+ m_aOut.write(tableDataCell( "NO" ) );
+ }
+
+ m_aOut.write( "</TR>" + ls);
+ }
+ catch (java.io.IOException e)
+ {
+ }
+ }
+
+// -----------------------------------------------------------------------------
+ public void checkDiffDiffSection(String _sDocumentName)
+ {
+ try
+ {
+ m_aOut.write( "<H2>Results for the document " + _sDocumentName + "</H2>" + ls);
+
+ m_aOut.write( "<p>Legend:<br>");
+ m_aOut.write( "</p>");
+
+ m_aOut.write( "<table class=\"infotable\">" + ls);
+
+ m_aOut.write( "<TR>" + ls);
+ m_aOut.write( tableHeaderCell( "Source to actual difference" ) );
+ m_aOut.write( tableHeaderCell( "Actual difference" ) );
+ m_aOut.write( tableHeaderCell(DIFFER_TABLETITLE ) );
+ m_aOut.write( tableHeaderCell(PIXELDIFF_TABLETITLE ) );
+
+ m_aOut.write( tableHeaderCell( OK_TABLETITLE) );
+
+ m_aOut.write( "</TR>" + ls);
+ m_aOut.flush();
+ }
+ catch (java.io.IOException e)
+ {
+ }
+ }
+
+ public void checkDiffDiffLine(StatusHelper _aStatus, boolean _bCurrentResult)
+ {
+ try
+ {
+ m_aOut.write( "<TR>" + ls);
+ // the link to the old difference can't offer here
+ // String sLink = getHREF(FileHelper.getBasename(_aStatus.m_sOldGfx), FileHelper.getBasename(_aStatus.m_sOldGfx));
+ // m_aOut.write( tableDataCell(sLink) );
+
+ String sBasename = FileHelper.getBasename(m_sFilename);
+ String sNew = sBasename.substring(m_sNamePrefix.length());
+
+ String sLink;
+ sLink = getHREF(sNew, sNew);
+ m_aOut.write( tableDataCell(sLink) );
+
+ sLink = getHREF(FileHelper.getBasename(_aStatus.m_sNewGfx), FileHelper.getBasename(_aStatus.m_sNewGfx));
+ m_aOut.write( tableDataCell(sLink) );
+
+ sLink = getHREF(FileHelper.getBasename(_aStatus.m_sDiffGfx), FileHelper.getBasename(_aStatus.m_sDiffGfx));
+ m_aOut.write( tableDataCell(sLink) );
+
+ String sPercent = String.valueOf(_aStatus.nPercent) + "%";
+ // if (_aStatus.nPercent > 0 && _aStatus.nPercent < 5)
+ // {
+ // sPercent += " (less 5% is ok)";
+ // }
+ m_aOut.write(tableDataCell( sPercent ) );
+
+ // is the check positiv, in a defined range
+ if (_bCurrentResult)
+ {
+ m_aOut.write(tableDataCell( "YES" ) );
+ }
+ else
+ {
+ m_aOut.write(tableDataCell( "NO" ) );
+ }
+
+ m_aOut.write( "</TR>" + ls);
+ }
+ catch (java.io.IOException e)
+ {
+ }
+ }
+
+}
diff --git a/qadevOOo/runner/convwatch/INIOutputter.java b/qadevOOo/runner/convwatch/INIOutputter.java
new file mode 100644
index 000000000000..faa542a05cb8
--- /dev/null
+++ b/qadevOOo/runner/convwatch/INIOutputter.java
@@ -0,0 +1,207 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package convwatch;
+
+import java.io.File;
+import java.io.FileWriter;
+
+public class INIOutputter
+{
+ FileWriter m_aOut;
+ String m_sFilename;
+ String m_sNamePrefix; // the HTML files used a suffix to build it's right name
+
+ /**
+ * ls is the current line separator (carridge return)
+ */
+ String ls;
+
+ public static INIOutputter create( String _sOutputPath, String _sHTMLFilename, String _sNamePrefix, String _sTitle )
+ {
+ FileHelper.makeDirectories("", _sOutputPath);
+ INIOutputter a = new INIOutputter();
+ String fs = System.getProperty("file.separator");
+ String sFilename = _sOutputPath + fs + _sHTMLFilename;
+
+ try
+ {
+ File outputFile = new File(sFilename);
+ a.m_aOut = new FileWriter(outputFile.toString());
+ a.ls = System.getProperty("line.separator");
+ }
+ catch (java.io.IOException e)
+ {
+ e.printStackTrace();
+ GlobalLogWriter.get().println("ERROR: Can't create INI Outputter");
+ return null;
+ }
+ a.m_sFilename = sFilename;
+ a.m_sNamePrefix = _sNamePrefix;
+
+ return a;
+ }
+ public String getFilename() {return m_sFilename;}
+
+ public void createHeader()
+ {
+ try
+ {
+ m_aOut.write("; This file is automatically created by a convwatch run" + ls);
+ m_aOut.write("; " + ls);
+ m_aOut.write("; If you see this file in a browser you may have forgotten to set the follows in the property file" + ls);
+ m_aOut.write("; " + PropertyName.DOC_COMPARATOR_HTML_OUTPUT_PREFIX + "=http://lla-1.germany/gfxcmp/cw.php?inifile=" + ls);
+ m_aOut.write("; Please check the documentation if you got confused." + ls);
+ m_aOut.write("; " + ls);
+ m_aOut.write("; " + ls);
+ }
+ catch (java.io.IOException e)
+ {
+ }
+ }
+
+ public void writeSection(String _sSectionName)
+ {
+ try
+ {
+ m_aOut.write("[" + _sSectionName + "]" + ls);
+ m_aOut.flush();
+ }
+ catch (java.io.IOException e)
+ {
+ }
+ }
+
+ public void writeValue(String _sName, String _sValue)
+ {
+ try
+ {
+ m_aOut.write(_sName + "=" + _sValue + ls);
+ m_aOut.flush();
+ }
+ catch (java.io.IOException e)
+ {
+ }
+ }
+
+ public void startSection(int _nNumber)
+ {
+ writeSection( "page" + String.valueOf(_nNumber));
+ }
+
+ public void close()
+ {
+ try
+ {
+ m_aOut.flush();
+ m_aOut.close();
+ }
+ catch (java.io.IOException e)
+ {
+ }
+ }
+
+ public void checkLine(StatusHelper _aStatus, boolean _bCurrentResult)
+ {
+ try
+ {
+ m_aOut.write( "oldgfx=" + _aStatus.m_sOldGfx + ls);
+ m_aOut.write( "newgfx=" + _aStatus.m_sNewGfx + ls);
+ m_aOut.write( "diffgfx=" + _aStatus.m_sDiffGfx + ls);
+
+ String sPercent = String.valueOf(_aStatus.nPercent) + "%";
+ if (_aStatus.nPercent > 0 && _aStatus.nPercent < 5)
+ {
+ sPercent += " (less 5% is ok)";
+ }
+ m_aOut.write("percent=" + sPercent + ls);
+
+ if (_aStatus.m_sDiff_BM_Gfx == null)
+ {
+ m_aOut.write("BM=false" + ls);
+ }
+ else
+ {
+ m_aOut.write("BM=true" + ls);
+ m_aOut.write( "old_BM_gfx=" + _aStatus.m_sOld_BM_Gfx + ls);
+ m_aOut.write( "new_BM_gfx=" + _aStatus.m_sNew_BM_Gfx + ls);
+ m_aOut.write( "diff_BM_gfx=" + _aStatus.m_sDiff_BM_Gfx + ls);
+
+ String sPercent2 = String.valueOf(_aStatus.nPercent2) + "%";
+ if (_aStatus.nPercent2 > 0 && _aStatus.nPercent2 < 5)
+ {
+ sPercent2 += " (less 5% is ok)";
+ }
+ m_aOut.write("percent2=" + sPercent2 + ls);
+ }
+
+ writeResult(_bCurrentResult);
+ m_aOut.flush();
+ }
+ catch (java.io.IOException e)
+ {
+ }
+ }
+
+ void writeResult(boolean _bCurrentResult) throws java.io.IOException
+ {
+ // is the check positiv, in a defined range
+ if (_bCurrentResult)
+ {
+ m_aOut.write("result=YES" + ls);
+ }
+ else
+ {
+ m_aOut.write("result=NO" + ls);
+ }
+ }
+
+ public void checkDiffDiffLine(StatusHelper _aStatus, boolean _bCurrentResult)
+ {
+ try
+ {
+ m_aOut.write( "oldgfx=" + _aStatus.m_sOldGfx + ls);
+ m_aOut.write( "newgfx=" + _aStatus.m_sNewGfx + ls);
+ m_aOut.write( "diffgfx=" + _aStatus.m_sDiffGfx + ls);
+
+ String sPercent = String.valueOf(_aStatus.nPercent) + "%";
+ // if (_aStatus.nPercent > 0 && _aStatus.nPercent < 5)
+ // {
+ // sPercent += " (less 5% is ok)";
+ // }
+ m_aOut.write("percent=" + sPercent + ls);
+
+ // is the check positiv, in a defined range
+ writeResult(_bCurrentResult);
+ m_aOut.flush();
+ }
+ catch (java.io.IOException e)
+ {
+ }
+ }
+
+}
diff --git a/qadevOOo/runner/convwatch/ImageHelper.java b/qadevOOo/runner/convwatch/ImageHelper.java
new file mode 100644
index 000000000000..6eec5dee6b63
--- /dev/null
+++ b/qadevOOo/runner/convwatch/ImageHelper.java
@@ -0,0 +1,116 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package convwatch;
+
+import java.awt.Image;
+import java.awt.image.PixelGrabber;
+import java.awt.image.ImageObserver;
+import java.io.File;
+//import javax.imageio.ImageIO;
+import java.lang.reflect.Method;
+
+class ImageHelper
+{
+ Image m_aImage;
+ int[] m_aPixels;
+ int m_w = 0;
+ int m_h = 0;
+ boolean m_bGrabbed = false;
+
+ public ImageHelper(Image _aImage)
+ {
+ m_aImage = _aImage;
+
+ // grab all (consume much memory)
+ m_w = getWidth();
+ m_h = getHeight();
+ int x = 0;
+ int y = 0;
+ m_aPixels = new int[m_w * m_h];
+ PixelGrabber pg = new PixelGrabber(m_aImage, x, y, m_w, m_h, m_aPixels, 0, m_w);
+ try {
+ pg.grabPixels();
+ } catch (InterruptedException e) {
+ System.err.println("interrupted waiting for pixels!");
+ return;
+ }
+ if ((pg.getStatus() & ImageObserver.ABORT) != 0) {
+ System.err.println("image fetch aborted or errored");
+ return;
+ }
+ m_bGrabbed = true;
+ }
+ public int getWidth() {return m_aImage.getWidth(null);}
+ public int getHeight() {return m_aImage.getHeight(null);}
+ // direct access to a pixel
+ public int getPixel(int x, int y)
+ {
+ return m_aPixels[y * m_w + x];
+ }
+
+ // Write down the current image to a file.
+ // public void storeImage(String _sFilename)
+ // {
+ // }
+
+ public static ImageHelper createImageHelper(String _sFilename)
+ throws java.io.IOException
+ {
+ Image aImage = null;
+ File aFile = new File(_sFilename);
+ Exception ex = null;
+ try {
+ Class imageIOClass = Class.forName("javax.imageio.ImageIO");
+ Method readMethod = imageIOClass.getDeclaredMethod("read", new Class[]{java.io.File.class});
+ Object retValue = readMethod.invoke(imageIOClass, new Object[]{aFile});
+ aImage = (Image)retValue;
+ }
+ catch(java.lang.ClassNotFoundException e) {
+ ex = e;
+ }
+ catch(java.lang.NoSuchMethodException e) {
+ ex = e;
+ }
+ catch(java.lang.IllegalAccessException e) {
+ ex = e;
+ }
+ catch(java.lang.reflect.InvocationTargetException e) {
+ ex = e;
+ }
+
+ if (ex != null) {
+ // get Java version:
+ String javaVersion = System.getProperty("java.version");
+ throw new java.io.IOException(
+ "Cannot construct object with current Java version " +
+ javaVersion + ": " + ex.getMessage());
+ }
+// aImage = ImageIO.read(aFile);
+ return new ImageHelper(aImage);
+ }
+}
diff --git a/qadevOOo/runner/convwatch/IniFile.java b/qadevOOo/runner/convwatch/IniFile.java
new file mode 100644
index 000000000000..fbcaaea0b33b
--- /dev/null
+++ b/qadevOOo/runner/convwatch/IniFile.java
@@ -0,0 +1,452 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package convwatch;
+
+import java.io.File;
+import java.io.RandomAccessFile;
+import java.util.ArrayList;
+
+/**
+ Helper class to give a simple API to read/write windows like ini files
+ */
+/* public */ // is only need, if we need this class outside package convwatch
+class IniFile
+{
+ /**
+ * internal representation of the ini file content.
+ * Problem, if ini file changed why other write something difference, we don't realise this.
+ */
+ String m_sFilename;
+ ArrayList m_aList;
+ boolean m_bListContainUnsavedChanges = false;
+
+ /**
+ open a ini file by it's name
+ @param _sFilename string a filename, if the file doesn't exist, a new empty ini file will create.
+ write back to disk only if there are really changes.
+ */
+ public IniFile(String _sFilename)
+ {
+ m_sFilename = _sFilename;
+ m_aList = loadLines();
+ }
+
+ ArrayList loadLines()
+ {
+ File aFile = new File(m_sFilename);
+ ArrayList aLines = new ArrayList();
+ if (! aFile.exists())
+ {
+ GlobalLogWriter.get().println("couldn't find file " + m_sFilename);
+ // DebugHelper.exception(BasicErrorCode.SbERR_FILE_NOT_FOUND, "");
+ // m_bListContainUnsavedChanges = false;
+ return aLines;
+ }
+ RandomAccessFile aReader = null;
+ try
+ {
+ aReader = new RandomAccessFile(aFile,"r");
+ String aLine = "";
+ while (aLine != null)
+ {
+ aLine = aReader.readLine();
+ if (aLine != null)
+ {
+ aLines.add(aLine);
+ }
+ }
+ }
+ catch (java.io.FileNotFoundException fne)
+ {
+ GlobalLogWriter.get().println("couldn't open file " + m_sFilename);
+ GlobalLogWriter.get().println("Message: " + fne.getMessage());
+ // DebugHelper.exception(BasicErrorCode.SbERR_FILE_NOT_FOUND, "");
+ }
+ catch (java.io.IOException ie)
+ {
+ GlobalLogWriter.get().println("Exception occurs while reading from file " + m_sFilename);
+ GlobalLogWriter.get().println("Message: " + ie.getMessage());
+ // DebugHelper.exception(BasicErrorCode.SbERR_INTERNAL_ERROR, ie.getMessage());
+ }
+ try
+ {
+ aReader.close();
+ }
+ catch (java.io.IOException ie)
+ {
+ GlobalLogWriter.get().println("Couldn't close file " + m_sFilename);
+ GlobalLogWriter.get().println("Message: " + ie.getMessage());
+ // DebugHelper.exception(BasicErrorCode.SbERR_INTERNAL_ERROR, ie.getMessage());
+ }
+ return aLines;
+ }
+
+ /**
+ * @return true, if the ini file contain some readable data
+ */
+ public boolean is()
+ {
+ return m_aList.size() > 1 ? true : false;
+ }
+
+ // -----------------------------------------------------------------------------
+
+ boolean isRemark(String _sLine)
+ {
+ if ( ((_sLine.length() < 2) ) ||
+ ( _sLine.startsWith("#")) ||
+ ( _sLine.startsWith(";")) )
+ {
+ return true;
+ }
+ return false;
+ }
+
+ String getItem(int i)
+ {
+ return (String)m_aList.get(i);
+ }
+
+ String buildSectionName(String _sSectionName)
+ {
+ String sFindSection = "[" + _sSectionName + "]";
+ return sFindSection;
+ }
+ String toLowerIfNeed(String _sName)
+ {
+ return _sName.toLowerCase();
+ }
+
+ // return the number where this section starts
+ int findSection(String _sSection)
+ {
+ String sFindSection = toLowerIfNeed(buildSectionName(_sSection));
+ // ----------- find _sSection ---------------
+ int i;
+ for (i=0; i<m_aList.size();i++)
+ {
+ String sLine = toLowerIfNeed(getItem(i).trim());
+ if (isRemark(sLine))
+ {
+ continue;
+ }
+ if (sFindSection.equals("[]"))
+ {
+ // special case, empty Section.
+ return i - 1;
+ }
+ if (sLine.startsWith(sFindSection))
+ {
+ return i;
+ }
+ }
+ return -1;
+ }
+
+ // return the line number, where the key is found.
+ int findKey(String _sSection, String _sKey)
+ {
+ int i = findSection(_sSection);
+ if (i == -1)
+ {
+ // Section not found, therefore the value can't exist
+ return -1;
+ }
+ return findKeyFromKnownSection(i, _sKey);
+ }
+
+ // i must be the index in the list, where the well known section starts
+ int findKeyFromKnownSection(int _nSectionIndex, String _sKey)
+ {
+ _sKey = toLowerIfNeed(_sKey);
+ for (int j=_nSectionIndex + 1; j<m_aList.size();j++)
+ {
+ String sLine = getItem(j).trim();
+
+ if (isRemark(sLine))
+ {
+ continue;
+ }
+
+ if (sLine.startsWith("[") /* && sLine.endsWith("]") */)
+ {
+ // found end.
+ break;
+ }
+
+ int nEqual = sLine.indexOf("=");
+ if (nEqual >= 0)
+ {
+ String sKey = toLowerIfNeed(sLine.substring(0, nEqual).trim());
+ if (sKey.equals(_sKey))
+ {
+ return j;
+ }
+ }
+ }
+ return -1;
+ }
+
+ // i must be the index in the list, where the well known section starts
+ int findLastKnownKeyIndex(int _nSectionIndex, String _sKey)
+ {
+ _sKey = toLowerIfNeed(_sKey);
+ int i = _nSectionIndex + 1;
+ for (int j=i; j<m_aList.size();j++)
+ {
+ String sLine = getItem(j).trim();
+
+ if (isRemark(sLine))
+ {
+ continue;
+ }
+
+ if (sLine.startsWith("[") /* && sLine.endsWith("]") */)
+ {
+ // found end.
+ return j;
+ }
+
+ int nEqual = sLine.indexOf("=");
+ if (nEqual >= 0)
+ {
+ String sKey = toLowerIfNeed(sLine.substring(0, nEqual).trim());
+ if (sKey.equals(_sKey))
+ {
+ return j;
+ }
+ }
+ }
+ return i;
+ }
+
+ String getValue(int _nIndex)
+ {
+ String sLine = getItem(_nIndex).trim();
+ if (isRemark(sLine))
+ {
+ return "";
+ }
+ int nEqual = sLine.indexOf("=");
+ if (nEqual >= 0)
+ {
+ String sKey = sLine.substring(0, nEqual).trim();
+ String sValue = sLine.substring(nEqual + 1).trim();
+ return sValue;
+ }
+ return "";
+ }
+
+ /**
+ @param _sSection string
+ @param _sKey string
+ @return the value found in the inifile which is given by the section and key parameter
+ */
+ public String getValue(String _sSection, String _sKey)
+ {
+ String sValue = "";
+ int i = findKey(_sSection, _sKey);
+ if (i == -1)
+ {
+ // Section not found, therefore the value can't exist
+ return "";
+ }
+
+ sValue = getValue(i);
+
+ return sValue;
+ }
+
+ /**
+ write back the ini file to the disk, only if there exist changes
+ */
+ public void store()
+ {
+ if (m_bListContainUnsavedChanges == false)
+ {
+ // nothing has changed, so no need to store
+ return;
+ }
+
+ File aFile = new File(m_sFilename);
+ if (aFile.exists())
+ {
+ // System.out.println("couldn't find file " + m_sFilename);
+ aFile.delete();
+ if (aFile.exists())
+ {
+ GlobalLogWriter.get().println("Couldn't delete the file " + m_sFilename);
+ return;
+ // DebugHelper.exception(BasicErrorCode.SbERR_INTERNAL_ERROR, "Couldn't delete the file " + m_sFilename);
+ }
+ }
+ // if (! aFile.canWrite())
+ // {
+ // System.out.println("Couldn't write to file " + m_sFilename);
+ // DebugHelper.exception(BasicErrorCode.SbERR_INTERNAL_ERROR, "");
+ // }
+ try
+ {
+ RandomAccessFile aWriter = new RandomAccessFile(aFile, "rw");
+ for (int i=0; i<m_aList.size();i++)
+ {
+ String sLine = getItem(i);
+ aWriter.writeBytes(sLine);
+ aWriter.writeByte((int)'\n');
+ }
+ aWriter.close();
+ }
+
+ catch (java.io.FileNotFoundException fne)
+ {
+ GlobalLogWriter.get().println("couldn't open file for writing " + m_sFilename);
+ GlobalLogWriter.get().println("Message: " + fne.getMessage());
+ // DebugHelper.exception(BasicErrorCode.SbERR_FILE_NOT_FOUND, "");
+ }
+ catch(java.io.IOException ie)
+ {
+ GlobalLogWriter.get().println("Exception occurs while writing to file " + m_sFilename);
+ GlobalLogWriter.get().println("Message: " + ie.getMessage());
+ // DebugHelper.exception(BasicErrorCode.SbERR_INTERNAL_ERROR, ie.getMessage());
+ }
+ }
+
+
+
+ /**
+ insert a value
+ there are 3 cases
+ 1. section doesn't exist, goto end and insert a new section, insert a new key value pair
+ 2. section exist but key not, search section, search key, if key is -1 get last known key position and insert new key value pair there
+ 3. section exist and key exist, remove the old key and insert the key value pair at the same position
+ */
+ public void insertValue(String _sSection, String _sKey, String _sValue)
+ {
+ int i = findSection(_sSection);
+ if (i == -1)
+ {
+ // case 1: section doesn't exist
+ String sFindSection = buildSectionName(_sSection);
+
+ m_aList.add(sFindSection);
+ String sKeyValuePair = _sKey + "=" + _sValue;
+ m_aList.add(sKeyValuePair);
+ m_bListContainUnsavedChanges = true;
+ return;
+ }
+ int j = findKeyFromKnownSection(i, _sKey);
+ if (j == -1)
+ {
+ // case 2: section exist, but not the key
+ j = findLastKnownKeyIndex(i, _sKey);
+ String sKeyValuePair = _sKey + "=" + _sValue;
+ m_aList.add(j, sKeyValuePair);
+ m_bListContainUnsavedChanges = true;
+ return;
+ }
+ else
+ {
+ // case 3: section exist, and also the key
+ String sKeyValuePair = _sKey + "=" + _sValue;
+ m_aList.set(j, sKeyValuePair);
+ m_bListContainUnsavedChanges = true;
+ }
+ }
+ // -----------------------------------------------------------------------------
+ // String replaceEvaluatedValue(String _sSection, String _sValue)
+ // {
+ // String sValue = _sValue;
+ // int nIndex = 0;
+ // while (( nIndex = sValue.indexOf("$(", nIndex)) >= 0)
+ // {
+ // int nNextIndex = sValue.indexOf(")", nIndex);
+ // if (nNextIndex >= 0)
+ // {
+ // String sKey = sValue.substring(nIndex + 2, nNextIndex);
+ // String sNewValue = getValue(_sSection, sKey);
+ // if (sNewValue != null && sNewValue.length() > 0)
+ // {
+ // String sRegexpKey = "\\$\\(" + sKey + "\\)";
+ // sValue = sValue.replaceAll(sRegexpKey, sNewValue);
+ // }
+ // nIndex = nNextIndex;
+ // }
+ // else
+ // {
+ // nIndex += 2;
+ // }
+ // }
+ // return sValue;
+ // }
+ // -----------------------------------------------------------------------------
+
+ // public String getLocalEvaluatedValue(String _sSection, String _sKey)
+ // {
+ // String sValue = getValue(_sSection, _sKey);
+ // sValue = replaceEvaluatedValue(_sSection, sValue);
+ // return sValue;
+ // }
+
+ // -----------------------------------------------------------------------------
+
+ // this is a special behaviour.
+ // public String getGlobalLocalEvaluatedValue(String _sSection, String _sKey)
+ // {
+ // String sGlobalValue = getKey("global", _sKey);
+ // String sLocalValue = getKey(_sSection, _sKey);
+ // if (sLocalValue.length() == 0)
+ // {
+ // sGlobalValue = replaceEvaluatedKey(_sSection, sGlobalValue);
+ // sGlobalValue = replaceEvaluatedKey("global", sGlobalValue);
+ // return sGlobalValue;
+ // }
+ // sLocalValue = replaceEvaluatedKey(_sSection, sLocalValue);
+ // sLocalValue = replaceEvaluatedKey("global", sLocalValue);
+ //
+ // return sLocalValue;
+ // }
+
+
+ /**
+ * some tests for this class
+ */
+// public static void main(String[] args)
+// {
+// IniFile aIniFile = new IniFile("/tmp/inifile");
+// String sValue = aIniFile.getValue("Section","Key");
+// // insert a new value to a already exist section
+// aIniFile.insertValue("Section","Key2","a new value in a existing section");
+// // replace a value
+// aIniFile.insertValue("Section","Key","replaced value");
+// // create a new value
+// aIniFile.insertValue("New Section", "Key", "a new key value pair");
+//
+// String sValue2 = aIniFile.getValue("Section2","Key");
+// aIniFile.store();
+// }
+}
diff --git a/qadevOOo/runner/convwatch/LISTOutputter.java b/qadevOOo/runner/convwatch/LISTOutputter.java
new file mode 100644
index 000000000000..87c13ea0477a
--- /dev/null
+++ b/qadevOOo/runner/convwatch/LISTOutputter.java
@@ -0,0 +1,104 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package convwatch;
+
+import java.io.File;
+import java.io.FileWriter;
+
+public class LISTOutputter
+{
+ FileWriter m_aOut;
+ String m_sFilename;
+
+ /**
+ * ls is the current line separator (carridge return)
+ */
+ String ls;
+
+ public static LISTOutputter create( String _sOutputPath, String _sFilename)
+ {
+ FileHelper.makeDirectories("", _sOutputPath);
+ LISTOutputter a = new LISTOutputter();
+ String fs = System.getProperty("file.separator");
+ String sFilename = _sOutputPath + fs + _sFilename;
+
+ try
+ {
+ File outputFile = new File(sFilename);
+ a.m_aOut = new FileWriter(outputFile.toString());
+ a.ls = System.getProperty("line.separator");
+ }
+ catch (java.io.IOException e)
+ {
+ e.printStackTrace();
+ GlobalLogWriter.get().println("ERROR: Can't create LIST Outputter");
+ return null;
+ }
+ a.m_sFilename = sFilename;
+
+ return a;
+ }
+ public String getFilename() {return m_sFilename;}
+
+ public void createHeader()
+ {
+ try
+ {
+ m_aOut.write("# This file is automatically created by a convwatch run" + ls);
+ m_aOut.write("# " + ls);
+ }
+ catch (java.io.IOException e)
+ {
+ }
+ }
+
+ public void writeValue(String _sValue)
+ {
+ try
+ {
+ m_aOut.write(_sValue + ls);
+ m_aOut.flush();
+ }
+ catch (java.io.IOException e)
+ {
+ }
+ }
+
+ public void close()
+ {
+ try
+ {
+ m_aOut.flush();
+ m_aOut.close();
+ }
+ catch (java.io.IOException e)
+ {
+ }
+ }
+
+}
diff --git a/qadevOOo/runner/convwatch/MSOfficePrint.java b/qadevOOo/runner/convwatch/MSOfficePrint.java
new file mode 100644
index 000000000000..5be0cfe058ce
--- /dev/null
+++ b/qadevOOo/runner/convwatch/MSOfficePrint.java
@@ -0,0 +1,870 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package convwatch;
+
+import convwatch.FileHelper;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.RandomAccessFile;
+import convwatch.GraphicalTestArguments;
+import helper.ProcessHandler;
+import java.util.ArrayList;
+import helper.OSHelper;
+
+/**
+ * This object gives all functionallity to print msoffice documents.
+ * It also offers functions to check what type of document it is.
+ * It handles *.doc as word documents and use word to print
+ * *.xls as excel
+ * *.ppt as powerpoint
+ */
+
+class ProcessHelper
+{
+ ArrayList m_aArray;
+}
+
+public class MSOfficePrint
+{
+ private String m_sPrinterName; // within Windows the tools need a printer name;
+
+ public void setPrinterName(String _s) {m_sPrinterName = _s;}
+
+ // -----------------------------------------------------------------------------
+ static boolean isWordDocument(String _sSuffix)
+ {
+ if (_sSuffix.toLowerCase().endsWith(".doc") ||
+ _sSuffix.toLowerCase().endsWith(".rtf") ||
+ _sSuffix.toLowerCase().endsWith(".dot"))
+ {
+ return true;
+ }
+ return false;
+ }
+
+ static boolean isExcelDocument(String _sSuffix)
+ {
+ // xlt templates
+ // xlw
+ // xla addin
+ if (_sSuffix.toLowerCase().endsWith(".xls"))
+ {
+ return true;
+ }
+ /* temporal insertion by SUS
+ if (_sSuffix.endsWith(".xml"))
+ {
+ return true;
+ }*/
+ return false;
+ }
+
+ static boolean isPowerPointDocument(String _sSuffix)
+ {
+ if (_sSuffix.toLowerCase().endsWith(".pps") ||
+ _sSuffix.toLowerCase().endsWith(".ppt"))
+ {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * returns true, if the given filename has a MS Office suffix.
+ */
+ public static boolean isMSOfficeDocumentFormat(String _sFile)
+ {
+ String sDocumentSuffix = FileHelper.getSuffix(_sFile);
+ if (isWordDocument(sDocumentSuffix)) return true;
+ if (isExcelDocument(sDocumentSuffix)) return true;
+ if (isPowerPointDocument(sDocumentSuffix)) return true;
+ // if suffix is xml, return also true, but we can't decide if word or excel
+ if (sDocumentSuffix.toLowerCase().endsWith(".xml")) return true;
+ return false;
+ }
+
+ public void storeToFileWithMSOffice( GraphicalTestArguments _aGTA,
+ String _sInputFile,
+ String _sOutputFile) throws ConvWatchCancelException, java.io.IOException
+ {
+ String sDocumentSuffix = FileHelper.getSuffix(_sInputFile);
+ String sFilterName = _aGTA.getExportFilterName();
+ ArrayList aStartCommand = new ArrayList();
+ if (isWordDocument(sDocumentSuffix))
+ {
+ aStartCommand = createWordStoreHelper();
+ }
+ else if (isExcelDocument(sDocumentSuffix))
+ {
+ aStartCommand = createExcelStoreHelper();
+ }
+ else if (isPowerPointDocument(sDocumentSuffix))
+ {
+ }
+ else if (sDocumentSuffix.toLowerCase().equals(".xml"))
+ {
+ // special case, if xml we prefer word, but with DEFAULT_XML_FORMAT_APP=excel it's changeable.
+ if (_aGTA.getDefaultXMLFormatApp().toLowerCase().equals("excel"))
+ {
+ aStartCommand = createExcelStoreHelper();
+ }
+ // else
+ // {
+ // }
+ }
+ else
+ {
+ GlobalLogWriter.get().println("No Microsoft Office document format found.");
+// TODO: use a better Exception!!!
+ throw new ConvWatchCancelException/*WrongSuffixException*/("No MS office document format found.");
+ }
+ if (aStartCommand != null)
+ {
+ if (sFilterName == null)
+ {
+// TODO: hardcoded FilterName in perl script
+ sFilterName = ""; // xlXMLSpreadsheet";
+ }
+
+ // String sCommand = sStartCommand + " " +
+ // _sInputFile + " " +
+ // StringHelper.doubleQuote(sFilterName) + " " +
+ // _sOutputFile;
+
+ aStartCommand.add(_sInputFile);
+ aStartCommand.add(sFilterName);
+ aStartCommand.add(_sOutputFile);
+ realStartCommand(aStartCommand);
+ }
+ }
+
+ // -----------------------------------------------------------------------------
+ /**
+ * print the given file (_sInputFile) to the file name (_sPrintFile)
+ */
+ public void printToFileWithMSOffice( GraphicalTestArguments _aGTA,
+ String _sInputFile,
+ String _sPrintFilename) throws ConvWatchCancelException, java.io.IOException
+ {
+ String sDocumentSuffix = FileHelper.getSuffix(_sInputFile);
+
+ setPrinterName(_aGTA.getPrinterName());
+
+ ArrayList aStartCommand = new ArrayList();
+ if (isWordDocument(sDocumentSuffix))
+ {
+ aStartCommand = createWordPrintHelper();
+ }
+ else if (isExcelDocument(sDocumentSuffix))
+ {
+ aStartCommand = createExcelPrintHelper();
+ }
+ else if (isPowerPointDocument(sDocumentSuffix))
+ {
+ aStartCommand = createPowerPointPrintHelper();
+ }
+ else if (sDocumentSuffix.toLowerCase().equals(".xml"))
+ {
+// TODO: Open XML File and check if we need excel or word
+ String sOfficeType = getOfficeType(_sInputFile);
+
+ // special case, if xml we prefer word, but with DEFAULT_XML_FORMAT_APP=excel it's changeable.
+ // if (_aGTA.getDefaultXMLFormatApp().toLowerCase().equals("excel"))
+ if (sOfficeType.equals("excel"))
+ {
+ aStartCommand = createExcelPrintHelper();
+ }
+ else if (sOfficeType.equals("word"))
+ {
+ aStartCommand = createWordPrintHelper();
+ }
+ else
+ {
+ return;
+ }
+ }
+ else
+ {
+ GlobalLogWriter.get().println("No Microsoft Office document format found.");
+// TODO: use a better Exception!!!
+ throw new ConvWatchCancelException/*WrongSuffixException*/("No Mircosoft Office document format found.");
+ }
+
+ if (aStartCommand.isEmpty() == false)
+ {
+ String sPrinterName = m_sPrinterName;
+ if (sPrinterName == null)
+ {
+ sPrinterName = "";
+ }
+
+ // String sCommand = sStartCommand + " " +
+ // _sInputFile + " " +
+ // StringHelper.doubleQuote(m_sPrinterName) + " " +
+ // _sPrintFilename;
+ aStartCommand.add(_sInputFile);
+ aStartCommand.add(m_sPrinterName);
+ aStartCommand.add(_sPrintFilename);
+
+ realStartCommand(aStartCommand);
+ }
+ String sUserDir = System.getProperty("user.home");
+ String fs = System.getProperty("file.separator");
+ if (! sUserDir.endsWith(fs))
+ {
+ sUserDir = sUserDir + fs;
+ }
+ _aGTA.getPerformance().readWordValuesFromFile(sUserDir + "msofficeloadtimes.txt");
+ OfficePrint.createInfoFile(_sPrintFilename, _aGTA, "msoffice");
+ TimeHelper.waitInSeconds(2, "Give Microsoft Office some time to print.");
+ }
+
+ public void realStartCommand(ArrayList _aStartCommand) throws ConvWatchCancelException
+ {
+ if (_aStartCommand.isEmpty())
+ {
+ throw new ConvWatchCancelException/*WrongEnvironmentException*/("Given list is empty.");
+ }
+
+ try
+ {
+ // Convert the StartCommand ArrayList to a String List
+ int nValues = _aStartCommand.size();
+ String[] aList = new String[nValues];
+ for (int i=0;i<nValues;i++)
+ {
+ String aStr = (String) _aStartCommand.get(i);
+ if (aStr == null)
+ {
+ aStr = "";
+ }
+ if (aStr.length() == 0)
+ {
+ aStr = "\"\"";
+ }
+ aList[i] = new String(aStr);
+ }
+
+ // This is really the latest point where we can check if we are running within windows environment
+ if (! OSHelper.isWindows())
+ {
+ // TODO: use a better Exception!!!
+ throw new ConvWatchCancelException/*WrongEnvironmentException*/("We doesn't work within windows environment.");
+ }
+
+
+ ProcessHandler aHandler = new ProcessHandler(aList);
+ boolean bBackValue = aHandler.executeSynchronously();
+ }
+ catch (IndexOutOfBoundsException e)
+ {
+ throw new ConvWatchCancelException/*WrongEnvironmentException*/("Given list is too short.");
+ }
+
+ // return aHandler.getExitCode();
+ }
+
+
+ ArrayList createWordPrintHelper() throws java.io.IOException
+ {
+ // create a program in tmp file
+ String sTmpPath = util.utils.getUsersTempDir();
+ String ls = System.getProperty("line.separator");
+ String fs = System.getProperty("file.separator");
+
+ String sPrintViaWord = "printViaWord.pl";
+
+ ArrayList aList = searchLocalFile(sPrintViaWord);
+ if (aList.isEmpty() == false)
+ {
+ return aList;
+ }
+
+ String sName = sTmpPath + fs + sPrintViaWord;
+ File aFile = new File(sName);
+ FileWriter out = new FileWriter(aFile.toString());
+
+
+ out.write( "eval 'exec perl -wS $0 ${1+\"$@\"}' " + ls );
+ out.write( " if 0; " + ls );
+ out.write( "use strict; " + ls );
+ out.write( "use Time::HiRes; " + ls );
+ out.write( "if ( $^O ne \"MSWin32\") " + ls );
+ out.write( "{ " + ls );
+ out.write( " print 'Windows only.\\n'; " + ls );
+ out.write( " print_usage(); " + ls );
+ out.write( " exit(1); " + ls );
+ out.write( "} " + ls );
+ out.write( " " + ls );
+ out.write( "use Win32::OLE; " + ls );
+ out.write( "use Win32::OLE::Const 'Microsoft Word'; " + ls );
+ out.write( " " + ls );
+ out.write( "# ------ usage ------ " + ls );
+ out.write( "sub print_usage() " + ls );
+ out.write( "{ " + ls );
+ out.write( " print STDERR \"Usage: word_print.pl <Word file> <name of printer> <output file> .\\n " + ls );
+ out.write( " Please use the same string for the name of the printer as you can find \\n " + ls );
+ out.write( " under Start-Control Panel-Printer and Faxes \\n " + ls );
+ out.write( " The name could look like the the following line: \\n " + ls );
+ out.write( " Apple LaserWriter II NT v47.0 \\n " + ls );
+ out.write( " Sample command line: \\n " + ls );
+ out.write( " execl_print.pl c:\\book1.doc Apple LaserWriter II NT v47.0 c:\\output\\book1.ps \\n\"; " + ls );
+ out.write( "} " + ls );
+ out.write( " " + ls );
+ out.write( " " + ls );
+ out.write( "if ($#ARGV != 2) " + ls );
+ out.write( "{ " + ls );
+ out.write( " print 'Too less arguments.\\n'; " + ls );
+ out.write( " print_usage(); " + ls );
+ out.write( " exit(1); " + ls );
+ out.write( "} " + ls );
+ out.write( " " + ls );
+ out.write( "my $startWordTime = Time::HiRes::time(); " + ls );
+ out.write( "my $Word = Win32::OLE->new('Word.Application'); " + ls );
+ out.write( "my $stopWordTime = Time::HiRes::time() - $startWordTime; " + ls );
+ out.write( "# $Word->{'Visible'} = 1; # if you want to see what's going on " + ls );
+ out.write( "# , ReadOnly => 1})" + ls );
+ out.write(ls);
+ out.write( "my $startLoadWordTime = Time::HiRes::time(); " + ls );
+ out.write( "$Word->Documents->Open({Filename => $ARGV[0]}) " + ls );
+ out.write( " || die('Unable to open document ', Win32::OLE->LastError()); " + ls );
+ out.write( "my $stopLoadWordTime = Time::HiRes::time() - $startLoadWordTime; " + ls );
+ out.write(ls);
+ out.write( "my $startPrintWordTime = Time::HiRes::time(); " + ls);
+ out.write( "my $oldActivePrinte = $Word->{ActivePrinter} ; " + ls );
+ out.write( "$Word->{ActivePrinter} = $ARGV[1]; " + ls );
+ out.write( "$Word->ActiveDocument->PrintOut({ " + ls );
+ out.write( " Background => 0, " + ls );
+ out.write( " Append => 0, " + ls );
+ out.write( " Range => wdPrintAllDocument, " + ls );
+ out.write( " Item => wdPrintDocumentContent, " + ls );
+ out.write( " Copies => 1, " + ls );
+ out.write( " PageType => wdPrintAllPages, " + ls );
+ out.write( " PrintToFile => 1, " + ls );
+ out.write( " OutputFileName => $ARGV[2] " + ls );
+ out.write( " }); " + ls );
+ out.write( "$Word->{ActivePrinter} = $oldActivePrinte; " + ls );
+ out.write( "my $stopPrintWordTime = Time::HiRes::time() - $startPrintWordTime;" + ls);
+
+ out.write( "# ActiveDocument.Close(SaveChanges:=WdSaveOptions.wdDoNotSaveChanges)" + ls );
+ out.write( "my $sVersion = $Word->Application->Version();"+ls);
+ out.write( "$Word->ActiveDocument->Close({SaveChanges => 0}); " + ls );
+ out.write( "$Word->Quit(); " + ls );
+
+ out.write( "local *FILE;" + ls);
+ out.write( "if (open(FILE, \">$ENV{HOME}/msofficeloadtimes.txt\"))" + ls);
+ out.write( "{" + ls);
+ out.write( " print FILE \"name=$ARGV[0]\\n\";" + ls);
+ out.write( " print FILE \"WordVersion=$sVersion\\n\";" + ls);
+ out.write( " print FILE \"WordStartTime=$stopWordTime\\n\";" + ls);
+ out.write( " print FILE \"WordLoadTime=$stopLoadWordTime\\n\";" + ls);
+ out.write( " print FILE \"WordPrintTime=$stopPrintWordTime\\n\";" + ls);
+ out.write( " close(FILE);" + ls);
+ out.write( "}" + ls);
+ out.close();
+
+ aList.add("perl");
+ aList.add(sName);
+ return aList;
+ }
+
+ // TODO: Maybe give a possibility to say where search the script from outside
+
+ ArrayList searchLocalFile(String _sScriptName)
+ {
+ String userdir = System.getProperty("user.dir");
+ String fs = System.getProperty("file.separator");
+
+ ArrayList aList = new ArrayList();
+ File aPerlScript = new File(userdir + fs + _sScriptName);
+ if (FileHelper.isDebugEnabled())
+ {
+ GlobalLogWriter.get().println("Search for local existance of " + aPerlScript.getAbsolutePath());
+ }
+
+ if (aPerlScript.exists())
+ {
+ if (FileHelper.isDebugEnabled())
+ {
+ GlobalLogWriter.get().println("OK, found it, use this instead the internal one.");
+ }
+
+ String sName = aPerlScript.getAbsolutePath();
+ // String sCommand = "perl " + sName;
+ // System.out.println(sCommand);
+ aList.add("perl");
+ aList.add(sName);
+ return aList;
+ }
+ return aList;
+ }
+
+ ArrayList createWordStoreHelper() throws java.io.IOException
+ {
+ // create a program in tmp file
+ String sTmpPath = util.utils.getUsersTempDir();
+ String ls = System.getProperty("line.separator");
+ String fs = System.getProperty("file.separator");
+
+ // ArrayList aList = new ArrayList();
+ String sSaveViaWord = "saveViaWord.pl";
+
+ ArrayList aList = searchLocalFile(sSaveViaWord);
+ if (aList.isEmpty() == false)
+ {
+ return aList;
+ }
+
+ String sName = sTmpPath + fs + sSaveViaWord;
+ if (FileHelper.isDebugEnabled())
+ {
+ GlobalLogWriter.get().println("No local found, create a perl script: " + sName);
+ }
+
+ File aFile = new File(sName);
+ FileWriter out = new FileWriter(aFile.toString());
+
+ out.write( "eval 'exec perl -wS $0 ${1+\"$@\"}' " + ls );
+ out.write( " if 0; " + ls );
+ out.write( "use strict; " + ls );
+ out.write( " " + ls );
+ out.write( "if ( $^O ne \"MSWin32\") " + ls );
+ out.write( "{ " + ls );
+ out.write( " print 'Windows only.\\n'; " + ls );
+ out.write( " print_usage(); " + ls );
+ out.write( " exit(1); " + ls );
+ out.write( "} " + ls );
+ out.write( " " + ls );
+ out.write( "use Win32::OLE; " + ls );
+ out.write( "use Win32::OLE::Const 'Microsoft Word'; " + ls );
+ out.write( " " + ls );
+ out.write( "# ------ usage ------ " + ls );
+ out.write( "sub print_usage() " + ls );
+ out.write( "{ " + ls );
+ out.write( " print STDERR \"Usage: storeViaWord.pl <Word file> <output filer> <output file> \\n\" " + ls );
+ out.write( "} " + ls );
+ out.write( " " + ls );
+ out.write( " " + ls );
+ out.write( "if ($#ARGV != 2) " + ls );
+ out.write( "{ " + ls );
+ out.write( " print 'Too less arguments.\\n'; " + ls );
+ out.write( " print_usage(); " + ls );
+ out.write( " exit(1); " + ls );
+ out.write( "} " + ls );
+ out.write( " " + ls );
+ out.write( " " + ls );
+ out.write( "my $Word = Win32::OLE->new('Word.Application'); " + ls );
+ out.write( "# $Word->{'Visible'} = 1; # if you want to see what's going on " + ls );
+ out.write( "my $Book = $Word->Documents->Open($ARGV[0]) " + ls );
+ out.write( " || die('Unable to open document ', Win32::OLE->LastError()); " + ls );
+ out.write( "# my $oldActivePrinte = $Word->{ActivePrinter} ; " + ls );
+ out.write( "# $Word->{ActivePrinter} = $ARGV[1]; " + ls );
+ out.write( "# $Word->ActiveDocument->PrintOut({ " + ls );
+ out.write( "# Background => 0, " + ls );
+ out.write( "# Append => 0, " + ls );
+ out.write( "# Range => wdPrintAllDocument, " + ls );
+ out.write( "# Item => wdPrintDocumentContent, " + ls );
+ out.write( "# Copies => 1, " + ls );
+ out.write( "# PageType => wdPrintAllPages, " + ls );
+ out.write( "# PrintToFile => 1, " + ls );
+ out.write( "# OutputFileName => $ARGV[2] " + ls );
+ out.write( "# }); " + ls );
+ out.write( "# $Word->{ActivePrinter} = $oldActivePrinte; " + ls );
+ out.write( "$Book->savaAs($ARGV[2], $ARGV[1]); " + ls );
+ out.write( "# ActiveDocument.Close(SaveChanges:=WdSaveOptions.wdDoNotSaveChanges)" + ls );
+ out.write( "$Book->Close({SaveChanges => 0}); " + ls );
+ out.write( "$Word->Quit(); " + ls );
+ out.close();
+
+ aList.add("perl");
+ aList.add(sName);
+ return aList;
+ }
+
+
+ ArrayList createExcelPrintHelper() throws java.io.IOException
+ {
+ // create a program in tmp file
+ String sTmpPath = util.utils.getUsersTempDir();
+ String ls = System.getProperty("line.separator");
+ String fs = System.getProperty("file.separator");
+
+ String sPrintViaExcel = "printViaExcel.pl";
+
+ ArrayList aList = searchLocalFile(sPrintViaExcel);
+ if (aList.isEmpty() == false)
+ {
+ return aList;
+ }
+ String sName = sTmpPath + fs + sPrintViaExcel;
+ if (FileHelper.isDebugEnabled())
+ {
+ GlobalLogWriter.get().println("No local found, create a perl script: " + sName);
+ }
+
+ File aFile = new File(sName);
+ FileWriter out = new FileWriter(aFile.toString());
+
+ out.write( "eval 'exec perl -wS $0 ${1+\"$@\"}' " + ls );
+ out.write( " if 0; " + ls );
+ out.write( "use strict; " + ls );
+ out.write( " " + ls );
+ out.write( "if ( $^O ne \"MSWin32\") " + ls );
+ out.write( "{ " + ls );
+ out.write( " print \"Windows only.\\n\"; " + ls );
+ out.write( " print_usage(); " + ls );
+ out.write( " exit(1); " + ls );
+ out.write( "} " + ls );
+ out.write( " " + ls );
+ out.write( " " + ls );
+ out.write( "use Win32::OLE qw(in with); " + ls );
+ out.write( "use Win32::OLE::Const 'Microsoft Excel'; " + ls );
+ out.write( " " + ls );
+ out.write( "# ------ usage ------ " + ls );
+ out.write( "sub print_usage() " + ls );
+ out.write( "{ " + ls );
+ out.write( " print STDERR \"Usage: printViaExcel.pl <Excel file> <name of printer> <output file> .\\n " + ls );
+ out.write( " Please use the same string for the name of the printer as you can find \\n " + ls );
+ out.write( " under Start-Control Panel-Printer and Faxes \\n " + ls );
+ out.write( " The name could look like the the following line: \\n " + ls );
+ out.write( " Apple LaserWriter II NT v47.0 \\n " + ls );
+ out.write( " Sample command line: \\n " + ls );
+ out.write( " execl_print.pl c:\\book1.xls Apple LaserWriter II NT v47.0 c:\\output\\book1.ps \\n\"; " + ls );
+ out.write( "} " + ls );
+ out.write( " " + ls );
+ out.write( " " + ls );
+ out.write( " " + ls );
+ out.write( "$Win32::OLE::Warn = 3; # die on errors... " + ls );
+ out.write( " " + ls );
+ out.write( " " + ls );
+ out.write( "if ($#ARGV != 2) " + ls );
+ out.write( "{ " + ls );
+ out.write( " print STDERR \"Too less arguments.\\n\"; " + ls );
+ out.write( " print STDERR \"ARGV[0] $ARGV[0]\\n\"; " + ls );
+ out.write( " print STDERR \"ARGV[1] $ARGV[1]\\n\"; " + ls );
+ out.write( " print STDERR \"ARGV[2] $ARGV[2]\\n\"; " + ls );
+ out.write( " print_usage(); " + ls );
+ out.write( " exit(1); " + ls );
+ out.write( "} " + ls );
+ out.write( " " + ls );
+ out.write( "my $Excel = Win32::OLE->GetActiveObject('Excel.Application') " + ls );
+ out.write( " || Win32::OLE->new('Excel.Application', 'Quit'); # get already active Excel " + ls );
+ out.write( " # application or open new " + ls );
+ out.write( " " + ls );
+ out.write( " " + ls );
+ out.write( " " + ls );
+ out.write( "my $Book = $Excel->Workbooks->Open( $ARGV[0] ); " + ls );
+ out.write( " $Book->PrintOut({Copies => 1, " + ls );
+ out.write( " ActivePrinter => $ARGV[1], " + ls );
+ out.write( " PrToFileName => $ARGV[2], " + ls );
+ out.write( " Collate => 1 " + ls );
+ out.write( " }); " + ls );
+ out.write( "# Close worksheets without store changes" + ls );
+ out.write( "# $Book->Close({SaveChanges => 0}); " + ls );
+ out.write( "my $sVersion = $Excel->Application->Version();"+ls);
+ out.write( "$Excel->Quit(); " + ls );
+ out.write( "local *FILE;" + ls);
+ out.write( "if (open(FILE, \">$ENV{HOME}/msofficeloadtimes.txt\"))" + ls);
+ out.write( "{" + ls);
+ out.write( " print FILE \"name=$ARGV[0]\\n\";" + ls);
+ out.write( " print FILE \"ExcelVersion=$sVersion\\n\";" + ls);
+// out.write( " print FILE \"WordStartTime=$stopWordTime\\n\";" + ls);
+// out.write( " print FILE \"WordLoadTime=$stopLoadWordTime\\n\";" + ls);
+// out.write( " print FILE \"WordPrintTime=$stopPrintWordTime\\n\";" + ls);
+ out.write( " close(FILE);" + ls);
+ out.write( "}" + ls);
+ out.close();
+
+ aList.add("perl");
+ aList.add(sName);
+ return aList;
+ }
+
+ ArrayList createExcelStoreHelper() throws java.io.IOException
+ {
+ // create a program in tmp file
+ String sTmpPath = util.utils.getUsersTempDir();
+ String ls = System.getProperty("line.separator");
+ String fs = System.getProperty("file.separator");
+
+ String sSaveViaExcel = "saveViaExcel.pl";
+
+ ArrayList aList = searchLocalFile(sSaveViaExcel);
+ if (aList.isEmpty() == false)
+ {
+ return aList;
+ }
+ String sName = sTmpPath + fs + sSaveViaExcel;
+ if (FileHelper.isDebugEnabled())
+ {
+ GlobalLogWriter.get().println("No local found, create a script: " + sName);
+ }
+
+ File aFile = new File(sName);
+ FileWriter out = new FileWriter(aFile.toString());
+
+ out.write( "eval 'exec perl -wS $0 ${1+\"$@\"}' " + ls );
+ out.write( " if 0; " + ls );
+ out.write( "use strict; " + ls );
+ out.write( "# This script is automatically created. " + ls );
+ out.write( " " + ls );
+ out.write( "use Win32::OLE qw(in with); " + ls );
+ out.write( "use Win32::OLE::Const 'Microsoft Excel'; " + ls );
+ out.write( " " + ls );
+ out.write( "# ------ usage ------ " + ls );
+ out.write( "sub print_usage() " + ls );
+ out.write( "{ " + ls );
+ out.write( " print STDERR \"Usage: savaViaExcel.pl <Excel file> <filefilter> <output file> .\\n " + ls );
+ out.write( " execl_print.pl c:\\book1.xls Apple LaserWriter II NT v47.0 c:\\output\\book1.ps \\n\"; " + ls );
+ out.write( "} " + ls );
+ out.write( " " + ls );
+ out.write( " " + ls );
+ out.write( " " + ls );
+ out.write( "$Win32::OLE::Warn = 3; # die on errors... " + ls );
+ out.write( " " + ls );
+ out.write( " " + ls );
+ out.write( "if ($#ARGV != 2) " + ls );
+ out.write( "{ " + ls );
+ out.write( " print \"Too less arguments.\\n\"; " + ls );
+ out.write( " print_usage(); " + ls );
+ out.write( " exit(1); " + ls );
+ out.write( "} " + ls );
+ out.write( " " + ls );
+ out.write( "my $Excel = Win32::OLE->GetActiveObject('Excel.Application') " + ls );
+ out.write( " || Win32::OLE->new('Excel.Application', 'Quit'); # get already active Excel " + ls );
+ out.write( " # application or open new " + ls );
+ out.write( "my $sFilterParameter = $ARGV[1]; " + ls );
+ out.write( "my $sFilterName = xlHTML; " + ls );
+ out.write( "if ($sFilterParameter eq 'xlXMLSpreadsheet') " + ls );
+ out.write( "{ " + ls );
+ out.write( " $sFilterName = xlXMLSpreadsheet; " + ls );
+ out.write( "} " + ls );
+ out.write( "elsif ($sFilterParameter eq 'xlHTML') " + ls );
+ out.write( "{ " + ls );
+ out.write( " $sFilterName = xlHTML; " + ls );
+ out.write( "} " + ls );
+ out.write( "else " + ls );
+ out.write( "{ " + ls );
+ out.write( " my $undefined; " + ls);
+ out.write( " $sFilterName = $undefined; " + ls );
+ out.write( "} " + ls );
+ out.write( " " + ls );
+ out.write( "my $Book = $Excel->Workbooks->Open( $ARGV[0] ); " + ls );
+ out.write( "$Excel->{DisplayAlerts} = 0; " + ls );
+ out.write( "$Book->saveAs($ARGV[2], " + ls );
+ out.write( " $sFilterName, " + ls );
+ out.write( " '', " + ls );
+ out.write( " '', " + ls );
+ out.write( " 0, " + ls );
+ out.write( " 0, " + ls );
+ out.write( " xlNoChange, " + ls );
+ out.write( " xlLocalSessionChanges, " + ls );
+ out.write( " 1); " + ls );
+ out.write( "# Close worksheets without store changes" + ls );
+ out.write( "# $Book->Close({SaveChanges => 0}); " + ls );
+ out.write( "$Excel->Quit(); " + ls );
+ out.close();
+
+ aList.add("perl");
+ aList.add(sName);
+ return aList;
+ }
+
+ ArrayList createPowerPointPrintHelper() throws java.io.IOException
+ {
+ // create a program in tmp file
+ String sTmpPath = util.utils.getUsersTempDir();
+ String ls = System.getProperty("line.separator");
+ String fs = System.getProperty("file.separator");
+
+ String sPrintViaPowerPoint = "printViaPowerPoint.pl";
+
+ ArrayList aList = searchLocalFile(sPrintViaPowerPoint);
+ if (aList.isEmpty() == false)
+ {
+ return aList;
+ }
+ String sName = sTmpPath + fs + sPrintViaPowerPoint;
+ if (FileHelper.isDebugEnabled())
+ {
+ GlobalLogWriter.get().println("No local found, create a script: " + sName);
+ }
+
+ File aFile = new File(sName);
+ FileWriter out = new FileWriter(aFile.toString());
+
+
+ out.write( "eval 'exec perl -wS $0 $1 $2 ' " + ls );
+ out.write( " if 0; " + ls );
+ out.write( "use strict; " + ls );
+ out.write( " " + ls );
+ out.write( "if ( $^O ne \"MSWin32\") " + ls );
+ out.write( "{ " + ls );
+ out.write( " print \"Windows only.\\n\"; " + ls );
+ out.write( " print_usage(); " + ls );
+ out.write( " exit(1); " + ls );
+ out.write( "} " + ls );
+ out.write( " " + ls );
+ out.write( " " + ls );
+ out.write( "use Win32::OLE qw(in with); " + ls );
+ out.write( "use Win32::OLE::Const 'Microsoft PowerPoint'; " + ls );
+ out.write( " " + ls );
+ out.write( "# ------ usage ------ " + ls );
+ out.write( "sub print_usage() " + ls );
+ out.write( "{ " + ls );
+ out.write( " print STDERR \"Usage: powerpoint_print.pl <PowerPoint file> <name of printer> <output file> .\\n " + ls );
+ out.write( " Please use the same string for the name of the printer as you can find \\n " + ls );
+ out.write( " under Start-Control Panel-Printer and Faxes \\n " + ls );
+ out.write( " The name could look like the the following line: \\n " + ls );
+ out.write( " Apple LaserWriter II NT v47.0 \\n " + ls );
+ out.write( " Sample command line: \\n " + ls );
+ out.write( " powerpoint_print.pl c:\\book.ppt Apple LaserWriter II NT v47.0 c:\\output\\book.ps \\n\"; " + ls );
+ out.write( "} " + ls );
+ out.write( " " + ls );
+ out.write( " " + ls );
+ out.write( " " + ls );
+ out.write( "$Win32::OLE::Warn = 3; # die on errors... " + ls );
+ out.write( " " + ls );
+ out.write( " " + ls );
+ out.write( "if ($#ARGV < 2) " + ls );
+ out.write( "{ " + ls );
+ out.write( " print \"Too less arguments.\\n\"; " + ls );
+ out.write( " print_usage(); " + ls );
+ out.write( " exit(1); " + ls );
+ out.write( "} " + ls );
+ out.write( " " + ls );
+ out.write( "my $PowerPoint = Win32::OLE->GetActiveObject('PowerPoint.Application') " + ls );
+ out.write( " || Win32::OLE->new('PowerPoint.Application', 'Quit'); # get already active Excel " + ls );
+ out.write( " # application or open new " + ls );
+ out.write( " " + ls );
+ out.write( " " + ls );
+ out.write( " " + ls );
+ out.write( " $PowerPoint->{'Visible'} = 1; " + ls );
+ out.write( " my $Presentation = $PowerPoint->Presentations->Add; " + ls );
+ out.write( " my $Presentation = $PowerPoint->Presentations->Open( $ARGV[0] ); " + ls );
+ out.write( "# we can't change active printer in powerpoint " + ls );
+ out.write( "# $Presentation->PrintOptions->{ActivePrinter} = $ARGV[1]; " + ls );
+ out.write( " print \"Active printer is: \" . $Presentation->PrintOptions->{ActivePrinter} . \"\\n\"; " + ls );
+ out.write( " $Presentation->PrintOptions->{PrintInBackground} = 0; " + ls );
+ out.write( " # PrintColorType = 1 means print in color and PrintColorType = 2 means print in gray " + ls );
+ out.write( " $Presentation->PrintOptions->{PrintColorType} = 1; " + ls );
+ out.write( " " + ls );
+ out.write( " $Presentation->PrintOut({PrintToFile => $ARGV[2]}); " + ls );
+ out.write( " sleep 5; " + ls );
+ out.write( " print \"Presentation has been printed\\n\"; " + ls );
+ out.write( "my $sVersion = $Presentation->Application->Version();"+ls);
+ out.write( " $PowerPoint->Quit(); " + ls );
+
+ out.write( "local *FILE;" + ls);
+ out.write( "if (open(FILE, \">$ENV{HOME}/msofficeloadtimes.txt\"))" + ls);
+ out.write( "{" + ls);
+ out.write( " print FILE \"name=$ARGV[0]\\n\";" + ls);
+ out.write( " print FILE \"PowerPointVersion=$sVersion\\n\";" + ls);
+// out.write( " print FILE \"WordStartTime=$stopWordTime\\n\";" + ls);
+// out.write( " print FILE \"WordLoadTime=$stopLoadWordTime\\n\";" + ls);
+// out.write( " print FILE \"WordPrintTime=$stopPrintWordTime\\n\";" + ls);
+ out.write( " close(FILE);" + ls);
+ out.write( "}" + ls);
+ out.close();
+
+ aList.add("perl");
+ aList.add(sName);
+ return aList;
+ }
+
+ /**
+ @param _sFilename a name to a ms office xml file
+ @return 'word' or 'excel' or '' if type not known
+ */
+ public String getOfficeType(String _sFilename)
+ {
+ File aFile = new File(_sFilename);
+ if (! aFile.exists())
+ {
+ GlobalLogWriter.get().println("couldn't find file " + _sFilename);
+ return "";
+ }
+ RandomAccessFile aReader = null;
+ String sOfficeType = "";
+ try
+ {
+ aReader = new RandomAccessFile(aFile,"r");
+ String aLine = "";
+ while (aLine != null)
+ {
+ aLine = aReader.readLine();
+ if (aLine != null)
+ {
+ aLine = aLine.trim();
+ if ( (! (aLine.length() < 2) ) &&
+ (! aLine.startsWith("#")) &&
+ (! aLine.startsWith(";")) )
+ {
+ int nIdx = aLine.indexOf("mso-application");
+ if (nIdx > 0)
+ {
+ if (aLine.indexOf("Word.Document") > 0)
+ {
+ sOfficeType = "word";
+ }
+ else if (aLine.indexOf("Excel") > 0)
+ {
+ sOfficeType = "excel";
+ }
+ else
+ {
+ GlobalLogWriter.get().println("Unknown/unsupported data file: " + aLine);
+ }
+ }
+ }
+ }
+ }
+ }
+ catch (java.io.FileNotFoundException fne)
+ {
+ System.out.println("couldn't open file " + _sFilename);
+ System.out.println("Message: " + fne.getMessage());
+ }
+ catch (java.io.IOException ie)
+ {
+ System.out.println("Exception while reading file " + _sFilename);
+ System.out.println("Message: " + ie.getMessage());
+ }
+ try
+ {
+ aReader.close();
+ }
+ catch (java.io.IOException ie)
+ {
+ System.out.println("Couldn't close file " + _sFilename);
+ System.out.println("Message: " + ie.getMessage());
+ }
+ return sOfficeType;
+ }
+
+}
diff --git a/qadevOOo/runner/convwatch/NameHelper.java b/qadevOOo/runner/convwatch/NameHelper.java
new file mode 100644
index 000000000000..cddf3aca75f2
--- /dev/null
+++ b/qadevOOo/runner/convwatch/NameHelper.java
@@ -0,0 +1,89 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package convwatch;
+
+/**
+ * This container class should help to handle the name of the current document
+ */
+
+public class NameHelper
+{
+ /**
+ *
+ */
+ String m_sOutputPath;
+
+ /**
+ *
+ */
+ String m_sRelativeOutputPath;
+
+ /**
+ *
+ */
+ String m_sNameNoSuffix;
+ String m_sSuffix;
+
+ public NameHelper(String _sOutputPath, String _sRelativeOutputPath, String _sBasename)
+ {
+ m_sOutputPath = _sOutputPath;
+ m_sRelativeOutputPath = _sRelativeOutputPath;
+ String sNameNoSuffix = FileHelper.getNameNoSuffix(_sBasename);
+ m_sNameNoSuffix = sNameNoSuffix;
+ m_sSuffix = FileHelper.getSuffix(_sBasename);
+ }
+ /**
+ * @return the OutputPath
+ */
+ public String getOutputPath() {return m_sOutputPath;}
+
+ /**
+ * @return the relative OutputPath
+ */
+ public String getRelativePath() {return m_sRelativeOutputPath;}
+
+ /**
+ * @return the document name without it's suffix
+ */
+ public String getName() {return m_sNameNoSuffix;}
+
+ /**
+ * @return the document suffix from the original document
+ */
+ public String getSuffix() {return m_sSuffix;}
+
+ public void print()
+ {
+ GlobalLogWriter.get().println(" Outputpath: " + m_sOutputPath);
+ GlobalLogWriter.get().println("relative Outputpath: " + m_sRelativeOutputPath);
+ GlobalLogWriter.get().println(" Name: " + m_sNameNoSuffix);
+ GlobalLogWriter.get().println(" Suffix: " + m_sSuffix);
+
+ }
+
+}
diff --git a/qadevOOo/runner/convwatch/OSHelper.java b/qadevOOo/runner/convwatch/OSHelper.java
new file mode 100644
index 000000000000..1fbf804831d7
--- /dev/null
+++ b/qadevOOo/runner/convwatch/OSHelper.java
@@ -0,0 +1,84 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package convwatch;
+//
+// class OSHelper
+// {
+// public static boolean isWindows()
+// {
+// String sOSName = System.getProperty("os.name");
+// if (sOSName.toLowerCase().startsWith("windows"))
+// {
+// return true;
+// }
+// return false;
+// }
+// // not need
+// // public static boolean isUnix()
+// public static boolean isSolarisIntel()
+// {
+// if ( ( System.getProperty("os.name").toLowerCase().startsWith("solaris") ||
+// System.getProperty("os.name").toLowerCase().startsWith("sunos") ) &&
+// System.getProperty("os.arch").equals("x86"))
+// {
+// return true;
+// }
+// return false;
+// }
+// public static boolean isSolarisSparc()
+// {
+// if ( ( System.getProperty("os.name").toLowerCase().startsWith("solaris") ||
+// System.getProperty("os.name").toLowerCase().startsWith("sunos") ) &&
+// System.getProperty("os.arch").equals("sparc"))
+// {
+// return true;
+// }
+// return false;
+// }
+// public static boolean isLinuxIntel()
+// {
+// if (System.getProperty("os.name").toLowerCase().startsWith("linux") &&
+// System.getProperty("os.arch").equals("i386"))
+// {
+// return true;
+// }
+// return false;
+// }
+//
+// public static boolean isUnix()
+// {
+// if (isLinuxIntel() ||
+// isSolarisIntel() ||
+// isSolarisSparc())
+// {
+// return true;
+// }
+// return false;
+// }
+//
+// }
diff --git a/qadevOOo/runner/convwatch/OfficePrint.java b/qadevOOo/runner/convwatch/OfficePrint.java
new file mode 100644
index 000000000000..c9a656ac84b4
--- /dev/null
+++ b/qadevOOo/runner/convwatch/OfficePrint.java
@@ -0,0 +1,1377 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package convwatch;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.io.FileWriter;
+
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.document.XTypeDetection;
+import com.sun.star.container.XNameAccess;
+import com.sun.star.frame.XDesktop;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.frame.XComponentLoader;
+import com.sun.star.lang.XComponent;
+import com.sun.star.frame.XStorable;
+import com.sun.star.view.XPrintable;
+import com.sun.star.lang.XServiceInfo;
+import com.sun.star.frame.XModel;
+import com.sun.star.uno.AnyConverter;
+
+import helper.URLHelper;
+import helper.PropertyHelper;
+import helper.OSHelper;
+// import convwatch.FileHelper;
+// import convwatch.MSOfficePrint;
+// import convwatch.GraphicalTestArguments;
+// import convwatch.ConvWatchCancelException;
+
+// import helper.Parameter;
+
+/**
+ * This Object is to print a given document with OpenOffice.org / StarOffice
+ * over the normal printer driver
+ * or over it's pdf exporter
+ */
+public class OfficePrint {
+
+
+// static long m_nStartTime;
+// // static Date m_aDateCache = null;
+//
+// /*
+// simple helper functions to start/stop a timer, to know how long a process need in milliseconds
+// */
+// public static void startTimer()
+// {
+// // if (m_aDateCache == null)
+// // {
+// // m_aDateCache = new Date();
+// // }
+// // m_nStartTime = m_aDateCache.getTime();
+// m_nStartTime = System.currentTimeMillis();
+// }
+// public static long stopTimer()
+// {
+// // if (m_aDateCache == null)
+// // {
+// // System.out.println("Forgotten to initialise start timer.");
+// // return 0;
+// // }
+// // long m_nStopTime = m_aDateCache.getTime();
+// if (m_nStartTime == 0)
+// {
+// System.out.println("Forgotten to initialise start timer.");
+// return 0;
+// }
+// long m_nStopTime = System.currentTimeMillis();
+// return m_nStopTime - m_nStartTime;
+// }
+
+
+ private static void showProperty(PropertyValue _aValue)
+ {
+ String sName = _aValue.Name;
+ String sValue;
+ try
+ {
+ sValue = AnyConverter.toString(_aValue.Value);
+ GlobalLogWriter.get().println("Property " + sName + ":=" + sValue);
+ }
+ catch (com.sun.star.lang.IllegalArgumentException e)
+ {
+ // GlobalLogWriter.get().println("showProperty: can't convert a object to string.");
+ GlobalLogWriter.get().println("Property " + sName + ":= a Object which can't convert by AnyConverter()");
+ }
+ }
+
+ /**
+ * shows the FilterName and MediaType from the given XComponent
+ */
+ static String getDocumentType( XComponent _aDoc )
+ {
+ XModel xModel = UnoRuntime.queryInterface( XModel.class, _aDoc);
+ PropertyValue[] aArgs = xModel.getArgs();
+ for (int i=0;i<aArgs.length;i++)
+ {
+ PropertyValue aValue = aArgs[i];
+ // System.out.print("Property: '" + aValue.Name);
+ // System.out.println("' := '" + aValue.Value + "'");
+ if (aValue.Name.equals("FilterName") ||
+ aValue.Name.equals("MediaType"))
+ {
+ String sNameValue = "'" + aValue.Name + "' := '" + aValue.Value + "'";
+ return sNameValue;
+ }
+ }
+ return "";
+ }
+
+ static void showDocumentType( XComponent _aDoc )
+ {
+ String sNameValue = getDocumentType(_aDoc);
+ GlobalLogWriter.get().println(" Property: '" + sNameValue);
+ }
+ /**
+ * load a OpenOffice.org document from a given URL (_sInputURL)
+ * the GraphicalTestArguments must contain a living MultiServiceFactory object
+ * or we crash here.
+ * Be aware, the ownership of the document gets to you, you have to close it.
+ * @param _aGTA
+ * @param _sInputURL
+ * @return
+ */
+ public static XComponent loadFromURL(GraphicalTestArguments _aGTA,
+ String _sInputURL)
+ {
+ XComponent aDoc = null;
+ try
+ {
+ if (_aGTA.getMultiServiceFactory() == null)
+ {
+ GlobalLogWriter.get().println("MultiServiceFactory in GraphicalTestArgument not set.");
+ return null;
+ }
+ Object oDsk = _aGTA.getMultiServiceFactory().createInstance("com.sun.star.frame.Desktop");
+ XDesktop aDesktop = UnoRuntime.queryInterface(XDesktop.class, oDsk);
+
+ if (aDesktop != null)
+ {
+ GlobalLogWriter.get().println("com.sun.star.frame.Desktop created.");
+ // String sInputURL = aCurrentParameter.sInputURL;
+ // String sOutputURL = aCurrentParameter.sOutputURL;
+ // String sPrintFileURL = aCurrentParameter.sPrintToFileURL;
+ // System.out.println(_sInputURL);
+
+
+ // set here the loadComponentFromURL() properties
+ // at the moment only 'Hidden' is set, so no window is opened at work
+
+ ArrayList<PropertyValue> aPropertyList = new ArrayList<PropertyValue>();
+
+ // check which properties should set and count it.
+ // if (_aGTA.isHidden())
+ // {
+ // nPropertyCount ++;
+ // }
+ // if (_aGTA.getImportFilterName() != null && _aGTA.getImportFilterName().length() > 0)
+ // {
+ // nPropertyCount ++;
+ // }
+
+ // initialize the propertyvalue
+ // int nPropertyIndex = 0;
+ // aProps = new PropertyValue[ nPropertyCount ];
+
+ // set all property values
+ if (_aGTA.isHidden())
+ {
+ PropertyValue Arg = new PropertyValue();
+ Arg.Name = "Hidden";
+ Arg.Value = Boolean.TRUE;
+ aPropertyList.add(Arg);
+ showProperty(Arg);
+ }
+ if (_aGTA.getImportFilterName() != null && _aGTA.getImportFilterName().length() > 0)
+ {
+ PropertyValue Arg = new PropertyValue();
+ Arg.Name = "FilterName";
+ Arg.Value = _aGTA.getImportFilterName();
+ aPropertyList.add(Arg);
+ showProperty(Arg);
+ }
+
+ GlobalLogWriter.get().println(DateHelper.getDateTimeForHumanreadableLog() + " Load document");
+ // GlobalLogWriter.get().flush();
+
+ XComponentLoader aCompLoader = UnoRuntime.queryInterface( XComponentLoader.class, aDesktop);
+
+ // XComponent aDoc = null;
+
+ _aGTA.getPerformance().startTime(PerformanceContainer.Load);
+ aDoc = aCompLoader.loadComponentFromURL(_sInputURL, "_blank", 0, PropertyHelper.createPropertyValueArrayFormArrayList(aPropertyList) );
+ _aGTA.getPerformance().stopTime(PerformanceContainer.Load);
+ if (aDoc != null)
+ {
+ GlobalLogWriter.get().println(DateHelper.getDateTimeForHumanreadableLog() + " Load document done.");
+ showDocumentType(aDoc);
+ _aGTA.setDocumentType(getDocumentType(aDoc));
+ }
+ else
+ {
+ GlobalLogWriter.get().println(" Load document failed.");
+ if (_aGTA.getImportFilterName() != null && _aGTA.getImportFilterName().length() > 0)
+ {
+ GlobalLogWriter.get().println(" Please check FilterName := '" + _aGTA.getImportFilterName() + "'");
+ }
+ GlobalLogWriter.get().println("");
+ }
+ }
+ else
+ {
+ GlobalLogWriter.get().println("com.sun.star.frame.Desktop failed.");
+ }
+ }
+ catch ( com.sun.star.uno.Exception e )
+ {
+ // Some exception occures.FAILED
+ GlobalLogWriter.get().println("UNO Exception caught.");
+ GlobalLogWriter.get().println("Message: " + e.getMessage());
+ e.printStackTrace();
+ aDoc = null;
+ }
+ return aDoc;
+ }
+
+ static boolean exportToPDF(XComponent _xComponent, String _sDestinationName)
+ {
+ XServiceInfo xServiceInfo =
+ UnoRuntime.queryInterface(
+ XServiceInfo.class, _xComponent
+ );
+
+ ArrayList<PropertyValue> aPropertyList = new ArrayList<PropertyValue>();
+ PropertyValue aFiltername = new PropertyValue();
+ aFiltername.Name = "FilterName";
+ aFiltername.Value = getFilterName_forPDF(xServiceInfo);
+ aPropertyList.add(aFiltername);
+ showProperty(aFiltername);
+ boolean bWorked = true;
+
+ try
+ {
+ XStorable store =
+ UnoRuntime.queryInterface(
+ XStorable.class, _xComponent
+ );
+ store.storeToURL(_sDestinationName, PropertyHelper.createPropertyValueArrayFormArrayList(aPropertyList));
+ }
+ catch (com.sun.star.io.IOException e)
+ {
+ GlobalLogWriter.get().println("IO Exception caught.");
+ GlobalLogWriter.get().println("Message: " + e.getMessage());
+ bWorked = false;
+ }
+
+ return bWorked;
+ }
+
+ static String getFilterName_forPDF(XServiceInfo xServiceInfo)
+ {
+ String filterName = "";
+
+ if (xServiceInfo.supportsService("com.sun.star.text.TextDocument"))
+ {
+ //writer
+ filterName = "writer_pdf_Export";
+ }
+ else if ( xServiceInfo.supportsService( "com.sun.star.sheet.SpreadsheetDocument" ) )
+ {
+ //calc
+ filterName = "calc_pdf_Export";
+ }
+ else if ( xServiceInfo.supportsService( "com.sun.star.drawing.DrawingDocument" ) )
+ {
+ //draw
+ filterName = "draw_pdf_Export";
+ }
+ else if ( xServiceInfo.supportsService( "com.sun.star.presentation.PresentationDocument" ) )
+ {
+ //impress
+ filterName = "impress_pdf_Export";
+ }
+ else if (xServiceInfo.supportsService("com.sun.star.text.WebDocument"))
+ {
+ //html document
+ filterName = "writer_web_pdf_Export";
+ }
+ else if ( xServiceInfo.supportsService("com.sun.star.text.GlobalDocument") )
+ {
+ //master document
+ filterName = "writer_globaldocument_pdf_Export";
+ }
+ else if ( xServiceInfo.supportsService( "com.sun.star.formulaFormulaProperties" ) )
+ {
+ //math document
+ filterName = "math_pdf_Export";
+ }
+
+ return filterName;
+ }
+
+ // -----------------------------------------------------------------------------
+
+ public static boolean storeAsPDF(GraphicalTestArguments _aGTA,
+ String _sInputURL,
+ String _sOutputURL)
+ {
+ boolean bBack = false;
+ XComponent aDoc = loadFromURL(_aGTA, _sInputURL);
+
+ if (aDoc == null)
+ {
+ GlobalLogWriter.get().println("Can't load document.");
+ return bBack;
+ }
+ bBack = storeAsPDF(_aGTA, aDoc, _sOutputURL);
+ createInfoFile(_sOutputURL, _aGTA, "as pdf");
+
+ GlobalLogWriter.get().println("Close document.");
+ aDoc.dispose();
+ return bBack;
+ }
+
+ public static boolean storeAsPDF(GraphicalTestArguments _aGTA,
+ XComponent _aDoc,
+ String _sOutputURL)
+ {
+ // try {
+ boolean bBack = true;
+ _aGTA.getPerformance().startTime(PerformanceContainer.StoreAsPDF);
+ bBack = exportToPDF(_aDoc, _sOutputURL);
+ _aGTA.getPerformance().stopTime(PerformanceContainer.StoreAsPDF);
+
+ if (!bBack)
+ {
+ GlobalLogWriter.get().println("Can't store document as PDF.");
+ bBack = false;
+ }
+ return bBack;
+ }
+
+ // -----------------------------------------------------------------------------
+
+ /**
+ * print the document found in file (_sInputURL) to as postscript to file (_sPrintFileURL)
+ * Due to the fact we use a printer to convert the file to postscript, the default printer
+ * to create such postscript format must be installed, this is not tested here.
+ *
+ * @param _aGTA
+ * @param _sInputURL
+ * @param _sOutputURL
+ * @param _sPrintFileURL
+ * @return true, if print has been done.
+ * Be careful, true means only print returns with no errors, to be sure print is really done
+ * check existance of _sPrintFileURL
+ */
+
+ public static boolean printToFileWithOOo(GraphicalTestArguments _aGTA,
+ String _sInputURL,
+ String _sOutputURL,
+ String _sPrintFileURL)
+ {
+ // waitInSeconds(1);
+ boolean bBack = false;
+
+ XComponent aDoc = loadFromURL(_aGTA, _sInputURL);
+ if (aDoc != null)
+ {
+ if ( _sInputURL.equals(_sOutputURL) )
+ {
+ // don't store document
+ // input and output are equal OR
+ GlobalLogWriter.get().println("Warning: Inputpath and Outputpath are equal. Document will not stored again.");
+ _aGTA.disallowStore();
+ }
+ bBack = impl_printToFileWithOOo(_aGTA, aDoc, _sOutputURL, _sPrintFileURL);
+
+ GlobalLogWriter.get().println("Close document.");
+ aDoc.dispose();
+ }
+ else
+ {
+ GlobalLogWriter.get().println("loadDocumentFromURL() failed with document: " + _sInputURL);
+ }
+ return bBack;
+ }
+
+ // -----------------------------------------------------------------------------
+ public static void createInfoFile(String _sFile, GraphicalTestArguments _aGTA)
+ {
+ createInfoFile(_sFile, _aGTA, "");
+ }
+
+ public static void createInfoFile(String _sFile, GraphicalTestArguments _aGTA, String _sSpecial)
+ {
+ String sFilename;
+ if (_sFile.startsWith("file://"))
+ {
+ sFilename = FileHelper.getSystemPathFromFileURL(_sFile);
+ GlobalLogWriter.get().println("CreateInfoFile: '" + sFilename + "'" );
+ }
+ else
+ {
+ sFilename = _sFile;
+ }
+ String sFileDir = FileHelper.getPath(sFilename);
+ String sBasename = FileHelper.getBasename(sFilename);
+ String sNameNoSuffix = FileHelper.getNameNoSuffix(sBasename);
+
+ String fs = System.getProperty("file.separator");
+ String ls = System.getProperty("line.separator");
+ String sInfoFilename = sFileDir + fs + sNameNoSuffix + ".info";
+ File aInfoFile = new File(sInfoFilename);
+
+ String sBuildID = "";
+
+ try
+ {
+ FileWriter out = new FileWriter(aInfoFile.toString());
+ out.write("# automatically created file by graphical compare" + ls);
+ if (_aGTA != null)
+ {
+ if (_sSpecial != null && _sSpecial.equals("msoffice"))
+ {
+ out.write("# buildid from wordloadfile" + ls);
+ sBuildID = _aGTA.getPerformance().getMSOfficeVersion();
+ out.write("buildid=" + sBuildID + ls);
+ }
+ else
+ {
+ out.write("# buildid is read out of the bootstrap file" + ls);
+ sBuildID = _aGTA.getBuildID();
+ out.write("buildid=" + sBuildID + ls);
+ }
+ // if (_sSpecial != null && _sSpecial.length() > 0)
+ // {
+ // out.write("special=" + _sSpecial + ls);
+ // }
+ out.write(ls);
+ out.write("# resolution given in DPI" + ls);
+ out.write("resolution=" + _aGTA.getResolutionInDPI() + ls);
+ }
+ else
+ {
+ out.write("buildid=" + _sSpecial + ls);
+ }
+ // long nTime = stopTimer();
+ // if (nTime != 0)
+ // {
+ // out.write("# time is given in milli seconds" + ls);
+ // out.write("time=" + nTime + ls);
+ // }
+
+ out.write(ls);
+ out.write("# Values out of System.getProperty(...)" + ls);
+ out.write("os.name=" + System.getProperty("os.name") + ls);
+ out.write("os.arch=" + System.getProperty("os.arch") + ls);
+ out.write("os.version=" + System.getProperty("os.version") + ls);
+
+ if (_aGTA != null)
+ {
+ out.write(ls);
+ out.write("# Performance output, values are given in milli sec." + ls);
+ _aGTA.getPerformance().print(out);
+ }
+
+ out.flush();
+ out.close();
+ }
+ catch (java.io.IOException e)
+ {
+ GlobalLogWriter.get().println("can't create Info file.");
+ e.printStackTrace();
+ }
+
+ String sExtension = FileHelper.getSuffix(_aGTA.getInputFile());
+ if (sExtension.startsWith("."))
+ {
+ sExtension = sExtension.substring(1);
+ }
+
+ DB.writeToDB(_aGTA.getInputFile(),
+ sNameNoSuffix,
+ sExtension,
+ sBuildID,
+ _aGTA.getReferenceType(),
+ _aGTA.getResolutionInDPI()
+ );
+ }
+
+
+
+ // -----------------------------------------------------------------------------
+ private static boolean impl_printToFileWithOOo(GraphicalTestArguments _aGTA,
+ XComponent _aDoc,
+ String _sOutputURL,
+ String _sPrintFileURL)
+ {
+ boolean bBack = false;
+ boolean bFailed = true; // always be a pessimist,
+ if (_aDoc == null)
+ {
+ GlobalLogWriter.get().println("No document is given.");
+ return bBack;
+ }
+
+ try
+ {
+ if (_sOutputURL != null)
+ {
+ if (_aGTA.isStoreAllowed())
+ {
+ // store the document in an other directory
+ XStorable aStorable = UnoRuntime.queryInterface( XStorable.class, _aDoc);
+ if (aStorable != null)
+ {
+ PropertyValue [] szEmptyArgs = new PropertyValue [0];
+
+ GlobalLogWriter.get().println(DateHelper.getDateTimeForHumanreadableLog() + " Store document.");
+ _aGTA.getPerformance().startTime(PerformanceContainer.Store);
+ aStorable.storeAsURL(_sOutputURL, szEmptyArgs);
+ _aGTA.getPerformance().stopTime(PerformanceContainer.Store);
+
+ GlobalLogWriter.get().println(DateHelper.getDateTimeForHumanreadableLog() + " Store document done.");
+ TimeHelper.waitInSeconds(2, "After store as URL to:" + _sOutputURL);
+ GlobalLogWriter.get().println("Reload stored file test.");
+ XComponent aDoc = loadFromURL(_aGTA, _sOutputURL);
+ if (aDoc == null)
+ {
+ GlobalLogWriter.get().println("Reload stored file test failed, can't reload file: " + _sOutputURL);
+ }
+ }
+ }
+ }
+ }
+ catch ( com.sun.star.uno.Exception e )
+ {
+ // Some exception occures.FAILED
+ GlobalLogWriter.get().println("UNO Exception caught.");
+ GlobalLogWriter.get().println("Message: " + e.getMessage());
+
+ e.printStackTrace();
+ bBack = false;
+ }
+
+ try
+ {
+
+ // System.out.println("Document loaded.");
+ // Change Pagesettings to DIN A4
+
+ GlobalLogWriter.get().println(DateHelper.getDateTimeForHumanreadableLog() + " Print document.");
+ XPrintable aPrintable = UnoRuntime.queryInterface( XPrintable.class, _aDoc);
+ if (aPrintable != null)
+ {
+ // System.out.println(" Set PaperFormat to DIN A4");
+ // {
+ // PropertyValue[] aPrinterProps = aPrintable.getPrinter();
+ // System.out.println("PrinterProps size: " + String.valueOf(aPrinterProps.length));
+ // int nPropIndex = 0;
+ // while (!"PaperFormat".equals(aPrinterProps[nPropIndex].Name))
+ // {
+ // // System.out.println(aPrinterProps[nPropIndex].Name);
+ // nPropIndex++;
+ // }
+ // aPrinterProps[nPropIndex].Value = com.sun.star.view.PaperFormat.A4;
+ // aPrintable.setPrinter(aPrinterProps);
+ // }
+
+ // configure Office to allow to execute macos
+
+// TODO: We need a possiblity to set the printer name also for StarOffice/OpenOffice
+ if (OSHelper.isWindows())
+ {
+ if (_aGTA.getPrinterName() != null)
+ {
+ ArrayList<PropertyValue> aPropertyList = new ArrayList<PropertyValue>();
+ // PropertyValue [] aPrintProps = new PropertyValue[1];
+ PropertyValue Arg = new PropertyValue();
+ Arg.Name = "Name";
+ Arg.Value = _aGTA.getPrinterName();
+ aPropertyList.add(Arg);
+ showProperty(Arg);
+ // GlobalLogWriter.get().println("Printername is not null, so set to " + _aGTA.getPrinterName());
+ aPrintable.setPrinter(PropertyHelper.createPropertyValueArrayFormArrayList(aPropertyList));
+ }
+ }
+
+ // set property values for XPrintable.print()
+ // more can be found at "http://api.openoffice.org/docs/common/ref/com/sun/star/view/PrintOptions.html"
+
+ // int nProperties = 1; // default for 'FileName' property
+ // if (_aGTA.printAllPages() == false)
+ // {
+ // // we don't want to print all pages, build Pages string by ourself
+ // nProperties ++;
+ // }
+ // int nPropsCount = 0;
+
+ // If we are a SpreadSheet (calc), we need to set PrintAllSheets property to 'true'
+ XServiceInfo xServiceInfo = UnoRuntime.queryInterface( XServiceInfo.class, _aDoc );
+ if ( xServiceInfo.supportsService( "com.sun.star.sheet.SpreadsheetDocument" ) )
+ {
+ XMultiServiceFactory xMSF = _aGTA.getMultiServiceFactory();
+ Object aSettings = xMSF.createInstance( "com.sun.star.sheet.GlobalSheetSettings" );
+ if (aSettings != null)
+ {
+ XPropertySet xPropSet = UnoRuntime.queryInterface( XPropertySet.class, aSettings );
+ xPropSet.setPropertyValue( "PrintAllSheets", new Boolean( true ) );
+ GlobalLogWriter.get().println("PrintAllSheets := true");
+ }
+ }
+
+ ArrayList<PropertyValue> aPrintProps = new ArrayList<PropertyValue>();
+ // GlobalLogWriter.get().println("Property FileName:=" + _sPrintFileURL);
+
+ // PropertyValue [] aPrintProps = new PropertyValue[nProperties];
+ PropertyValue Arg = new PropertyValue();
+ Arg.Name = "FileName";
+ Arg.Value = _sPrintFileURL;
+ // aPrintProps[nPropsCount ++] = Arg;
+ aPrintProps.add(Arg);
+ showProperty(Arg);
+
+ if (_aGTA.printAllPages() == false)
+ {
+ String sPages = "";
+ if (_aGTA.getMaxPages() > 0)
+ {
+ sPages = "1-" + String.valueOf(_aGTA.getMaxPages());
+ }
+ if (_aGTA.getOnlyPages().length() != 0)
+ {
+ if (sPages.length() != 0)
+ {
+ sPages += ";";
+ }
+ sPages += String.valueOf(_aGTA.getOnlyPages());
+ }
+
+ Arg = new PropertyValue();
+ Arg.Name = "Pages";
+ Arg.Value = sPages;
+ aPrintProps.add(Arg);
+ showProperty(Arg);
+ }
+
+ // GlobalLogWriter.get().println("Start printing.");
+
+ _aGTA.getPerformance().startTime(PerformanceContainer.Print);
+ aPrintable.print(PropertyHelper.createPropertyValueArrayFormArrayList(aPrintProps));
+ TimeHelper.waitInSeconds(1, "Start waiting for print ready.");
+
+ GlobalLogWriter.get().println("Wait until document is printed.");
+ boolean isBusy = true;
+ int nPrintCount = 0;
+ while (isBusy)
+ {
+ PropertyValue[] aPrinterProps = aPrintable.getPrinter();
+ int nPropIndex = 0;
+ while (!"IsBusy".equals(aPrinterProps[nPropIndex].Name))
+ {
+ // System.out.println(aPrinterProps[nPropIndex].Name);
+ nPropIndex++;
+ }
+ isBusy = (aPrinterProps[nPropIndex].Value == Boolean.TRUE) ? true : false;
+ TimeHelper.waitInSeconds(1, "is print ready?");
+ nPrintCount++;
+ if (nPrintCount > 3600)
+ {
+ // we will never wait >1h until print is ready!
+ GlobalLogWriter.get().println("ERROR: Cancel print due to too long wait.");
+ throw new com.sun.star.uno.Exception("Convwatch exception, wait too long for printing.");
+ }
+ }
+ _aGTA.getPerformance().stopTime(PerformanceContainer.Print);
+ GlobalLogWriter.get().println(DateHelper.getDateTimeForHumanreadableLog() + " Print document done.");
+
+ // Create a .info file near the printed '.ps' or '.prn' file.
+ createInfoFile(_sPrintFileURL, _aGTA);
+ }
+ else
+ {
+ GlobalLogWriter.get().println("Can't get XPrintable interface.");
+ }
+ bFailed = false;
+ bBack = true;
+ }
+ catch ( com.sun.star.uno.Exception e )
+ {
+ // Some exception occures.FAILED
+ GlobalLogWriter.get().println("UNO Exception caught.");
+ GlobalLogWriter.get().println("Message: " + e.getMessage());
+
+ e.printStackTrace();
+ bBack = false;
+ }
+
+ if (bFailed == true)
+ {
+ GlobalLogWriter.get().println("convwatch.OfficePrint: FAILED");
+ }
+ else
+ {
+ GlobalLogWriter.get().println("convwatch.OfficePrint: OK");
+ }
+ return bBack;
+ }
+
+
+ /**
+ * @param _aGTA
+ * @param _sAbsoluteOutputPath
+ * @param _sAbsoluteInputFile
+ * @return true, if the reference (*.prrn file) based on given output path and given input path exist.
+ * If OVERWRITE_REFERENCE is set, always return false.
+ */
+ public static boolean isReferenceExists(GraphicalTestArguments _aGTA,
+ String _sAbsoluteOutputPath,
+ String _sAbsoluteInputFile)
+ {
+ if (! FileHelper.exists(_sAbsoluteInputFile))
+ {
+ // throw new ConvWatchCancelException("Input file: " + _sAbsoluteInputFile + " does not exist.");
+ return false;
+ }
+
+ String fs = System.getProperty("file.separator");
+
+ // String sInputFileURL = URLHelper.getFileURLFromSystemPath(_sAbsoluteInputFile);
+
+ String sInputFileBasename = FileHelper.getBasename(_sAbsoluteInputFile);
+ // String sOutputFileURL = null;
+ String sOutputPath;
+ if (_sAbsoluteOutputPath != null)
+ {
+ sOutputPath = _sAbsoluteOutputPath;
+ // FileHelper.makeDirectories("", sOutputPath);
+ }
+ else
+ {
+ String sInputPath = FileHelper.getPath(_sAbsoluteInputFile);
+ sOutputPath = sInputPath;
+ }
+ // sOutputFileURL = URLHelper.getFileURLFromSystemPath(sOutputPath + fs + sInputFileBasename);
+ // sOutputFileURL = null;
+
+ String sPrintFilename = FileHelper.getNameNoSuffix(sInputFileBasename);
+ // String sPrintFileURL;
+
+ String sAbsolutePrintFilename = sOutputPath + fs + sPrintFilename + ".prn";
+ if (FileHelper.exists(sAbsolutePrintFilename) && _aGTA.getOverwrite() == false)
+ {
+ GlobalLogWriter.get().println("Reference already exist, don't overwrite. Set " + PropertyName.DOC_COMPARATOR_OVERWRITE_REFERENCE + "=true to force overwrite.");
+ return true;
+ }
+ return false;
+ }
+
+ // -----------------------------------------------------------------------------
+ /**
+ * create a reference file
+ * _sAbsoluteInputPath contains the source file, if not exists, return with failure.
+ * _sAbsoluteOutputPath contains the destination, where the file will store after load with StarOffice/OpenOffice.org
+ * if is null, print only near the Input file path
+ * _sPrintType ".prn" Print input file with StarOffice/OpenOffice.org and the default printer as PostScript
+ *
+ * @param _aGTA
+ * @param _sAbsoluteOutputPath
+ * @param _sAbsoluteInputFile
+ * @return
+ * @throws ConvWatchCancelException
+ */
+ public static boolean buildReference(GraphicalTestArguments _aGTA,
+ String _sAbsoluteOutputPath,
+ String _sAbsoluteInputFile)
+ throws ConvWatchCancelException
+ {
+ if (! FileHelper.exists(_sAbsoluteInputFile))
+ {
+ throw new ConvWatchCancelException("buildReference(): Input file: " + _sAbsoluteInputFile + " does not exist.");
+ }
+
+ String fs = System.getProperty("file.separator");
+
+ String sInputFileURL = URLHelper.getFileURLFromSystemPath(_sAbsoluteInputFile);
+
+ String sInputFileBasename = FileHelper.getBasename(_sAbsoluteInputFile);
+ String sOutputFileURL = null;
+ String sOutputPath;
+ if (_sAbsoluteOutputPath != null)
+ {
+ sOutputPath = _sAbsoluteOutputPath;
+ FileHelper.makeDirectories("", sOutputPath);
+ }
+ else
+ {
+ String sInputPath = FileHelper.getPath(_sAbsoluteInputFile);
+ sOutputPath = sInputPath;
+ }
+ // sOutputFileURL = URLHelper.getFileURLFromSystemPath(sOutputPath + fs + sInputFileBasename);
+ sOutputFileURL = null;
+
+ String sPrintFilename = FileHelper.getNameNoSuffix(sInputFileBasename);
+ String sPrintFileURL;
+
+ String sAbsolutePrintFilename = sOutputPath + fs + sPrintFilename + ".prn";
+ if (FileHelper.exists(sAbsolutePrintFilename) && _aGTA.getOverwrite() == false)
+ {
+ GlobalLogWriter.get().println("Reference already exist, don't overwrite. Set " + PropertyName.DOC_COMPARATOR_OVERWRITE_REFERENCE + "=true to force overwrite.");
+ return true;
+ }
+
+ if (_aGTA.getReferenceType().toLowerCase().equals("msoffice"))
+ {
+ sPrintFileURL = URLHelper.getFileURLFromSystemPath(sAbsolutePrintFilename);
+ }
+ else if (_aGTA.getReferenceType().toLowerCase().equals("pdf"))
+ {
+// TODO: If we rename the stored file to *.pdf, we have to be sure that we use *.pdf also as a available reference
+ sPrintFileURL = URLHelper.getFileURLFromSystemPath(sAbsolutePrintFilename );
+ }
+ else if (_aGTA.getReferenceType().toLowerCase().equals("ooo"))
+ {
+ sPrintFileURL = URLHelper.getFileURLFromSystemPath(sAbsolutePrintFilename );
+ }
+ else
+ {
+ GlobalLogWriter.get().println("OfficePrint.buildreference(): Unknown print type.");
+ return false;
+ }
+ return printToFile(_aGTA, sInputFileURL, sOutputFileURL, sPrintFileURL);
+ }
+
+ public static boolean printToFile(GraphicalTestArguments _aGTA,
+ String _sInputFileURL,
+ String _sOutputFileURL,
+ String _sPrintFileURL) throws ConvWatchCancelException
+ {
+ boolean bBack = false;
+ String sPrintFileURL = null;
+
+ // check if given file is a picture, then do nothing
+ String sDocumentSuffix = FileHelper.getSuffix(_sInputFileURL);
+ if (sDocumentSuffix.toLowerCase().endsWith(".png") ||
+ sDocumentSuffix.toLowerCase().endsWith(".gif") ||
+ sDocumentSuffix.toLowerCase().endsWith(".jpg") ||
+ sDocumentSuffix.toLowerCase().endsWith(".bmp"))
+ {
+ return false;
+ }
+
+
+ // remember the current timer, to know how long a print process need.
+ // startTimer();
+
+ if (_aGTA.getReferenceType().toLowerCase().equals("ooo"))
+ {
+ bBack = printToFileWithOOo(_aGTA, _sInputFileURL, _sOutputFileURL, _sPrintFileURL);
+ }
+ else if (_aGTA.getReferenceType().toLowerCase().equals("pdf"))
+ {
+ GlobalLogWriter.get().println("USE PDF AS EXPORT FORMAT.");
+ bBack = storeAsPDF(_aGTA, _sInputFileURL, _sPrintFileURL);
+ }
+ else if (_aGTA.getReferenceType().toLowerCase().equals("msoffice"))
+ {
+ if (MSOfficePrint.isMSOfficeDocumentFormat(_sInputFileURL))
+ {
+ GlobalLogWriter.get().println("USE MSOFFICE AS EXPORT FORMAT.");
+ MSOfficePrint a = new MSOfficePrint();
+ try
+ {
+ a.printToFileWithMSOffice(_aGTA, FileHelper.getSystemPathFromFileURL(_sInputFileURL),
+ FileHelper.getSystemPathFromFileURL(_sPrintFileURL));
+ }
+ catch(ConvWatchCancelException e)
+ {
+ e.printStackTrace();
+ GlobalLogWriter.get().println(e.getMessage());
+ throw new ConvWatchCancelException("Exception caught. Problem with MSOffice printer methods.");
+ }
+ catch(java.io.IOException e)
+ {
+ GlobalLogWriter.get().println(e.getMessage());
+ throw new ConvWatchCancelException("IOException caught. Problem with MSOffice printer methods.");
+ }
+ bBack = true;
+ }
+ else
+ {
+ GlobalLogWriter.get().println("This document type is not recognized as MSOffice format, as default fallback StarOffice/OpenOffice.org instead is used.");
+ bBack = printToFileWithOOo(_aGTA, _sInputFileURL, _sOutputFileURL, _sPrintFileURL);
+ }
+ }
+ else
+ {
+ // System.out.println("");
+ throw new ConvWatchCancelException("OfficePrint.printToFile(): Unknown print type.");
+ }
+ return bBack;
+ }
+
+ // -----------------------------------------------------------------------------
+ // TODO: move this away!
+ // -----------------------------------------------------------------------------
+ static void showType(String _sInputURL, XMultiServiceFactory _xMSF)
+ {
+ if (_sInputURL.length() == 0)
+ {
+ return;
+ }
+
+ if (_xMSF == null)
+ {
+ GlobalLogWriter.get().println("MultiServiceFactory not set.");
+ return;
+ }
+ XTypeDetection aTypeDetection = null;
+ try
+ {
+ Object oObj = _xMSF.createInstance("com.sun.star.document.TypeDetection");
+ aTypeDetection = UnoRuntime.queryInterface(XTypeDetection.class, oObj);
+ }
+ catch(com.sun.star.uno.Exception e)
+ {
+ GlobalLogWriter.get().println("Can't get com.sun.star.document.TypeDetection.");
+ return;
+ }
+ if (aTypeDetection != null)
+ {
+ String sType = aTypeDetection.queryTypeByURL(_sInputURL);
+ GlobalLogWriter.get().println("Type is: " + sType);
+ }
+ }
+
+
+ // -----------------------------------------------------------------------------
+ public static String getInternalFilterName(String _sFilterName, XMultiServiceFactory _xMSF)
+ {
+ if (_sFilterName.length() == 0)
+ {
+ // System.out.println("No FilterName set.");
+ return null;
+ }
+
+ if (_xMSF == null)
+ {
+ GlobalLogWriter.get().println("MultiServiceFactory not set.");
+ return null;
+ }
+ // XFilterFactory aFilterFactory = null;
+ Object aObj = null;
+ try
+ {
+ aObj = _xMSF.createInstance("com.sun.star.document.FilterFactory");
+ }
+ catch(com.sun.star.uno.Exception e)
+ {
+ GlobalLogWriter.get().println("Can't get com.sun.star.document.FilterFactory.");
+ return null;
+ }
+ if (aObj != null)
+ {
+ XNameAccess aNameAccess = UnoRuntime.queryInterface(XNameAccess.class, aObj);
+ if (aNameAccess != null)
+ {
+
+ // if (_sFilterName.toLowerCase().equals("help"))
+ // {
+ // System.out.println("Show all possible ElementNames from current version." );
+ // String[] aElementNames = aNameAccess.getElementNames();
+ // for (int i = 0; i<aElementNames.length; i++)
+ // {
+ // System.out.println(aElementNames[i]);
+ // }
+ // System.out.println("Must quit.");
+ // System.out.exit(1);
+ // }
+
+ if (! aNameAccess.hasByName(_sFilterName))
+ {
+ GlobalLogWriter.get().println("FilterFactory.hasByName() says there exist no '" + _sFilterName + "'" );
+ return null;
+ }
+
+ Object[] aElements = null;
+ String[] aExtensions;
+ try
+ {
+ aElements = (Object[]) aNameAccess.getByName(_sFilterName);
+ if (aElements != null)
+ {
+ String sInternalFilterName = null;
+ // System.out.println("getByName().length: " + String.valueOf(aElements.length));
+ for (int i=0;i<aElements.length; i++)
+ {
+ PropertyValue aPropertyValue = (PropertyValue)aElements[i];
+ // System.out.println("PropertyValue.Name: " + aPropertyValue.Name);
+ if (aPropertyValue.Name.equals("Type"))
+ {
+ String sValue = (String)aPropertyValue.Value;
+ // System.out.println("Type: " + sValue);
+ sInternalFilterName = sValue;
+ }
+ }
+ return sInternalFilterName;
+ }
+ else
+ {
+ GlobalLogWriter.get().println("There are no elements for FilterName '" + _sFilterName + "'");
+ return null;
+ }
+ }
+ catch (com.sun.star.container.NoSuchElementException e)
+ {
+ GlobalLogWriter.get().println("NoSuchElementException caught. " + e.getMessage());
+ }
+ catch (com.sun.star.lang.WrappedTargetException e)
+ {
+ GlobalLogWriter.get().println("WrappedTargetException caught. " + e.getMessage());
+ }
+ }
+ }
+ return null;
+ }
+
+ // -----------------------------------------------------------------------------
+
+ static String getServiceNameFromFilterName(String _sFilterName, XMultiServiceFactory _xMSF)
+ {
+ if (_sFilterName.length() == 0)
+ {
+ // System.out.println("No FilterName set.");
+ return null;
+ }
+
+ if (_xMSF == null)
+ {
+ GlobalLogWriter.get().println("MultiServiceFactory not set.");
+ return null;
+ }
+ // XFilterFactory aFilterFactory = null;
+ Object aObj = null;
+ try
+ {
+ aObj = _xMSF.createInstance("com.sun.star.document.FilterFactory");
+ }
+ catch(com.sun.star.uno.Exception e)
+ {
+ GlobalLogWriter.get().println("Can't get com.sun.star.document.FilterFactory.");
+ return null;
+ }
+ if (aObj != null)
+ {
+ XNameAccess aNameAccess = UnoRuntime.queryInterface(XNameAccess.class, aObj);
+ if (aNameAccess != null)
+ {
+ if (! aNameAccess.hasByName(_sFilterName))
+ {
+ GlobalLogWriter.get().println("FilterFactory.hasByName() says there exist no '" + _sFilterName + "'" );
+ return null;
+ }
+
+ Object[] aElements = null;
+ String[] aExtensions;
+ try
+ {
+ aElements = (Object[]) aNameAccess.getByName(_sFilterName);
+ if (aElements != null)
+ {
+ String sServiceName = null;
+ // System.out.println("getByName().length: " + String.valueOf(aElements.length));
+ for (int i=0;i<aElements.length; i++)
+ {
+ PropertyValue aPropertyValue = (PropertyValue)aElements[i];
+ if (aPropertyValue.Name.equals("DocumentService"))
+ {
+ String sValue = (String)aPropertyValue.Value;
+ // System.out.println("DocumentService: " + sValue);
+ sServiceName = sValue;
+ break;
+ }
+ }
+ return sServiceName;
+ }
+ else
+ {
+ GlobalLogWriter.get().println("There are no elements for FilterName '" + _sFilterName + "'");
+ return null;
+ }
+ }
+ catch (com.sun.star.container.NoSuchElementException e)
+ {
+ GlobalLogWriter.get().println("NoSuchElementException caught. " + e.getMessage());
+ }
+ catch (com.sun.star.lang.WrappedTargetException e)
+ {
+ GlobalLogWriter.get().println("WrappedTargetException caught. " + e.getMessage());
+ }
+ }
+ }
+ return null;
+ }
+ // -----------------------------------------------------------------------------
+
+ public static String getFileExtension(String _sInternalFilterName, XMultiServiceFactory _xMSF)
+ {
+ if (_sInternalFilterName.length() == 0)
+ {
+ // System.out.println("No FilterName set.");
+ return null;
+ }
+
+ if (_xMSF == null)
+ {
+ GlobalLogWriter.get().println("MultiServiceFactory not set.");
+ return null;
+ }
+ XTypeDetection aTypeDetection = null;
+ try
+ {
+ Object oObj = _xMSF.createInstance("com.sun.star.document.TypeDetection");
+ aTypeDetection =UnoRuntime.queryInterface(XTypeDetection.class, oObj);
+ }
+ catch(com.sun.star.uno.Exception e)
+ {
+ GlobalLogWriter.get().println("Can't get com.sun.star.document.TypeDetection.");
+ return null;
+ }
+ if (aTypeDetection != null)
+ {
+ XNameAccess aNameAccess = UnoRuntime.queryInterface(XNameAccess.class, aTypeDetection);
+ if (aNameAccess != null)
+ {
+
+ // System.out.println("Show ElementNames" );
+ // String[] aElementNames = aNameAccess.getElementNames();
+ // for (int i = 0; i<aElementNames.length; i++)
+ // {
+ // System.out.println(aElementNames[i]);
+ // }
+
+ if (! aNameAccess.hasByName(_sInternalFilterName))
+ {
+ GlobalLogWriter.get().println("TypeDetection.hasByName() says there exist no '" + _sInternalFilterName + "'" );
+ return null;
+ }
+
+ Object[] aElements = null;
+ String[] aExtensions;
+ try
+ {
+ aElements = (Object[]) aNameAccess.getByName(_sInternalFilterName);
+ if (aElements != null)
+ {
+ String sExtension = null;
+ // System.out.println("getByName().length: " + String.valueOf(aElements.length));
+ for (int i=0;i<aElements.length; i++)
+ {
+ PropertyValue aPropertyValue = (PropertyValue)aElements[i];
+ // System.out.println("PropertyValue.Name: " + aPropertyValue.Name);
+ if (aPropertyValue.Name.equals("Extensions"))
+ {
+ aExtensions = (String[])aPropertyValue.Value;
+ GlobalLogWriter.get().println(" Possible extensions are: " + String.valueOf(aExtensions.length));
+ if (aExtensions.length > 0)
+ {
+ for (int j=0;j<aExtensions.length;j++)
+ {
+ GlobalLogWriter.get().println(" " + aExtensions[j]);
+ }
+ sExtension = aExtensions[0];
+ GlobalLogWriter.get().println("");
+ }
+ }
+ }
+ return sExtension;
+ }
+ else
+ {
+ GlobalLogWriter.get().println("There are no elements for FilterName '" + _sInternalFilterName + "'");
+ return null;
+ }
+ }
+ catch (com.sun.star.container.NoSuchElementException e)
+ {
+ GlobalLogWriter.get().println("NoSuchElementException caught. " + e.getMessage());
+ }
+ catch (com.sun.star.lang.WrappedTargetException e)
+ {
+ GlobalLogWriter.get().println("WrappedTargetException caught. " + e.getMessage());
+ }
+}
+ }
+ return null;
+ }
+
+ // -----------------------------------------------------------------------------
+ public static void convertDocument(String _sInputFile, String _sOutputPath, GraphicalTestArguments _aGTA) throws ConvWatchCancelException
+ {
+ XMultiServiceFactory xMSF = _aGTA.getMultiServiceFactory();
+ if (xMSF == null)
+ {
+ GlobalLogWriter.get().println("MultiServiceFactory in GraphicalTestArgument not set.");
+ return;
+ }
+
+ String sInputURL = URLHelper.getFileURLFromSystemPath(_sInputFile);
+ // showType(sInputURL, xMSF);
+ XComponent aDoc = loadFromURL( _aGTA, sInputURL);
+ if (aDoc == null)
+ {
+ GlobalLogWriter.get().println("Can't load document '"+ sInputURL + "'");
+ return;
+ }
+
+ if (_sOutputPath == null)
+ {
+ GlobalLogWriter.get().println("Outputpath not set.");
+ return;
+ }
+
+ if (! _aGTA.isStoreAllowed())
+ {
+ GlobalLogWriter.get().println("It's not allowed to store, check Input/Output path.");
+ return;
+ }
+// TODO: Do we need to wait?
+ TimeHelper.waitInSeconds(1, "wait after loadFromURL.");
+
+ XServiceInfo xServiceInfo = UnoRuntime.queryInterface( XServiceInfo.class, aDoc );
+ // String sFilter = getFilterName_forExcel(xServiceInfo);
+ // System.out.println("Filter is " + sFilter);
+
+ // store the document in an other directory
+ XStorable xStorable = UnoRuntime.queryInterface( XStorable.class, aDoc);
+ if (xStorable == null)
+ {
+ GlobalLogWriter.get().println("com.sun.star.frame.XStorable is null");
+ return;
+ }
+
+ String sFilterName = _aGTA.getExportFilterName();
+
+ // check how many Properties should initialize
+ int nPropertyCount = 0;
+ // if (sFilterName != null && sFilterName.length() > 0)
+ // {
+ // nPropertyCount ++;
+ // }
+
+ // initialize PropertyArray
+ // PropertyValue [] aStoreProps = new PropertyValue[ nPropertyCount ];
+ // int nPropertyIndex = 0;
+ ArrayList<PropertyValue> aPropertyList = new ArrayList<PropertyValue>();
+
+ String sExtension = "";
+
+ if (sFilterName != null && sFilterName.length() > 0)
+ {
+ String sInternalFilterName = getInternalFilterName(sFilterName, xMSF);
+ String sServiceName = getServiceNameFromFilterName(sFilterName, xMSF);
+
+ GlobalLogWriter.get().println("Filter detection:");
+ // check if service name from file filter is the same as from the loaded document
+ boolean bServiceFailed = false;
+ if (sServiceName == null || sInternalFilterName == null)
+ {
+ GlobalLogWriter.get().println("Given FilterName '" + sFilterName + "' seems to be unknown.");
+ bServiceFailed = true;
+ }
+ if (! xServiceInfo.supportsService(sServiceName))
+ {
+ GlobalLogWriter.get().println("Service from FilterName '" + sServiceName + "' is not supported by loaded document.");
+ bServiceFailed = true;
+ }
+ if (bServiceFailed == true)
+ {
+ GlobalLogWriter.get().println("Please check '" + PropertyName.DOC_CONVERTER_EXPORT_FILTER_NAME + "' in the property file.");
+ return;
+ }
+
+ if (sInternalFilterName != null && sInternalFilterName.length() > 0)
+ {
+ // get the FileExtension, by the filter name, if we don't get a file extension
+ // we assume the is also no right filter name.
+ sExtension = getFileExtension(sInternalFilterName, xMSF);
+ if (sExtension == null)
+ {
+ GlobalLogWriter.get().println("Can't found an extension for filtername, take it from the source.");
+ }
+ }
+
+ PropertyValue Arg = new PropertyValue();
+ Arg.Name = "FilterName";
+ Arg.Value = sFilterName;
+ // aStoreProps[nPropertyIndex ++] = Arg;
+ aPropertyList.add(Arg);
+ showProperty(Arg);
+ GlobalLogWriter.get().println("FilterName is set to: " + sFilterName);
+ }
+
+ String sOutputURL = "";
+ try
+ {
+ // create the new filename with the extension, which is ok to the file format
+ String sInputFileBasename = FileHelper.getBasename(_sInputFile);
+ // System.out.println("InputFileBasename " + sInputFileBasename);
+ String sInputFileNameNoSuffix = FileHelper.getNameNoSuffix(sInputFileBasename);
+ // System.out.println("InputFilename no suffix " + sInputFileNameNoSuffix);
+ String fs = System.getProperty("file.separator");
+ String sOutputFile = _sOutputPath;
+ if (! sOutputFile.endsWith(fs))
+ {
+ sOutputFile += fs;
+ }
+ if (sExtension != null && sExtension.length() > 0)
+ {
+ sOutputFile += sInputFileNameNoSuffix + "." + sExtension;
+ }
+ else
+ {
+ sOutputFile += sInputFileBasename;
+ }
+
+ if (FileHelper.exists(sOutputFile) && _aGTA.getOverwrite() == false)
+ {
+ GlobalLogWriter.get().println("File already exist, don't overwrite. Set " + PropertyName.DOC_COMPARATOR_OVERWRITE_REFERENCE + "=true to force overwrite.");
+ return;
+ }
+
+ sOutputURL = URLHelper.getFileURLFromSystemPath(sOutputFile);
+
+ GlobalLogWriter.get().println("Store document as '" + sOutputURL + "'");
+ xStorable.storeAsURL(sOutputURL, PropertyHelper.createPropertyValueArrayFormArrayList(aPropertyList));
+ GlobalLogWriter.get().println("Document stored.");
+ }
+ catch (com.sun.star.io.IOException e)
+ {
+ GlobalLogWriter.get().println("Can't store document '" + sOutputURL + "'. Message is :'" + e.getMessage() + "'");
+ }
+// TODO: Do we need to wait?
+ TimeHelper.waitInSeconds(1, "unknown in OfficePrint.convertDocument()");
+
+ }
+
+}
+
diff --git a/qadevOOo/runner/convwatch/PRNCompare.java b/qadevOOo/runner/convwatch/PRNCompare.java
new file mode 100644
index 000000000000..1d0503299d67
--- /dev/null
+++ b/qadevOOo/runner/convwatch/PRNCompare.java
@@ -0,0 +1,805 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package convwatch;
+
+
+import helper.ProcessHandler;
+import java.io.File;
+import convwatch.PixelCounter;
+import convwatch.StatusHelper;
+import helper.OSHelper;
+import helper.StringHelper;
+import java.util.ArrayList;
+import util.utils;
+
+// -----------------------------------------------------------------------------
+// --------------------------------- PRNCompare ---------------------------------
+
+// class DifferenceType
+// {
+// final static int NO_DIFFERENCE = 1;
+// final static int DIFFERENCE = 2;
+//
+// public int nValue = NO_DIFFERENCE;
+// public boolean equals(int _n)
+// {
+// if ( _n == nValue ) return true;
+// return false;
+// }
+// }
+
+// -----------------------------------------------------------------------------
+public class PRNCompare
+{
+ // OSHelper m_aHelper;
+ String fs;
+
+ public PRNCompare()
+ {
+ // m_aHelper = new OSHelper();
+ fs = System.getProperty("file.separator");
+ }
+
+ String executeSynchronously(String _sCommand)
+ {
+ // System.out.println(_sCommand);
+
+ ProcessHandler aHandler = new ProcessHandler(_sCommand);
+ boolean bBackValue = aHandler.executeSynchronously();
+
+ String sText = aHandler.getOutputText();
+
+ GlobalLogWriter.get().println("Exitcode: " + String.valueOf(aHandler.getExitCode()));
+ return sText;
+ }
+
+
+ int getMaxNumOfFileEntry(String _sDirectory, String _sBasename)
+ {
+// TODO: check if directory exist should be done earlier
+ File aDirectory = new File(_sDirectory);
+ File[] aDirList = aDirectory.listFiles(
+ /*
+ new FileFilter() {
+ boolean accept(File filename)
+ {
+ if (filename.getName().endsWith("jpg"))
+ return true;
+ return false;
+ }
+ } */
+ );
+
+ int nMaxNumber = 0;
+ for(int n = 0; n<aDirList.length ; n++)
+ {
+ String sDirEntry = aDirList[n].getName();
+ if (sDirEntry.endsWith(".jpg"))
+ {
+ int nNum = nMaxNumber;
+
+ if (sDirEntry.startsWith(_sBasename))
+ {
+ // System.out.println(sDirEntry);
+ int nJpgIdx = sDirEntry.lastIndexOf(".jpg");
+ String sValue = sDirEntry.substring(_sBasename.length(), nJpgIdx);
+ int nValue = 0;
+ try
+ {
+ nValue = Integer.valueOf(sValue).intValue();
+ }
+ catch(java.lang.NumberFormatException e)
+ {
+ }
+
+ // System.out.println(nValue);
+ nNum = nValue;
+ }
+
+ if (nNum > nMaxNumber)
+ {
+ nMaxNumber = nNum;
+ }
+ }
+ }
+ return nMaxNumber;
+ }
+
+ String m_sInputPath;
+ String m_sReferencePath;
+ String m_sOutputPath;
+ String m_sDocFile;
+ String m_sReferenceFile;
+ String m_sPostScriptFile;
+ // String m_sOldDiff;
+ int m_nMaxPages = 0;
+ int m_nResolutionInDPI = 0;
+ TriState m_tUseBorderMove;
+ String m_sDocumentType;
+
+ public void setInputPath(String _sInputPath) { m_sInputPath = _sInputPath; }
+
+ public void setReferencePath(String _sReferencePath) { m_sReferencePath = _sReferencePath; }
+
+ public void setOutputPath(String _sOutPath) { m_sOutputPath = _sOutPath; }
+
+ public void setDocFile(String _sDocFile) { m_sDocFile = _sDocFile;}
+
+ public void setReferenceFile(String _sPRNFile){ m_sReferenceFile = _sPRNFile;}
+
+ public void setPostScriptFile(String _sPSFile){ m_sPostScriptFile = _sPSFile;}
+
+ public void setBorderMove(TriState _b) {m_tUseBorderMove = _b;}
+ public TriState getBorderMove() {return m_tUseBorderMove;}
+ // public void setOldDiffPath(String _sOldDiff)
+ // {
+ // m_sOldDiff = _sOldDiff;
+ // }
+ public void setMaxPages(int _n) {m_nMaxPages = _n;}
+ int getMaxPages() {return m_nMaxPages;}
+
+ public void setResolutionInDPI(int _n) {m_nResolutionInDPI = _n;}
+ int getResolutionInDPI() {return m_nResolutionInDPI;}
+
+ public void setDocumentType(String _sTypeName)
+ {
+ m_sDocumentType = _sTypeName;
+ }
+
+ // -----------------------------------------------------------------------------
+
+ public StatusHelper[] compare()
+ {
+ createJPEGFromPostscript(m_sOutputPath, m_sReferencePath, m_sReferenceFile, getResolutionInDPI());
+// TODO: Assume, that Postscript is already in the OutputPath, this may change.
+ createJPEGFromPostscript(m_sOutputPath, m_sOutputPath, m_sPostScriptFile, getResolutionInDPI());
+ StatusHelper[] aList = createDiffs(m_sOutputPath,
+ m_sOutputPath, m_sReferenceFile,
+ m_sOutputPath, m_sPostScriptFile,
+ getMaxPages(), m_tUseBorderMove);
+
+// TODO: Rename?
+
+ return aList;
+ }
+
+ public StatusHelper[] compare_new()
+ {
+ String[] aRefList = createJPEGFromPostscript(m_sOutputPath, m_sReferencePath, m_sReferenceFile, getResolutionInDPI());
+// TODO: Assume, that Postscript is already in the OutputPath, this may change.
+ String[] aPSList = createJPEGFromPostscript(m_sOutputPath, m_sOutputPath, m_sPostScriptFile, getResolutionInDPI());
+ StatusHelper[] aList = createDiffs(m_sOutputPath,
+ aRefList,
+ aPSList,
+ getMaxPages(), m_tUseBorderMove);
+
+ return aList;
+ }
+
+ static String getJPEGName(String _sOutputPath, String _sBasename, String _sGS_PageOutput)
+ {
+ String fs = System.getProperty("file.separator");
+
+ String sJPEGName = _sOutputPath + fs + _sBasename + _sGS_PageOutput + ".jpg";
+ return sJPEGName;
+ }
+
+ /**
+ * Create via ghostscript (gs) from the reference file for every page a JPEG file
+ *
+ * MUST set:
+ * m_sOutputPath, m_sReferenceFile, m_sReferencePath
+ *
+ * return exit code from gs command
+ */
+ public static String[] createJPEGFromPostscript(String _sOutputPath, String _sSourcePath, String _sSourceFile, int _nResolutionInDPI)
+ {
+ String sGS_PageOutput = "%04d";
+ // if ( OSHelper.isWindows() )
+ // {
+ // sGS_PageOutput = "%%d";
+ // }
+
+ FileHelper.makeDirectories("", _sOutputPath);
+
+ // create a jpeg from original prn
+ String fs = System.getProperty("file.separator");
+
+ String sJPGFilename = getJPEGName(_sOutputPath, _sSourceFile, sGS_PageOutput);
+ String sOriginalFile = _sSourcePath + fs + _sSourceFile;
+ String sCommand;
+ String sGS = "gs";
+ if (OSHelper.isWindows())
+ {
+ sGS = "gswin32c.exe";
+ }
+
+ sCommand = sGS + " -dNOPROMPT -dBATCH -sDEVICE=jpeg -r" + String.valueOf(_nResolutionInDPI) + " -dNOPAUSE -sOutputFile=" + StringHelper.doubleQuoteIfNeed(sJPGFilename) + " " + StringHelper.doubleQuoteIfNeed(sOriginalFile);
+ String[] sCommandArray =
+ {
+ sGS,
+ "-dNOPROMPT",
+ "-dBATCH",
+ "-sDEVICE=jpeg",
+ "-r" + String.valueOf(_nResolutionInDPI),
+ "-dNOPAUSE",
+ "-sOutputFile=" + sJPGFilename,
+ sOriginalFile
+ };
+ // System.out.println("Start Command array");
+ // try
+ // {
+ // Runtime.getRuntime().exec(sCommandArray);
+ // } catch (Exception e) {
+ // System.out.println("FAILED");
+ // }
+ // System.out.println("done");
+
+ ProcessHandler aHandler = new ProcessHandler(sCommandArray);
+ boolean bBackValue = aHandler.executeSynchronously();
+
+ // TODO: return a real filename, due to the fact we don't know how much files are created, maybe better to return a list
+
+ ArrayList m_aFileList = new ArrayList();
+ for (int i=1;i<9999;i++)
+ {
+ String sNewJPEGFilename = utils.replaceAll13(sJPGFilename, sGS_PageOutput, StringHelper.createValueString(i, 4));
+ if (FileHelper.exists(sNewJPEGFilename))
+ {
+ m_aFileList.add(sNewJPEGFilename); // as long as the files exist, fill the array
+ }
+ else
+ {
+ break; // stop file check
+ }
+ }
+ String[] aList = new String[m_aFileList.size()];
+ aList = (String[])m_aFileList.toArray(aList);
+ return aList; // sNewJPEGFilename;
+ }
+
+ /**
+ * Create Difference Files from the JPEGs
+ * parameter, how much difference files should create
+ *
+ * m_sPostScriptFile
+ * m_sReferenceFile
+ * m_sOutputPath
+ */
+ public StatusHelper[] createDiffs(String _sOutputPath, String _sSourcePath1, String _sSourceFile1, String _sSourcePath2, String _sSourceFile2, int _nMaxDiffs, TriState _tUseBorderMove)
+ {
+ if (_nMaxDiffs < 1)
+ {
+ _nMaxDiffs = 1;
+ }
+
+ String sS1Basename = FileHelper.getBasename(_sSourceFile1);
+ String sS2Basename = FileHelper.getBasename(_sSourceFile2);
+
+ // count, from which file (jpegs) exist more, take the less one
+ // more are not compareable
+ int nS1_Files = getMaxNumOfFileEntry(_sSourcePath1, sS1Basename);
+ int nS2_Files = getMaxNumOfFileEntry(_sSourcePath2, sS2Basename);
+
+ // System.out.println("count of s1 files " + String.valueOf(nS1_Files));
+ // System.out.println("count of s2 files " + String.valueOf(nS2_Files));
+
+ // take the min of both
+ int nMin = Math.min(nS1_Files, nS2_Files);
+ nMin = Math.min(nMin, _nMaxDiffs);
+
+ StatusHelper[] aList = new StatusHelper[nMin];
+
+// TODO: if both document do not have same page count, produce an error
+ // System.out.println("min of both: " + String.valueOf(nMin));
+
+ int nStatusIndex = 0;
+ for (int i=1;i<=nMin;i++)
+ {
+ String sOldGfx = getJPEGName(_sSourcePath1, sS1Basename, StringHelper.createValueString(i, 4));
+ String sNewGfx = getJPEGName(_sSourcePath2, sS2Basename, StringHelper.createValueString(i, 4));
+ String sDiffGfx_ = getJPEGName(_sOutputPath, sS1Basename + ".diff", StringHelper.createValueString(i, 4));
+
+
+ String sDiffGfx = compareJPEGs(sOldGfx, sNewGfx, sDiffGfx_);
+ StatusHelper aStatus = new StatusHelper(sOldGfx, sNewGfx, sDiffGfx);
+
+ // if (FileHelper.exists(sDiffGfx))
+ if (sDiffGfx.length() > 0)
+ {
+ int nResult = identify(sDiffGfx);
+ if (nResult == 1)
+ {
+ aStatus.nDiffStatus = StatusHelper.DIFF_NO_DIFFERENCES;
+ }
+ else
+ {
+ try
+ {
+ int nPercent = estimateGfx(sOldGfx, sNewGfx, sDiffGfx);
+ aStatus.nDiffStatus = StatusHelper.DIFF_DIFFERENCES_FOUND;
+ aStatus.nPercent = nPercent;
+
+ // GlobalLogWriter.get().println("Hello World: Percent:= " + nPercent);
+ // GlobalLogWriter.get().println("Hello World: TriState:= " + _tUseBorderMove.intValue());
+ // GlobalLogWriter.get().println("Hello World: DocType:= " + m_sDocumentType);
+
+// TODO: insert here the new BorderRemover if the percentage value is creater than 75%
+ if (nPercent > 75 &&
+ ((_tUseBorderMove == TriState.TRUE ) ||
+ ((_tUseBorderMove == TriState.UNSET) &&
+ m_sDocumentType.indexOf("MS PowerPoint") > 0)))
+ {
+ setBorderMove(TriState.TRUE);
+
+ String sOld_BM_Gfx = getJPEGName(_sSourcePath1, sS1Basename + ".BM", StringHelper.createValueString(i, 4));
+ String sNew_BM_Gfx = getJPEGName(_sSourcePath2, sS2Basename + ".BM", StringHelper.createValueString(i, 4));
+ String sDiff_BM_Gfx_ = getJPEGName(_sOutputPath, sS1Basename + ".diff.BM", StringHelper.createValueString(i, 4));
+ aStatus.setFilesForBorderMove(sOld_BM_Gfx, sNew_BM_Gfx, sDiff_BM_Gfx_);
+ try
+ {
+ BorderRemover a = new BorderRemover();
+ a.createNewImageWithoutBorder(sOldGfx, sOld_BM_Gfx);
+ a.createNewImageWithoutBorder(sNewGfx, sNew_BM_Gfx);
+
+ String sDiff_BM_Gfx = compareJPEGs( sOld_BM_Gfx, sNew_BM_Gfx, sDiff_BM_Gfx_);
+
+ // if (FileHelper.exists(sDiff_BM_Gfx))
+ if (sDiff_BM_Gfx.length() > 0)
+ {
+ nResult = identify(sDiff_BM_Gfx);
+ if (nResult == 1)
+ {
+ aStatus.nDiffStatus = StatusHelper.DIFF_AFTER_MOVE_DONE_NO_PROBLEMS;
+ aStatus.nPercent2 = 0;
+ }
+ else
+ {
+ nPercent = estimateGfx(sOld_BM_Gfx, sNew_BM_Gfx, sDiff_BM_Gfx);
+ aStatus.nDiffStatus = StatusHelper.DIFF_AFTER_MOVE_DONE_DIFFERENCES_FOUND;
+ aStatus.nPercent2 = nPercent;
+ }
+ }
+ else
+ {
+ }
+ }
+ catch(java.io.IOException e)
+ {
+ GlobalLogWriter.get().println("Exception caught. At border remove: " + e.getMessage());
+ }
+ }
+
+
+ }
+ catch (java.io.IOException e)
+ {
+ GlobalLogWriter.get().println(e.getMessage());
+ }
+ }
+
+ // checkDiff(sOldGfx, sNewGfx, sDiffGfx);
+ // if (i >= _nMaxDiffs)
+ // {
+ // break;
+ // }
+ }
+ aList[nStatusIndex ++] = aStatus;
+ }
+ return aList;
+ }
+
+
+ public StatusHelper[] createDiffs(String _sOutputPath, String[] _aRefList, String[] _aPSList, int _nMaxDiffs, TriState _tUseBorderMove)
+ {
+ if (_nMaxDiffs < 1)
+ {
+ _nMaxDiffs = 1;
+ }
+
+ // count, from which file (jpegs) exist more, take the less one
+ // more are not compareable
+
+ // take the min of both
+ int nMin = Math.min(_aRefList.length, _aPSList.length);
+ nMin = Math.min(nMin, _nMaxDiffs);
+
+ StatusHelper[] aList = new StatusHelper[nMin];
+
+// TODO: if both document do not have same page count, produce an error
+ // System.out.println("min of both: " + String.valueOf(nMin));
+
+ int nStatusIndex = 0;
+ for (int i=1;i<=nMin;i++)
+ {
+ String sOldGfx = _aRefList[i];
+ String sNewGfx = _aPSList[i];
+ // String sDiffGfx_ = getJPEGName(_sOutputPath, sS1Basename + ".diff", StringHelper.createValueString(i, 4));
+
+
+ String sDiffGfx = compareJPEGs(sOldGfx, sNewGfx );
+ StatusHelper aStatus = new StatusHelper(sOldGfx, sNewGfx, sDiffGfx);
+
+ // if (FileHelper.exists(sDiffGfx))
+ if (sDiffGfx.length() > 0)
+ {
+ int nResult = identify(sDiffGfx);
+ if (nResult == 1)
+ {
+ aStatus.nDiffStatus = StatusHelper.DIFF_NO_DIFFERENCES;
+ }
+ else
+ {
+ try
+ {
+ int nPercent = estimateGfx(sOldGfx, sNewGfx, sDiffGfx);
+ // GlobalLogWriter.get().println("Hello World: Percent:= " + nPercent);
+ // GlobalLogWriter.get().println("Hello World: TriState:= " + _tUseBorderMove.intValue());
+ // GlobalLogWriter.get().println("Hello World: DocType:= " + m_sDocumentType);
+
+ aStatus.nDiffStatus = StatusHelper.DIFF_DIFFERENCES_FOUND;
+ aStatus.nPercent = nPercent;
+
+ if (nPercent > 75 &&
+ ((_tUseBorderMove == TriState.TRUE ) ||
+ ((_tUseBorderMove == TriState.UNSET) &&
+ m_sDocumentType.indexOf("MS PowerPoint") > 0)))
+ {
+ _tUseBorderMove = TriState.TRUE;
+// TODO: problem is here, that we have to create some new names.
+
+ String sBasename1 = FileHelper.getBasename(sOldGfx);
+ String sNameNoSuffix1 = FileHelper.getNameNoSuffix(sBasename1);
+ String sBasename2 = FileHelper.getBasename(sNewGfx);
+ String sNameNoSuffix2 = FileHelper.getNameNoSuffix(sBasename2);
+
+ String sTmpDir = util.utils.getUsersTempDir();
+ String fs = System.getProperty("file.separator");
+
+ String sOld_BM_Gfx = sTmpDir + fs + sNameNoSuffix1 + "-BM-" + StringHelper.createValueString(i, 4) + ".jpg";
+ String sNew_BM_Gfx = sTmpDir + fs + sNameNoSuffix2 + "-BM-" + StringHelper.createValueString(i, 4) + ".jpg";
+ try
+ {
+ BorderRemover a = new BorderRemover();
+ a.createNewImageWithoutBorder(sOldGfx, sOld_BM_Gfx);
+ a.createNewImageWithoutBorder(sNewGfx, sNew_BM_Gfx);
+
+ String sDiff_BM_Gfx = compareJPEGs( sOld_BM_Gfx, sNew_BM_Gfx );
+
+ aStatus.setFilesForBorderMove(sOld_BM_Gfx, sNew_BM_Gfx, sDiff_BM_Gfx);
+
+ // if (FileHelper.exists(sDiff_BM_Gfx))
+ if (sDiff_BM_Gfx.length() > 0)
+ {
+ nResult = identify(sDiff_BM_Gfx);
+ if (nResult == 1)
+ {
+ aStatus.nDiffStatus = StatusHelper.DIFF_AFTER_MOVE_DONE_NO_PROBLEMS;
+ aStatus.nPercent2 = 0;
+ }
+ else
+ {
+ nPercent = estimateGfx(sOld_BM_Gfx, sNew_BM_Gfx, sDiff_BM_Gfx);
+ aStatus.nDiffStatus = StatusHelper.DIFF_AFTER_MOVE_DONE_DIFFERENCES_FOUND;
+ aStatus.nPercent2 = nPercent;
+ }
+ }
+ else
+ {
+ }
+ }
+ catch(java.io.IOException e)
+ {
+ GlobalLogWriter.get().println("Exception caught. At border remove: " + e.getMessage());
+ }
+ }
+ }
+ catch (java.io.IOException e)
+ {
+ GlobalLogWriter.get().println(e.getMessage());
+ }
+ }
+
+ // checkDiff(sOldGfx, sNewGfx, sDiffGfx);
+ // if (i >= _nMaxDiffs)
+ // {
+ // break;
+ // }
+ }
+ aList[nStatusIndex ++] = aStatus;
+ }
+ return aList;
+ }
+
+ public static String compareJPEGs(String _sOldGfx, String _sNewGfx)
+ {
+ String sBasename1 = FileHelper.getBasename(_sOldGfx);
+ String sNameNoSuffix1 = FileHelper.getNameNoSuffix(sBasename1);
+ String sBasename2 = FileHelper.getBasename(_sNewGfx);
+ String sNameNoSuffix2 = FileHelper.getNameNoSuffix(sBasename2);
+
+ String sTmpDir = util.utils.getUsersTempDir();
+ String fs = System.getProperty("file.separator");
+
+ String sDiffName = sTmpDir + fs + sNameNoSuffix1 + "-" + sNameNoSuffix2 + "-diff.jpg";
+
+ return compareJPEGs(_sOldGfx, _sNewGfx, sDiffName);
+ }
+
+ public static String compareJPEGs(String _sOldGfx, String _sNewGfx, String _sDiffGfx)
+ {
+ String sComposite = "composite";
+ if (OSHelper.isWindows())
+ {
+ sComposite = "composite.exe";
+ }
+
+ // String sCommand = sComposite + " -compose difference " +
+ // StringHelper.doubleQuoteIfNeed(_sOldGfx) + " " +
+ // StringHelper.doubleQuoteIfNeed(_sNewGfx) + " " +
+ // StringHelper.doubleQuoteIfNeed(_sDiffGfx);
+
+ String[] sCommandArray =
+ {
+ sComposite,
+ "-compose",
+ "difference",
+ _sOldGfx,
+ _sNewGfx,
+ _sDiffGfx
+ };
+
+ ProcessHandler aHandler = new ProcessHandler(sCommandArray);
+ boolean bBackValue = aHandler.executeSynchronously();
+
+ String sBack = aHandler.getOutputText();
+ GlobalLogWriter.get().println("'" + sBack + "'");
+
+ // return aHandler.getExitCode();
+ if (FileHelper.exists(_sDiffGfx))
+ {
+ return _sDiffGfx;
+ }
+ return "";
+ }
+
+ /**
+ * wrapper for ImageMagick identify,
+ * function checks how many different colors a picture contains.
+ * if it's only one color (nResult==1), like background color, there is no difference.
+ */
+ int identify(String _sDiffGfx)
+ {
+ int nResult = 0;
+ // would like to know what the meaning of %k is for ImageMagick's 'identify'
+ String sIM_Format = "%k";
+ // if (OSHelper.isWindows())
+ // {
+ // sIM_Format = "%%k";
+ // }
+
+ String sIdentify = "identify";
+ if (OSHelper.isWindows())
+ {
+ sIdentify = "identify.exe";
+ }
+
+ // String sCommand = sIdentify + " " + sIM_Format + " " + StringHelper.doubleQuoteIfNeed(_sDiffGfx);
+
+ String[] sCommandArray =
+ {
+ sIdentify,
+ "-format",
+ sIM_Format,
+ _sDiffGfx
+ };
+ ProcessHandler aHandler = new ProcessHandler(sCommandArray);
+ boolean bBackValue = aHandler.executeSynchronously();
+ String sBack = aHandler.getOutputText();
+ GlobalLogWriter.get().println("'" + sBack + "'");
+
+ // try to interpret the result, which we get as a String
+ try
+ {
+ int nIdx = sBack.indexOf("\n");
+ if (nIdx > 0)
+ {
+ sBack = sBack.substring(0, nIdx);
+ }
+
+ nResult = Integer.valueOf(sBack).intValue();
+ }
+ catch(java.lang.NumberFormatException e)
+ {
+ GlobalLogWriter.get().println("Number format exception");
+ nResult = 0;
+ }
+ return nResult;
+ }
+
+ /*
+ * Check 2 different differ files
+ * return 1 if there is no difference between both diff files.
+ */
+
+// TODO: Maybe a StatusHelper is a better return value
+ public StatusHelper checkDiffDiff(String _sOutputPath, String _sSourcePath1, String _sSourceFile1, String _sSourcePath2, String _sSourceFile2)
+ {
+ String sNewGfx = _sSourcePath1 + fs + _sSourceFile1;
+ String sOldGfx = _sSourcePath2 + fs + _sSourceFile2;
+
+ int nNumber = 1;
+ String sDiffGfx;
+ sDiffGfx = getJPEGName(_sOutputPath, _sSourceFile1 + ".diff", StringHelper.createValueString(nNumber, 4));
+
+ StatusHelper aCurrentStatus = new StatusHelper(sOldGfx, sNewGfx, sDiffGfx);
+
+ // String sComposite = "composite";
+ // if (OSHelper.isWindows())
+ // {
+ // sComposite = "composite.exe";
+ // }
+ //
+ // String sCommand = sComposite +" -compose difference " +
+ // StringHelper.doubleQuoteIfNeed(sOldGfx) + " " +
+ // StringHelper.doubleQuoteIfNeed(sNewGfx) + " " +
+ // StringHelper.doubleQuoteIfNeed(sDiffGfx);
+ //
+ //
+ // // System.out.println(sCommand);
+ // // executeSynchronously(sCommand);
+ // ProcessHandler aHandler = new ProcessHandler(sCommand);
+ // boolean bBackValue = aHandler.executeSynchronously();
+
+ compareJPEGs(sOldGfx, sNewGfx, sDiffGfx);
+
+ if (FileHelper.exists(sDiffGfx))
+ {
+ int nResult = identify(sDiffGfx);
+ if (nResult == 1)
+ {
+ aCurrentStatus.nDiffStatus = StatusHelper.DIFF_NO_DIFFERENCES;
+ }
+ else
+ {
+ aCurrentStatus.nDiffStatus = StatusHelper.DIFF_DIFFERENCES_FOUND;
+ try
+ {
+ aCurrentStatus.nPercent = estimateGfx(sOldGfx, sNewGfx, sDiffGfx);
+ }
+ catch (java.io.IOException e)
+ {
+ GlobalLogWriter.get().println(e.getMessage());
+ aCurrentStatus.nPercent = -1;
+ }
+ }
+ // LLA: should diffdiff file delete?
+ // File aFile = new File(sDiffGfx);
+ // aFile.delete();
+ }
+ else
+ {
+ GlobalLogWriter.get().println("composite can't create the diffdiff file.");
+ }
+
+ return aCurrentStatus;
+ }
+
+ // -----------------------------------------------------------------------------
+ /**
+ * count how much pixel differ and between Old or New and the Difference graphics
+ *
+ * First, count the old graphics, then the new graphics due to the fact both should be equal
+ * it should be legal to take result from old or new. We take the graphics with less values.
+ *
+ * Second, count the difference graphics, now take the percent algorithm and
+ * build a percent value, which contain the number of different pixels as a percent value
+ *
+ * Interpretation:
+ * 0% there is no difference
+ *
+ * <100% Take a look into the difference graphics, maybe the difference graphics shows
+ * text like outlined or the text is little bit move left, right up or down.
+ *
+ * >100% Yes it's possible that there is a difference more then 100%, maybe a font problem
+ * between old and new graphics. The font of the new graphics is little bit bigger,
+ * so the pixel count between old graphics and new graphics is twice the more.
+ *
+ */
+ public int estimateGfx(String _sOldGfx, String _sNewGfx, String _sDiffGfx)
+ throws java.io.IOException
+ {
+ // new count pixels
+ int nNotWhiteCount_OldGraphic = PixelCounter.countNotWhitePixelsFromImage(_sOldGfx);
+ int nNotWhiteCount_NewGraphic = PixelCounter.countNotWhitePixelsFromImage(_sNewGfx);
+ int nNotBlackCount_DiffGraphic = PixelCounter.countNotBlackPixelsFromImage(_sDiffGfx);
+
+ int nMinNotWhiteCount = Math.min(nNotWhiteCount_NewGraphic, nNotWhiteCount_OldGraphic);
+
+ // check if not zero
+ if (nMinNotWhiteCount == 0)
+ {
+ nMinNotWhiteCount = Math.max(nNotWhiteCount_NewGraphic, nNotWhiteCount_OldGraphic);
+ if (nMinNotWhiteCount == 0)
+ {
+ nMinNotWhiteCount = 1;
+ }
+ }
+
+ int nPercent = Math.abs(nNotBlackCount_DiffGraphic * 100 / nMinNotWhiteCount);
+ GlobalLogWriter.get().println( "Graphics check, pixel based:" + String.valueOf(nPercent) + "% pixel differ ");
+ return nPercent;
+ }
+
+
+
+/*
+ * Some selftest functionallity
+ */
+// public static void main(String[] args)
+// {
+ // System.out.println(FileHelper.getNameNoSuffix("doc.sxw"));
+ // System.out.println(FileHelper.getSuffix("doc.sxw"));
+ // System.out.println(FileHelper.getBasename("doc.sxw"));
+ // System.out.println(FileHelper.getBasename("/tmp/doc.sxw"));
+
+// PRNCompare a = new PRNCompare();
+// a.setInputPath( "/cws/so-cwsserv06/qadev18/SRC680/src.m47/convwatch.keep/input/msoffice/xp/PowerPoint");
+// a.setReferencePath( "/cws/so-cwsserv06/qadev18/SRC680/src.m47/convwatch.keep/input/msoffice/xp/PowerPoint");
+// a.setOutputPath( "/tmp/convwatch_java");
+// a.setDocFile( "1_Gov.ppt");
+// a.setReferenceFile( "1_Gov.prn" );
+// a.setPostScriptFile("1_Gov.ps" );
+ // a.compare();
+
+
+// LLA: 20040804 sample how to build jpegs from reference files
+// a.createJPEGFromPostscript("/tmp/convwatch_java",
+// "/home/apitest/WorkFromHome/20040804/reference", "worddoc.prn" );
+//
+// a.createJPEGFromPostscript("/tmp/convwatch_java",
+// "/home/apitest/WorkFromHome/20040804/reference", "worddoc.ps" );
+
+// Status[] aList = a.createDiffs("/tmp/convwatch_java",
+// "/tmp/convwatch_java", "worddoc.prn",
+// "/tmp/convwatch_java", "worddoc.ps",
+// 2);
+
+// LLA: 20040805 sample how to check 2 gfx files
+// this function return DifferenceType.NO_DIFFERENCE if the pictures contain no graphically difference
+// DifferenceType aReturnValue = a.checkDiffDiff("/tmp/convwatch_java",
+// "/tmp/convwatch_java", "worddoc.prn.diff1.jpg",
+// "/tmp/convwatch_java/old", "worddoc.prn.diff1.jpg");
+// if (aReturnValue.equals( DifferenceType.NO_DIFFERENCE ))
+// {
+// System.out.println("There is no difference between both diff files.");
+// }
+
+ // a.setOldDiff( "/olddiffs");
+// }
+}
diff --git a/qadevOOo/runner/convwatch/PerformanceContainer.java b/qadevOOo/runner/convwatch/PerformanceContainer.java
new file mode 100644
index 000000000000..d0c1e0fb5ed1
--- /dev/null
+++ b/qadevOOo/runner/convwatch/PerformanceContainer.java
@@ -0,0 +1,250 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package convwatch;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.RandomAccessFile;
+import java.lang.Double;
+
+
+public class PerformanceContainer /* extends *//* implements */ {
+ private long m_nStartTime;
+
+ /*
+ simple helper functions to start/stop a timer, to know how long a process need in milliseconds
+ */
+ public long getStartTime()
+ {
+ return System.currentTimeMillis();
+ }
+ public void setStartTime(long _nStartTime)
+ {
+ m_nStartTime = _nStartTime;
+ }
+
+ /*
+ return the time, which is done until last startTime()
+ */
+ private long meanTime(long _nCurrentTimer)
+ {
+ if (_nCurrentTimer == 0)
+ {
+ GlobalLogWriter.get().println("Forgotten to initialise a start timer.");
+ return 0;
+ }
+ long nMeanTime = System.currentTimeMillis();
+ return nMeanTime - _nCurrentTimer;
+ }
+
+ /*
+ public long stopTimer()
+ {
+ if (m_nStartTime == 0)
+ {
+ System.out.println("Forgotten to initialise start timer.");
+ return 0;
+ }
+ long nStopTime = System.currentTimeMillis();
+ return nStopTime - m_nStartTime;
+ }
+ */
+
+ final static int Load = 0;
+ final static int Store = 1;
+ final static int Print = 2;
+ final static int OfficeStart = 3;
+ final static int StoreAsPDF = 4;
+
+ private long m_nTime[];
+ private String m_sMSOfficeVersion;
+
+ public PerformanceContainer()
+ {
+ m_nTime = new long[5];
+ // @todo: is this need?
+ for (int i=0;i<5;i++)
+ {
+ m_nTime[i] = 0;
+ }
+ }
+
+ public void setTime(int _nIndex, long _nValue)
+ {
+ m_nTime[_nIndex] = _nValue;
+ }
+ public long getTime(int _nIndex)
+ {
+ return m_nTime[_nIndex];
+ }
+
+ public void startTime(int _nIndex)
+ {
+ m_nTime[_nIndex] = getStartTime();
+ }
+
+ public void stopTime(int _nIndex)
+ {
+ m_nTime[_nIndex] = meanTime(m_nTime[_nIndex]);
+ }
+
+ public String getMSOfficeVersion()
+ {
+ return m_sMSOfficeVersion;
+ }
+ public void print(FileWriter out) throws java.io.IOException
+ {
+ String ls = System.getProperty("line.separator");
+
+ out.write("loadtime=" + String.valueOf(m_nTime[ Load ]) + ls);
+ out.write("storetime=" + String.valueOf(m_nTime[ Store ]) + ls);
+ out.write("printtime=" + String.valueOf(m_nTime[ Print ]) + ls);
+ out.write("officestarttime=" + String.valueOf(m_nTime[ OfficeStart ]) + ls);
+ out.write("storeaspdftime=" + String.valueOf(m_nTime[ StoreAsPDF ]) + ls);
+ }
+
+ public static double stringToDouble(String _sStr)
+ {
+ double nValue = 0;
+ try
+ {
+ nValue = Double.parseDouble( _sStr );
+ }
+ catch (NumberFormatException e)
+ {
+ GlobalLogWriter.get().println("Can't convert string to double " + _sStr);
+ }
+ return nValue;
+ }
+
+ public static long secondsToMilliSeconds(double _nSeconds)
+ {
+ return (long)(_nSeconds * 1000.0);
+ }
+
+ /*
+ Helper function, which read some values from a given file
+
+ sample of wordinfofile
+ name=c:\doc-pool\wntmsci\samples\msoffice\word\LineSpacing.doc
+ WordVersion=11.0
+ WordStartTime=0.340490102767944
+ WordLoadTime=0.650935888290405
+ WordPrintTime=0.580835103988647
+ */
+ public void readWordValuesFromFile(String sFilename)
+ {
+ File aFile = new File(sFilename);
+ if (! aFile.exists())
+ {
+ GlobalLogWriter.get().println("couldn't find file " + sFilename);
+ return;
+ }
+
+ RandomAccessFile aRandomAccessFile = null;
+ try
+ {
+ aRandomAccessFile = new RandomAccessFile(aFile,"r");
+ String sLine = "";
+ while (sLine != null)
+ {
+ sLine = aRandomAccessFile.readLine();
+ if ( (sLine != null) &&
+ (! (sLine.length() < 2) ) &&
+ (! sLine.startsWith("#")))
+ {
+ if (sLine.startsWith("WordStartTime="))
+ {
+ String sTime = sLine.substring(14);
+ m_nTime[OfficeStart] = secondsToMilliSeconds(stringToDouble(sTime));
+ }
+ else if (sLine.startsWith("WordLoadTime="))
+ {
+ String sTime = sLine.substring(13);
+ m_nTime[Load] = secondsToMilliSeconds(stringToDouble(sTime));
+ }
+ else if (sLine.startsWith("WordPrintTime="))
+ {
+ String sTime = sLine.substring(14);
+ m_nTime[Print] = secondsToMilliSeconds(stringToDouble(sTime));
+ }
+ else if (sLine.startsWith("WordVersion="))
+ {
+ String sMSOfficeVersion = sLine.substring(12);
+ m_sMSOfficeVersion = "Word:" + sMSOfficeVersion;
+ }
+ else if (sLine.startsWith("ExcelVersion="))
+ {
+ String sMSOfficeVersion = sLine.substring(13);
+ m_sMSOfficeVersion = "Excel:" + sMSOfficeVersion;
+ }
+ else if (sLine.startsWith("PowerPointVersion="))
+ {
+ String sMSOfficeVersion = sLine.substring(18);
+ m_sMSOfficeVersion = "PowerPoint:" + sMSOfficeVersion;
+ }
+ }
+ }
+ }
+ catch (java.io.FileNotFoundException fne)
+ {
+ GlobalLogWriter.get().println("couldn't open file " + sFilename);
+ GlobalLogWriter.get().println("Message: " + fne.getMessage());
+ }
+ catch (java.io.IOException ie)
+ {
+ GlobalLogWriter.get().println("Exception while reading file " + sFilename);
+ GlobalLogWriter.get().println("Message: " + ie.getMessage());
+ }
+ try
+ {
+ aRandomAccessFile.close();
+ }
+ catch (java.io.IOException ie)
+ {
+ GlobalLogWriter.get().println("Couldn't close file " + sFilename);
+ GlobalLogWriter.get().println("Message: " + ie.getMessage());
+ }
+ }
+
+// public static void main(String[] args) {
+//
+///*
+// BorderRemover a = new BorderRemover();
+// try
+// {
+// a.createNewImageWithoutBorder(args[0], args[1]);
+// }
+// catch(java.io.IOException e)
+// {
+// System.out.println("Exception caught.");
+// }
+// */
+// }
+
+}
diff --git a/qadevOOo/runner/convwatch/PixelCounter.java b/qadevOOo/runner/convwatch/PixelCounter.java
new file mode 100644
index 000000000000..116b07e48d8e
--- /dev/null
+++ b/qadevOOo/runner/convwatch/PixelCounter.java
@@ -0,0 +1,206 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package convwatch;
+
+// import java.awt.Image;
+import convwatch.ImageHelper;
+
+// -----------------------------------------------------------------------------
+abstract class CountPixel
+{
+ int m_nCount = 0;
+ public int getCount() {return m_nCount;}
+ public abstract void count(int _nRGB);
+}
+
+// -----------------------------------------------------------------------------
+class CountNotWhite extends CountPixel
+{
+ public CountNotWhite()
+ {
+ // System.out.println("CountWhite()");
+ }
+
+ public void count(int pixel)
+ {
+ int alpha = (pixel >> 24) & 0xff;
+ int red = (pixel >> 16) & 0xff;
+ int green = (pixel >> 8) & 0xff;
+ int blue = (pixel ) & 0xff;
+
+ // System.out.println(String.valueOf(red) + ":" + String.valueOf(green) + ":" + String.valueOf(blue));
+ if (red == 0xff && green == 0xff && blue == 0xff)
+ {
+ return;
+ }
+ m_nCount++;
+ }
+}
+
+// -----------------------------------------------------------------------------
+class CountNotBlack extends CountPixel
+{
+ public CountNotBlack()
+ {
+ // System.out.println("CountBlack()");
+ }
+
+ public void count(int pixel)
+ {
+ int alpha = (pixel >> 24) & 0xff;
+ int red = (pixel >> 16) & 0xff;
+ int green = (pixel >> 8) & 0xff;
+ int blue = (pixel ) & 0xff;
+
+ if (red == 0x00 && green == 0x00 && blue == 0x00)
+ {
+ return;
+ }
+ m_nCount++;
+ }
+}
+
+// -----------------------------------------------------------------------------
+class graphics_stuff
+{
+ public int stuff()
+ {
+// (1) decoding
+ int rgba = 0; // ...; // comes from PixelGrabber, BufferedImage.getRGB etc.
+ int red = (rgba >> 16) & 0xff;
+ int green = (rgba >> 8) & 0xff;
+ int blue = rgba & 0xff;
+ int alpha = (rgba >> 24) & 0xff;
+// (2) now modify red, green, blue and alpha as you like;
+// make sure that each of the four values stays in the
+// interval 0 to 255
+// ...
+// (3) and encode back to an int, e.g. to give it to MemoryImageSource or
+// BufferedImage.setRGB
+ rgba = (alpha << 24) | (red << 16) | (green << 8) | blue;
+ return 0;
+ }
+
+ public static void handlesinglepixel(int x, int y, int pixel)
+ {
+ int alpha = (pixel >> 24) & 0xff;
+ int red = (pixel >> 16) & 0xff;
+ int green = (pixel >> 8) & 0xff;
+ int blue = (pixel ) & 0xff;
+ // Deal with the pixel as necessary...
+ }
+
+ public static void countPixel(ImageHelper img, int _x, int _y, int _w, int _h, CountPixel _aPixelCounter)
+ {
+ for (int y = 0; y < _h; y++) {
+ for (int x = 0; x < _w; x++) {
+ // handlesinglepixel(x+i, y+j, pixels[j * w + i]);
+ _aPixelCounter.count(img.getPixel(x,y));
+ }
+ }
+ }
+ public static int countNotWhitePixel(ImageHelper _aImage)
+ {
+ int w = _aImage.getWidth();
+ int h = _aImage.getHeight();
+
+ CountPixel aCountNotWhite = new CountNotWhite();
+ countPixel(_aImage, 0, 0, w, h, aCountNotWhite);
+ return aCountNotWhite.getCount();
+ }
+
+ public static int countNotBlackPixel(ImageHelper _aImage)
+ {
+ int w = _aImage.getWidth();
+ int h = _aImage.getHeight();
+
+ CountPixel aCountNotBlack = new CountNotBlack();
+ countPixel(_aImage, 0, 0, w, h, aCountNotBlack);
+ return aCountNotBlack.getCount();
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+public class PixelCounter {
+ // private Image m_aImage;
+ ImageHelper m_aImage;
+
+
+ public int countNotWhitePixel(String _sFile)
+ throws java.io.IOException
+ {
+ m_aImage = ImageHelper.createImageHelper(_sFile);
+ int nw = graphics_stuff.countNotWhitePixel(m_aImage);
+ return nw;
+ }
+
+ public int countNotBlackPixel(String _sFile)
+ throws java.io.IOException
+ {
+ m_aImage = ImageHelper.createImageHelper(_sFile);
+ int nw = graphics_stuff.countNotBlackPixel(m_aImage);
+ return nw;
+ }
+
+ public static int countNotWhitePixelsFromImage(String _sFile)
+ throws java.io.IOException
+ {
+ PixelCounter a = new PixelCounter();
+ return a.countNotWhitePixel(_sFile);
+ }
+
+ public static int countNotBlackPixelsFromImage(String _sFile)
+ throws java.io.IOException
+ {
+ PixelCounter a = new PixelCounter();
+ return a.countNotBlackPixel(_sFile);
+ }
+
+ // -----------------------------------------------------------------------------
+
+// public static void main(String[] args) {
+//
+// String a = helper.StringHelper.createValueString(10, 4);
+// int dummy = 1;
+///*
+// BorderRemover a = new BorderRemover();
+// try
+// {
+// a.createNewImageWithoutBorder(args[0], args[1]);
+// }
+// catch(java.io.IOException e)
+// {
+// System.out.println("Exception caught.");
+// }
+// */
+// }
+
+}
+
+
diff --git a/qadevOOo/runner/convwatch/PropertyName.java b/qadevOOo/runner/convwatch/PropertyName.java
new file mode 100644
index 000000000000..00130faf50e3
--- /dev/null
+++ b/qadevOOo/runner/convwatch/PropertyName.java
@@ -0,0 +1,67 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package convwatch;
+
+public interface PropertyName
+{
+ final public static String DOC_COMPARATOR_INPUT_PATH = "DOC_COMPARATOR_INPUT_PATH";
+ final public static String DOC_COMPARATOR_OUTPUT_PATH = "DOC_COMPARATOR_OUTPUT_PATH";
+ final public static String DOC_COMPARATOR_DIFF_PATH = "DOC_COMPARATOR_DIFF_PATH";
+ final public static String DOC_COMPARATOR_REFERENCE_PATH = "DOC_COMPARATOR_REFERENCE_PATH";
+ final public static String DOC_COMPARATOR_REFERENCE_INPUT_PATH = "DOC_COMPARATOR_REFERENCE_INPUT_PATH";
+ final public static String DOC_COMPARATOR_REFERENCE_TYPE = "DOC_COMPARATOR_REFERENCE_CREATOR_TYPE";
+ final public static String DOC_COMPARATOR_PRINTER_NAME = "DOC_COMPARATOR_PRINTER_NAME";
+ final public static String DOC_COMPARATOR_DEFAULT_XML_FORMAT_APP = "DOC_COMPARATOR_DEFAULT_XML_FORMAT_APP";
+ final public static String DOC_COMPARATOR_INCLUDE_SUBDIRS = "DOC_COMPARATOR_INCLUDE_SUBDIRS";
+ final public static String DOC_COMPARATOR_PRINT_MAX_PAGE = "DOC_COMPARATOR_PRINT_MAX_PAGE";
+ final public static String DOC_COMPARATOR_PRINT_ONLY_PAGE = "DOC_COMPARATOR_PRINT_ONLY_PAGE";
+ final public static String DOC_COMPARATOR_GFX_OUTPUT_DPI_RESOLUTION = "DOC_COMPARATOR_GFX_OUTPUT_DPI_RESOLUTION";
+ final public static String DOC_COMPARATOR_OVERWRITE_REFERENCE = "DOC_COMPARATOR_OVERWRITE_REFERENCE";
+
+ final public static String DOC_COMPARATOR_HTML_OUTPUT_PREFIX = "DOC_COMPARATOR_HTML_OUTPUT_PREFIX";
+ final public static String DOC_COMPARATOR_GFXCMP_WITH_BORDERMOVE = "DOC_COMPARATOR_GFXCMP_WITH_BORDERMOVE";
+
+ final public static String DOC_CONVERTER_IMPORT_FILTER_NAME = "DOC_CONVERTER_IMPORT_FILTER_NAME";
+ final public static String DOC_CONVERTER_EXPORT_FILTER_NAME = "DOC_CONVERTER_EXPORT_FILTER_NAME";
+ final public static String DOC_CONVERTER_OFFICE_PROGRAM = "DOC_CONVERTER_OFFICE_PROGRAM";
+ final public static String DOC_CONVERTER_REUSE_OFFICE = "DOC_CONVERTER_REUSE_OFFICE";
+
+ final public static String DOC_COMPARATOR_LEAVE_OUT_FILES = "DOC_COMPARATOR_LEAVE_OUT_FILES";
+
+ final public static String DOC_COMPARATOR_DB_INFO_STRING = "DOC_COMPARATOR_DB_INFO_STRING";
+
+ final public static String TEMPPATH = "TEMPPATH";
+
+ // set this variable to "true" or "yes" and loadComponentFromURL works with property Hidden=false
+ final public static String OFFICE_VIEWABLE = "OFFICE_VIEWABLE";
+
+ final public static String DB_CONNECTION_STRING = "DB_CONNECTION_STRING";
+ final public static String CHECK_NEED_TOOLS = "CHECK_NEED_TOOLS";
+ final public static String CREATE_DEFAULT = "CREATE_DEFAULT_REFERENCE";
+
+}
diff --git a/qadevOOo/runner/convwatch/ReferenceBuilder.java b/qadevOOo/runner/convwatch/ReferenceBuilder.java
new file mode 100644
index 000000000000..076d5f5804f4
--- /dev/null
+++ b/qadevOOo/runner/convwatch/ReferenceBuilder.java
@@ -0,0 +1,304 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package convwatch;
+
+// imports
+import java.io.File;
+import java.io.FileFilter;
+import java.util.ArrayList;
+
+import com.sun.star.lang.XMultiServiceFactory;
+
+import convwatch.DirectoryHelper;
+import convwatch.ConvWatchException;
+import convwatch.EnhancedComplexTestCase;
+import convwatch.PropertyName;
+import helper.OfficeProvider;
+import convwatch.PerformanceContainer;
+
+/**
+ * The following Complex Test will test
+ * an already created document and it's postscript output (by an older office version)
+ * with a new office version.
+ * This test use Ghostscript for the jpeg export and graphically compare tools from ImageMagick.
+ * Read the manual for more information.
+ *
+ * this is only the starter program
+ * more is found in qadevOOo/runner/convwatch/*
+ */
+
+public class ReferenceBuilder extends EnhancedComplexTestCase
+{
+ // The first of the mandatory functions:
+ /**
+ * Return the name of the test.
+ * In this case it is the actual name of the service.
+ * @return The tested service.
+ */
+ public String getTestObjectName() {
+ return "ReferenceBuilder runner";
+ }
+
+ // The second of the mandatory functions: return all test methods as an
+ // array. There is only one test function in this example.
+ /**
+ * Return all test methods.
+ * @return The test methods.
+ */
+ public String[] getTestMethodNames() {
+ return new String[]{"buildreference"};
+ }
+
+ // This test is fairly simple, so there is no need for before() or after()
+ // methods.
+
+ public void before()
+ {
+ // System.out.println("before()");
+ }
+
+ public void after()
+ {
+ // System.out.println("after()");
+ }
+
+ // The test method itself.
+ private String m_sInputPath = "";
+ private String m_sReferencePath = "";
+ private boolean m_bIncludeSubdirectories = true;
+
+ void initMember()
+ {
+ // MUST PARAMETER
+ // INPUT_PATH ----------
+ String sINPATH = (String)param.get( PropertyName.DOC_COMPARATOR_INPUT_PATH );
+ boolean bQuit = false;
+ String sError = "";
+ if (sINPATH == null || sINPATH.length() == 0)
+ {
+ log.println("Please set input path (path to documents) " + PropertyName.DOC_COMPARATOR_INPUT_PATH + "=path.");
+ bQuit = true;
+ }
+ else
+ {
+ log.println("found " + PropertyName.DOC_COMPARATOR_INPUT_PATH + " " + sINPATH);
+ m_sInputPath = sINPATH;
+ }
+
+ // REFERENCE_PATH ----------
+ String sREF = (String)param.get( PropertyName.DOC_COMPARATOR_REFERENCE_PATH );
+ if (sREF == null || sREF.length() == 0)
+ {
+ log.println("Please set output path (path to a directory, where the references should stay) " + PropertyName.DOC_COMPARATOR_REFERENCE_PATH + "=path.");
+ bQuit = true;
+ }
+ else
+ {
+ log.println("found " + PropertyName.DOC_COMPARATOR_REFERENCE_PATH + " " + sREF);
+ m_sReferencePath = sREF;
+ }
+
+ if (bQuit == true)
+ {
+ // log.println("must quit.");
+ assure("Must quit, Parameter problems.", false);
+ }
+
+ if (m_sInputPath.startsWith("file:") ||
+ m_sReferencePath.startsWith("file:"))
+ {
+ assure("We can't handle file: URL right, use system path instead.", false);
+ }
+
+ }
+
+ /**
+ * Function returns a List of software which must accessable as an external executable
+ */
+ protected Object[] mustInstalledSoftware()
+ {
+ ArrayList aList = new ArrayList();
+ aList.add("perl -version");
+ return aList.toArray();
+ }
+
+ // the test ======================================================================
+ public void buildreference()
+ {
+ GlobalLogWriter.set(log);
+ String sDBConnection = (String)param.get( PropertyName.DB_CONNECTION_STRING );
+
+ // check if all need software is installed and accessable
+ checkEnvironment(mustInstalledSoftware());
+
+ // test_removeFirstDirectorysAndBasenameFrom();
+ // Get the MultiServiceFactory.
+ // XMultiServiceFactory xMSF = (XMultiServiceFactory)param.getMSF();
+ GraphicalTestArguments aGTA = getGraphicalTestArguments();
+ if (aGTA == null)
+ {
+ assure("Must quit", false);
+ }
+ if (aGTA.cancelRequest())
+ {
+ return;
+ }
+
+ initMember();
+ DB.init(aGTA.getDBInfoString() + "," + sDBConnection);
+ File aInputPath = new File(m_sInputPath);
+ if (aInputPath.isDirectory())
+ {
+ String fs = System.getProperty("file.separator");
+
+ String sRemovePath = aInputPath.getAbsolutePath();
+ // a whole directory
+ FileFilter aFileFilter = FileHelper.getFileFilter();
+
+ Object[] aList = DirectoryHelper.traverse(m_sInputPath, aFileFilter, aGTA.includeSubDirectories());
+ // fill into DB
+ // DB.filesRemove(aGTA.getDBInfoString());
+ // for (int j=0;j<aList.length;j++)
+ // {
+ // String sEntry = (String)aList[j];
+ // DB.fileInsert(aGTA.getDBInfoString(), sEntry, sRemovePath);
+ // }
+
+ // normal run.
+ for (int i=0;i<aList.length;i++)
+ {
+ String sEntry = (String)aList[i];
+
+ String sNewReferencePath = m_sReferencePath + fs + FileHelper.removeFirstDirectorysAndBasenameFrom(sEntry, m_sInputPath);
+ log.println("- next file is: ------------------------------");
+ log.println(sEntry);
+ log.println(sNewReferencePath);
+
+ if (aGTA.checkIfUsableDocumentType(sEntry))
+ {
+ runGDC(sEntry, sNewReferencePath);
+ }
+ if (aGTA.cancelRequest())
+ {
+ break;
+ }
+ }
+ }
+ else
+ {
+ // String sRemovePath = aInputPath.getAbsolutePath();
+ // DB.fileInsert(aGTA.getDBInfoString(), m_sInputPath, sRemovePath);
+ // DB.updatestate_status(aGTA.getDBInfoString(), "started: " + m_sInputPath);
+ if (aGTA.checkIfUsableDocumentType(m_sInputPath))
+ {
+ runGDC(m_sInputPath, m_sReferencePath);
+ }
+ }
+ }
+
+ void runGDC(String _sInputPath, String _sReferencePath)
+ {
+ // first do a check if the reference not already exist, this is a big speedup, due to the fact,
+ // we don't need to start a new office.
+ GraphicalTestArguments aGTA = getGraphicalTestArguments();
+ if (GraphicalDifferenceCheck.isReferenceExists(_sInputPath, _sReferencePath, aGTA) == false)
+ {
+ // start a fresh Office
+ OfficeProvider aProvider = null;
+ // SimpleFileSemaphore aSemaphore = new SimpleFileSemaphore();
+ if (aGTA.shouldOfficeStart())
+ {
+ // if (OSHelper.isWindows())
+ // {
+ // aSemaphore.P(aSemaphore.getSemaphoreFile());
+ // }
+ aGTA.getPerformance().startTime(PerformanceContainer.OfficeStart);
+ aProvider = new OfficeProvider();
+ XMultiServiceFactory xMSF = (XMultiServiceFactory) aProvider.getManager(param);
+ param.put("ServiceFactory", xMSF);
+ aGTA.getPerformance().stopTime(PerformanceContainer.OfficeStart);
+
+ long nStartTime = aGTA.getPerformance().getTime(PerformanceContainer.OfficeStart);
+ aGTA = getGraphicalTestArguments();
+ aGTA.getPerformance().setTime(PerformanceContainer.OfficeStart, nStartTime);
+ }
+
+ // Watcher Object is need in log object to give a simple way to say if a running office is alive.
+ // As long as a log comes, it pings the Watcher and says the office is alive, if not an
+ // internal counter increase and at a given point (300 seconds) the office is killed.
+ GlobalLogWriter.get().println("Set office watcher");
+ Object aWatcher = param.get("Watcher");
+ GlobalLogWriter.get().setWatcher(aWatcher);
+ // initializeWatcher(param);
+
+ try
+ {
+ log.println("Reference type is " + aGTA.getReferenceType());
+ DB.source_start();
+ GraphicalDifferenceCheck.createOneReferenceFile(_sInputPath, _sReferencePath, aGTA);
+ DB.source_finished();
+ }
+ catch(ConvWatchCancelException e)
+ {
+ assure(e.getMessage(), false);
+ DB.source_failed(e.getMessage());
+ }
+ catch(ConvWatchException e)
+ {
+ assure(e.getMessage(), false);
+ DB.source_failed(e.getMessage());
+ }
+ catch(com.sun.star.lang.DisposedException e)
+ {
+ assure(e.getMessage(), false, true);
+ DB.source_failed(e.getMessage());
+ }
+
+ // Office shutdown
+ if (aProvider != null)
+ {
+ boolean bClosed = aProvider.closeExistingOffice(param, true);
+ // Hope I can check that the close of the office fails
+ assure("Office closed", bClosed, true);
+ // if (OSHelper.isWindows())
+ // {
+ // aSemaphore.V(aSemaphore.getSemaphoreFile());
+ // aSemaphore.sleep(2);
+ // // wait some time maybe an other process will take the semaphore
+ // // I know, this is absolutly dirty, but the whole convwatch is dirty and need a big cleanup.
+ // }
+ }
+ }
+ else
+ {
+ // Reference already exist, do nothing, but DB change
+ DB.source_finished();
+ }
+ }
+}
+
diff --git a/qadevOOo/runner/convwatch/ReportDesignerTest.java b/qadevOOo/runner/convwatch/ReportDesignerTest.java
new file mode 100755
index 000000000000..703a2b2f3073
--- /dev/null
+++ b/qadevOOo/runner/convwatch/ReportDesignerTest.java
@@ -0,0 +1,694 @@
+/*
+ ************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package convwatch;
+
+import java.io.File;
+import java.util.ArrayList;
+
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.container.XNameAccess;
+import com.sun.star.frame.XComponentLoader;
+import com.sun.star.frame.XDesktop;
+import com.sun.star.frame.XModel;
+import com.sun.star.frame.XStorable;
+import com.sun.star.lang.XComponent;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.sdb.XDocumentDataSource;
+import com.sun.star.sdb.XOfficeDatabaseDocument;
+import com.sun.star.sdb.XReportDocumentsSupplier;
+import com.sun.star.sdb.application.XDatabaseDocumentUI;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XInterface;
+import com.sun.star.util.XCloseable;
+import com.sun.star.lang.XServiceInfo;
+
+// import util.BasicMacroTools;
+// import util.DesktopTools;
+// import util.dbg;
+import complexlib.ComplexTestCase;
+import helper.OfficeProvider;
+import helper.URLHelper;
+import helper.OfficeWatcher;
+
+// import convwatch.DB;
+
+// import java.util.Date;
+// import java.text.SimpleDateFormat;
+// import java.text.ParsePosition;
+// import java.sql.Time;
+//
+// import java.io.BufferedReader;
+// import java.io.File;
+// import java.io.FileReader;
+// import java.io.IOException;
+// import java.io.FilenameFilter;
+//
+// import java.util.Vector;
+//
+// import helper.AppProvider;
+// import java.text.DecimalFormat;
+// import util.DynamicClassLoader;
+// import java.util.StringTokenizer;
+
+
+
+
+class PropertySetHelper
+{
+ XPropertySet m_xPropertySet;
+ public PropertySetHelper(Object _aObj)
+ {
+ m_xPropertySet = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, _aObj);
+ }
+
+ /**
+ get a property and don't convert it
+ @param _sName the string name of the property
+ @return the object value of the property without any conversion
+ */
+ public Object getPropertyValueAsObject(String _sName)
+ {
+ Object aObject = null;
+
+ if (m_xPropertySet != null)
+ {
+ try
+ {
+ aObject = m_xPropertySet.getPropertyValue(_sName);
+ }
+ catch (com.sun.star.beans.UnknownPropertyException e)
+ {
+ System.out.println("ERROR: UnknownPropertyException caught. '" + _sName + "'");
+ System.out.println("Message: " + e.getMessage());
+ }
+ catch (com.sun.star.lang.WrappedTargetException e)
+ {
+ System.out.println("ERROR: WrappedTargetException caught.");
+ System.out.println("Message: " + e.getMessage());
+ }
+ }
+ return aObject;
+ }
+}
+
+class PropertyHelper
+{
+ /**
+ Create a PropertyValue[] from a ArrayList
+ @param _aArrayList
+ @return a PropertyValue[]
+ */
+ public static PropertyValue[] createPropertyValueArrayFormArrayList(ArrayList _aPropertyList)
+ {
+ // copy the whole PropertyValue List to an PropertyValue Array
+ PropertyValue[] aSaveProperties = null;
+
+ if (_aPropertyList == null)
+ {
+ aSaveProperties = new PropertyValue[0];
+ }
+ else
+ {
+ if (_aPropertyList.size() > 0)
+ {
+ aSaveProperties = new PropertyValue[_aPropertyList.size()];
+ for (int i = 0;i<_aPropertyList.size(); i++)
+ {
+ aSaveProperties[i] = (PropertyValue) _aPropertyList.get(i);
+ }
+ }
+ else
+ {
+ aSaveProperties = new PropertyValue[0];
+ }
+ }
+ return aSaveProperties;
+ }
+}
+
+public class ReportDesignerTest extends ComplexTestCase {
+
+ String mTestDocumentPath;
+
+ /**
+ * This method returns a list of Strings, each string must be a function name in this class.
+ * @return
+ */
+ public String[] getTestMethodNames()
+ {
+ return new String[] {"ReportDesignTest"}; // MAIN
+ }
+
+ private void checkIfOfficeExists(String _sOfficePathWithTrash)
+ {
+ String sOfficePath = "";
+ int nIndex = _sOfficePathWithTrash.indexOf("soffice.exe");
+ if (nIndex > 0)
+ {
+ sOfficePath = _sOfficePathWithTrash.substring(0, nIndex + 11);
+ }
+ else
+ {
+ nIndex = _sOfficePathWithTrash.indexOf("soffice");
+ if (nIndex > 0)
+ {
+ sOfficePath = _sOfficePathWithTrash.substring(0, nIndex + 7);
+ }
+ }
+
+ // if (sOfficePath.startsWith("\"") ||
+ // sOfficePath.startsWith("'"))
+ // {
+ // sOfficePath = sOfficePath.substring(1);
+ // }
+ sOfficePath = helper.StringHelper.removeQuoteIfExists(sOfficePath);
+
+ log.println(sOfficePath);
+ File sOffice = new File(sOfficePath);
+ if (! sOffice.exists())
+ {
+ log.println("ERROR: There exists no office installation at given path: '" + sOfficePath + "'");
+ System.exit(0);
+ }
+ }
+
+
+ private static XDesktop m_xDesktop = null;
+ public static XDesktop getXDesktop()
+ {
+
+ if (m_xDesktop == null)
+ {
+ try
+ {
+ XInterface xInterface = (XInterface) m_xXMultiServiceFactory.createInstance( "com.sun.star.frame.Desktop" );
+ m_xDesktop = (XDesktop) UnoRuntime.queryInterface(XDesktop.class, xInterface);
+ }
+ catch (com.sun.star.uno.Exception e)
+ {
+ log.println("ERROR: uno.Exception caught");
+ log.println("Message: " + e.getMessage());
+ }
+ }
+ return m_xDesktop;
+ }
+
+ private void showElements(XNameAccess _xNameAccess)
+ {
+ if (_xNameAccess != null)
+ {
+ String[] sElementNames = _xNameAccess.getElementNames();
+ for(int i=0;i<sElementNames.length; i++)
+ {
+ System.out.println("Value: [" + i + "] := " + sElementNames[i]);
+ }
+ }
+ else
+ {
+ System.out.println("Warning: Given object is null.");
+ }
+ }
+
+
+ private OfficeProvider m_aProvider = null;
+ private static XMultiServiceFactory m_xXMultiServiceFactory = null;
+ private void startOffice()
+ {
+ // int tempTime = param.getInt("SingleTimeOut");
+ param.put("TimeOut", new Integer(300000));
+ System.out.println("TimeOut: " + param.getInt("TimeOut"));
+ System.out.println("ThreadTimeOut: " + param.getInt("ThreadTimeOut"));
+
+ // OfficeProvider aProvider = null;
+ m_aProvider = new OfficeProvider();
+ m_xXMultiServiceFactory = (XMultiServiceFactory) m_aProvider.getManager(param);
+ param.put("ServiceFactory", m_xXMultiServiceFactory);
+ }
+
+ private void stopOffice()
+ {
+ if (m_aProvider != null)
+ {
+ m_aProvider.closeExistingOffice(param, true);
+ m_aProvider = null;
+ }
+ TimeHelper.waitInSeconds(2, "Give close Office some time.");
+ }
+
+ private String m_sMailAddress = null;
+ private String m_sParentDistinct = null;
+
+ // private String m_sUPDMinor;
+ // private String m_sCWS_WORK_STAMP;
+
+ private static String m_sSourceVersion;
+ private static String m_sDestinationVersion;
+ private static String m_sSourceName;
+ private static String m_sDestinationName;
+
+ private static final int WRITER = 1;
+ private static final int CALC = 2;
+
+ /**
+ * This is the main test Function of current ReportDesignerTest
+ */
+ public void ReportDesignTest()
+ {
+ convwatch.GlobalLogWriter.set(log);
+
+ GlobalLogWriter.get().println("Set office watcher");
+ OfficeWatcher aWatcher = (OfficeWatcher)param.get("Watcher");
+ GlobalLogWriter.get().setWatcher(aWatcher);
+
+ try
+ {
+
+ // -------------------- preconditions, try to find an office --------------------
+
+ String sAppExecutionCommand = (String) param.get("AppExecutionCommand");
+ log.println("sAppExecutionCommand='" + sAppExecutionCommand + "'");
+
+ String sUser = System.getProperty("user.name");
+ log.println("user.name='" + sUser + "'");
+
+ // String sVCSID = System.getProperty("VCSID");
+ // log.println("VCSID='" + sVCSID + "'");
+ // m_sMailAddress = sVCSID + "@openoffice.org";
+ m_sMailAddress = System.getProperty("MailAddress");
+ log.println("Assumed mail address: " + m_sMailAddress);
+
+ m_sParentDistinct = System.getProperty("ParentDistinct");
+
+ m_sSourceVersion = System.getProperty("SourceVersion");
+ m_sSourceName = System.getProperty("SourceName");
+ m_sDestinationVersion = System.getProperty("DestinationVersion");
+ m_sDestinationName = System.getProperty("DestinationName");
+ // createDBEntry();
+ // log.println("Current CWS: " + m_sCWS_WORK_STAMP);
+ // log.println("Current MWS: " + m_sUPDMinor);
+
+ if (m_sSourceVersion == null)
+ {
+ System.out.println("Error, Sourceversion is null.");
+ System.exit(1);
+ }
+
+ sAppExecutionCommand = sAppExecutionCommand.replaceAll( "\\$\\{USERNAME\\}", sUser);
+ log.println("sAppExecutionCommand='" + sAppExecutionCommand + "'");
+
+ // an other way to replace strings
+ // sAppExecutionCommand = utils.replaceAll13(sAppExecutionCommand, "${USERNAME}", sUser);
+
+ checkIfOfficeExists(sAppExecutionCommand);
+ param.put("AppExecutionCommand", new String(sAppExecutionCommand));
+
+ // System.exit(1);
+
+ // --------------------------- Start the given Office ---------------------------
+
+ startOffice();
+
+ // ------------------------------ Start a test run ------------------------------
+
+ // String sCurrentDirectory = System.getProperty("user.dir");
+ // log.println("Current Dir: " + sCurrentDirectory);
+ String sDocument = (String) param.get(convwatch.PropertyName.DOC_COMPARATOR_INPUT_PATH);
+ sDocument = helper.StringHelper.removeQuoteIfExists( sDocument );
+ startTestForFile(sDocument);
+ // if (sDocument.toLowerCase().indexOf("writer") >= 0)
+ // {
+ // startTestForFile(sDocument, WRITER);
+ // }
+ // else if (sDocument.toLowerCase().indexOf("calc") >= 0)
+ // {
+ // startTestForFile(sDocument, CALC);
+ // }
+ // else
+ // {
+ // assure("Can't identify the document no 'writer' nor 'calc' in it's name given.", false);
+ // }
+ }
+ catch (AssureException e)
+ {
+ stopOffice();
+ throw new AssureException(e.getMessage());
+ }
+
+ // ------------------------------ Office shutdown ------------------------------
+ stopOffice();
+ }
+
+// -----------------------------------------------------------------------------
+ private void startTestForFile(String _sDocument /*, int _nType*/)
+ {
+ File aFile = new File(_sDocument);
+ assure("Test File '" + _sDocument + "' doesn't exist.", aFile.exists());
+
+ String sFileURL = URLHelper.getFileURLFromSystemPath(_sDocument);
+ log.println("File URL: " + sFileURL);
+
+ XComponent xDocComponent = loadComponent(sFileURL, getXDesktop(), null);
+ log.println("Load done");
+// context = createUnoService("com.sun.star.sdb.DatabaseContext")
+// oDataBase = context.getByName("hh")
+// oDBDoc = oDataBase.DatabaseDocument
+//
+// dim args(1) as new com.sun.star.beans.PropertyValue
+// args(0).Name = "ActiveConnection"
+// args(0).Value = oDBDoc.getCurrentController().getPropertyValue("ActiveConnection")
+// reportContainer = oDBDoc.getReportDocuments()
+// report = reportContainer.loadComponentFromURL("Report40","",0,args)
+
+ try
+ {
+ XInterface x = (XInterface)m_xXMultiServiceFactory.createInstance("com.sun.star.sdb.DatabaseContext");
+ assure("can't create instance of com.sun.star.sdb.DatabaseContext", x != null);
+ log.println("createInstance com.sun.star.sdb.DatabaseContext done");
+
+ XNameAccess xNameAccess = (XNameAccess) UnoRuntime.queryInterface(XNameAccess.class, x);
+ showElements(xNameAccess);
+ Object aObj = xNameAccess.getByName(sFileURL);
+// log.println("1");
+
+ // PropertySetHelper aHelper = new PropertySetHelper(aObj);
+ XDocumentDataSource xDataSource = (XDocumentDataSource)UnoRuntime.queryInterface(XDocumentDataSource.class, aObj);
+// Object aDatabaseDocmuent = aHelper.getPropertyValueAsObject("DatabaseDocument");
+ XOfficeDatabaseDocument xOfficeDBDoc = xDataSource.getDatabaseDocument();
+
+ // XOfficeDatabaseDocument xOfficeDBDoc = (XOfficeDatabaseDocument)UnoRuntime.queryInterface(XOfficeDatabaseDocument.class, aDatabaseDocument);
+ assure("can't access DatabaseDocument", xOfficeDBDoc != null);
+// log.println("2");
+
+ XModel xDBSource = (XModel)UnoRuntime.queryInterface(XModel.class, xOfficeDBDoc);
+ Object aController = xDBSource.getCurrentController();
+ assure("Controller of xOfficeDatabaseDocument is empty!", aController != null);
+// log.println("3");
+
+ XDatabaseDocumentUI aDBDocUI = (XDatabaseDocumentUI)UnoRuntime.queryInterface(XDatabaseDocumentUI.class, aController);
+ aDBDocUI.connect();
+// if (aDBDocUI.isConnected())
+// {
+// System.out.println("true");
+// }
+// else
+// {
+// System.out.println("false");
+// }
+// log.println("4");
+
+ // aHelper = new PropertySetHelper(aController);
+
+ // Object aActiveConnectionObj = aHelper.getPropertyValueAsObject("ActiveConnection");
+ Object aActiveConnectionObj = aDBDocUI.getActiveConnection();
+ assure("ActiveConnection is empty", aActiveConnectionObj != null);
+// log.println("5");
+
+ XReportDocumentsSupplier xSupplier = (XReportDocumentsSupplier)UnoRuntime.queryInterface(XReportDocumentsSupplier.class, xOfficeDBDoc);
+ xNameAccess = xSupplier.getReportDocuments();
+ assure("xOfficeDatabaseDocument returns no Report Document", xNameAccess != null);
+// log.println("5");
+
+ showElements(xNameAccess);
+
+ ArrayList aPropertyList = new ArrayList();
+
+ PropertyValue aActiveConnection = new PropertyValue();
+ aActiveConnection.Name = "ActiveConnection";
+ aActiveConnection.Value = aActiveConnectionObj;
+ aPropertyList.add(aActiveConnection);
+
+ loadAndStoreReports(xNameAccess, aPropertyList /*, _nType*/ );
+ createDBEntry(/*_nType*/);
+ }
+ catch(com.sun.star.uno.Exception e)
+ {
+ log.println("ERROR: Exception caught");
+ log.println("Message: " + e.getMessage());
+ }
+
+ // String mTestDocumentPath = (String) param.get("TestDocumentPath");
+ // System.out.println("mTestDocumentPath: '" + mTestDocumentPath + "'");
+ // // workaround for issue using deprecated "DOCPTH" prop
+ // System.setProperty("DOCPTH", mTestDocumentPath);
+
+ // Close the document
+ closeComponent(xDocComponent);
+ }
+
+ private String getDocumentPoolName(/*int _nType*/)
+ {
+ return "AutogenReportDesignTest";
+ // return getFileFormat(_nType);
+ }
+
+// -----------------------------------------------------------------------------
+ private void createDBEntry(/*int _nType*/)
+ {
+ // try to connect the database
+ String sDBConnection = (String)param.get( convwatch.PropertyName.DB_CONNECTION_STRING );
+ log.println("DBConnection: " + sDBConnection);
+ DB.init(sDBConnection);
+
+ // String sFixRefSubDirectory = "ReportDesign_qa_complex_" + getFileFormat(_nType);
+ String sFixRefSubDirectory = "ReportDesignFixRef";
+
+ String sSourceVersion = m_sSourceVersion;
+ // String sSourceVersion = sFixRefSubDirectory;
+ String sSourceName = m_sSourceName;
+ // String sSourceCreatorType = "fixref";
+ String sSourceCreatorType = "";
+ String sDestinationVersion = m_sDestinationVersion;
+ // if (sDestinationVersion.length() == 0)
+ // {
+ // sDestinationVersion = m_sUPDMinor;
+ // }
+ String sDestinationName = m_sDestinationName;
+ String sDestinationCreatorType = "";
+ String sDocumentPoolDir = getOutputPath(/*_nType*/);
+ String sDocumentPoolName = getDocumentPoolName(/*_nType*/);
+ String sSpecial = "";
+
+ DB.insertinto_documentcompare(sSourceVersion, sSourceName, sSourceCreatorType,
+ m_sDestinationVersion, sDestinationName, sDestinationCreatorType,
+ sDocumentPoolDir, sDocumentPoolName, m_sMailAddress,
+ sSpecial, m_sParentDistinct);
+ TimeHelper.waitInSeconds(1, "wait for DB.");
+ // DB.test();
+ // System.exit(1);
+ }
+
+ private void loadAndStoreReports(XNameAccess _xNameAccess, ArrayList _aPropertyList /*, int _nType*/ )
+ {
+ if (_xNameAccess != null)
+ {
+ String[] sElementNames = _xNameAccess.getElementNames();
+ for(int i=0;i<sElementNames.length; i++)
+ {
+ String sReportName = sElementNames[i];
+ XComponent xDoc = loadComponent(sReportName, _xNameAccess, _aPropertyList);
+ // print? or store?
+ storeComponent(sReportName, xDoc /*, _nType*/);
+ closeComponent(xDoc);
+ }
+ }
+ }
+
+ private String getFormatExtension(Object _xComponent /* int _nType*/ )
+ {
+ String sExtension;
+ XServiceInfo xServiceInfo = (XServiceInfo) UnoRuntime.queryInterface( XServiceInfo.class, _xComponent );
+ if ( xServiceInfo.supportsService( "com.sun.star.sheet.SpreadsheetDocument" ) )
+ {
+ // calc
+ sExtension = ".ods";
+ }
+ else if (xServiceInfo.supportsService("com.sun.star.text.TextDocument"))
+ {
+ //writer
+ sExtension = ".odt";
+ }
+ else
+ {
+ sExtension = ".UNKNOWN";
+ }
+ return sExtension;
+ }
+
+ // switch(_nType)
+ // {
+ // case WRITER:
+ // sExtension = ".odt";
+ // break;
+ // case CALC:
+ // sExtension = ".ods";
+ // break;
+ // default:
+ // sExtension = ".UNKNOWN";
+ // }
+ // return sExtension;
+ // }
+ // private String getFileFormat(int _nType)
+ // {
+ // String sFileType;
+ // switch(_nType)
+ // {
+ // case WRITER:
+ // sFileType = "writer8";
+ // break;
+ // case CALC:
+ // sFileType = "calc8";
+ // break;
+ // default:
+ // sFileType = "UNKNOWN";
+ // }
+ // return sFileType;
+ // }
+
+ private String m_sOutputPath = null;
+
+ private String getOutputPath(/*int _nType*/)
+ {
+ if (m_sOutputPath == null)
+ {
+ String sOutputPath = (String)param.get( convwatch.PropertyName.DOC_COMPARATOR_OUTPUT_PATH );
+ sOutputPath = helper.StringHelper.removeQuoteIfExists(sOutputPath);
+
+ if (!sOutputPath.endsWith("/") || // construct the output file name
+ !sOutputPath.endsWith("\\"))
+ {
+ sOutputPath += System.getProperty("file.separator");
+ }
+ // sOutputPath += "tmp_123";
+ sOutputPath += DateHelper.getDateTimeForFilename();
+ sOutputPath += System.getProperty("file.separator");
+
+ // sOutputPath += getFileFormat(_nType);
+ // sOutputPath += System.getProperty("file.separator");
+
+ File aOutputFile = new File(sOutputPath); // create the directory of the given output path
+ aOutputFile.mkdirs();
+ m_sOutputPath = sOutputPath;
+ }
+ return m_sOutputPath;
+ }
+
+ /*
+ store given _xComponent under the given Name in DOC_COMPARATOR_INPUTPATH
+ */
+ private void storeComponent(String _sName, Object _xComponent /*, int _nType*/ )
+ {
+ String sOutputPath = getOutputPath(/*_nType*/);
+
+ // add DocumentPoolName
+ sOutputPath += getDocumentPoolName(/*_nType*/);
+ sOutputPath += System.getProperty("file.separator");
+
+ File aOutputFile = new File(sOutputPath); // create the directory of the given output path
+ aOutputFile.mkdirs();
+
+ sOutputPath += _sName;
+ sOutputPath += getFormatExtension(_xComponent /*_nType*/);
+
+ String sOutputURL = URLHelper.getFileURLFromSystemPath(sOutputPath);
+
+ ArrayList aPropertyList = new ArrayList(); // set some properties for storeAsURL
+
+ // PropertyValue aFileFormat = new PropertyValue();
+ // aFileFormat.Name = "FilterName";
+ // aFileFormat.Value = getFileFormat(_nType);
+ // aPropertyList.add(aFileFormat);
+
+ PropertyValue aOverwrite = new PropertyValue(); // always overwrite already exist files
+ aOverwrite.Name = "Overwrite";
+ aOverwrite.Value = Boolean.TRUE;
+ aPropertyList.add(aOverwrite);
+
+ // store the document in an other directory
+ XStorable aStorable = (XStorable) UnoRuntime.queryInterface( XStorable.class, _xComponent);
+ if (aStorable != null)
+ {
+ log.println("store document as URL: '" + sOutputURL + "'");
+ try
+ {
+ aStorable.storeAsURL(sOutputURL, PropertyHelper.createPropertyValueArrayFormArrayList(aPropertyList));
+ }
+ catch (com.sun.star.io.IOException e)
+ {
+ log.println("ERROR: Exception caught");
+ log.println("Can't write document URL: '" + sOutputURL + "'");
+ log.println("Message: " + e.getMessage());
+ }
+ }
+ }
+
+ private XComponent loadComponent(String _sName, Object _xComponent, ArrayList _aPropertyList)
+ {
+ XComponent xDocComponent = null;
+ XComponentLoader xComponentLoader = (XComponentLoader) UnoRuntime.queryInterface( XComponentLoader.class, _xComponent );
+
+ try
+ {
+ PropertyValue[] aLoadProperties = PropertyHelper.createPropertyValueArrayFormArrayList(_aPropertyList);
+ log.println("Load component: '" + _sName + "'");
+ xDocComponent = xComponentLoader.loadComponentFromURL(_sName, "_blank", 0, aLoadProperties);
+ log.println("Load component: '" + _sName + "' done");
+ }
+ catch (com.sun.star.io.IOException e)
+ {
+ log.println("ERROR: Exception caught");
+ log.println("Can't load document '" + _sName + "'");
+ log.println("Message: " + e.getMessage());
+ }
+ catch (com.sun.star.lang.IllegalArgumentException e)
+ {
+ log.println("ERROR: Exception caught");
+ log.println("Illegal Arguments given to loadComponentFromURL.");
+ log.println("Message: " + e.getMessage());
+ }
+ return xDocComponent;
+ }
+
+ private void closeComponent(XComponent _xDoc)
+ {
+ // Close the document
+ XCloseable xCloseable = (XCloseable) UnoRuntime.queryInterface(XCloseable.class, _xDoc);
+ try
+ {
+ xCloseable.close(true);
+ }
+ catch (com.sun.star.util.CloseVetoException e)
+ {
+ log.println("ERROR: CloseVetoException caught");
+ log.println("CloseVetoException occured Can't close document.");
+ log.println("Message: " + e.getMessage());
+ }
+ }
+
+}
diff --git a/qadevOOo/runner/convwatch/SimpleFileSemaphore.java b/qadevOOo/runner/convwatch/SimpleFileSemaphore.java
new file mode 100644
index 000000000000..9d608bdb332b
--- /dev/null
+++ b/qadevOOo/runner/convwatch/SimpleFileSemaphore.java
@@ -0,0 +1,189 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package convwatch;
+
+import java.io.File;
+import java.io.RandomAccessFile;
+import helper.OSHelper;
+
+public class SimpleFileSemaphore /* extends *//* implements */
+{
+ String m_sInternSemaphoreFile;
+ File m_aInternSemaphoreFile;
+ GlobalLogWriter m_aLog;
+
+ public static void sleep( int _nSeconds)
+ {
+ // wait a second here
+ try
+ {
+ java.lang.Thread.sleep(_nSeconds * 1000);
+ }
+ catch (java.lang.InterruptedException e2)
+ {
+ }
+ }
+
+ public SimpleFileSemaphore() throws IllegalArgumentException
+ {
+ String sInternFileName;
+ if (OSHelper.isWindows())
+ {
+ sInternFileName = "C:/Temp/ConvwatchOOoSemaphore.txt";
+ }
+ else if (OSHelper.isUnix())
+ {
+ sInternFileName = "/tmp/ConvwatchOOoSemaphore.txt";
+ }
+ else
+ {
+ m_sInternSemaphoreFile = null;
+ throw new IllegalArgumentException("Unknown System, can't initialise SimpleFileSemaphore");
+ }
+
+ m_sInternSemaphoreFile = sInternFileName;
+ m_aInternSemaphoreFile = new File(sInternFileName);
+ }
+
+ public File getSemaphoreFile()
+ {
+ return m_aInternSemaphoreFile;
+ }
+// ------------------------------------------------------------------------------
+// wait until resource is available
+ public void P(File _aSemaphore)
+ {
+ int nCount = 0;
+ int nCheckLoop = 1;
+
+ while ( nCheckLoop == 1)
+ {
+ // check if resource is available, if not, wait.
+ if ( _aSemaphore.exists() )
+ {
+ m_aLog.get().println( "Active wait since " + nCount + "sec..");
+ nCount ++;
+ sleep( 1 );
+ }
+ else
+ {
+ sleep( 1 );
+ if ( _aSemaphore.exists() )
+ {
+ // ups
+ m_aLog.get().println( "ups...");
+ }
+ else
+ {
+ nCheckLoop = 0;
+ }
+ }
+ }
+
+ // block resource by ourself
+ try
+ {
+ RandomAccessFile aWriter = new RandomAccessFile(_aSemaphore, "rw");
+ aWriter.writeByte((int)1);
+ aWriter.close();
+ }
+
+ catch (java.io.FileNotFoundException fne)
+ {
+ m_aLog.get().println( "caught: FileNotFoundException");
+ }
+ catch(java.io.IOException ie)
+ {
+ m_aLog.get().println( "caught: IOException");
+ }
+ }
+
+// ------------------------------------------------------------------------------
+// block a resource
+ public void V(File _aSemaphore)
+ {
+
+ if ( _aSemaphore.exists() )
+ {
+ _aSemaphore.delete();
+ }
+ else
+ {
+ m_aLog.get().println("Could be a problem here? No resource block found.");
+ }
+ }
+
+ // --------------------------------- Unit test ---------------------------------
+
+ private static boolean SEMAPHORE_SHOULD_EXIST = true;
+ private static boolean SEMAPHORE_SHOULD_NOT_EXIST = false;
+
+ private static void assure(boolean _b, String _sText)
+ {
+ System.out.print(_sText);
+ System.out.print(" ");
+ if (_b)
+ {
+ System.out.println("ok");
+ }
+ else
+ {
+ System.out.println("FAILED");
+ }
+ }
+
+ private static void testSemaphoreFile(SimpleFileSemaphore a, boolean _bShouldFileExists)
+ {
+ System.out.println("Check if semaphore file exists.");
+ File aSemaphoreFile = a.getSemaphoreFile();
+ if (aSemaphoreFile.exists())
+ {
+ System.out.println("Name is: " + aSemaphoreFile.getAbsolutePath());
+ assure(_bShouldFileExists == SEMAPHORE_SHOULD_EXIST, "Semaphore should exist!");
+ }
+ else
+ {
+ assure(_bShouldFileExists == SEMAPHORE_SHOULD_NOT_EXIST, "Semaphore should not exist!");
+ }
+ }
+
+ public static void main( String[] argv )
+ {
+ SimpleFileSemaphore a = new SimpleFileSemaphore();
+
+ testSemaphoreFile(a, SEMAPHORE_SHOULD_NOT_EXIST);
+
+ a.P(a.getSemaphoreFile());
+
+ testSemaphoreFile(a, SEMAPHORE_SHOULD_EXIST);
+
+ a.V(a.getSemaphoreFile());
+
+ testSemaphoreFile(a, SEMAPHORE_SHOULD_NOT_EXIST);
+ }
+}
diff --git a/qadevOOo/runner/convwatch/StatusHelper.java b/qadevOOo/runner/convwatch/StatusHelper.java
new file mode 100644
index 000000000000..d37fa4a79af4
--- /dev/null
+++ b/qadevOOo/runner/convwatch/StatusHelper.java
@@ -0,0 +1,108 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package convwatch;
+
+public class StatusHelper
+{
+ final static public int DIFF_NOT_REALLY_INITIALISED = 1;
+ final static public int DIFF_NO_DIFFERENCES = 2;
+ final static public int DIFF_DIFFERENCES_FOUND = 3;
+ final static public int DIFF_AFTER_MOVE_DONE_NO_PROBLEMS = 4;
+ final static public int DIFF_AFTER_MOVE_DONE_DIFFERENCES_FOUND = 5;
+
+ // public String m_sOutputPath;
+ public String m_sMainName;
+
+ public String m_sOldGfx;
+ public String m_sNewGfx;
+ public String m_sDiffGfx;
+ public int nDiffStatus = DIFF_NOT_REALLY_INITIALISED;
+ public int nPercent = 0;
+
+ // BorderMove Values
+ public int nPercent2 = 0;
+ public String m_sOld_BM_Gfx;
+ public String m_sNew_BM_Gfx;
+ public String m_sDiff_BM_Gfx;
+
+ public StatusHelper(String _sOldGfx, String _sNewGfx, String _sDiffGfx)
+ {
+ m_sOldGfx = _sOldGfx;
+ m_sNewGfx = _sNewGfx;
+ m_sDiffGfx = _sDiffGfx;
+ }
+ public void setFilesForBorderMove(String _sOldGfx, String _sNewGfx, String _sDiffGfx)
+ {
+ m_sOld_BM_Gfx = _sOldGfx;
+ m_sNew_BM_Gfx = _sNewGfx;
+ m_sDiff_BM_Gfx = _sDiffGfx;
+
+ }
+
+ public void printStatus()
+ {
+ GlobalLogWriter.get().println(" Original file: " + m_sOldGfx);
+ GlobalLogWriter.get().println(" New file: " + m_sNewGfx);
+ GlobalLogWriter.get().println("Difference file: " + m_sDiffGfx);
+ if (nDiffStatus == DIFF_NOT_REALLY_INITIALISED)
+ {
+ GlobalLogWriter.get().println("Early problem, may be the files doesn't exist.");
+ }
+ else if (nDiffStatus == DIFF_NO_DIFFERENCES)
+ {
+ GlobalLogWriter.get().println("No differences found, ok.");
+ }
+ else if (nDiffStatus == DIFF_DIFFERENCES_FOUND)
+ {
+ GlobalLogWriter.get().println("Files differ by " + String.valueOf(nPercent) + "%");
+ }
+ else if (nDiffStatus == DIFF_AFTER_MOVE_DONE_NO_PROBLEMS)
+ {
+ GlobalLogWriter.get().println("No differences found, after move picture.");
+ }
+ else if (nDiffStatus == DIFF_AFTER_MOVE_DONE_DIFFERENCES_FOUND)
+ {
+ GlobalLogWriter.get().println("A picture move is done, the files differ by " + String.valueOf(nPercent2) + " old was " + String.valueOf(nPercent) + "%");
+ }
+ else
+ {
+ GlobalLogWriter.get().println("Unknown DIFF_ values used, not handles yet.");
+ }
+ }
+
+
+
+
+
+// TODO: stream output
+// public stream& statusline(stream)
+// {
+// stream << name << "PASS" << nDiff==0?"PASS":"FAIL" << endl;
+// return stream;
+// }
+}
diff --git a/qadevOOo/runner/convwatch/StringHelper.java b/qadevOOo/runner/convwatch/StringHelper.java
new file mode 100644
index 000000000000..b20e3b6bea01
--- /dev/null
+++ b/qadevOOo/runner/convwatch/StringHelper.java
@@ -0,0 +1,103 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// LLA: moved to helper.StringHelper package convwatch;
+// LLA: moved to helper.StringHelper
+// LLA: moved to helper.StringHelper public class StringHelper {
+// LLA: moved to helper.StringHelper
+// LLA: moved to helper.StringHelper public static String doubleQuote(String _sStr)
+// LLA: moved to helper.StringHelper {
+// LLA: moved to helper.StringHelper return "\"" + _sStr + "\"";
+// LLA: moved to helper.StringHelper }
+// LLA: moved to helper.StringHelper
+// LLA: moved to helper.StringHelper public static String singleQuote(String _sStr)
+// LLA: moved to helper.StringHelper {
+// LLA: moved to helper.StringHelper return "'" + _sStr + "'";
+// LLA: moved to helper.StringHelper }
+// LLA: moved to helper.StringHelper
+// LLA: moved to helper.StringHelper public static String removeQuoteIfNeed(String _sPath)
+// LLA: moved to helper.StringHelper {
+// LLA: moved to helper.StringHelper String sNewPath = _sPath;
+// LLA: moved to helper.StringHelper
+// LLA: moved to helper.StringHelper if (_sPath.startsWith("\"") ||
+// LLA: moved to helper.StringHelper _sPath.startsWith("'"))
+// LLA: moved to helper.StringHelper {
+// LLA: moved to helper.StringHelper // remove trailing quotes, if exists
+// LLA: moved to helper.StringHelper sNewPath = sNewPath.substring(1);
+// LLA: moved to helper.StringHelper }
+// LLA: moved to helper.StringHelper
+// LLA: moved to helper.StringHelper if (_sPath.endsWith("\"") ||
+// LLA: moved to helper.StringHelper _sPath.endsWith("'"))
+// LLA: moved to helper.StringHelper {
+// LLA: moved to helper.StringHelper // remove trailing quotes, if exists
+// LLA: moved to helper.StringHelper sNewPath = sNewPath.substring(0, sNewPath.length() - 1);
+// LLA: moved to helper.StringHelper }
+// LLA: moved to helper.StringHelper return sNewPath;
+// LLA: moved to helper.StringHelper }
+// LLA: moved to helper.StringHelper
+// LLA: moved to helper.StringHelper public static String doubleQuoteIfNeed(String _sStr)
+// LLA: moved to helper.StringHelper {
+// LLA: moved to helper.StringHelper if (_sStr.startsWith("\"") && _sStr.endsWith("\""))
+// LLA: moved to helper.StringHelper {
+// LLA: moved to helper.StringHelper // don't quote twice
+// LLA: moved to helper.StringHelper return _sStr;
+// LLA: moved to helper.StringHelper }
+// LLA: moved to helper.StringHelper if (_sStr.indexOf(" ") == -1)
+// LLA: moved to helper.StringHelper {
+// LLA: moved to helper.StringHelper // don't quote, if there is no space in name
+// LLA: moved to helper.StringHelper return _sStr;
+// LLA: moved to helper.StringHelper }
+// LLA: moved to helper.StringHelper if (_sStr.indexOf("%") != -1)
+// LLA: moved to helper.StringHelper {
+// LLA: moved to helper.StringHelper return singleQuote(_sStr);
+// LLA: moved to helper.StringHelper }
+// LLA: moved to helper.StringHelper
+// LLA: moved to helper.StringHelper return doubleQuote(_sStr);
+// LLA: moved to helper.StringHelper }
+// LLA: moved to helper.StringHelper
+// LLA: moved to helper.StringHelper /**
+// LLA: moved to helper.StringHelper * Convert a value to a string with a given length, if the len is greater the len of the value string representation
+// LLA: moved to helper.StringHelper * fill it's front with '0'
+// LLA: moved to helper.StringHelper * So ("5", 4) will result in a string "0005"
+// LLA: moved to helper.StringHelper * @param _nValue
+// LLA: moved to helper.StringHelper * @param _nLen
+// LLA: moved to helper.StringHelper * @return
+// LLA: moved to helper.StringHelper */
+// LLA: moved to helper.StringHelper public static String createValueString(int _nValue, int _nLen)
+// LLA: moved to helper.StringHelper {
+// LLA: moved to helper.StringHelper String sValue = String.valueOf(_nValue);
+// LLA: moved to helper.StringHelper StringBuffer a = new StringBuffer();
+// LLA: moved to helper.StringHelper while (_nLen > sValue.length())
+// LLA: moved to helper.StringHelper {
+// LLA: moved to helper.StringHelper a.append('0');
+// LLA: moved to helper.StringHelper _nLen --;
+// LLA: moved to helper.StringHelper }
+// LLA: moved to helper.StringHelper a.append(sValue);
+// LLA: moved to helper.StringHelper return a.toString();
+// LLA: moved to helper.StringHelper }
+// LLA: moved to helper.StringHelper
+// LLA: moved to helper.StringHelper }
diff --git a/qadevOOo/runner/convwatch/TimeHelper.java b/qadevOOo/runner/convwatch/TimeHelper.java
new file mode 100755
index 000000000000..923568db51c8
--- /dev/null
+++ b/qadevOOo/runner/convwatch/TimeHelper.java
@@ -0,0 +1,44 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package convwatch;
+
+public class TimeHelper
+{
+ /*
+ wait a second the caller don't need to handle the interruptexception
+ @param _nSeconds how long should we wait
+ @param _sReason give a good reason, why we have to wait
+ */
+ static void waitInSeconds(int _nSeconds, String _sReason)
+ {
+ GlobalLogWriter.get().println("Wait " + String.valueOf(_nSeconds) + " sec. Reason: " + _sReason);
+ try {
+ java.lang.Thread.sleep(_nSeconds * 1000);
+ } catch (java.lang.InterruptedException e2) {}
+ }
+}
diff --git a/qadevOOo/runner/convwatch/TriState.java b/qadevOOo/runner/convwatch/TriState.java
new file mode 100644
index 000000000000..7a9e9312c6bb
--- /dev/null
+++ b/qadevOOo/runner/convwatch/TriState.java
@@ -0,0 +1,76 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package convwatch;
+
+public class TriState
+{
+ public static final TriState TRUE = new TriState(1);
+ public static final TriState FALSE = new TriState(0);
+ public static final TriState UNSET = new TriState(-1);
+
+ int m_nValue;
+
+ /**
+ Allocates a <code>TriState</code> object representing the
+ <code>value</code> argument.
+
+ @param value the value of the <code>TriState</code>.
+ */
+ public TriState(int value)
+ {
+ m_nValue = value;
+ }
+
+ /**
+ Returns the value of this TriState object as an int
+ * @return the primitive <code>int</code> value of this object.
+ */
+ public int intValue()
+ {
+ return m_nValue;
+ }
+ /**
+ Returns <code>true</code> if and only if the argument is not
+ <code>null</code> and is a <code>TriState</code> object that
+ contains the same <code>int</code> value as this object.
+
+ @param obj the object to compare with.
+ @return <code>true</code> if the objects are the same;
+ <code>false</code> otherwise.
+ */
+
+ public boolean equals(Object obj)
+ {
+ if ((obj != null) &&
+ (obj instanceof TriState))
+ {
+ return m_nValue == ((TriState)obj).intValue();
+ }
+ return false;
+ }
+}
diff --git a/qadevOOo/runner/convwatch/ValueNotFoundException.java b/qadevOOo/runner/convwatch/ValueNotFoundException.java
new file mode 100644
index 000000000000..04957187d126
--- /dev/null
+++ b/qadevOOo/runner/convwatch/ValueNotFoundException.java
@@ -0,0 +1,36 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package convwatch;
+
+class ValueNotFoundException extends Exception
+{
+ ValueNotFoundException(String _sMessage)
+ {
+ super(_sMessage);
+ }
+}
diff --git a/qadevOOo/runner/convwatch/makefile.mk b/qadevOOo/runner/convwatch/makefile.mk
new file mode 100644
index 000000000000..aed1532cea6e
--- /dev/null
+++ b/qadevOOo/runner/convwatch/makefile.mk
@@ -0,0 +1,86 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+PRJ=..$/..
+
+PRJNAME = OOoRunner
+PACKAGE = convwatch
+TARGET = runner_convwatch
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+# --- Files --------------------------------------------------------
+
+JARFILES = ridl.jar unoil.jar jurt.jar juh.jar java_uno.jar
+JAVAFILES = \
+ TriState.java \
+ IniFile.java \
+ BuildID.java \
+ GfxCompare.java \
+ FilenameHelper.java \
+ NameHelper.java \
+ HTMLOutputter.java \
+ LISTOutputter.java \
+ INIOutputter.java \
+ PropertyName.java \
+ StatusHelper.java \
+ ConvWatchException.java \
+ ConvWatchCancelException.java \
+ OfficePrint.java \
+ PRNCompare.java \
+ FileHelper.java \
+ OSHelper.java \
+ PixelCounter.java \
+ ImageHelper.java \
+ BorderRemover.java \
+ ConvWatch.java \
+ DirectoryHelper.java \
+ ConvWatchStarter.java \
+ ReferenceBuilder.java \
+ EnhancedComplexTestCase.java \
+ MSOfficePrint.java \
+ GraphicalTestArguments.java \
+ GraphicalDifferenceCheck.java \
+ DocumentConverter.java\
+ DBHelper.java\
+ DB.java\
+ ValueNotFoundException.java \
+ GlobalLogWriter.java \
+ CrashLoopTest.java \
+ ReportDesignerTest.java \
+ DateHelper.java \
+ TimeHelper.java
+
+
+
+
+JAVACLASSFILES= $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class)
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
diff --git a/qadevOOo/runner/graphical/BuildID.java b/qadevOOo/runner/graphical/BuildID.java
new file mode 100644
index 000000000000..cf9188d84a47
--- /dev/null
+++ b/qadevOOo/runner/graphical/BuildID.java
@@ -0,0 +1,226 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package graphical;
+
+import java.io.File;
+import helper.OSHelper;
+
+public class BuildID
+{
+ private static String getOfficePath(String _sApp)
+ {
+ String sOfficePath = "";
+ // TODO: StringHelper.removeQuote?
+ if (_sApp.startsWith("\""))
+ {
+ int nIdx = _sApp.indexOf("\"", 1);
+ if (nIdx != -1)
+ {
+ // leave double qoute out.
+ sOfficePath = _sApp.substring(1, nIdx);
+ }
+ }
+ else
+ {
+ // check if _sApp ends with the office executable, if not
+ if (! (_sApp.endsWith("soffice.exe") || _sApp.endsWith("soffice")))
+ {
+ // check if a space exist, so we get all until space
+ int nIdx = _sApp.indexOf(" ", 1);
+ if (nIdx == -1)
+ {
+ sOfficePath = _sApp;
+ }
+ else
+ {
+ sOfficePath = _sApp.substring(0, nIdx);
+ }
+ }
+ else
+ {
+ sOfficePath = _sApp;
+ }
+ }
+ // GlobalLogWriter.get().println("Office path: " + sOfficePath);
+ return sOfficePath;
+ }
+
+ public static String getBuildID(String _sApp)
+ {
+ final String sOfficePath = getOfficePath(_sApp);
+ final String sBuildID = getBuildID(sOfficePath, "buildid");
+ return sBuildID;
+ }
+
+ private static String getBuildID(String _sOfficePath, String _sIniSection)
+ {
+ File aSOfficeFile = new File(_sOfficePath);
+ String sBuildID = "";
+ if (aSOfficeFile.exists())
+ {
+ String sOfficePath = FileHelper.getPath(_sOfficePath);
+ // ok. System.out.println("directory: " + sOfficePath);
+ sBuildID = getBuildIDFromBootstrap(sOfficePath, _sIniSection);
+ if (sBuildID.length() == 0)
+ {
+ sBuildID = getBuildIDFromVersion(sOfficePath, _sIniSection);
+ }
+ }
+ else
+ {
+ GlobalLogWriter.println("soffice executable not found.");
+ }
+
+// int dummy = 0;
+ return sBuildID;
+ }
+
+ private static String getBuildIDFromBootstrap(String _sOfficePath, String _sIniSection)
+ {
+ String sBuildID = "";
+ String sOfficePath;
+ if (OSHelper.isWindows())
+ {
+ sOfficePath = FileHelper.appendPath(_sOfficePath, "bootstrap.ini");
+ }
+ else
+ {
+ sOfficePath = FileHelper.appendPath(_sOfficePath, "bootstraprc");
+ }
+ IniFile aIniFile = new IniFile(sOfficePath);
+ if (aIniFile.is())
+ {
+ sBuildID = aIniFile.getValue("Bootstrap", /*"buildid"*/ _sIniSection);
+ }
+ else
+ {
+ GlobalLogWriter.println("Property Build, can't open file '" + sOfficePath + "', please check.");
+ }
+ return sBuildID;
+ }
+
+ private static String getBuildIDFromVersion(String _sOfficePath, String _sIniSection)
+ {
+ // String fs = System.getProperty("file.separator");
+ String sBuildID = "";
+ String sOfficePath;
+ if (OSHelper.isWindows())
+ {
+ sOfficePath = FileHelper.appendPath(_sOfficePath, "version.ini");
+ }
+ else
+ {
+ sOfficePath = FileHelper.appendPath(_sOfficePath, "versionrc");
+ }
+ IniFile aIniFile = new IniFile(sOfficePath);
+ if (aIniFile.is())
+ {
+ sBuildID = aIniFile.getValue("Version", /*"buildid"*/ _sIniSection);
+ }
+ else
+ {
+ GlobalLogWriter.println("Property Build, can't open file '" + sOfficePath + "', please check.");
+ }
+ return sBuildID;
+ }
+
+// public static void main(String[] args)
+// {
+// String sApp;
+// sApp = "/opt/staroffice8_m116/program/soffice -headless -accept=socket,host=localhost,port=8100;urp;";
+// String sBuildID;
+// sBuildID = getBuildID(sApp);
+// System.out.println("BuildID is: " + sBuildID);
+//
+// Date aDate = new Date();
+// long nStart = aDate.getTime();
+// System.out.println("Time:" + nStart);
+// // LLA: Just some more tests for getBuildID
+// // sApp = "/opt/staroffice8_net/program/soffice";
+// // sBuildID = getBuildID(sApp);
+// // System.out.println("BuildID is: " + sBuildID);
+// //
+// // sApp = "\"/opt/staroffice8_net/program/soffice\" test blah";
+// // sBuildID = getBuildID(sApp);
+// //
+// // System.out.println("BuildID is: " + sBuildID);
+// System.exit(1);
+// }
+
+ public static String getMaster(String _sOfficePath)
+ {
+ final String sOfficePath = getOfficePath(_sOfficePath);
+ final String sMaster = getBuildID(sOfficePath, "ProductSource");
+ return sMaster;
+ }
+
+ public static String getMinor(String _sOfficePath)
+ {
+ final String sOfficePath = getOfficePath(_sOfficePath);
+ final String sMinor = "m" + getBuildID(sOfficePath, "ProductMinor");
+ return sMinor;
+ }
+
+ public static String getCWSName(String _sOfficePath)
+ {
+ final String sOfficePath = getOfficePath(_sOfficePath);
+ final String sBuildID = getBuildID(sOfficePath, "buildid");
+ String sCWSName = "MWS";
+ int nIdx = sBuildID.indexOf("[CWS:");
+ if (nIdx > 0)
+ {
+ int nIdx2 = sBuildID.indexOf("]", nIdx);
+ sCWSName = sBuildID.substring(nIdx + 5, nIdx2);
+ }
+ return sCWSName;
+ }
+
+// public static void main(String[] args)
+// {
+// String sApp;
+// sApp = "D:/staroffice9_m63/Sun/StarOffice 9/program/soffice.exe";
+// String sBuildID;
+// sBuildID = getBuildID(sApp);
+// System.out.println("BuildID is: " + sBuildID);
+//
+// String sMaster;
+// sMaster = getMaster(sApp);
+// System.out.println("Master is: " + sMaster);
+//
+// String sMinor;
+// sMinor = getMinor(sApp);
+// System.out.println("Minor is: " + sMinor);
+//
+// String sCWSName;
+// sCWSName = getCWSName(sApp);
+// System.out.println("CWSName is: " + sCWSName);
+//
+// System.exit(1);
+// }
+
+}
diff --git a/qadevOOo/runner/graphical/DateHelper.java b/qadevOOo/runner/graphical/DateHelper.java
new file mode 100644
index 000000000000..07a5c5844099
--- /dev/null
+++ b/qadevOOo/runner/graphical/DateHelper.java
@@ -0,0 +1,58 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package graphical;
+
+import java.text.SimpleDateFormat;
+import java.util.GregorianCalendar;
+import java.text.FieldPosition;
+import java.util.Locale;
+
+public class DateHelper
+{
+ public static String getDateTimeForFilename()
+ {
+ return getDateString("yyyyMMdd-HHmmss");
+ }
+
+ public static String getDateTimeForHumanreadableLog()
+ {
+ return getDateString("[yyyy/MM/dd HH:mm:ss]");
+ }
+
+ public static String getDateString(String _sFormat)
+ {
+ GregorianCalendar aCalendar = new GregorianCalendar();
+ StringBuffer aBuf = new StringBuffer();
+
+ Locale aLocale = new Locale("en","US");
+ SimpleDateFormat aFormat = new SimpleDateFormat(_sFormat, aLocale);
+ aBuf = aFormat.format(aCalendar.getTime(), aBuf, new FieldPosition(0) );
+ // DebugHelper.writeInfo("Date: " + aBuf.toString());
+ return aBuf.toString();
+ }
+}
diff --git a/qadevOOo/runner/graphical/DirectoryHelper.java b/qadevOOo/runner/graphical/DirectoryHelper.java
new file mode 100644
index 000000000000..46930d19425f
--- /dev/null
+++ b/qadevOOo/runner/graphical/DirectoryHelper.java
@@ -0,0 +1,160 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package graphical;
+
+import java.io.File;
+import java.io.FileFilter;
+import java.util.ArrayList;
+
+/**
+ * Helper for directory access
+ *
+ * @author lla@openoffice.org
+ */
+public class DirectoryHelper
+{
+ ArrayList<String> m_aFileList = new ArrayList<String>();
+ boolean m_bRecursiveIsAllowed = true;
+
+ void setRecursiveIsAllowed(boolean _bValue)
+ {
+ m_bRecursiveIsAllowed = _bValue;
+ }
+
+ /**
+ * Traverse over a given directory, and filter with a given FileFilter
+ * object and gives back the deep directory as a Object[] list, which
+ * contain a String object for every directory entry.
+ *
+ * <B>Example</B>
+ * List directory /bin, filter out all files which ends with '.prn'
+ *
+ * FileFilter aFileFilter = new FileFilter()
+ * {
+ * public boolean accept( File pathname )
+ * {
+ * if (pathname.getName().endsWith(".prn"))
+ * {
+ * return false;
+ * }
+ * return true;
+ * }
+ * };
+ *
+ * Object[] aList = DirectoryHelper.traverse("/bin", aFileFilter);
+ * for (int i=0;i<aList.length;i++)
+ * {
+ * String aEntry = (String)aList[i];
+ * System.out.println(aEntry);
+ * }
+ *
+ * @param _sDirectory
+ * @param _aFileFilter
+ * @param _bRecursiveIsAllowed
+ * @return list of directories
+ */
+ public static Object[] traverse( String _sDirectory, FileFilter _aFileFilter, boolean _bRecursiveIsAllowed )
+ {
+ DirectoryHelper a = new DirectoryHelper();
+ a.setRecursiveIsAllowed(_bRecursiveIsAllowed);
+ a.traverse_impl(_sDirectory, _aFileFilter);
+ return a.m_aFileList.toArray();
+ }
+
+ public static Object[] traverse( String _sDirectory, boolean _bRecursiveIsAllowed )
+ {
+ DirectoryHelper a = new DirectoryHelper();
+ a.setRecursiveIsAllowed(_bRecursiveIsAllowed);
+ a.traverse_impl(_sDirectory, null);
+ return a.m_aFileList.toArray();
+ }
+
+ void traverse_impl( String afileDirectory, FileFilter _aFileFilter )
+ {
+ File fileDirectory = new File(afileDirectory);
+ // Testing, if the file is a directory, and if so, it throws an exception
+ if ( !fileDirectory.isDirectory() )
+ {
+ throw new IllegalArgumentException( "not a directory: " + fileDirectory.getName() );
+ }
+
+ // Getting all files and directories in the current directory
+ File[] aDirEntries;
+ if (_aFileFilter != null)
+ {
+ aDirEntries = fileDirectory.listFiles(_aFileFilter);
+ }
+ else
+ {
+ aDirEntries = fileDirectory.listFiles();
+ }
+
+ // Iterating for each file and directory
+ for ( int i = 0; i < aDirEntries.length; ++i )
+ {
+ if ( aDirEntries[ i ].isDirectory() )
+ {
+ if (m_bRecursiveIsAllowed == true)
+ {
+ // Recursive call for the new directory
+ traverse_impl( aDirEntries[ i ].getAbsolutePath(), _aFileFilter );
+ }
+ }
+ else
+ {
+ // adding file to List
+ try
+ {
+ // Composing the URL by replacing all backslashs
+ // String stringUrl = "file:///" + aFileEntries[ i ].getAbsolutePath().replace( '\\', '/' );
+ String aStr = aDirEntries[ i ].getAbsolutePath();
+ m_aFileList.add(aStr);
+ }
+ catch( Exception exception )
+ {
+ exception.printStackTrace();
+ break;
+ }
+ }
+ }
+ }
+
+ // tests
+ // public static void main(String[] args)
+ // {
+ // String sDirectory = "/misc/convwatch/gfxcmp/data/doc-pool/demo";
+ // Object[] aDirectoryList = DirectoryHelper.traverse( sDirectory, false );
+ //
+ // for (int i=0;i<aDirectoryList.length;i++)
+ // {
+ // String sEntry = (String)aDirectoryList[i];
+ // System.out.println(sEntry);
+ // }
+ // }
+}
+
diff --git a/qadevOOo/runner/graphical/EnhancedComplexTestCase.java b/qadevOOo/runner/graphical/EnhancedComplexTestCase.java
new file mode 100644
index 000000000000..c3ec2b3e8336
--- /dev/null
+++ b/qadevOOo/runner/graphical/EnhancedComplexTestCase.java
@@ -0,0 +1,519 @@
+/*
+ * ************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ * ***********************************************************************
+ */
+
+package graphical;
+
+import complexlib.ComplexTestCase;
+import java.io.File;
+import java.io.FileFilter;
+import java.util.ArrayList;
+
+/**
+ *
+ * @author ll93751
+ */
+abstract public class EnhancedComplexTestCase extends ComplexTestCase implements IDocument
+{
+
+
+private void callEntry(String _sEntry, ParameterHelper _aParam)
+{
+ // log.println("- next file is: ------------------------------");
+ log.println("File: " + _sEntry);
+ // TODO: check if 'sEntry' is a guilty document.
+ File aFile = new File(_aParam.getInputPath());
+ String sPath = _aParam.getInputPath();
+ // problem here, isFile() checks also if the file exists, but a not existing file is not really a directory
+ // therefore we check if the given file a path (isDirectory()) if not it must be a file
+ if (aFile.isDirectory())
+ {
+ }
+ else
+ {
+ // special case, if a file is given in inputpath
+ sPath = FileHelper.getPath(_aParam.getInputPath());
+ }
+ String sNewSubDir = FileHelper.removeFirstDirectorysAndBasenameFrom(_sEntry, sPath);
+
+// String sNewReferencePath = _aParam.getReferencePath();
+ String sNewOutputPath = _aParam.getOutputPath();
+ // String sNewDiffPath = m_sDiffPath;
+
+ // if there exist a subdirectory, add it to all result path
+ if (sNewSubDir.length() > 0)
+ {
+// if (sNewReferencePath != null)
+// {
+// sNewReferencePath = FileHelper.appendPath(sNewReferencePath, sNewSubDir);
+// }
+
+ sNewOutputPath = FileHelper.appendPath(sNewOutputPath, sNewSubDir);
+ // if (sNewDiffPath != null)
+ // {
+ // sNewDiffPath = FileHelper.appendPath(sNewDiffPath, sNewSubDir);
+ // }
+ }
+ // log.println("sEntry: " + _sEntry + " " /* + sNewReferencePath + " " */ + sNewOutputPath);
+ log.println("Outputpath: " + sNewOutputPath);
+
+
+ // call interface with parameters
+ try
+ {
+ checkOneFile(_sEntry, sNewOutputPath, _aParam);
+ }
+ catch (OfficeException e)
+ {
+ // TODO: unhandled yet.
+ GlobalLogWriter.println("Warning: caught OfficeException " + e.getMessage());
+ assure("Exception caught: " + e.getMessage(), false);
+ }
+
+}
+
+/**
+ * Run through all documents found in Inputpath.
+ * Call the IDocument interface function call(...);
+ * @param _aParam
+ */
+ public void foreachDocumentinInputPath(ParameterHelper _aParam)
+ {
+ // TODO: auslagern in eine function, die ein Interface annimmt.
+ File aInputPath = new File(_aParam.getInputPath());
+ if (aInputPath.isDirectory())
+ {
+ // check a whole directory
+ // a whole directory
+ FileFilter aFileFilter = FileHelper.getFileFilter();
+ traverseDirectory(aFileFilter, _aParam);
+ }
+ else
+ {
+ callEntry(_aParam.getInputPath(), _aParam);
+ }
+ }
+
+ private void traverseDirectory(FileFilter _aFileFilter, ParameterHelper _aParam)
+ {
+ Object[] aList = DirectoryHelper.traverse(_aParam.getInputPath(), _aFileFilter, _aParam.isIncludeSubDirectories());
+ if (aList.length == 0)
+ {
+ log.println("Nothing to do, there are no document files found.");
+ }
+ else
+ {
+ for (int i=0;i<aList.length;i++)
+ {
+ String sEntry = (String)aList[i];
+ callEntry(sEntry, _aParam);
+ }
+ }
+ }
+/**
+ * Run through a given index.ini or run through a given directory,
+ * find all postscript or pdf files.
+ * Call the IDocument interface function call(...);
+ * @param _aParam
+ */
+ public void foreachPSorPDFinInputPath(ParameterHelper _aParam)
+ {
+ // TODO: auslagern in eine function, die ein Interface annimmt.
+ String sInputPath = _aParam.getInputPath();
+ File aInputPath = new File(sInputPath);
+// if (!aInputPath.exists())
+// {
+// GlobalLogWriter.println("Error, InputPath or File in InputPath doesn't exists. Please check: '" + sInputPath + "'");
+// assure("Error, InputPath or File in InputPath doesn't exists. Please check: '" + sInputPath + "'", false);
+// }
+ if (aInputPath.isDirectory())
+ {
+ // check a whole directory
+ // a whole directory
+ FileFilter aFileFilter = FileHelper.getFileFilterPSorPDF();
+ traverseDirectory(aFileFilter, _aParam);
+ }
+ else
+ {
+ // the inputpath contains a file
+ if (sInputPath.toLowerCase().endsWith(".ini"))
+ {
+ IniFile aIniFile = new IniFile(_aParam.getInputPath());
+ while (aIniFile.hasMoreElements())
+ {
+ String sKey = (String)aIniFile.nextElement();
+ String sPath = FileHelper.getPath(_aParam.getInputPath());
+ String sEntry = FileHelper.appendPath(sPath, sKey);
+ File aFile = new File(sEntry);
+ assure("File '" + sEntry + "' doesn't exists.", aFile.exists(), true);
+ if (aFile.exists())
+ {
+ callEntry(sEntry, _aParam);
+ }
+ }
+ }
+ else
+ {
+ // call for a single pdf/ps file
+ if (sInputPath.toLowerCase().endsWith(".ps") ||
+ sInputPath.toLowerCase().endsWith(".pdf") ||
+ sInputPath.toLowerCase().endsWith(".prn"))
+ {
+ callEntry(sInputPath, _aParam);
+ }
+ else
+ {
+ String sInputPathWithPDF = sInputPath + ".pdf";
+ File aInputPathWithPDF = new File(sInputPathWithPDF);
+
+ if (aInputPathWithPDF.exists() &&
+ _aParam.getReferenceType().toLowerCase().equals("pdf"))
+ {
+ // create PDF only if a pdf file exists and creatortype is set to PDF
+ callEntry(sInputPathWithPDF, _aParam);
+ }
+ else
+ {
+ String sInputPathWithPS = sInputPath + ".ps";
+
+ File aInputPathWithPS = new File(sInputPathWithPS);
+ if (aInputPathWithPS.exists())
+ {
+ callEntry(sInputPathWithPS, _aParam);
+ }
+ else
+ {
+ String sPath = FileHelper.getPath(sInputPath);
+ String sBasename = FileHelper.getBasename(sInputPath);
+
+ // there exist an index file, therefore we assume the given
+ // file is already converted to postscript or pdf
+ runThroughEveryReportInIndex(sPath, sBasename, _aParam);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ private void runThroughEveryReportInIndex(String _sPath, String _sBasename, ParameterHelper _aParam)
+ {
+ String sIndexFile = FileHelper.appendPath(_sPath, "index.ini");
+ File aIndexFile = new File(sIndexFile);
+ if (aIndexFile.exists())
+ {
+ IniFile aIniFile = new IniFile(sIndexFile);
+
+ if (aIniFile.hasSection(_sBasename))
+ {
+ // special case for odb files
+ int nFileCount = aIniFile.getIntValue(_sBasename, "reportcount", 0);
+ ArrayList<String> aList = new ArrayList<String>();
+ for (int i=0;i<nFileCount;i++)
+ {
+ String sValue = aIniFile.getValue(_sBasename, "report" + i);
+
+ String sPSorPDFName = getPSorPDFNameFromIniFile(aIniFile, sValue);
+ if (sPSorPDFName.length() > 0)
+ {
+ String sEntry = FileHelper.appendPath(_sPath, sPSorPDFName);
+ aList.add(sEntry);
+ }
+ }
+ aIniFile.close();
+
+ int nOkStatus = 0;
+ String sStatusRunThrough = "";
+ String sStatusInfo = "";
+ // get the bad status and store it into the
+ for (int i=0;i<aList.size();i++)
+ {
+ String sEntry = aList.get(i);
+ callEntry(sEntry, _aParam);
+
+ // we want to know the current status of the run through
+ // if the status is greater (more bad) then the current,
+ // we will remember this. Only the very bad status will
+ // seen.
+ int nCurrentOkStatus = _aParam.getTestParameters().getInt("current_ok_status");
+ if (nCurrentOkStatus > nOkStatus)
+ {
+ sStatusRunThrough = (String)_aParam.getTestParameters().get("current_state");
+ sStatusInfo = (String)_aParam.getTestParameters().get("current_info");
+ nOkStatus = nCurrentOkStatus;
+ }
+ }
+ if (nOkStatus > 0)
+ {
+ _aParam.getTestParameters().put("last_state", sStatusRunThrough);
+ _aParam.getTestParameters().put("last_info", sStatusInfo);
+ }
+ }
+ else
+ {
+ // runThroughOneFileInIndex();
+ String sPSorPDFName = getPSorPDFNameFromIniFile(aIniFile, _sBasename);
+
+ aIniFile.close();
+
+ if (sPSorPDFName.length() > 0)
+ {
+ String sEntry = FileHelper.appendPath(_sPath, sPSorPDFName);
+ callEntry(sEntry, _aParam);
+ }
+ }
+ }
+ else
+ {
+ assure("File '" + sIndexFile + "' doesn't exists.", aIndexFile.exists(), true);
+ }
+ }
+
+ private String getPSorPDFNameFromIniFile(IniFile _aIniFile, String _sName)
+ {
+ boolean bHasPostscriptOrPDF = false;
+ String sPSBasename = _sName + ".ps";
+ if (_aIniFile.hasSection(sPSBasename)) // checks for Postscript
+ {
+ bHasPostscriptOrPDF = true;
+ }
+ else
+ {
+ sPSBasename = _sName + ".pdf"; // checks for PDF
+ if (_aIniFile.hasSection(sPSBasename))
+ {
+ bHasPostscriptOrPDF = true;
+ }
+ }
+ if (bHasPostscriptOrPDF)
+ {
+ return sPSBasename;
+ }
+ return "";
+ }
+
+ public void runThroughOneFileInIndex(String _sPath, String _sBasename, ParameterHelper _aParam)
+ {
+
+ }
+/**
+ * Run through a given index.ini or run through a given directory,
+ * find all postscript or pdf files.
+ * Call the IDocument interface function call(...);
+ * @param _aParam
+ */
+ public void foreachJPEGcompareWithJPEG(ParameterHelper _aParam)
+ {
+ // TODO: auslagern in eine function, die ein Interface annimmt.
+ String sInputPath = _aParam.getInputPath();
+ File aInputPath = new File(sInputPath);
+// if (!aInputPath.exists())
+// {
+// GlobalLogWriter.println("Error, InputPath or File in InputPath doesn't exists. Please check: '" + sInputPath + "'");
+// assure("Error, InputPath or File in InputPath doesn't exists. Please check: '" + sInputPath + "'", false);
+// }
+ if (aInputPath.isDirectory())
+ {
+ // check a whole directory
+ // a whole directory
+ FileFilter aFileFilter = FileHelper.getFileFilterJPEG();
+ traverseDirectory(aFileFilter, _aParam);
+ }
+ else
+ {
+ // the inputpath contains a file
+ if (sInputPath.toLowerCase().endsWith(".ini"))
+ {
+ IniFile aIniFile = new IniFile(_aParam.getInputPath());
+ while (aIniFile.hasMoreElements())
+ {
+ String sSection = (String)aIniFile.nextElement();
+// TODO: not supported yet.
+ // callEveryPictureInIniFile(aIniFile, sSection, _aParam);
+ }
+ }
+ else
+ {
+ // call for a single jpeg file
+ try
+ {
+ String sOutputFilename = _aParam.getOutputPath();
+ if (sInputPath.toLowerCase().endsWith(".jpg") ||
+ sInputPath.toLowerCase().endsWith(".jpeg") )
+ {
+ checkOneFile(sInputPath, sOutputFilename, _aParam);
+ }
+ else
+ {
+ // check if there exists a ini file
+ String sPath = FileHelper.getPath(sInputPath);
+ String sBasename = FileHelper.getBasename(sInputPath);
+
+ runThroughEveryReportInIndex(sPath, sBasename, _aParam);
+
+ String sStatusRunThrough = (String)_aParam.getTestParameters().get("last_state");
+ String sStatusInfo = (String)_aParam.getTestParameters().get("last_info");
+
+ if (sStatusRunThrough != null &&
+ sStatusInfo != null )
+ {
+ // store the bad status in the <Name>.odb.ps.ini file
+ String sOutputPath = _aParam.getOutputPath();
+ String sBasenameIni = FileHelper.appendPath(sOutputPath, sBasename + ".ps.ini");
+ IniFile aBasenameIni = new IniFile(sBasenameIni);
+ aBasenameIni.insertValue("global", "state", sStatusRunThrough);
+ aBasenameIni.insertValue("global", "info", sStatusInfo);
+ aBasenameIni.close();
+ }
+
+ }
+ }
+ catch (OfficeException e)
+ {
+ // TODO: unhandled yet.
+ GlobalLogWriter.println("Warning: caught OfficeException " + e.getMessage());
+ }
+ // callEntry(sInputPath, _aParam);
+ }
+ }
+ }
+
+
+/**
+ * Run through a given index.ini or run through a given directory,
+ * find all ini files.
+ * Call the IDocument interface function call(...);
+ * @param _aParam
+ */
+ public void foreachResultCreateHTML(ParameterHelper _aParam)
+ {
+ // TODO: auslagern in eine function, die ein Interface annimmt.
+ String sInputPath = _aParam.getInputPath();
+ File aInputPath = new File(sInputPath);
+// if (!aInputPath.exists())
+// {
+// GlobalLogWriter.println("Error, InputPath or File in InputPath doesn't exists. Please check: '" + sInputPath + "'");
+// assure("Error, InputPath or File in InputPath doesn't exists. Please check: '" + sInputPath + "'", false);
+// }
+
+ // call for a single ini file
+ if (sInputPath.toLowerCase().endsWith(".ini") )
+ {
+ callEntry(sInputPath, _aParam);
+ }
+ else
+ {
+ // check if there exists an ini file
+ String sPath = FileHelper.getPath(sInputPath);
+ String sBasename = FileHelper.getBasename(sInputPath);
+
+ runThroughEveryReportInIndex(sPath, sBasename, _aParam);
+
+ // Create a HTML page which shows locally to all files in .odb
+ if (sInputPath.toLowerCase().endsWith(".odb"))
+ {
+ String sIndexFile = FileHelper.appendPath(sPath, "index.ini");
+ File aIndexFile = new File(sIndexFile);
+ if (aIndexFile.exists())
+ {
+ IniFile aIniFile = new IniFile(sIndexFile);
+
+ if (aIniFile.hasSection(sBasename))
+ {
+ // special case for odb files
+ int nFileCount = aIniFile.getIntValue(sBasename, "reportcount", 0);
+ ArrayList<String> aList = new ArrayList<String>();
+ for (int i=0;i<nFileCount;i++)
+ {
+ String sValue = aIniFile.getValue(sBasename, "report" + i);
+
+ String sPSorPDFName = getPSorPDFNameFromIniFile(aIniFile, sValue);
+ if (sPSorPDFName.length() > 0)
+ {
+ aList.add(sPSorPDFName);
+ }
+ }
+ if (aList.size() > 0)
+ {
+ // HTML output for the odb file, shows only all other documents.
+ HTMLResult aOutputter = new HTMLResult(sPath, sBasename + ".ps.html" );
+ aOutputter.header("content of DB file: " + sBasename);
+ aOutputter.indexSection(sBasename);
+
+ for (int i=0;i<aList.size();i++)
+ {
+ String sPSFile = aList.get(i);
+
+ // TODO: this information has to come out of the ini files
+ String sStatusRunThrough = "";
+ String sStatusMessage = "";
+
+ String sHTMLFile = sPSFile + ".html";
+ aOutputter.indexLine(sHTMLFile, sPSFile, sStatusRunThrough, sStatusMessage);
+ }
+ aOutputter.close();
+
+// String sHTMLFile = FileHelper.appendPath(sPath, sBasename + ".ps.html");
+// try
+// {
+//
+// FileOutputStream out2 = new FileOutputStream(sHTMLFile);
+// PrintStream out = new PrintStream(out2);
+//
+// out.println("<HTML>");
+// out.println("<BODY>");
+// for (int i=0;i<aList.size();i++)
+// {
+// // <A href="link">blah</A>
+// String sPSFile = (String)aList.get(i);
+// out.print("<A href=\"");
+// out.print(sPSFile + ".html");
+// out.print("\">");
+// out.print(sPSFile);
+// out.println("</A>");
+// out.println("<BR>");
+// }
+// out.println("</BODY></HTML>");
+// out.close();
+// out2.close();
+// }
+// catch (java.io.IOException e)
+// {
+//
+// }
+ }
+ }
+ aIniFile.close();
+ }
+
+ }
+ }
+ }
+
+
+}
diff --git a/qadevOOo/runner/graphical/FileHelper.java b/qadevOOo/runner/graphical/FileHelper.java
new file mode 100644
index 000000000000..892f652567c1
--- /dev/null
+++ b/qadevOOo/runner/graphical/FileHelper.java
@@ -0,0 +1,767 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package graphical;
+
+import java.io.File;
+import java.io.FileFilter;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.StringTokenizer;
+import helper.OSHelper;
+
+import java.io.PrintStream;
+import javax.swing.JOptionPane;
+
+public class FileHelper
+{
+ public FileHelper()
+ {
+ // fs = System.getProperty("file.separator");
+
+
+ String sOSName = System.getProperty("os.name");
+ String sOSArch = System.getProperty("os.arch");
+ String sOSVersion = System.getProperty("os.version");
+
+ GlobalLogWriter.println(sOSName);
+ GlobalLogWriter.println(sOSArch);
+ GlobalLogWriter.println(sOSVersion);
+
+ }
+
+ public static void MessageBox(String _sStr)
+ {
+ String sVersion = System.getProperty("java.version");
+ String sOSName = System.getProperty("os.name");
+ JOptionPane.showMessageDialog( null, _sStr, sVersion + " " + sOSName + " Hello World Debugger", JOptionPane.INFORMATION_MESSAGE );
+ }
+
+ public static boolean exists(String _sFile)
+ {
+ if (_sFile == null)
+ {
+ return false;
+ }
+
+ File aFile = new File(_sFile);
+ if (aFile.exists())
+ {
+ return true;
+ }
+ // This is just nice for DEBUG behaviour
+ // due to the fact this is absolutly context dependency no one should use it.
+ // else
+ // {
+ // System.out.println("FileHelper:exists() tell this path doesn't exists. Check it. path is:" );
+ // System.out.println( _sFile );
+ // System.out.println( aFile.getAbsolutePath() );
+ // MessageBox("Der JavaProzess wartet auf eine interaktion ihrerseits.");
+ //
+ // File aFile2 = new File(_sFile);
+ // if (aFile2.exists())
+ // {
+ // System.out.println("Thanks, file exists." );
+ // return true;
+ // }
+ // }
+ return false;
+ }
+
+ public static boolean isDir(String _sDir)
+ {
+ if (_sDir == null)
+ {
+ return false;
+ }
+ try
+ {
+ File aFile = new File(_sDir);
+ if (aFile.exists() && aFile.isDirectory())
+ {
+ return true;
+ }
+ }
+ catch (NullPointerException e)
+ {
+ GlobalLogWriter.println("Exception caught. FileHelper.isDir('" + _sDir + "')");
+ e.printStackTrace();
+ }
+ return false;
+ }
+
+ public static String getBasename(String _sFilename)
+ {
+ if (_sFilename == null)
+ {
+ return "";
+ }
+ // String fs = System.getProperty("file.separator");
+
+ int nIdx = _sFilename.lastIndexOf("\\");
+ if (nIdx == -1)
+ {
+ nIdx = _sFilename.lastIndexOf("/");
+ }
+ if (nIdx > 0)
+ {
+ return _sFilename.substring(nIdx + 1);
+ }
+ return _sFilename;
+ }
+
+ public static String getNameNoSuffix(String _sFilename)
+ {
+ if (_sFilename == null)
+ {
+ return "";
+ }
+ int nIdx = _sFilename.lastIndexOf(".");
+ if (nIdx > 0)
+ {
+ return _sFilename.substring(0, nIdx);
+ }
+ return _sFilename;
+ }
+
+ public static String getSuffix(String _sFilename)
+ {
+ if (_sFilename == null)
+ {
+ return "";
+ }
+ int nIdx = _sFilename.lastIndexOf(".");
+ if (nIdx > 0)
+ {
+ return _sFilename.substring(nIdx );
+ }
+ return "";
+ }
+
+ public static String getPath(String _sFilename)
+ {
+ if (_sFilename == null)
+ {
+ return "";
+ }
+ // String fs = System.getProperty("file.separator");
+
+ int nIdx = _sFilename.lastIndexOf("\\");
+ if (nIdx == -1)
+ {
+ nIdx = _sFilename.lastIndexOf("/");
+ }
+ if (nIdx > 0)
+ {
+ return _sFilename.substring(0, nIdx);
+ }
+ return "";
+ }
+
+/*
+ static ArrayList files = new ArrayList();
+ public static Object[] traverse( String afileDirectory )
+ {
+
+ File fileDirectory = new File(afileDirectory);
+ // Testing, if the file is a directory, and if so, it throws an exception
+ if ( !fileDirectory.isDirectory() )
+ {
+ throw new IllegalArgumentException( "not a directory: " + fileDirectory.getName() );
+ }
+
+ // Getting all files and directories in the current directory
+ File[] entries = fileDirectory.listFiles();
+
+ // Iterating for each file and directory
+ for ( int i = 0; i < entries.length; ++i )
+ {
+ // adding file to List
+ try
+ {
+ // Composing the URL by replacing all backslashs
+ String stringUrl = "file:///"
+ + entries[ i ].getAbsolutePath().replace( '\\', '/' );
+ files.add(stringUrl);
+ }
+ catch( Exception exception )
+ {
+ exception.printStackTrace();
+ }
+ }
+ return files.toArray();
+ }
+*/
+
+ // makeDirectories("", "/tmp/a/b");
+ // creates all directories /tmp/a/b
+ //
+ public static void makeDirectories(String first, String path)
+ {
+ makeDirectories(first, path, "0777");
+ }
+
+ public static void makeDirectories(String first, String path, String _sMode)
+ {
+ String fs = System.getProperty("file.separator");
+ if (path.startsWith(fs + fs)) // starts with UNC Path
+ {
+ int n = path.indexOf(fs, 2);
+ n = path.indexOf(fs, n + 1);
+ first = path.substring(0, n);
+ path = path.substring(n + 1);
+ }
+
+ String already_done = null;
+ StringTokenizer path_tokenizer = new StringTokenizer(path,fs,false);
+ already_done = first;
+ while (path_tokenizer.hasMoreTokens())
+ {
+ String part = path_tokenizer.nextToken();
+ File new_dir = new File(already_done + File.separatorChar + part);
+ already_done = new_dir.toString();
+ // System.out.println(already_done);
+ //create the directory
+ new_dir.mkdirs();
+ if (OSHelper.isUnix() &&
+ _sMode.length() > 0)
+ {
+ try
+ {
+ chmod(new_dir, _sMode);
+ }
+ catch (java.io.IOException e)
+ {
+ GlobalLogWriter.println("Exception caught. FileHelper.makeDirectories('" + new_dir.getAbsolutePath() + "')");
+ }
+ }
+ }
+ // return;
+ }
+
+ public static void chmod(File file, String mode) throws java.io.IOException
+ {
+ Runtime.getRuntime().exec
+ (new String[]
+ {"chmod", mode, file.getAbsolutePath()});
+ }
+
+ public static String removeFirstDirectorysAndBasenameFrom(String _sName, String _sRemovePath)
+ {
+ // pre: _sName: /a/b/c/d/e/f.g _sRemovePath /a/b/c
+ // result: d/e
+ String fs = System.getProperty("file.separator");
+
+ String sBasename = FileHelper.getBasename(_sName);
+ String sSubDirs = "";
+ if (_sName.startsWith(_sRemovePath))
+ {
+ // if _sName starts with _sRemovePath
+ int nRemovePathIndex = _sRemovePath.length();
+ if (! _sRemovePath.endsWith(fs))
+ {
+ // add 1 if we not ends with file separator
+ nRemovePathIndex ++;
+ }
+ int nBasenameIndex = _sName.length() - sBasename.length() - 1;
+ if (nRemovePathIndex < nBasenameIndex)
+ {
+ sSubDirs = _sName.substring(nRemovePathIndex, nBasenameIndex);
+ }
+ }
+ else
+ {
+ // special case, the _sRemovePath is not part of _sName
+ sSubDirs = FileHelper.getPath(_sName);
+ if (sSubDirs.startsWith(fs))
+ {
+ // remove leading file separator
+ sSubDirs = sSubDirs.substring(1);
+ }
+ }
+
+ return sSubDirs;
+ }
+
+ public static void test_removeFirstDirectorysAndBasenameFrom()
+ {
+ String a = removeFirstDirectorysAndBasenameFrom("/a/b/c/d/e/f.g", "/a/b/c");
+ // assure("", a.equals("d/e"));
+ String b = removeFirstDirectorysAndBasenameFrom("/a/b/c/d/e/f.g", "/a/b/c/");
+ // assure("", b.equals("d/e"));
+ String c = removeFirstDirectorysAndBasenameFrom("/a/b/c/d/e/f.g", "/b/c");
+ // assure("", c.equals("a/b/c/d/e"));
+ }
+
+
+ public static String getSystemPathFromFileURL( String _sFileURL )
+ {
+ String sSystemFile = null;
+
+ if(_sFileURL.startsWith("file:///"))
+ {
+ if (OSHelper.isWindows())
+ {
+ sSystemFile = _sFileURL.substring(8);
+ }
+ else
+ {
+ sSystemFile = _sFileURL.substring(7);
+ }
+ }
+ else if (_sFileURL.startsWith("file://"))
+ {
+ sSystemFile = _sFileURL.substring(5);
+ }
+ String fs = System.getProperty("file.separator");
+ if (! fs.equals("/"))
+ {
+ sSystemFile = sSystemFile.replace ('/', fs.toCharArray ()[0]);
+ }
+// FEATURE FOR UNC NEED!!!
+ return sSystemFile;
+ }
+
+ private static boolean m_bDebugTextShown = false;
+ public static boolean isDebugEnabled()
+ {
+ boolean bDebug = false;
+ String sTmpPath = util.utils.getUsersTempDir();
+ //util.utils.getUsersTempDir();
+ String fs = System.getProperty("file.separator");
+ String sName = sTmpPath + fs + "DOC_COMPARATOR_DEBUG";
+ File aFile = new File(sName);
+ if (aFile.exists())
+ {
+ if (m_bDebugTextShown == false)
+ {
+ GlobalLogWriter.println("Found file: " + sName);
+ GlobalLogWriter.println("Activate debug mode.");
+ GlobalLogWriter.println("If debug mode is no longer necessary, remove the above file.");
+ m_bDebugTextShown = true;
+ }
+ bDebug = true;
+ }
+ return bDebug;
+ }
+
+ private static void copyStream(InputStream _aIn, OutputStream _aOut) throws java.io.IOException
+ {
+ byte[] aBuffer = new byte[0xFFFF];
+ for (int len; (len = _aIn.read(aBuffer)) != -1; )
+ {
+ _aOut.write(aBuffer, 0, len);
+ }
+ }
+
+ public static void copy(String _sSource, String _sDestination)
+ {
+ FileInputStream aFIS = null;
+ FileOutputStream aFOS = null;
+
+ try
+ {
+ aFIS = new FileInputStream(_sSource);
+ aFOS = new FileOutputStream(_sDestination);
+ copyStream(aFIS, aFOS);
+ }
+ catch (java.io.IOException e)
+ {
+ System.out.println("Error: caught Exception: " + e.getMessage());
+ }
+ finally
+ {
+ if (aFIS != null)
+ {
+ try
+ {
+ aFIS.close();
+ }
+ catch (java.io.IOException e)
+ {
+ System.out.println("Error: caught Exception: " + e.getMessage());
+ }
+ }
+ if (aFOS != null)
+ {
+ try
+ {
+ aFOS.close();
+ }
+ catch (java.io.IOException e)
+ {
+ System.out.println("Error: caught Exception: " + e.getMessage());
+ }
+ }
+ }
+
+// try
+// {
+// File inputFile = new File(_sSource);
+// File outputFile = new File(_sDestination);
+//
+// java.io.FileReader in = new java.io.FileReader(inputFile);
+// java.io.FileWriter out = new java.io.FileWriter(outputFile);
+// int c;
+//
+// while ((c = in.read()) != -1)
+// {
+// out.write(c);
+// }
+//
+// in.close();
+// out.close();
+// }
+// catch (java.io.IOException e)
+// {
+// GlobalLogWriter.get().println("Exception caught. FileHelper.copy('" + _sSource + ", " + _sDestination + "')");
+// GlobalLogWriter.get().println("Message: " + e.getMessage());
+// }
+ }
+
+
+ /**
+ * Within the directory run through, it's possible to say which file extension types should not
+ * consider like '*.prn' because it's not a document.
+ *
+ * @return a FileFilter function
+ */
+ public static FileFilter getFileFilter()
+ {
+ FileFilter aFileFilter = new FileFilter()
+ {
+ public boolean accept( File pathname )
+ {
+ // leave out files which started by '~$' these are Microsoft Office temp files
+ if (pathname.getName().startsWith("~$"))
+ {
+ return false;
+ }
+ // leave out files starts with '.~lock.' these are OpenOffice.org lock files
+ if (pathname.getName().startsWith(".~lock."))
+ {
+ return false;
+ }
+ // leave out files ends with '#' these could be temp files
+ if (pathname.getName().endsWith("#"))
+ {
+ return false;
+ }
+ if (pathname.getName().endsWith(".prn"))
+ {
+ return false;
+ }
+ if (pathname.getName().endsWith(".ps"))
+ {
+ return false;
+ }
+ // This type of document no one would like to load.
+ if (pathname.getName().endsWith(".zip"))
+ {
+ return false;
+ }
+ // just a hack
+ if (pathname.getName().endsWith("_"))
+ {
+ return false;
+ }
+ return true;
+ }
+ };
+ return aFileFilter;
+ }
+ /**
+ * Within the directory run through, it's possible to say which file extension types should not
+ * consider like '*.prn' because it's not a document.
+ *
+ * @return a FileFilter function
+ */
+ public static FileFilter getFileFilterPSorPDF()
+ {
+ FileFilter aFileFilter = new FileFilter()
+ {
+ public boolean accept( File pathname )
+ {
+ if (pathname.getName().endsWith(".ps"))
+ {
+ return true;
+ }
+ if (pathname.getName().endsWith(".pdf"))
+ {
+ return true;
+ }
+ return false;
+ }
+ };
+ return aFileFilter;
+ }
+ /**
+ * Within the directory run through, it's possible to say which file extension types should not
+ * consider like '*.prn' because it's not a document.
+ *
+ * @return a FileFilter function
+ */
+ public static FileFilter getFileFilterJPEG()
+ {
+ FileFilter aFileFilter = new FileFilter()
+ {
+ public boolean accept( File pathname )
+ {
+ if (pathname.getName().toLowerCase().endsWith(".jpg"))
+ {
+ return true;
+ }
+ if (pathname.getName().toLowerCase().endsWith(".jpeg"))
+ {
+ return true;
+ }
+ return false;
+ }
+ };
+ return aFileFilter;
+ }
+ /**
+ * Within the directory run through, it's possible to say which file extension types should not
+ * consider like '*.ini' because it's not a document.
+ *
+ * @return a FileFilter function
+ */
+ public static FileFilter getFileFilterINI()
+ {
+ FileFilter aFileFilter = new FileFilter()
+ {
+ public boolean accept( File pathname )
+ {
+ String sPathname = pathname.getName().toLowerCase();
+ if (sPathname.endsWith("index.ini"))
+ {
+ // don't consider the index.ini file
+ return false;
+ }
+ if (sPathname.endsWith(".ini"))
+ {
+ return true;
+ }
+ return false;
+ }
+ };
+ return aFileFilter;
+ }
+
+ public static String appendPath(String _sPath, String _sRelativePathToAdd)
+ {
+ String sNewPath = _sPath;
+ String fs = System.getProperty("file.separator");
+ if (_sPath.startsWith("file:"))
+ {
+ fs = "/"; // we use a file URL so only '/' is allowed.
+ }
+ if (! (sNewPath.endsWith("/") || sNewPath.endsWith("\\") ) )
+ {
+ sNewPath += fs;
+ }
+ sNewPath += _sRelativePathToAdd;
+ return sNewPath;
+ }
+
+ // -----------------------------------------------------------------------------
+ public static void createInfoFile(String _sFile, ParameterHelper _aGTA)
+ {
+ createInfoFile(_sFile, _aGTA, "");
+ }
+
+ public static void createInfoFile(String _sFile, ParameterHelper _aGTA, String _sSpecial)
+ {
+ String sFilename;
+ if (_sFile.startsWith("file://"))
+ {
+ sFilename = FileHelper.getSystemPathFromFileURL(_sFile);
+ GlobalLogWriter.println("CreateInfoFile: '" + sFilename + "'" );
+ }
+ else
+ {
+ sFilename = _sFile;
+ }
+ String sFileDir = FileHelper.getPath(sFilename);
+ String sBasename = FileHelper.getBasename(sFilename);
+ String sNameNoSuffix = FileHelper.getNameNoSuffix(sBasename);
+
+ String sIniFile = FileHelper.appendPath(sFileDir, sBasename + ".ini");
+ IniFile aIniFile = new IniFile(sIniFile);
+
+ // OLD INFO FILE
+
+ // String fs = System.getProperty("file.separator");
+ String ls = System.getProperty("line.separator");
+ String sInfoFilename = FileHelper.appendPath(sFileDir, sNameNoSuffix + ".info");
+ File aInfoFile = new File(sInfoFilename);
+
+ String sBuildID = "";
+
+ try
+ {
+ FileOutputStream out2 = new FileOutputStream(aInfoFile.toString());
+ PrintStream out = new PrintStream(out2);
+
+ out.println("# automatically created file by graphical compare");
+ if (_aGTA != null)
+ {
+ if (_sSpecial != null && _sSpecial.equals("msoffice"))
+ {
+ out.println("# buildid from wordloadfile");
+ sBuildID = _aGTA.getPerformance().getMSOfficeVersion();
+ out.println("buildid=" + sBuildID);
+ }
+ else
+ {
+ out.println("# buildid is read out of the bootstrap file");
+ sBuildID = _aGTA.getBuildID();
+ out.println("buildid=" + sBuildID);
+ }
+ aIniFile.insertValue("global", "buildid", sBuildID);
+
+ // if (_sSpecial != null && _sSpecial.length() > 0)
+ // {
+ // out.write("special=" + _sSpecial + ls);
+ // }
+ out.println();
+ out.println("# resolution given in DPI");
+ out.println("resolution=" + _aGTA.getResolutionInDPI());
+ aIniFile.insertValue("global", "resolution", _aGTA.getResolutionInDPI());
+ }
+ else
+ {
+ out.println("buildid=" + _sSpecial);
+ aIniFile.insertValue("global", "buildid", _sSpecial);
+ }
+
+ // long nTime = stopTimer();
+ // if (nTime != 0)
+ // {
+ // out.write("# time is given in milli seconds" + ls);
+ // out.write("time=" + nTime + ls);
+ // }
+
+ out.println();
+ out.println("# Values out of System.getProperty(...)");
+ out.println("os.name=" + System.getProperty("os.name"));
+ out.println("os.arch=" + System.getProperty("os.arch"));
+ out.println("os.version=" + System.getProperty("os.version"));
+
+ aIniFile.insertValue("global", "os.name", System.getProperty("os.name"));
+ aIniFile.insertValue("global", "os.arch", System.getProperty("os.arch"));
+ aIniFile.insertValue("global", "os.version", System.getProperty("os.version"));
+
+ if (_aGTA != null)
+ {
+ out.println();
+ out.println("# Performance output, values are given in milli sec.");
+ _aGTA.getPerformance().print(out);
+ _aGTA.getPerformance().print(aIniFile, "global");
+ }
+
+ out.flush();
+ out.close();
+ out2.close();
+ }
+ catch (java.io.IOException e)
+ {
+ GlobalLogWriter.println("can't create Info file.");
+ e.printStackTrace();
+ }
+ aIniFile.close();
+
+// String sExtension = FileHelper.getSuffix(_aGTA.getInputFile());
+// if (sExtension.startsWith("."))
+// {
+// sExtension = sExtension.substring(1);
+// }
+//
+// DB.writeToDB(_aGTA.getInputFile(),
+// sNameNoSuffix,
+// sExtension,
+// sBuildID,
+// _aGTA.getReferenceType(),
+// _aGTA.getResolutionInDPI()
+// );
+ }
+
+ public static void addBasenameToFile(String _sIndexFilename, String _sBasename, String _sCreator, String _sType, String _sSource)
+ {
+ // String sOutputDir = FileHelper.getPath(_sOutputFilename);
+ String sPath;
+ if (_sIndexFilename.startsWith("file:"))
+ {
+ sPath = FileHelper.getSystemPathFromFileURL(_sIndexFilename);
+ }
+ else
+ {
+ sPath = _sIndexFilename;
+ }
+ String sIndexFilename = sPath; // FileHelper.appendPath(sPath, _sFilename);
+ IniFile aIniFile = new IniFile(sIndexFilename);
+ aIniFile.insertValue(_sBasename, "creator", _sCreator);
+ aIniFile.insertValue(_sBasename, "type", _sType);
+ aIniFile.insertValue(_sBasename, "source", _sSource);
+ aIniFile.close();
+// File aFile = new File(sIndexFilename);
+// try
+// {
+// RandomAccessFile aRandomAccess = new RandomAccessFile(aFile, "rw");
+// // String sBasename = FileHelper.getBasename(_sOutputFilename);
+// aRandomAccess.seek(aRandomAccess.length()); // jump to the end.
+//// TODO: seems to be wrong, there exist no writeLine() with 'return' ending?
+// aRandomAccess.writeUTF(_sBasename);
+// aRandomAccess.close();
+// }
+// catch (java.io.FileNotFoundException e)
+// {
+// }
+// catch (java.io.IOException e)
+// {
+// }
+ }
+
+ public static void addBasenameToPostscript(String _sOutputFilename)
+ {
+ String sIndexFilename = FileHelper.appendPath(_sOutputFilename, "postscript.ini");
+ // String sPath = FileHelper.getPath(sIndexFilename);
+ String sBasename = FileHelper.getBasename(_sOutputFilename);
+ addBasenameToFile(sIndexFilename, sBasename, "", "", "");
+ }
+ public static void addBasenameToIndex(String _sOutputFilename, String _sBasename, String _sCreator, String _sType, String _sSource)
+ {
+ String sIndexFilename = FileHelper.appendPath(_sOutputFilename, "index.ini");
+ // String sPath = FileHelper.getPath(sIndexFilename);
+ // String sBasename = FileHelper.getBasename(_sOutputFilename);
+ addBasenameToFile(sIndexFilename, _sBasename, _sCreator, _sType, _sSource);
+ }
+
+}
+
diff --git a/qadevOOo/runner/graphical/GlobalLogWriter.java b/qadevOOo/runner/graphical/GlobalLogWriter.java
new file mode 100644
index 000000000000..478d3323abda
--- /dev/null
+++ b/qadevOOo/runner/graphical/GlobalLogWriter.java
@@ -0,0 +1,72 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package graphical;
+
+import share.LogWriter;
+import stats.SimpleLogWriter;
+
+public class GlobalLogWriter
+{
+ private static LogWriter m_aGlobalLogWriter = null;
+
+ /**
+ * This is just a helper to get clearer code.
+ * use this GlobalLogWriter.println(...)
+ * @param _sMsg
+ */
+ protected static synchronized void println(String _sMsg)
+ {
+ get().println(_sMsg);
+ }
+
+ /**
+ * @deprecated use GlobalLogWriter.println(...) direct
+ * @return
+ */
+ protected static synchronized LogWriter get()
+ {
+ if (m_aGlobalLogWriter == null)
+ {
+ SimpleLogWriter aLog = new SimpleLogWriter();
+ m_aGlobalLogWriter = aLog;
+ }
+ return m_aGlobalLogWriter;
+ }
+
+// public static synchronized void initialize()
+// {
+// get().initialize(null, true);
+// }
+
+ protected static synchronized void set(LogWriter _aLog)
+ {
+ m_aGlobalLogWriter = _aLog;
+ }
+
+}
+
diff --git a/qadevOOo/runner/graphical/GraphicalComparator.java b/qadevOOo/runner/graphical/GraphicalComparator.java
new file mode 100644
index 000000000000..c10bbff8b49e
--- /dev/null
+++ b/qadevOOo/runner/graphical/GraphicalComparator.java
@@ -0,0 +1,31 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package graphical;
+
+// import graphical.EnhancedComplexTestCase;
+
+/**
+ *
+ * @author ll93751
+ */
+public class GraphicalComparator extends EnhancedComplexTestCase
+{
+
+ // @Override
+ public String[] getTestMethodNames() {
+ return new String[]{"check"};
+ }
+
+ public void check()
+ {
+ }
+
+ public void checkOneFile(String _sDocument, String _sResult, ParameterHelper _aParams) throws OfficeException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+}
+
diff --git a/qadevOOo/runner/graphical/HTMLResult.java b/qadevOOo/runner/graphical/HTMLResult.java
new file mode 100644
index 000000000000..af2a31a308ea
--- /dev/null
+++ b/qadevOOo/runner/graphical/HTMLResult.java
@@ -0,0 +1,212 @@
+/*
+ ************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package graphical;
+
+import java.io.File;
+import java.io.FileWriter;
+// import util.utils;
+// import helper.OSHelper;
+
+public class HTMLResult
+{
+ private FileWriter m_aOut;
+ // private String m_sFilename;
+ // private String m_sNamePrefix; // the HTML files used a suffix to build it's right name
+
+ /**
+ * ls is the current line separator (carridge return)
+ */
+ private String ls;
+
+ public HTMLResult( String _sOutputPath, String _sHTMLFilename )
+ {
+ FileHelper.makeDirectories("", _sOutputPath);
+ // HTMLResult a = new HTMLResult();
+ String sFilename = FileHelper.appendPath(_sOutputPath, _sHTMLFilename);
+
+ try
+ {
+ File outputFile = new File(sFilename);
+ m_aOut = new FileWriter(outputFile.toString());
+ ls = System.getProperty("line.separator");
+ }
+ catch (java.io.IOException e)
+ {
+ e.printStackTrace();
+ GlobalLogWriter.println("ERROR: Can't create HTML Outputter");
+ // return null;
+ }
+ // m_sFilename = sFilename;
+ // a.m_sNamePrefix = _sNamePrefix;
+ // return a;
+ }
+
+ // public String getFilename() {return m_sFilename;}
+
+ private void writeln(String _sStr)
+ {
+ try
+ {
+ m_aOut.write( _sStr );
+ m_aOut.write ( ls );
+ }
+ catch (java.io.IOException e)
+ {
+ }
+ }
+ private void flush()
+ {
+ try
+ {
+ m_aOut.flush();
+ }
+ catch (java.io.IOException e)
+ {
+ }
+ }
+
+
+ /**
+ * create the HTML header
+ * @param _sTitle
+ */
+ public void header(String _sTitle)
+ {
+ writeln( "<HTML>");
+ writeln( "<HEAD>" );
+ writeln( "<TITLE>" + _sTitle + "</TITLE>");
+ writeln( "<LINK rel=\"stylesheet\" type=\"text/css\" href=\"/gfxcmp_ui/xmloff.css\" media=\"screen\" />");
+ writeln( "<LINK rel=\"stylesheet\" type=\"text/css\" href=\"/gfxcmp_ui/style.css\" media=\"screen\" />");
+ writeln( "</HEAD>");
+ writeln( "<BODY bgcolor=white>");
+ flush();
+ }
+
+ final static String TEST_TABLETITLE = "Document";
+ final static String VISUAL_STATUS_TABLETITLE = "Visual status";
+ final static String VISUAL_STATUS_MESSAGE_TABLETITLE = "Message";
+ final static String FIRSTGFX_TABLETITLE = "Original print file as jpeg";
+
+ public void indexSection(String _sOfficeInfo)
+ {
+ writeln( "<H2>Results for " + _sOfficeInfo + "</H2>");
+ writeln( "<P>This result was created at: " + DateHelper.getDateTimeForHumanreadableLog());
+ writeln( "<P>Legend:<BR>");
+ writeln( stronghtml(FIRSTGFX_TABLETITLE) + " contains the output printed via 'ghostscript' as a jpeg picture.<BR>");
+
+ writeln( "<TABLE class=\"infotable\">");
+ writeln( "<TR>");
+ writeln( tableHeaderCell(TEST_TABLETITLE));
+ writeln( tableHeaderCell(""));
+ writeln( tableHeaderCell(VISUAL_STATUS_TABLETITLE));
+ writeln( tableHeaderCell(VISUAL_STATUS_MESSAGE_TABLETITLE));
+ writeln( "</TR>");
+ flush();
+ }
+/**
+ * Returns the given _sHREF & _sPathInfo as a HTML String
+ * <A HREF="_sHREF">_sPathInfo</A>
+ * @param _sHREF
+ * @param _sPathInfo
+ * @return
+ */
+ private String getHREF(String _sHREF, String _sPathInfo)
+ {
+ StringBuffer a = new StringBuffer();
+ a.append("<A HREF=\"");
+ a.append(_sHREF);
+ a.append("\">");
+ a.append(_sPathInfo);
+ a.append("</A>");
+ return a.toString();
+ }
+
+ /**
+ * Returns the given _sValue as a HTML Table cell with _sValue as content
+ * @param _sValue
+ * @return
+ */
+ private String tableDataCell(String _sValue)
+ {
+ StringBuffer a = new StringBuffer();
+ a.append("<TD>");
+ a.append(_sValue);
+ a.append("</TD>");
+ return a.toString();
+ }
+
+ /**
+ * Returns the given _sValue as a HTML Table header cell with _sValue as content
+ * @param _sValue
+ * @return
+ */
+ private String tableHeaderCell(String _sValue)
+ {
+ StringBuffer a = new StringBuffer();
+ a.append("<TH>");
+ a.append(_sValue);
+ a.append("</TH>");
+ return a.toString();
+ }
+
+ public void indexLine(String _sHTMLFile, String _sHTMLName, String _sStatusRunThrough, String _sStatusMessage)
+ {
+ writeln( "<TR>");
+ writeln(tableDataCell( getHREF(_sHTMLFile, _sHTMLName) ) );
+ writeln(tableDataCell( "" ) );
+ writeln( tableDataCell(_sStatusRunThrough) );
+ writeln( tableDataCell(_sStatusMessage) );
+ writeln( "</TR>");
+ flush();
+ }
+
+ public void close()
+ {
+ writeln( "</TABLE>");
+ writeln( "</BODY></HTML>");
+ try
+ {
+ m_aOut.close();
+ }
+ catch (java.io.IOException e)
+ {
+ }
+ }
+
+// -----------------------------------------------------------------------------
+ private String stronghtml(String _sValue)
+ {
+ StringBuffer a = new StringBuffer();
+ a.append("<STRONG>");
+ a.append(_sValue);
+ a.append("</STRONG>");
+ return a.toString();
+ }
+
+}
diff --git a/qadevOOo/runner/graphical/IDocument.java b/qadevOOo/runner/graphical/IDocument.java
new file mode 100644
index 000000000000..e23ddd4b91a1
--- /dev/null
+++ b/qadevOOo/runner/graphical/IDocument.java
@@ -0,0 +1,46 @@
+/*
+ * ************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ * ***********************************************************************
+ */
+
+package graphical;
+
+/**
+ *
+ * @author ll93751
+ */
+public interface IDocument
+{
+ /**
+ * Call this for each document
+ * @param _sDocument
+ * @param _sResult
+ * @param _aParams
+ * @throws OfficeException
+ */
+ public void checkOneFile(String _sDocument, String _sResult, ParameterHelper _aParams) throws OfficeException;
+}
diff --git a/qadevOOo/runner/graphical/IOffice.java b/qadevOOo/runner/graphical/IOffice.java
new file mode 100644
index 000000000000..ec1dc3b7371f
--- /dev/null
+++ b/qadevOOo/runner/graphical/IOffice.java
@@ -0,0 +1,63 @@
+/*
+ * ************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ * ***********************************************************************
+ */
+
+package graphical;
+
+/**
+ *
+ * @author ll93751
+ */
+public interface IOffice
+{
+ /**
+ * start an Office, if need
+ * @throws graphical.OfficeException
+ */
+ public void start() throws OfficeException;
+
+ /**
+ * Load a document by it's Name
+ * @param Name
+ * @throws graphical.OfficeException
+ */
+ public void load(String Name) throws OfficeException;
+
+ /**
+ * Create a postscript file in the DOC_COMPARATOR_OUTPUT_DIR directory from a loaded document
+ * @throws graphical.OfficeException
+ */
+ public void storeAsPostscript() throws OfficeException;
+
+
+ /**
+ * Close the background office
+ * @throws graphical.OfficeException
+ */
+ public void close() throws OfficeException;
+}
diff --git a/qadevOOo/runner/graphical/ImageHelper.java b/qadevOOo/runner/graphical/ImageHelper.java
new file mode 100644
index 000000000000..e016e08f0df1
--- /dev/null
+++ b/qadevOOo/runner/graphical/ImageHelper.java
@@ -0,0 +1,120 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package graphical;
+
+import java.awt.Image;
+import java.awt.image.PixelGrabber;
+import java.awt.image.ImageObserver;
+import java.io.File;
+//import javax.imageio.ImageIO;
+import java.lang.reflect.Method;
+
+class ImageHelper
+{
+ Image m_aImage;
+ int[] m_aPixels;
+ int m_w = 0;
+ int m_h = 0;
+ boolean m_bGrabbed = false;
+
+ private ImageHelper(Image _aImage)
+ {
+ m_aImage = _aImage;
+
+ // grab all (consume much memory)
+ m_w = getWidth();
+ m_h = getHeight();
+ int x = 0;
+ int y = 0;
+ m_aPixels = new int[m_w * m_h];
+ PixelGrabber pg = new PixelGrabber(m_aImage, x, y, m_w, m_h, m_aPixels, 0, m_w);
+ try
+ {
+ pg.grabPixels();
+ }
+ catch (InterruptedException e)
+ {
+ System.err.println("interrupted waiting for pixels!");
+ return;
+ }
+ if ((pg.getStatus() & ImageObserver.ABORT) != 0)
+ {
+ System.err.println("image fetch aborted or errored");
+ return;
+ }
+ m_bGrabbed = true;
+ }
+ public int getWidth() {return m_aImage.getWidth(null);}
+ public int getHeight() {return m_aImage.getHeight(null);}
+ // direct access to a pixel
+ public int getPixel(final int x, final int y)
+ {
+ return m_aPixels[y * m_w + x];
+ }
+
+ // Write down the current image to a file.
+ // public void storeImage(String _sFilename)
+ // {
+ // }
+
+ public static ImageHelper createImageHelper(String _sFilename)
+ throws java.io.IOException
+ {
+ Image aImage = null;
+ File aFile = new File(_sFilename);
+ Exception ex = null;
+ try {
+ Class imageIOClass = Class.forName("javax.imageio.ImageIO");
+ Method readMethod = imageIOClass.getDeclaredMethod("read", new Class[]{java.io.File.class});
+ Object retValue = readMethod.invoke(imageIOClass, new Object[]{aFile});
+ aImage = (Image)retValue;
+ }
+ catch(java.lang.ClassNotFoundException e) {
+ ex = e;
+ }
+ catch(java.lang.NoSuchMethodException e) {
+ ex = e;
+ }
+ catch(java.lang.IllegalAccessException e) {
+ ex = e;
+ }
+ catch(java.lang.reflect.InvocationTargetException e) {
+ ex = e;
+ }
+
+ if (ex != null) {
+ // get Java version:
+ String javaVersion = System.getProperty("java.version");
+ throw new java.io.IOException(
+ "Cannot construct object with current Java version " +
+ javaVersion + ": " + ex.getMessage());
+ }
+// aImage = ImageIO.read(aFile);
+ return new ImageHelper(aImage);
+ }
+}
diff --git a/qadevOOo/runner/graphical/IniFile.java b/qadevOOo/runner/graphical/IniFile.java
new file mode 100644
index 000000000000..bd54a66b65fd
--- /dev/null
+++ b/qadevOOo/runner/graphical/IniFile.java
@@ -0,0 +1,693 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package graphical;
+
+// import java.io.BufferedReader;
+import java.io.File;
+import java.io.RandomAccessFile;
+import java.util.ArrayList;
+import java.util.Enumeration;
+
+/**
+ Helper class to give a simple API to read/write windows like ini files
+*/
+/* public */ // is only need, if we need this class outside package convwatch
+public class IniFile implements Enumeration
+{
+
+ /**
+ * internal representation of the ini file content.
+ * Problem, if ini file changed why other write something difference, we don't realise this.
+ */
+ private String m_sFilename;
+ private ArrayList<String> m_aList;
+ boolean m_bListContainUnsavedChanges = false;
+ private int m_aEnumerationPos = 0;
+
+ /**
+ open a ini file by it's name
+ @param _sFilename string a filename, if the file doesn't exist, a new empty ini file will create.
+ write back to disk only if there are really changes.
+ */
+ public IniFile(String _sFilename)
+ {
+ m_sFilename = _sFilename;
+ m_aList = loadLines();
+ m_aEnumerationPos = findNextSection(0);
+// if (_sFilename.endsWith(".odb.ps.ini"))
+// {
+// int dummy = 0;
+// }
+ }
+
+ public void insertFirstComment(String[] _aList)
+ {
+ if (m_aList.size() == 0)
+ {
+ // can only insert if there is nothing else already in the ini file
+ for (int i = 0; i < _aList.length; i++)
+ {
+ m_aList.add(_aList[i]);
+ }
+ }
+ }
+
+ private ArrayList<String> loadLines()
+ {
+ File aFile = new File(m_sFilename);
+ ArrayList<String> aLines = new ArrayList<String>();
+ if (!aFile.exists())
+ {
+ // GlobalLogWriter.println("couldn't find file '" + m_sFilename + "', will be created.");
+ // DebugHelper.exception(BasicErrorCode.SbERR_FILE_NOT_FOUND, "");
+ // m_bListContainUnsavedChanges = false;
+ return aLines;
+ }
+ RandomAccessFile aReader = null;
+ // BufferedReader aReader;
+ try
+ {
+ aReader = new RandomAccessFile(aFile, "r");
+ String aLine = "";
+ while (aLine != null)
+ {
+ aLine = aReader.readLine();
+ if (aLine != null && aLine.length() > 0)
+ {
+ aLines.add(aLine);
+ }
+ }
+ }
+ catch (java.io.FileNotFoundException fne)
+ {
+ GlobalLogWriter.println("couldn't open file " + m_sFilename);
+ GlobalLogWriter.println("Message: " + fne.getMessage());
+ // DebugHelper.exception(BasicErrorCode.SbERR_FILE_NOT_FOUND, "");
+ }
+ catch (java.io.IOException ie)
+ {
+ GlobalLogWriter.println("Exception occurs while reading from file " + m_sFilename);
+ GlobalLogWriter.println("Message: " + ie.getMessage());
+ // DebugHelper.exception(BasicErrorCode.SbERR_INTERNAL_ERROR, ie.getMessage());
+ }
+ try
+ {
+ aReader.close();
+ }
+ catch (java.io.IOException ie)
+ {
+ GlobalLogWriter.println("Couldn't close file " + m_sFilename);
+ GlobalLogWriter.println("Message: " + ie.getMessage());
+ // DebugHelper.exception(BasicErrorCode.SbERR_INTERNAL_ERROR, ie.getMessage());
+ }
+ return aLines;
+ }
+
+ /**
+ * @return true, if the ini file contain some readable data
+ */
+ public boolean is()
+ {
+ return m_aList.size() > 1 ? true : false;
+ }
+
+ /**
+ * Check if a given Section and Key exists in the ini file
+ * @param _sSectionName
+ * @param _sKey
+ * @return true if the given Section, Key exists, now you can get the value
+ */
+ public boolean hasValue(String _sSectionName, String _sKey)
+ {
+ int n = findKey(_sSectionName, _sKey);
+ if (n > 0)
+ {
+ return true;
+ }
+ return false;
+ }
+ // -----------------------------------------------------------------------------
+
+ private boolean isRemark(String _sLine)
+ {
+ if (((_sLine.length() < 2)) ||
+ (_sLine.startsWith("#")) ||
+ (_sLine.startsWith(";")))
+ {
+ return true;
+ }
+ return false;
+ }
+
+ private String getItem(int i)
+ {
+ return m_aList.get(i);
+ }
+
+ private String buildSectionName(String _sSectionName)
+ {
+ String sFindSection = "[" + _sSectionName + "]";
+ return sFindSection;
+ }
+
+ private String sectionToString(String _sSectionName)
+ {
+ String sKeyName = _sSectionName;
+ if (sKeyName.startsWith("[") &&
+ sKeyName.endsWith("]"))
+ {
+ sKeyName = sKeyName.substring(1, sKeyName.length() - 1);
+ }
+ return sKeyName;
+ }
+
+ private String toLowerIfNeed(String _sName)
+ {
+ return _sName.toLowerCase();
+ }
+
+ // return the number where this section starts
+ private int findSection(String _sSection)
+ {
+ String sFindSection = toLowerIfNeed(buildSectionName(_sSection));
+ // ----------- find _sSection ---------------
+ int i;
+ for (i = 0; i < m_aList.size(); i++)
+ {
+ String sLine = toLowerIfNeed(getItem(i).trim());
+ if (isRemark(sLine))
+ {
+ continue;
+ }
+ if (sFindSection.equals("[]"))
+ {
+ // special case, empty Section.
+ return i - 1;
+ }
+ if (sLine.startsWith(sFindSection))
+ {
+ return i;
+ }
+ }
+ return -1;
+ }
+
+ /**
+ * Checks if a given section exists in the ini file
+ * @param _sSection
+ * @return true if the given _sSection was found
+ */
+ public boolean hasSection(String _sSection)
+ {
+ int i = findSection(_sSection);
+ if (i == -1)
+ {
+ return false;
+ }
+ return true;
+ }
+
+ // return the line number, where the key is found.
+ private int findKey(String _sSection, String _sKey)
+ {
+ int i = findSection(_sSection);
+ if (i == -1)
+ {
+ // Section not found, therefore the value can't exist
+ return -1;
+ }
+ return findKeyFromKnownSection(i, _sKey);
+ }
+
+ // i must be the index in the list, where the well known section starts
+ private int findKeyFromKnownSection(int _nSectionIndex, String _sKey)
+ {
+ _sKey = toLowerIfNeed(_sKey);
+ for (int j = _nSectionIndex + 1; j < m_aList.size(); j++)
+ {
+ String sLine = getItem(j).trim();
+
+ if (isRemark(sLine))
+ {
+ continue;
+ }
+ if (sLine.startsWith("[") /* && sLine.endsWith("]") */)
+ {
+ // TODO: due to the fact we would like to insert an empty line before new sections
+ // TODO: we should check if we are in an empty line and if, go back one line.
+
+ // found end.
+ break;
+ }
+
+ int nEqual = sLine.indexOf("=");
+ if (nEqual >= 0)
+ {
+ String sKey = toLowerIfNeed(sLine.substring(0, nEqual).trim());
+ if (sKey.equals(_sKey))
+ {
+ return j;
+ }
+ }
+ }
+ return -1;
+ }
+
+ // i must be the index in the list, where the well known section starts
+ private int findLastKnownKeyIndex(int _nSectionIndex, String _sKey)
+ {
+ _sKey = toLowerIfNeed(_sKey);
+ int i = _nSectionIndex + 1;
+ for (int j = i; j < m_aList.size(); j++)
+ {
+ String sLine = getItem(j).trim();
+
+ if (isRemark(sLine))
+ {
+ continue;
+ }
+
+ if (sLine.startsWith("[") /* && sLine.endsWith("]") */)
+ {
+ // found end.
+ return j;
+ }
+
+ int nEqual = sLine.indexOf("=");
+ if (nEqual >= 0)
+ {
+ String sKey = toLowerIfNeed(sLine.substring(0, nEqual).trim());
+ if (sKey.equals(_sKey))
+ {
+ return j;
+ }
+ }
+ }
+ return i;
+ }
+
+ private String getValue(int _nIndex)
+ {
+ String sLine = getItem(_nIndex).trim();
+ if (isRemark(sLine))
+ {
+ return "";
+ }
+ int nEqual = sLine.indexOf("=");
+ if (nEqual >= 0)
+ {
+ String sKey = sLine.substring(0, nEqual).trim();
+ String sValue = sLine.substring(nEqual + 1).trim();
+ return sValue;
+ }
+ return "";
+ }
+
+ /**
+ @param _sSection string
+ @param _sKey string
+ @return the value found in the inifile which is given by the section and key parameter
+ */
+ // private int m_nCurrentPosition;
+ // private String m_sOldKey;
+ public String getValue(String _sSection, String _sKey)
+ {
+ String sValue = "";
+ int m_nCurrentPosition = findKey(_sSection, _sKey);
+ if (m_nCurrentPosition == -1)
+ {
+ // Section not found, therefore the value can't exist
+ return "";
+ }
+
+ // m_sOldKey = _sKey;
+ sValue = getValue(m_nCurrentPosition);
+
+ return sValue;
+ }
+
+// private String getNextValue()
+// {
+// if (m_nCurrentPosition >= 0)
+// {
+// ++m_nCurrentPosition;
+// String sValue = getValue(m_nCurrentPosition);
+// return sValue;
+// }
+// return "";
+// }
+ /**
+ * Returns the value at Section, Key converted to an integer
+ * Check with hasValue(Section, Key) to check before you get into trouble.
+ * @param _sSection
+ * @param _sKey
+ * @param _nDefault if there is a problem, key not found... this value will return
+ * @return
+ */
+ public int getIntValue(String _sSection, String _sKey, int _nDefault)
+ {
+ String sValue = getValue(_sSection, _sKey);
+ int nValue = _nDefault;
+ if (sValue.length() > 0)
+ {
+ try
+ {
+ nValue = Integer.valueOf(sValue).intValue();
+ }
+ catch (java.lang.NumberFormatException e)
+ {
+ GlobalLogWriter.println("IniFile.getIntValue(): Caught a number format exception, return the default value.");
+ }
+ }
+ return nValue;
+ }
+
+ public void close()
+ {
+ store();
+ }
+
+ /**
+ write back the ini file to the disk, only if there exist changes
+ * @deprecated use close() instead!
+ */
+
+ // TODO: make private
+ public void store()
+ {
+ if (m_bListContainUnsavedChanges == false)
+ {
+ // nothing has changed, so no need to store
+ return;
+ }
+
+ File aFile = new File(m_sFilename);
+ if (aFile.exists())
+ {
+ // System.out.println("couldn't find file " + m_sFilename);
+ // TODO: little bit unsafe here, first rename, after write is complete, delete the old.
+ aFile.delete();
+ if (aFile.exists())
+ {
+ GlobalLogWriter.println("Couldn't delete the file " + m_sFilename);
+ return;
+ // DebugHelper.exception(BasicErrorCode.SbERR_INTERNAL_ERROR, "Couldn't delete the file " + m_sFilename);
+ }
+ }
+ // if (! aFile.canWrite())
+ // {
+ // System.out.println("Couldn't write to file " + m_sFilename);
+ // DebugHelper.exception(BasicErrorCode.SbERR_INTERNAL_ERROR, "");
+ // }
+ try
+ {
+ RandomAccessFile aWriter = new RandomAccessFile(aFile, "rw");
+ for (int i = 0; i < m_aList.size(); i++)
+ {
+ String sLine = getItem(i);
+ if (sLine.startsWith("["))
+ {
+ // write an extra empty line before next section.
+ aWriter.writeByte((int) '\n');
+ }
+ aWriter.writeBytes(sLine);
+ aWriter.writeByte((int) '\n');
+ }
+ aWriter.close();
+ }
+ catch (java.io.FileNotFoundException fne)
+ {
+ GlobalLogWriter.println("couldn't open file for writing " + m_sFilename);
+ GlobalLogWriter.println("Message: " + fne.getMessage());
+ // DebugHelper.exception(BasicErrorCode.SbERR_FILE_NOT_FOUND, "");
+ }
+ catch (java.io.IOException ie)
+ {
+ GlobalLogWriter.println("Exception occurs while writing to file " + m_sFilename);
+ GlobalLogWriter.println("Message: " + ie.getMessage());
+ // DebugHelper.exception(BasicErrorCode.SbERR_INTERNAL_ERROR, ie.getMessage());
+ }
+ }
+
+ public void insertValue(String _sSection, String _sKey, int _nValue)
+ {
+ insertValue(_sSection, _sKey, String.valueOf(_nValue));
+ }
+
+ public void insertValue(String _sSection, String _sKey, long _nValue)
+ {
+ insertValue(_sSection, _sKey, String.valueOf(_nValue));
+ }
+
+ /**
+ insert a value
+ there are 3 cases
+ 1. section doesn't exist, goto end and insert a new section, insert a new key value pair
+ 2. section exist but key not, search section, search key, if key is -1 get last known key position and insert new key value pair there
+ 3. section exist and key exist, remove the old key and insert the key value pair at the same position
+ * @param _sSection
+ * @param _sKey
+ * @param _sValue
+ */
+ public void insertValue(String _sSection, String _sKey, String _sValue)
+ {
+ int i = findSection(_sSection);
+ if (i == -1)
+ {
+ // case 1: section doesn't exist
+ String sFindSection = buildSectionName(_sSection);
+
+ // TODO: before create a new Section, insert a empty line
+ m_aList.add(sFindSection);
+ if (_sKey.length() > 0)
+ {
+ String sKeyValuePair = _sKey + "=" + _sValue;
+ m_aList.add(sKeyValuePair);
+ }
+ m_bListContainUnsavedChanges = true;
+ return;
+ }
+ int j = findKeyFromKnownSection(i, _sKey);
+ if (j == -1)
+ {
+ // case 2: section exist, but not the key
+ j = findLastKnownKeyIndex(i, _sKey);
+ if (_sKey.length() > 0)
+ {
+ String sKeyValuePair = _sKey + "=" + _sValue;
+ m_aList.add(j, sKeyValuePair);
+ m_bListContainUnsavedChanges = true;
+ }
+ return;
+ }
+ else
+ {
+ // case 3: section exist, and also the key
+ String sKeyValuePair = _sKey + "=" + _sValue;
+ m_aList.set(j, sKeyValuePair);
+ m_bListContainUnsavedChanges = true;
+ }
+ }
+ // -----------------------------------------------------------------------------
+ // String replaceEvaluatedValue(String _sSection, String _sValue)
+ // {
+ // String sValue = _sValue;
+ // int nIndex = 0;
+ // while (( nIndex = sValue.indexOf("$(", nIndex)) >= 0)
+ // {
+ // int nNextIndex = sValue.indexOf(")", nIndex);
+ // if (nNextIndex >= 0)
+ // {
+ // String sKey = sValue.substring(nIndex + 2, nNextIndex);
+ // String sNewValue = getValue(_sSection, sKey);
+ // if (sNewValue != null && sNewValue.length() > 0)
+ // {
+ // String sRegexpKey = "\\$\\(" + sKey + "\\)";
+ // sValue = sValue.replaceAll(sRegexpKey, sNewValue);
+ // }
+ // nIndex = nNextIndex;
+ // }
+ // else
+ // {
+ // nIndex += 2;
+ // }
+ // }
+ // return sValue;
+ // }
+ // -----------------------------------------------------------------------------
+
+ // public String getLocalEvaluatedValue(String _sSection, String _sKey)
+ // {
+ // String sValue = getValue(_sSection, _sKey);
+ // sValue = replaceEvaluatedValue(_sSection, sValue);
+ // return sValue;
+ // }
+
+ // -----------------------------------------------------------------------------
+
+ // this is a special behaviour.
+ // public String getGlobalLocalEvaluatedValue(String _sSection, String _sKey)
+ // {
+ // String sGlobalValue = getKey("global", _sKey);
+ // String sLocalValue = getKey(_sSection, _sKey);
+ // if (sLocalValue.length() == 0)
+ // {
+ // sGlobalValue = replaceEvaluatedKey(_sSection, sGlobalValue);
+ // sGlobalValue = replaceEvaluatedKey("global", sGlobalValue);
+ // return sGlobalValue;
+ // }
+ // sLocalValue = replaceEvaluatedKey(_sSection, sLocalValue);
+ // sLocalValue = replaceEvaluatedKey("global", sLocalValue);
+ //
+ // return sLocalValue;
+ // }
+ public void removeSection(String _sSectionToRemove)
+ {
+ // first, search for the name
+ int i = findSection(_sSectionToRemove);
+ if (i == -1)
+ {
+ // Section to remove not found, do nothing.
+ return;
+ }
+ // second, find the next section
+ int j = findNextSection(i + 1);
+ if (j == -1)
+ {
+ // if we are at the end, use size() as second section
+ j = m_aList.size();
+ }
+ // remove all between first and second section
+ for (int k = i; k < j; k++)
+ {
+ m_aList.remove(i);
+ }
+ // mark the list as changed
+ m_bListContainUnsavedChanges = true;
+ }
+
+ /**
+ * some tests for this class
+ */
+// public static void main(String[] args)
+// {
+// String sTempFile = System.getProperty("java.io.tmpdir");
+// sTempFile += "inifile";
+//
+//
+// IniFile aIniFile = new IniFile(sTempFile);
+// String sValue = aIniFile.getValue("Section", "Key");
+// // insert a new value to a already exist section
+// aIniFile.insertValue("Section", "Key2", "a new value in a existing section");
+// // replace a value
+// aIniFile.insertValue("Section", "Key", "replaced value");
+// // create a new value
+// aIniFile.insertValue("New Section", "Key", "a new key value pair");
+// aIniFile.insertValue("New Section", "Key2", "a new second key value pair");
+//
+// String sValue2 = aIniFile.getValue("Section2", "Key");
+//
+// aIniFile.removeSection("Section");
+// aIniFile.removeSection("New Section");
+//
+// aIniFile.close();
+// }
+
+ /**
+ * Enumeration Interface
+ * @return true, if there are more Key values
+ */
+ public boolean hasMoreElements()
+ {
+ if (m_aEnumerationPos >= 0 &&
+ m_aEnumerationPos < m_aList.size())
+ {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Find the next line, which starts with '['
+ * @param i start position
+ * @return the line where '[' found or -1
+ */
+ private int findNextSection(int i)
+ {
+ if (i >= 0)
+ {
+ while (i < m_aList.size())
+ {
+ String sLine = m_aList.get(i);
+ if (sLine.startsWith("["))
+ {
+ return i;
+ }
+ i++;
+ }
+ }
+ return -1;
+ }
+
+ /**
+ * Enumeration Interface
+ * @return a key without the enveloped '[' ']'
+ */
+ public Object nextElement()
+ {
+ int nLineWithSection = findNextSection(m_aEnumerationPos);
+ if (nLineWithSection != -1)
+ {
+ String sSection = m_aList.get(nLineWithSection);
+ m_aEnumerationPos = findNextSection(nLineWithSection + 1);
+ sSection = sectionToString(sSection);
+ return sSection;
+ }
+ else
+ {
+ m_aEnumerationPos = m_aList.size();
+ }
+ return null;
+ }
+
+ /**
+ * Helper to count the occurence of Sections
+ * @return returns the count of '^['.*']$' Elements
+ */
+ public int getElementCount()
+ {
+ int nCount = 0;
+ int nPosition = 0;
+ while ((nPosition = findNextSection(nPosition)) != -1)
+ {
+ nCount++;
+ nPosition++;
+ }
+ return nCount;
+ }
+}
+
diff --git a/qadevOOo/runner/graphical/JPEGComparator.java b/qadevOOo/runner/graphical/JPEGComparator.java
new file mode 100644
index 000000000000..a643b2b333c3
--- /dev/null
+++ b/qadevOOo/runner/graphical/JPEGComparator.java
@@ -0,0 +1,816 @@
+/*
+ * ************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ * ***********************************************************************
+ */
+package graphical;
+
+import helper.OSHelper;
+import helper.ProcessHandler;
+import java.io.File;
+import java.io.IOException;
+
+/**
+ * Helper class to interpret a jpg filename
+ */
+class NameDPIPage
+{
+
+ String Name;
+ int DPI;
+ int Page;
+
+ private NameDPIPage(String _sName, int _nDPI, int _nPage)
+ {
+ Name = _sName;
+ DPI = _nDPI;
+ Page = _nPage;
+ }
+
+ public static NameDPIPage interpret(String _sFilename)
+ {
+ String sBasename = FileHelper.getBasename(_sFilename); // if exist a path, remove it
+ String sNameNoSuffix = FileHelper.getNameNoSuffix(sBasename); // remove extension (.jpg)
+
+ // check if there exist a 'DPI_' at specific position
+ String sDPICheck = sNameNoSuffix.substring(sNameNoSuffix.length() - 8, sNameNoSuffix.length() - 4);
+ String sName;
+ int nDPI = -1;
+ int nPage = -1;
+ if (sDPICheck.equals("DPI_"))
+ {
+ // seems to be a generated filename by us.
+ int nDPIStart = sNameNoSuffix.lastIndexOf("_", sNameNoSuffix.length() - 8);
+ sName = sNameNoSuffix.substring(0, nDPIStart);
+ if (nDPIStart > 0)
+ {
+ String sDPI = sNameNoSuffix.substring(nDPIStart + 1, sNameNoSuffix.length() - 8);
+ try
+ {
+ nDPI = Integer.valueOf(sDPI).intValue();
+ }
+ catch (java.lang.NumberFormatException e)
+ {
+ GlobalLogWriter.println("DPI: Number format exception");
+ }
+ String sPage = sNameNoSuffix.substring(sNameNoSuffix.length() - 4);
+ try
+ {
+ nPage = Integer.valueOf(sPage).intValue();
+ }
+ catch (java.lang.NumberFormatException e)
+ {
+ GlobalLogWriter.println("Page: Number format exception");
+ }
+ }
+ }
+ else
+ {
+ sName = sNameNoSuffix;
+ }
+
+ return new NameDPIPage(sName, nDPI, nPage);
+ }
+}
+
+class CountNotXXXPixelsFromImage extends Thread
+{
+
+ private String m_sFilename;
+ protected int m_nValue;
+
+ CountNotXXXPixelsFromImage(String _sFilename)
+ {
+ m_sFilename = _sFilename;
+ }
+
+ public int getValue()
+ {
+ return m_nValue;
+ }
+
+ protected void setValue(int _nValue)
+ {
+ m_nValue = _nValue;
+ }
+
+ protected String getFilename()
+ {
+ return m_sFilename;
+ }
+}
+
+class CountNotWhitePixelsFromImage extends CountNotXXXPixelsFromImage
+{
+
+ CountNotWhitePixelsFromImage(String _sFilename)
+ {
+ super(_sFilename);
+ }
+
+ public void run()
+ {
+ try
+ {
+ final int nNotWhiteCount = PixelCounter.countNotWhitePixelsFromImage(getFilename());
+ setValue(nNotWhiteCount);
+ }
+ catch (java.io.IOException e)
+ {
+ m_nValue = -1;
+ }
+ }
+}
+
+class CountNotBlackPixelsFromImage extends CountNotXXXPixelsFromImage
+{
+
+ CountNotBlackPixelsFromImage(String _sFilename)
+ {
+ super(_sFilename);
+ }
+
+ public void run()
+ {
+ try
+ {
+ final int nNotBlackCount = PixelCounter.countNotBlackPixelsFromImage(getFilename());
+ setValue(nNotBlackCount);
+ }
+ catch (java.io.IOException e)
+ {
+ m_nValue = -1;
+ }
+ }
+}
+
+/**
+ *
+ * @author ll93751
+ */
+public class JPEGComparator extends EnhancedComplexTestCase
+{
+ // @Override
+
+ public String[] getTestMethodNames()
+ {
+ return new String[]{"CompareJPEGvsJPEG"};
+ }
+ private Tolerance m_aTolerance;
+
+ /**
+ * test function.
+ */
+ public void CompareJPEGvsJPEG()
+ {
+ GlobalLogWriter.set(log);
+ ParameterHelper aParam = new ParameterHelper(param);
+
+ // run through all documents found in Inputpath
+ foreachJPEGcompareWithJPEG(aParam);
+ }
+
+ public void checkOneFile(String _sDocumentName, String _sResult, ParameterHelper _aParams) throws OfficeException
+ {
+ // private void callEveryPictureInIniFile(IniFile _aIniFile, String _sSectionName, ParameterHelper _aParam)
+ // {
+ String sPath = FileHelper.getPath(_sDocumentName);
+ String sSectionName = FileHelper.getBasename(_sDocumentName);
+
+ // take the build id out of the ini file in the reference file and put it into the current parameter helper
+ String sIniFileForRefBuildID = FileHelper.appendPath(sPath, sSectionName + ".ini");
+ IniFile aIniFileForRefBuildID = new IniFile(sIniFileForRefBuildID);
+ String sRefBuildID = aIniFileForRefBuildID.getValue("global", "buildid");
+ aIniFileForRefBuildID.close();
+
+ _aParams.getTestParameters().put("RefBuildId", sRefBuildID);
+
+ String sIniFile = FileHelper.appendPath(sPath, "index.ini");
+ IniFile aIniFile = new IniFile(sIniFile);
+ if (aIniFile.hasValue(sSectionName, "pages"))
+ {
+ // only which has 'pages' has also pictures
+ int nPages = aIniFile.getIntValue(sSectionName, "pages", 0);
+ String sJPEGSchema = aIniFile.getValue(sSectionName, "jpegschema");
+ int nTolerance = aIniFile.getIntValue(sSectionName, "tolerance", 0);
+ m_aTolerance = new Tolerance(nTolerance);
+ for (int i = 1; i <= nPages; i++)
+ {
+ String sJPEGFilename = JPEGCreator.getFilenameForJPEGSchema(sJPEGSchema, i);
+ // String sPath = FileHelper.getPath(_aParam.getInputPath());
+ String sJPEGPath = FileHelper.getPath(sJPEGFilename);
+ if (!sPath.equals(sJPEGPath))
+ {
+ GlobalLogWriter.println("Path where to find the index and where to file the JPEG pictures are not the same.");
+
+ }
+ // String sEntry = FileHelper.appendPath(sPath, sSection);
+ File aFile = new File(sJPEGFilename);
+ assure("File '" + sJPEGFilename + "' doesn't exists.", aFile.exists(), true);
+ if (aFile.exists())
+ {
+ GlobalLogWriter.println("Page: " + i);
+ checkOnePicture(sJPEGFilename, _sResult, _aParams);
+ }
+ }
+ }
+ else
+ {
+ GlobalLogWriter.println("The document '" + sSectionName + "' seems to have no picture representation.");
+ }
+
+ String sResultIniFile = FileHelper.appendPath(_sResult, sSectionName);
+ evaluateResult(sResultIniFile, _aParams);
+ }
+
+ private void evaluateResult(String _sDocument, ParameterHelper _aParams)
+ {
+ String sResultIniFile = _sDocument + ".ini";
+ File aFile = new File(sResultIniFile);
+ assure("Result file doesn't exists " + sResultIniFile, aFile.exists());
+
+ int good = 0;
+ int bad = 0;
+ int ugly = 0;
+ int ok_status = 1; // 1=ok 2=bad 3=ugly
+
+ IniFile aResultIniFile = new IniFile(sResultIniFile);
+ int nPages = aResultIniFile.getIntValue("global", "pages", 0);
+ for (int i = 0; i < nPages; i++)
+ {
+ String sCurrentPage = "page" + String.valueOf(i + 1);
+ int nPercent = aResultIniFile.getIntValue(sCurrentPage, "percent", -1);
+ if (nPercent == 0)
+ {
+ good++;
+ }
+ else if (nPercent <= 5)
+ {
+ bad++;
+ ok_status = 2;
+ }
+ else
+ {
+ ugly++;
+ ok_status = 3;
+ }
+ }
+
+ assure("Error: document doesn't contains pages", nPages > 0);
+
+// TODO: this information has to come out of the ini files
+ String sStatusRunThrough = "PASSED, ";
+ String sPassed = "OK";
+
+ String sStatusMessage = "From " + nPages + " page(s) are: ";
+ String sGood = "";
+ String sBad = "";
+ String sUgly = "";
+
+ if (good > 0)
+ {
+ sGood = " good:=" + good;
+ sStatusMessage += sGood;
+ }
+ if (bad > 0)
+ {
+ sBad = " bad:=" + bad;
+ sStatusMessage += sBad;
+ }
+ if (ugly > 0)
+ {
+ sUgly = " ugly:=" + ugly;
+ sStatusMessage += sUgly;
+ }
+
+ // Failure matrix
+ // 0 1
+ // ugly OK FAILED
+ // bad OK
+ // good OK
+
+ if (ugly > 0)
+ {
+ sPassed = "FAILED";
+ }
+ else
+ {
+ if (bad > 0)
+ {
+ sPassed = "NEED A LOOK";
+ }
+ else
+ {
+ sPassed = "OK";
+ }
+ }
+ sStatusRunThrough += sPassed;
+ aResultIniFile.insertValue("global", "state", sStatusRunThrough);
+ aResultIniFile.insertValue("global", "info", sStatusMessage);
+ aResultIniFile.close();
+
+ _aParams.getTestParameters().put("current_state", sStatusRunThrough);
+ _aParams.getTestParameters().put("current_info", sStatusMessage);
+ _aParams.getTestParameters().put("current_ok_status", ok_status);
+
+ // if we have a ugly page, we must return this as a FAILED STATUS in Log file!
+ assure("There exist pages marked as ugly.", ugly == 0);
+ }
+
+ private void checkOnePicture(String _sDocumentName, String _sResult, ParameterHelper _aParams)
+ {
+ GlobalLogWriter.println("JPEG: Compare difference between '" + _sDocumentName + "' and '" + _sResult + "'");
+ File aResultFile = new File(_sResult);
+ if (aResultFile.isDirectory())
+ {
+ // result is just a directory, so we search for the basename of the source and take this.
+ String sBasename = FileHelper.getBasename(_sDocumentName);
+ String sResultFilename = FileHelper.appendPath(_sResult, sBasename);
+ aResultFile = new File(sResultFilename);
+ if (aResultFile.exists())
+ {
+ // Original and Result exists
+ String sInputPath = _aParams.getInputPath();
+ if (sInputPath.toLowerCase().endsWith("index.ini"))
+ {
+ // special case
+ // we want to get the buildid from the info file.
+ }
+
+ compareJPEG(_sDocumentName, sResultFilename, _aParams);
+
+ }
+ else
+ {
+ String sResultFilenamePDF = util.utils.replaceAll13(sResultFilename, ".ps_", ".pdf_");
+ File aResultPDFFile = new File(sResultFilenamePDF);
+ if (aResultPDFFile.exists())
+ {
+ // Original and Result exists
+ String sInputPath = _aParams.getInputPath();
+ if (sInputPath.toLowerCase().endsWith("index.ini"))
+ {
+ // special case
+ // we want to get the buildid from the info file.
+ }
+
+ compareJPEG(_sDocumentName, sResultFilenamePDF, _aParams);
+ }
+ else
+ {
+ GlobalLogWriter.println("Warning: Result JPEG doesn't exists '" + sResultFilename + "'");
+ }
+ }
+ }
+ else
+ {
+ // result is also a file
+ if (aResultFile.exists())
+ {
+ compareJPEG(_sDocumentName, _sResult, _aParams);
+ }
+ else
+ {
+ GlobalLogWriter.println("Warning: Result JPEG doesn't exists '" + _sResult + "'");
+ }
+ }
+ }
+
+ /**
+ * compare 2 JPEGs, it is a need, that both _sDocumentName and _sResultFilename exist.
+ * @param _sDocumentName
+ * @param _sResult
+ * @param _aParams
+ * @return 0=no difference !=0 both files differ
+ */
+ private void compareJPEG(String _sDocumentName, String _sResult, ParameterHelper _aParams)
+ {
+ NameDPIPage aNameDPIPage = NameDPIPage.interpret(_sDocumentName);
+
+ String sSourceBasename = FileHelper.getBasename(_sDocumentName);
+ String sSourcePath = FileHelper.getPath(_sDocumentName);
+ String sDestinationBasename = FileHelper.getBasename(_sResult);
+ String sDestinationPath = FileHelper.getPath(_sResult);
+
+ if (!sSourcePath.equals(sDestinationPath))
+ {
+ // we want to have all in one Directory, Original, Reference and the Difference result.
+ // copy the original file to the reference path
+ String sNewSourceBasename = "Original_" + sSourceBasename;
+ // String sSource = FileHelper.appendPath(sSourcePath, sSourceBasename);
+ String sSource = _sDocumentName;
+ String sDestination = FileHelper.appendPath(sDestinationPath, sNewSourceBasename);
+ FileHelper.copy(sSource, sDestination);
+ sSourceBasename = sNewSourceBasename;
+ //
+ JPEGCreator.convertToNearSameFileWithWidth340(sDestination);
+ }
+ String sDifferenceBasename = "Difference_between_" + FileHelper.getNameNoSuffix(sSourceBasename) + "_and_" + FileHelper.getNameNoSuffix(sDestinationBasename) + ".jpg";
+ // String sDifferencePath = sDestinationPath;
+
+ String sSource = FileHelper.appendPath(sDestinationPath, sSourceBasename);
+ String sDestination = FileHelper.appendPath(sDestinationPath, sDestinationBasename);
+ String sDifference = FileHelper.appendPath(sDestinationPath, sDifferenceBasename);
+ int nErr = compareJPEG(sSource, sDestination, sDifference);
+ if (nErr == 0 && FileHelper.exists(sDifference))
+ {
+ // check the difference, returns the count of different colors
+ // this means, 1=only one color, no differences found.
+ int nResult = identify(sDifference);
+ int nPercentColorDiffer = 0;
+
+ String sResult = "YES";
+
+ if (m_aTolerance != null)
+ {
+ final int nAcceptedTolerance = m_aTolerance.getAccept();
+ if (nResult <= nAcceptedTolerance)
+ {
+ nResult = 1;
+ sResult = "IN TOLERANCE";
+ GlobalLogWriter.println("The differences are in tolerance.");
+
+ }
+ }
+ if (nResult != 1)
+ {
+ sResult = "NO";
+ try
+ {
+ nPercentColorDiffer = estimateGfx(sSource, sDestination, sDifference);
+ }
+ catch (java.io.IOException e)
+ {
+ GlobalLogWriter.println("Can't estimate the different colors. " + e.getMessage());
+ }
+ }
+
+ // store the result in a result.ini file
+ String sResultFile = FileHelper.appendPath(sDestinationPath, aNameDPIPage.Name + ".ini");
+ int nPage = aNameDPIPage.Page;
+ if (nPage < 0)
+ {
+ nPage = 0;
+ }
+ IniFile aResultIni = new IniFile(sResultFile);
+
+ String[] aComment =
+ {
+ "; This file is automatically created by a graphical.JPEGComparator run",
+ "; ",
+ "; If you see this file in a browser you may have forgotten to set the follows in the property file",
+ "; " + PropertyName.DOC_COMPARATOR_HTML_OUTPUT_PREFIX + "=http://<computer>/gfxcmp_ui/cw.php?inifile=",
+ "; Please check the documentation if you got confused.",
+ "; ",
+ "; "
+ };
+ aResultIni.insertFirstComment(aComment);
+
+ // write down the global flags
+ int nMaxPage = Math.max(nPage, aResultIni.getIntValue("global", "pages", 0));
+ aResultIni.insertValue("global", "pages", nMaxPage);
+
+ // INIoutput.writeValue("buildid", _sBuildID);
+ // INIoutput.writeValue("refbuildid", _sRefBuildID);
+ String sRefBuildId = (String) _aParams.getTestParameters().get("RefBuildId");
+ if (sRefBuildId == null)
+ {
+ sRefBuildId = "";
+ }
+ aResultIni.insertValue("global", "refbuildid", sRefBuildId);
+
+ aResultIni.insertValue("global", "diffdiff", "no");
+ aResultIni.insertValue("global", "basename", aNameDPIPage.Name);
+ aResultIni.insertValue("global", "dpi", aNameDPIPage.DPI);
+
+ // write down flags for each page
+ String sSection = "page" + String.valueOf(nPage);
+
+ aResultIni.insertValue(sSection, "oldgfx", sSource);
+ aResultIni.insertValue(sSection, "newgfx", sDestination);
+ aResultIni.insertValue(sSection, "diffgfx", sDifference);
+ aResultIni.insertValue(sSection, "percent", nPercentColorDiffer);
+ aResultIni.insertValue(sSection, "BM", "false");
+ aResultIni.insertValue(sSection, "result", sResult);
+
+ aResultIni.close();
+ }
+ }
+
+// // This creates a status for exact on document
+// static boolean createINIStatus(StatusHelper[] aList, String _sFilenamePrefix, String _sOutputPath, String _sAbsoluteInputFile, String _sBuildID, String _sRefBuildID)
+// {
+// // Status
+// String fs = System.getProperty("file.separator");
+// String sBasename = FileHelper.getBasename(_sAbsoluteInputFile);
+// String sNameNoSuffix = FileHelper.getNameNoSuffix(sBasename);
+//// String sHTMLFile = _sFilenamePrefix + sNameNoSuffix + ".html";
+//// HTMLOutputter HTMLoutput = HTMLOutputter.create(_sOutputPath, sHTMLFile, "", "");
+//// HTMLoutput.header(sNameNoSuffix);
+//// TODO: version info was fine
+//// HTMLoutput.checkSection(sBasename);
+// // Status end
+//
+// String sINIFile = _sFilenamePrefix + sNameNoSuffix + ".ini";
+// INIOutputter INIoutput = INIOutputter.create(_sOutputPath, sINIFile, "", "");
+// INIoutput.createHeader();
+//// TODO: version info was fine
+//
+// INIoutput.writeSection("global");
+// INIoutput.writeValue("pages", String.valueOf(aList.length));
+// INIoutput.writeValue("buildid", _sBuildID);
+// INIoutput.writeValue("refbuildid", _sRefBuildID);
+// INIoutput.writeValue("diffdiff", "no");
+// INIoutput.writeValue("basename", sBasename);
+//
+// boolean bResultIsOk = true; // result over all pages
+// for (int i=0;i<aList.length; i++)
+// {
+// INIoutput.writeSection("page" + String.valueOf(i + 1)); // list start at point 0, but this is page 1 and so on... current_page = (i + 1)
+// aList[i].printStatus();
+//
+// boolean bCurrentResult = true; // result over exact one page
+//
+// int nCurrentDiffStatus = aList[i].nDiffStatus;
+//
+// // check if the status is in a defined range
+// if (nCurrentDiffStatus == StatusHelper.DIFF_NO_DIFFERENCES)
+// {
+// // ok.
+// }
+// else if (nCurrentDiffStatus == StatusHelper.DIFF_DIFFERENCES_FOUND && aList[i].nPercent < 5)
+// {
+// // ok.
+// }
+// else if (nCurrentDiffStatus == StatusHelper.DIFF_AFTER_MOVE_DONE_NO_PROBLEMS)
+// {
+// // ok.
+// }
+// else if (nCurrentDiffStatus == StatusHelper.DIFF_AFTER_MOVE_DONE_DIFFERENCES_FOUND && aList[i].nPercent2 < 5)
+// {
+// // ok.
+// }
+// else
+// {
+// // failed.
+// bCurrentResult = false; // logic: nDiff==0 = true if there is no difference
+// }
+//
+// // Status
+//// HTMLoutput.checkLine(aList[i], bCurrentResult);
+// INIoutput.checkLine(aList[i], bCurrentResult);
+// bResultIsOk &= bCurrentResult;
+// }
+// // Status
+//// HTMLoutput.close();
+// INIoutput.close();
+// return bResultIsOk;
+// }
+ /**
+ * count how much pixel differ and between Old or New and the Difference graphics
+ *
+ * First, count the old graphics, then the new graphics due to the fact both should be equal
+ * it should be legal to take result from old or new. We take the graphics with less values.
+ *
+ * Second, count the difference graphics, now take the percent algorithm and
+ * build a percent value, which contain the number of different pixels as a percent value
+ *
+ * Interpretation:
+ * 0% there is no difference
+ *
+ * &lt;100% Take a look into the difference graphics, maybe the difference graphics shows
+ * text like outlined or the text is little bit move left, right up or down.
+ *
+ * &gt;>100% Yes it's possible that there is a difference more then 100%, maybe a font problem
+ * between old and new graphics. The font of the new graphics is little bit bigger,
+ * so the pixel count between old graphics and new graphics is twice the more.
+ *
+ * @param _sOldGfx path & name to the jpeg file (1)
+ * @param _sNewGfx path & name to the other jpeg file (2)
+ * @param _sDiffGfx path & name to the new difference file which shows the difference between (1) and (2)
+ * @return the count of different pixels
+ * @throws java.io.IOException if file access is not possible
+ */
+ public static int estimateGfx(String _sOldGfx, String _sNewGfx, String _sDiffGfx)
+ throws java.io.IOException
+ {
+ TimeHelper a = new TimeHelper();
+ a.start();
+ // Count Pixels
+ final int nNotWhiteCount_OldGraphic = PixelCounter.countNotWhitePixelsFromImage(_sOldGfx);
+ final int nNotWhiteCount_NewGraphic = PixelCounter.countNotWhitePixelsFromImage(_sNewGfx);
+ final int nNotBlackCount_DiffGraphic = PixelCounter.countNotBlackPixelsFromImage(_sDiffGfx);
+
+ // Count Pixels in different threads
+// CountNotWhitePixelsFromImage t1 = new CountNotWhitePixelsFromImage(_sOldGfx);
+// CountNotWhitePixelsFromImage t2 = new CountNotWhitePixelsFromImage(_sNewGfx);
+// CountNotBlackPixelsFromImage t3 = new CountNotBlackPixelsFromImage(_sDiffGfx);
+// t1.start();
+// t2.start();
+// t3.start();
+// try
+// {
+// t1.join();
+// }
+// catch (InterruptedException ex)
+// {
+// GlobalLogWriter.get().println("Thread 1 failed: " + ex.getMessage());
+// }
+// try
+// {
+// t2.join();
+// }
+// catch (InterruptedException ex)
+// {
+// GlobalLogWriter.get().println("Thread 2 failed: " + ex.getMessage());
+// }
+// try
+// {
+// t3.join();
+// }
+// catch (InterruptedException ex)
+// {
+// GlobalLogWriter.get().println("Thread 3 failed: " + ex.getMessage());
+// }
+// final int nNotWhiteCount_OldGraphic = t1.getValue();
+// final int nNotWhiteCount_NewGraphic = t2.getValue();
+// final int nNotBlackCount_DiffGraphic = t3.getValue();
+
+ a.stop();
+ GlobalLogWriter.println("Thread Time is: " + a.getTime());
+
+ int nMinNotWhiteCount = Math.min(nNotWhiteCount_NewGraphic, nNotWhiteCount_OldGraphic);
+
+ // check if not zero
+ if (nMinNotWhiteCount == 0)
+ {
+ nMinNotWhiteCount = Math.max(nNotWhiteCount_NewGraphic, nNotWhiteCount_OldGraphic);
+ if (nMinNotWhiteCount == 0)
+ {
+ nMinNotWhiteCount = 1;
+ }
+ }
+
+ int nPercent = Math.abs(nNotBlackCount_DiffGraphic * 100 / nMinNotWhiteCount);
+ GlobalLogWriter.println("Graphics check, pixel based:" + String.valueOf(nPercent) + "% pixel differ ");
+ return nPercent;
+ }
+
+ private static int compareJPEG(String _sOldGfx, String _sNewGfx, String _sDiffGfx)
+ {
+ String sComposite = "composite";
+ if (OSHelper.isWindows())
+ {
+ sComposite = "composite.exe";
+ String sIMPath = (String) param.get("imagemagick.path");
+ if (sIMPath != null)
+ {
+ sComposite = FileHelper.appendPath(sIMPath, sComposite);
+ }
+ }
+
+ // String sCommand = sComposite + " -compose difference " +
+ // StringHelper.doubleQuoteIfNeed(_sOldGfx) + " " +
+ // StringHelper.doubleQuoteIfNeed(_sNewGfx) + " " +
+ // StringHelper.doubleQuoteIfNeed(_sDiffGfx);
+
+ String[] sCommandArray =
+ {
+ sComposite,
+ "-compose",
+ "difference",
+ _sOldGfx,
+ _sNewGfx,
+ _sDiffGfx
+ };
+
+ ProcessHandler aHandler = new ProcessHandler(sCommandArray);
+ boolean bBackValue = aHandler.executeSynchronously();
+ int nExitCode = aHandler.getExitCode();
+ if (nExitCode != 0)
+ {
+ GlobalLogWriter.println("'" + sComposite + "' return with ");
+ String sBack = aHandler.getOutputText();
+ GlobalLogWriter.println("'" + sBack + "'");
+ }
+ else
+ {
+ // creates an extra smaller difference picture
+ File aDiffFile = new File(_sDiffGfx);
+ if (aDiffFile.exists())
+ {
+ JPEGCreator.convertToNearSameFileWithWidth340(_sDiffGfx);
+ }
+ }
+ return nExitCode;
+ }
+
+ /**
+ * wrapper for ImageMagick identify,
+ * function checks how many different colors a picture contains.
+ * if it's only one color (nResult==1), like background color, there is no difference.
+ */
+ int identify(String _sDiffGfx)
+ {
+ int nResult = 0;
+ // would like to know what the meaning of %k is for ImageMagick's 'identify'
+ String sIM_Format = "%k";
+ // if (OSHelper.isWindows())
+ // {
+ // sIM_Format = "%%k";
+ // }
+
+ String sIdentify = "identify";
+ if (OSHelper.isWindows())
+ {
+ sIdentify = "identify.exe";
+ String sIMPath = (String) param.get("imagemagick.path");
+ if (sIMPath != null)
+ {
+ sIdentify = FileHelper.appendPath(sIMPath, sIdentify);
+ }
+ }
+
+ // String sCommand = sIdentify + " " + sIM_Format + " " + StringHelper.doubleQuoteIfNeed(_sDiffGfx);
+
+ String[] sCommandArray =
+ {
+ sIdentify,
+ "-format",
+ sIM_Format,
+ _sDiffGfx
+ };
+ ProcessHandler aHandler = new ProcessHandler(sCommandArray);
+ boolean bBackValue = aHandler.executeSynchronously();
+ int nExitCode = aHandler.getExitCode();
+
+ String sBack = aHandler.getOutputText();
+ GlobalLogWriter.println("'" + sBack + "'");
+
+ // try to interpret the result, which we get as a String
+ try
+ {
+ int nIdx = sBack.indexOf("\n");
+ if (nIdx > 0)
+ {
+ sBack = sBack.substring(0, nIdx);
+ }
+
+ nResult = Integer.valueOf(sBack).intValue();
+ }
+ catch (java.lang.NumberFormatException e)
+ {
+ GlobalLogWriter.println("identify(): Number format exception");
+ nResult = 0;
+ }
+ return nResult;
+ }
+// public static void main(String [] _args)
+// {
+//// give an index.ini file, ok
+//// give a directory, where exist jpeg files ok
+//// inputpath (given file) doesn't exists
+//// give a jpeg file.
+//
+// String args[] = {
+// "-TimeOut", "3600000",
+// "-tb", "java_complex",
+// "-o", "graphical.JPEGComparator",
+// "-DOC_COMPARATOR_INPUT_PATH", "C:\\CWS\\temp\\output\\index.ini",
+// "-DOC_COMPARATOR_OUTPUT_PATH", "C:\\CWS\\temp\\output2",
+//// "-DOC_COMPARATOR_INPUT_PATH", "C:\\CWS\\temp\\output\\GroupReport.odt.pdf_180DPI_0001.jpg",
+//// "-DOC_COMPARATOR_OUTPUT_PATH", "C:\\CWS\\temp\\output2\\Report1.odt.pdf_180DPI_0001.jpg",
+// "-DOC_COMPARATOR_HTML_OUTPUT_PREFIX", "http://so-gfxcmp-lin.germany.sun.com/gfxcmp_ui/cw.php?inifile=",
+//// "-DOC_COMPARATOR_REFERENCE_CREATOR_TYPE", "PDF", /* default: "OOo" */
+//// "-DOC_COMPARATOR_REFERENCE_CREATOR_TYPE", "msoffice", /* default: "OOo" */
+//// "-OFFICE_VIEWABLE", "false",
+//// "-AppExecutionCommand", "\"C:/Programme/sun/staroffice 9/program/soffice.exe\" -norestore -nocrashreport -accept=pipe,name=ll93751;urp;",
+// "-NoOffice"
+// };
+//
+// org.openoffice.Runner.main(args);
+// }
+}
diff --git a/qadevOOo/runner/graphical/JPEGCreator.java b/qadevOOo/runner/graphical/JPEGCreator.java
new file mode 100644
index 000000000000..a4336229e448
--- /dev/null
+++ b/qadevOOo/runner/graphical/JPEGCreator.java
@@ -0,0 +1,475 @@
+/*
+ * ************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ * ***********************************************************************
+ */
+
+package graphical;
+
+import helper.OSHelper;
+import helper.ProcessHandler;
+import helper.StringHelper;
+import java.io.File;
+
+/**
+ *
+ * @author ll93751
+ */
+public class JPEGCreator extends EnhancedComplexTestCase
+{
+ // @Override
+ public String[] getTestMethodNames()
+ {
+ return new String[]{"PostscriptOrPDFToJPEG"};
+ }
+
+ /**
+ * test function.
+ */
+ public void PostscriptOrPDFToJPEG()
+ {
+ GlobalLogWriter.set(log);
+ ParameterHelper aParam = new ParameterHelper(param);
+
+ // run through all documents found in Inputpath
+ foreachPSorPDFinInputPath(aParam);
+ }
+
+
+ public void checkOneFile(String _sDocumentName, String _sResult, ParameterHelper _aParams) throws OfficeException
+ {
+ GlobalLogWriter.println("Document: " + _sDocumentName + " results: " + _sResult);
+// IOffice aOffice = new Office(_aParams, _sResult);
+// aOffice.start();
+// aOffice.load(_sDocumentName);
+// aOffice.storeAsPostscript();
+// aOffice.close();
+ String sJPEGNameSchema = createJPEG(_sDocumentName, "", _aParams);
+
+ // store information only if jpeg files exists
+ int nPages = countPages(sJPEGNameSchema);
+ if (nPages > 0)
+ {
+ createSmallPictures(sJPEGNameSchema);
+
+ // read out tolerance file
+ String sFileDir = FileHelper.getPath(_sDocumentName);
+ String sBasename = FileHelper.getBasename(_sDocumentName);
+ int nTolerance = 0;
+ String sToleranceFile = FileHelper.appendPath(sFileDir, "tolerance.ini");
+ File aToleranceFile = new File(sToleranceFile);
+ if (aToleranceFile.exists())
+ {
+ IniFile aIniFile = new IniFile(sToleranceFile);
+ nTolerance = aIniFile.getIntValue(sBasename, "accept", 0); // default for all pages
+ aIniFile.close();
+ }
+
+ String sIndexFile = FileHelper.appendPath(_sResult, "index.ini");
+ File aIndexFile = new File(sIndexFile);
+ if (aIndexFile.exists())
+ {
+ // store only if an index file exists
+ IniFile aIniFile = new IniFile(sIndexFile);
+ aIniFile.insertValue(sBasename, "jpegschema", sJPEGNameSchema);
+ aIniFile.insertValue(sBasename, "pages", nPages);
+ aIniFile.insertValue(sBasename, "tolerance", nTolerance);
+ aIniFile.close();
+ }
+ }
+ else
+ {
+ assure("There are no pages in document:'" + _sDocumentName + "', maybe document currupt?", false, true);
+ }
+ }
+
+/**
+ * Create a lot of smaller and nicer Pictures of the big fat pages.
+ * Looks better
+ * @param _sJPEGSchema
+ */
+ public void createSmallPictures(String _sJPEGSchema)
+ {
+ ParameterHelper aParam = new ParameterHelper(param);
+ if (! aParam.createSmallPictures())
+ {
+ return;
+ }
+
+ int nPages = 0;
+ if (_sJPEGSchema.length() > 0)
+ {
+ // TODO: if there doesn't exists a '%04d' in the schema we will return 9999 which is a little bit wrong here.
+ for (int i=1;i<10000;i++)
+ {
+ String sJPEGFilename = getFilenameForJPEGSchema(_sJPEGSchema, i);
+ if (FileHelper.exists(sJPEGFilename))
+ {
+ convertToNearSameFileWithWidth340(sJPEGFilename);
+ // m_aFileList.add(sNewJPEGFilename); // as long as the files exist, fill the array
+ nPages ++;
+ }
+ else
+ {
+ break; // stop file check
+ }
+ }
+ }
+ // return nPages;
+ }
+
+/**
+ * convert a picture to a new picture with 340 pixel width.
+ * @param _sJPEGFilename
+ */
+public static void convertToNearSameFileWithWidth340(String _sJPEGFilename)
+{
+ ParameterHelper aParam = new ParameterHelper(param);
+ if (! aParam.createSmallPictures())
+ {
+ return;
+ }
+ String sJPEGFilename = _sJPEGFilename.replaceAll("\\\\", "/");
+// if (OSHelper.isWindows())
+// {
+// sJPEGFilename = sJPEGFilename.replaceAll("/", "\\\\");
+// }
+ String sNewJPEGFilename;
+ sNewJPEGFilename = util.utils.replaceAll13(sJPEGFilename, ".jpg", "_w340.jpg");
+ convertToWidth340(sJPEGFilename, sNewJPEGFilename);
+}
+
+ /**
+ * convert chart2_Regression.ods.ps_180DPI_0001.jpg -filter Catrom -resize
+340x chart2_Regression.ods.ps_180DPI_0001_w340.jpg
+
+Point wie bisher
+Cubic schlecht, weil unscharf
+...
+Triangle ganz brauchbar (default?)
+Catrom am besten
+
+ * @param _sFrom
+ * @param _To
+ */
+private static void convertToWidth340(String _sFrom, String _To)
+{
+ // int nResult = 0;
+
+ String sConvertEXE = "convert";
+ if (OSHelper.isLinuxIntel())
+ {
+ sConvertEXE = "convert";
+ }
+ if (OSHelper.isWindows())
+ {
+ // TODO!
+ // HACK Hard coded!
+ // sConvertEXE = "C:\\Programme\\ImageMagick-6.0.3-q8\\convert.exe";
+ sConvertEXE = "convert.exe";
+ String sConvertPath = (String)param.get("imagemagick.path");
+ if (sConvertPath != null)
+ {
+ sConvertEXE = FileHelper.appendPath(sConvertPath, sConvertEXE);
+ }
+ }
+
+ String[] sCommandArray =
+ {
+ sConvertEXE,
+ _sFrom,
+ "-filter", "Catrom",
+ "-resize", "340x",
+ _To
+ };
+ ProcessHandler aHandler = new ProcessHandler(sCommandArray);
+ boolean bBackValue = aHandler.executeSynchronously();
+ int nExitCode = aHandler.getExitCode();
+
+ String sBack = aHandler.getOutputText();
+ if (sBack.length() > 0)
+ {
+ GlobalLogWriter.println("'" + sBack + "'");
+ }
+ // try to interpret the result, which we get as a String
+// try
+// {
+// int nIdx = sBack.indexOf("\n");
+// if (nIdx > 0)
+// {
+// sBack = sBack.substring(0, nIdx);
+// }
+//
+// nResult = Integer.valueOf(sBack).intValue();
+// }
+// catch(java.lang.NumberFormatException e)
+// {
+// GlobalLogWriter.get().println("Number format exception");
+// nResult = 0;
+// }
+ // return nResult;
+}
+
+/**
+ * create out of a given Postscript/PDF _sFile a list of JPEGs, one for every page
+ * @param _sFile
+ * @param _sAdditional
+ * @param _aParam
+ * @return the schema of the first jpeg name
+ */
+ String createJPEG(String _sFile, String _sAdditional, ParameterHelper _aParam)
+ {
+ if (_sFile.startsWith("file:///"))
+ {
+ _sFile = FileHelper.getSystemPathFromFileURL(_sFile);
+ }
+ File aFile = new File(_sFile);
+ if (aFile.exists())
+ {
+ String sAbsFile = aFile.getAbsolutePath();
+ if (!sAbsFile.equals(_sFile))
+ {
+ _sFile = sAbsFile;
+ }
+ }
+ else
+ {
+ GlobalLogWriter.println("File: '" + _sFile + "' doesn't exist.");
+ return "";
+ }
+ String sFileDir = FileHelper.getPath(_sFile);
+ String sBasename = FileHelper.getBasename(_sFile);
+// String sNameNoSuffix = FileHelper.getNameNoSuffix(sBasename);
+
+ String sTmpDir = util.utils.getUsersTempDir();
+ if (_aParam.getOutputPath() != null)
+ {
+ sTmpDir = _aParam.getOutputPath();
+ }
+
+ String sJPEGNameSchema = "";
+ if (_sFile.toLowerCase().endsWith("ps") ||
+ _sFile.toLowerCase().endsWith("prn") ||
+ _sFile.toLowerCase().endsWith("pdf"))
+ {
+ // seems to be a Postscript of PDF file
+
+ sJPEGNameSchema = createJPEGsFromPostscript(sTmpDir, sFileDir, sBasename, _aParam.getResolutionInDPI());
+ }
+ else if (_sFile.toLowerCase().endsWith("jpg") ||
+ _sFile.toLowerCase().endsWith("jpeg"))
+ {
+ // do nothing, it's already a picture.
+ return _sFile;
+ }
+ else
+ {
+ // we assume it's an office document.
+ // Office files will not handled here, we need a PS or PDF file
+ }
+ return sJPEGNameSchema;
+ }
+
+ private String getJPEGName(String _sOutputPath, String _sBasename, int _nResolutionInDPI, String _sGS_PageOutput)
+ {
+ // String fs = System.getProperty("file.separator");
+ String sName = _sBasename + "_" + String.valueOf(_nResolutionInDPI) + "DPI_" + _sGS_PageOutput + ".jpg";
+ String sJPEGName = FileHelper.appendPath(_sOutputPath, sName);
+ return sJPEGName;
+ }
+
+ /**
+ * Create via ghostscript (gs) from the reference file for every page a JPEG file
+ *
+ * MUST set:
+ * m_sOutputPath, m_sReferenceFile, m_sReferencePath
+ *
+ * return exit code from gs command
+ */
+
+ private static final String m_sGS_PageOutput = "%04d";
+
+ private String createJPEGsFromPostscript(String _sOutputPath, String _sSourcePath, String _sSourceFile, int _nResolutionInDPI)
+ {
+ FileHelper.makeDirectories("", _sOutputPath);
+
+ // create a jpeg from original prn
+ // String fs = System.getProperty("file.separator");
+
+ String sJPEGNameSchema = getJPEGName(_sOutputPath, _sSourceFile, _nResolutionInDPI, m_sGS_PageOutput);
+ String sPostscriptOrPDFFile = FileHelper.appendPath(_sSourcePath, _sSourceFile);
+ String sGhostscriptEXE = "gs";
+ if (OSHelper.isWindows())
+ {
+ sGhostscriptEXE = "gswin32c.exe";
+ String sGhostscriptEXE2 = (String)param.get("gs.exe");
+ if (sGhostscriptEXE2 != null)
+ {
+ sGhostscriptEXE = sGhostscriptEXE2;
+ }
+ String sGhostscriptPath = (String)param.get("gs.path");
+ if (sGhostscriptPath != null)
+ {
+ sGhostscriptEXE = FileHelper.appendPath(sGhostscriptPath, sGhostscriptEXE);
+ }
+ }
+
+// String sCommand = sGhostscriptEXE + " -dNOPROMPT -dBATCH -sDEVICE=jpeg -r" + String.valueOf(_nResolutionInDPI) + " -dNOPAUSE -sOutputFile=" + StringHelper.doubleQuoteIfNeed(sJPGFilename) + " " + StringHelper.doubleQuoteIfNeed(sOriginalFile);
+ String[] sCommandArray =
+ {
+ sGhostscriptEXE,
+ "-dNOPROMPT",
+ "-dBATCH",
+ "-sDEVICE=jpeg",
+ "-r" + String.valueOf(_nResolutionInDPI),
+ "-dNOPAUSE",
+ "-sOutputFile=" + sJPEGNameSchema,
+ sPostscriptOrPDFFile
+
+
+
+ };
+ // System.out.println("Start Command array");
+ // try
+ // {
+ // Runtime.getRuntime().exec(sCommandArray);
+ // } catch (Exception e) {
+ // System.out.println("FAILED");
+ // }
+ // System.out.println("done");
+
+// TODO: gives ghostscript an error we can handle?
+ ProcessHandler aHandler = new ProcessHandler(sCommandArray);
+ boolean bBackValue = aHandler.executeSynchronously();
+ assure("There seems to be a problem with ghostscript", bBackValue, true);
+ int nExitCode = aHandler.getExitCode();
+ // ArrayList m_aFileList = new ArrayList();
+
+ // String sJPEGNameSchema = "";
+ if (nExitCode == 0)
+ {
+ // TODO: return a real filename, due to the fact we don't know how much files are created, maybe better to return a list
+ int nPages = countPages(sJPEGNameSchema);
+ if (nPages == 0)
+ {
+ // return only a valid schema name if there at least one page.
+ sJPEGNameSchema = "";
+ assure("Document '" + sPostscriptOrPDFFile + "' doesn't create pages.", false, true);
+ }
+ }
+ else
+ {
+ assure("There seems to be a problem with ghostscript and '" + sPostscriptOrPDFFile + "' exit code: " + nExitCode, false, true);
+ GlobalLogWriter.println("Warning: There seems to be a problem with '" + sGhostscriptEXE + "'...");
+ }
+ // String[] aList = new String[m_aFileList.size()];
+ // aList = (String[])m_aFileList.toArray(aList);
+ return sJPEGNameSchema; // sNewJPEGFilename;
+ }
+
+ public static String getFilenameForJPEGSchema(String _sJPEGSchema, int _nPage)
+ {
+ if (_nPage < 1 || _nPage > 9999)
+ {
+ return "";
+ }
+ final String sFilename = util.utils.replaceAll13(_sJPEGSchema, m_sGS_PageOutput, StringHelper.createValueString(_nPage, 4));
+ return sFilename;
+ }
+
+ /**
+ * Return the number of really exists JPEG files
+ * Give a JPEG Schema which contains something like '%04d' which will be converted by a number between 0001 and 9999 always
+ * with leading '0' (zero)
+ * @param _sJPEGSchema
+ * @return number of really existing pages of a given JPEG schema
+ */
+ public int countPages(String _sJPEGSchema)
+ {
+ int nPages = 0;
+ if (_sJPEGSchema.length() > 0)
+ {
+ // TODO: if there doesn't exists a '%04d' in the schema we will return 9999 which is a little bit wrong here.
+ for (int i=1;i<10000;i++)
+ {
+ String sNewJPEGFilename = getFilenameForJPEGSchema(_sJPEGSchema, i);
+ if (FileHelper.exists(sNewJPEGFilename))
+ {
+ // m_aFileList.add(sNewJPEGFilename); // as long as the files exist, fill the array
+ nPages ++;
+ }
+ else
+ {
+ break; // stop file check
+ }
+ }
+ }
+ return nPages;
+ }
+
+// public static void main(String [] _args)
+// {
+//// DONE: give an index.ini file ok
+//// String args[] = {
+//// "-TimeOut", "3600000",
+//// "-tb", "java_complex",
+//// "-o", "graphical.JPEGCreator",
+//// "-DOC_COMPARATOR_INPUT_PATH", "C:\\CWS\\temp\\output\\index.ini",
+//// "-DOC_COMPARATOR_OUTPUT_PATH", "C:\\CWS\\temp\\output",
+//// "-DOC_COMPARATOR_PRINT_MAX_PAGE", "9999",
+//// "-DOC_COMPARATOR_GFX_OUTPUT_DPI_RESOLUTION", "180",
+//// "-DOC_COMPARATOR_HTML_OUTPUT_PREFIX", "http://so-gfxcmp-lin.germany.sun.com/gfxcmp_ui/cw.php?inifile=",
+////// "-DOC_COMPARATOR_REFERENCE_CREATOR_TYPE", "PDF", /* default: "OOo" */
+////// "-DOC_COMPARATOR_REFERENCE_CREATOR_TYPE", "msoffice", /* default: "OOo" */
+////// "-OFFICE_VIEWABLE", "false",
+//// "-AppExecutionCommand", "\"C:/Programme/sun/staroffice 9/program/soffice.exe\" -norestore -nocrashreport -accept=pipe,name=ll93751;urp;",
+//// "-NoOffice"
+//// };
+//
+//// Done: give a directory, where exist pdf/ps files ok.
+//// Done: inputpath (given file) doesn't exists, ok.
+//// Done: give a ps/pdf file. ok.
+//
+// String args[] = {
+// "-TimeOut", "3600000",
+// "-tb", "java_complex",
+// "-o", "graphical.JPEGCreator",
+// "-DOC_COMPARATOR_INPUT_PATH", "C:\\CWS\\temp\\output\\Names7.odt.pdf",
+// "-DOC_COMPARATOR_OUTPUT_PATH", "C:\\CWS\\temp\\output",
+// "-DOC_COMPARATOR_PRINT_MAX_PAGE", "9999",
+// "-DOC_COMPARATOR_GFX_OUTPUT_DPI_RESOLUTION", "180",
+// "-DOC_COMPARATOR_HTML_OUTPUT_PREFIX", "http://so-gfxcmp-lin.germany.sun.com/gfxcmp_ui/cw.php?inifile=",
+//// "-DOC_COMPARATOR_REFERENCE_CREATOR_TYPE", "PDF", /* default: "OOo" */
+//// "-DOC_COMPARATOR_REFERENCE_CREATOR_TYPE", "msoffice", /* default: "OOo" */
+//// "-OFFICE_VIEWABLE", "false",
+// "-AppExecutionCommand", "\"C:/Programme/sun/staroffice 9/program/soffice.exe\" -norestore -nocrashreport -accept=pipe,name=ll93751;urp;",
+// "-NoOffice"
+// };
+//
+// org.openoffice.Runner.main(args);
+// }
+
+}
diff --git a/qadevOOo/runner/graphical/JPEGEvaluator.java b/qadevOOo/runner/graphical/JPEGEvaluator.java
new file mode 100644
index 000000000000..07b265b62355
--- /dev/null
+++ b/qadevOOo/runner/graphical/JPEGEvaluator.java
@@ -0,0 +1,163 @@
+/*
+ * ************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ * ***********************************************************************
+ */
+
+package graphical;
+
+// import java.io.File;
+
+/**
+ *
+ * @author ll93751
+ */
+public class JPEGEvaluator extends EnhancedComplexTestCase
+{
+ // @Override
+ public String[] getTestMethodNames()
+ {
+ return new String[]{"EvaluateResult"};
+ }
+
+ /**
+ * test function.
+ */
+ public void EvaluateResult()
+ {
+ GlobalLogWriter.set(log);
+ ParameterHelper aParam = new ParameterHelper(param);
+
+ // run through all documents found in Inputpath
+ foreachResultCreateHTML(aParam);
+ }
+
+ public void checkOneFile(String _sDocument, String _sResult, ParameterHelper _aParams) throws OfficeException
+ {
+ // throw new UnsupportedOperationException("Not supported yet.");
+ // int dummy = 0;
+
+ String sBasename = FileHelper.getBasename(_sDocument);
+ String sResultIniFile = _sDocument + ".ini";
+// File aFile = new File(sResultIniFile);
+// assure("Result file doesn't exists " + sResultIniFile, aFile.exists());
+//
+// int good = 0;
+// int bad = 0;
+// int ugly = 0;
+//
+// IniFile aResultIniFile = new IniFile(sResultIniFile);
+// int nPages = aResultIniFile.getIntValue("global", "pages", 0);
+// for (int i=0;i<nPages;i++)
+// {
+// String sCurrentPage = "page" + String.valueOf(i + 1);
+// int nPercent = aResultIniFile.getIntValue(sCurrentPage, "percent", -1);
+// if (nPercent == 0)
+// {
+// good++;
+// }
+// else if (nPercent <= 5)
+// {
+// bad ++;
+// }
+// else
+// {
+// ugly ++;
+// }
+// }
+//
+// assure("Error: document doesn't contains pages", nPages > 0);
+
+ HTMLResult aOutputter = new HTMLResult(_sResult, sBasename + ".html" );
+ aOutputter.header(_sResult);
+ aOutputter.indexSection(sBasename);
+
+ IniFile aResultIniFile = new IniFile(sResultIniFile);
+ String sStatusRunThrough = aResultIniFile.getValue("global", "state");
+ String sStatusMessage = aResultIniFile.getValue("global", "info");
+
+// // TODO: this information has to come out of the ini files
+// String sStatusRunThrough = "PASSED, ";
+// String sPassed = "OK";
+//
+// String sStatusMessage = "From " + nPages + " page(s) are: ";
+// String sGood = "";
+// String sBad = "";
+// String sUgly = "";
+//
+// if (good > 0)
+// {
+// sGood = " good:=" + good;
+// sStatusMessage += sGood;
+// }
+// if (bad > 0)
+// {
+// sBad = " bad:=" + bad;
+// sStatusMessage += sBad;
+// }
+// if (ugly > 0)
+// {
+// sUgly = " ugly:=" + ugly;
+// sStatusMessage += sUgly;
+// }
+//
+// // Failure matrix
+// // 0 1
+// // ugly OK FAILED
+// // bad OK
+// // good OK
+//
+// if (ugly > 0)
+// {
+// sPassed = "FAILED";
+// }
+// else
+// {
+// if (bad > 0)
+// {
+// sPassed = "NEED A LOOK";
+// }
+// else
+// {
+// sPassed = "OK";
+// }
+// }
+// sStatusRunThrough += sPassed;
+// aResultIniFile.insertValue("global", "state", sStatusRunThrough);
+// aResultIniFile.insertValue("global", "info", sStatusMessage);
+// aResultIniFile.close();
+
+ String sHTMLFile = _aParams.getHTMLPrefix(); // "http://so-gfxcmp-lin/gfxcmp_ui/cw.php?inifile=";
+ sHTMLFile += _sDocument + ".ini";
+ aOutputter.indexLine(sHTMLFile, sBasename, sStatusRunThrough, sStatusMessage);
+ aOutputter.close();
+ // IniFile aIniFile = new IniFile(_sDocument);
+ // aIniFile.
+
+ }
+
+
+}
diff --git a/qadevOOo/runner/graphical/MSOfficePostscriptCreator.java b/qadevOOo/runner/graphical/MSOfficePostscriptCreator.java
new file mode 100644
index 000000000000..86eb28143ed2
--- /dev/null
+++ b/qadevOOo/runner/graphical/MSOfficePostscriptCreator.java
@@ -0,0 +1,1004 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package graphical;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.RandomAccessFile;
+import helper.ProcessHandler;
+import java.util.ArrayList;
+import helper.OSHelper;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+
+/**
+ * This object gives all functionallity to print msoffice documents.
+ * It also offers functions to check what type of document it is.
+ * It handles *.doc as word documents and use word to print
+ * *.xls as excel
+ * *.ppt as powerpoint
+ */
+
+//class ProcessHelper
+//{
+// ArrayList m_aArray;
+//}
+
+public class MSOfficePostscriptCreator implements IOffice
+{
+ private String m_sPrinterName; // within Windows the tools need a printer name;
+
+ public void setPrinterName(String _s)
+ {
+ m_sPrinterName = _s;
+ }
+
+ private ParameterHelper m_aParameterHelper;
+ private String m_sDocumentName;
+ private String m_sResult;
+
+ // CTor
+ public MSOfficePostscriptCreator(ParameterHelper _aParam, String _sResult)
+ {
+ m_aParameterHelper = _aParam;
+ m_sResult = _sResult;
+// String sKillCommand = (String)_aParam.getTestParameters().get(util.PropertyName.APP_KILL_COMMAND);
+// if (sKillCommand == null)
+// {
+// sKillCommand = "";
+// }
+// if (sKillCommand.length() > 0)
+// {
+// sKillCommand += ";";
+// }
+ String sKillCommand = "C:/bin/kill.exe -9 winword;C:/bin/kill.exe -9 excel";
+ _aParam.getTestParameters().put(util.PropertyName.APP_KILL_COMMAND, sKillCommand);
+ }
+
+ public void load(String _sDocumentName) throws OfficeException
+ {
+ m_sDocumentName = _sDocumentName;
+
+ if (! isMSOfficeDocumentFormat(m_sDocumentName))
+ {
+ GlobalLogWriter.println("This document type is not recognized as MSOffice format, as default fallback StarOffice/OpenOffice.org instead is used.");
+ throw new OfficeException("This document type is not recognized as MSOffice format, as default fallback StarOffice/OpenOffice.org instead is used.");
+ }
+ }
+
+ public void storeAsPostscript() throws OfficeException
+ {
+ GlobalLogWriter.println("USE MSOFFICE AS EXPORT FORMAT.");
+ try
+ {
+ String sDocumentName = m_sDocumentName + ".ps";
+ printToFileWithMSOffice(m_aParameterHelper,
+ m_sDocumentName,
+ m_sResult);
+ File aFile = new File(sDocumentName);
+ if (aFile.exists())
+ {
+ String sBasename = FileHelper.getBasename(sDocumentName);
+ FileHelper.addBasenameToIndex(m_sResult, sBasename, "msoffice", "postscript", m_sDocumentName);
+ }
+ }
+ catch(OfficeException e)
+ {
+ e.printStackTrace();
+ GlobalLogWriter.println(e.getMessage());
+ throw new OfficeException("Exception caught. Problem with MSOffice printer methods.");
+ }
+ catch(java.io.IOException e)
+ {
+ GlobalLogWriter.println(e.getMessage());
+ throw new OfficeException("IOException caught. Problem with MSOffice printer methods.");
+ }
+ }
+
+ public void start() throws OfficeException
+ {
+ // we don't have an office to start
+ }
+
+ public void close() throws OfficeException
+ {
+ // we don't have an office to stop
+ }
+
+ // -----------------------------------------------------------------------------
+ private boolean isWordDocument(String _sSuffix)
+ {
+ if (_sSuffix.toLowerCase().endsWith(".doc") ||
+ _sSuffix.toLowerCase().endsWith(".rtf") ||
+ _sSuffix.toLowerCase().endsWith(".dot"))
+ {
+ return true;
+ }
+ return false;
+ }
+
+ private boolean isExcelDocument(String _sSuffix)
+ {
+ // xlt templates
+ // xlw
+ // xla addin
+ if (_sSuffix.toLowerCase().endsWith(".xls"))
+ {
+ return true;
+ }
+ /* temporal insertion by SUS
+ if (_sSuffix.endsWith(".xml"))
+ {
+ return true;
+ }*/
+ return false;
+ }
+
+ private boolean isPowerPointDocument(String _sSuffix)
+ {
+ if (_sSuffix.toLowerCase().endsWith(".pps") ||
+ _sSuffix.toLowerCase().endsWith(".ppt"))
+ {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * returns true, if the given filename has a MS Office suffix.
+ */
+ private boolean isMSOfficeDocumentFormat(String _sFile)
+ {
+ String sDocumentSuffix = FileHelper.getSuffix(_sFile);
+ if (isWordDocument(sDocumentSuffix)) {return true;}
+ if (isExcelDocument(sDocumentSuffix)) {return true;}
+ if (isPowerPointDocument(sDocumentSuffix)) {return true;}
+ // if suffix is xml, return also true, but we can't decide if word or excel
+ if (sDocumentSuffix.toLowerCase().endsWith(".xml")) {return true;}
+ return false;
+ }
+
+ public void storeToFileWithMSOffice( ParameterHelper _aGTA,
+ String _sInputFile,
+ String _sOutputFile) throws OfficeException, java.io.IOException
+ {
+ String sDocumentSuffix = FileHelper.getSuffix(_sInputFile);
+ String sFilterName = _aGTA.getExportFilterName();
+ ArrayList<String> aStartCommand = new ArrayList<String>();
+ if (isWordDocument(sDocumentSuffix))
+ {
+ aStartCommand = createWordStoreHelper();
+ }
+ else if (isExcelDocument(sDocumentSuffix))
+ {
+ aStartCommand = createExcelStoreHelper();
+ }
+ else if (isPowerPointDocument(sDocumentSuffix))
+ {
+ }
+ else if (sDocumentSuffix.toLowerCase().equals(".xml"))
+ {
+ // special case, if xml we prefer word, but with DEFAULT_XML_FORMAT_APP=excel it's changeable.
+ String sDocFormat = getXMLDocumentFormat(_sInputFile);
+ // if (_aGTA.getDefaultXMLFormatApp().toLowerCase().equals("excel"))
+ if (sDocFormat.equals("excel"))
+ {
+ aStartCommand = createExcelStoreHelper();
+ }
+ else
+ {
+ aStartCommand = createWordStoreHelper();
+ }
+ // else
+ // {
+ // }
+ }
+ else
+ {
+ GlobalLogWriter.println("No Microsoft Office document format found.");
+
+ throw new WrongSuffixException("No MS office document format found.");
+ }
+ if (aStartCommand != null)
+ {
+ if (sFilterName == null)
+ {
+// TODO: hardcoded FilterName in perl script
+ sFilterName = ""; // xlXMLSpreadsheet";
+ }
+
+ // String sCommand = sStartCommand + " " +
+ // _sInputFile + " " +
+ // StringHelper.doubleQuote(sFilterName) + " " +
+ // _sOutputFile;
+
+ aStartCommand.add(_sInputFile);
+ aStartCommand.add(sFilterName);
+ aStartCommand.add(_sOutputFile);
+ realStartCommand(aStartCommand);
+ }
+ }
+
+ // -----------------------------------------------------------------------------
+ /**
+ * print the given file (_sInputFile) to the file name (_sPrintFile)
+ * @param _aGTA
+ * @param _sInputFile
+ * @param _sPrintFilename
+ * @throws OfficeException
+ * @throws java.io.IOException
+ */
+ public void printToFileWithMSOffice( ParameterHelper _aGTA,
+ String _sInputFile,
+ String _sPrintFilename) throws OfficeException, java.io.IOException
+ {
+ String sDocumentSuffix = FileHelper.getSuffix(_sInputFile);
+
+ setPrinterName(_aGTA.getPrinterName());
+
+ ArrayList<String> aStartCommand = new ArrayList<String>();
+ if (isWordDocument(sDocumentSuffix))
+ {
+ aStartCommand = createWordPrintHelper();
+ }
+ else if (isExcelDocument(sDocumentSuffix))
+ {
+ aStartCommand = createExcelPrintHelper();
+ }
+ else if (isPowerPointDocument(sDocumentSuffix))
+ {
+ aStartCommand = createPowerPointPrintHelper();
+ }
+ else if (sDocumentSuffix.toLowerCase().equals(".xml"))
+ {
+// TODO: Open XML File and check if we need excel or word
+ String sOfficeType = getOfficeType(_sInputFile);
+
+ // special case, if xml we prefer word, but with DEFAULT_XML_FORMAT_APP=excel it's changeable.
+ // if (_aGTA.getDefaultXMLFormatApp().toLowerCase().equals("excel"))
+ if (sOfficeType.equals("excel"))
+ {
+ aStartCommand = createExcelPrintHelper();
+ }
+ else if (sOfficeType.equals("word"))
+ {
+ aStartCommand = createWordPrintHelper();
+ }
+ else
+ {
+ return;
+ }
+ }
+ else
+ {
+ GlobalLogWriter.println("No Microsoft Office document format found.");
+// TODO: use a better Exception!!!
+ throw new WrongSuffixException("No Mircosoft Office document format found.");
+ }
+
+ if (aStartCommand.isEmpty() == false)
+ {
+ String sPrinterName = m_sPrinterName;
+ if (sPrinterName == null)
+ {
+ sPrinterName = "";
+ }
+
+ // String sCommand = sStartCommand + " " +
+ // _sInputFile + " " +
+ // StringHelper.doubleQuote(m_sPrinterName) + " " +
+ // _sPrintFilename;
+ aStartCommand.add(_sInputFile);
+ aStartCommand.add(m_sPrinterName);
+ aStartCommand.add(_sPrintFilename);
+
+ realStartCommand(aStartCommand);
+ }
+ String sUserDir = System.getProperty("user.home");
+ _aGTA.getPerformance().readWordValuesFromFile(FileHelper.appendPath(sUserDir, "msofficeloadtimes.txt"));
+ FileHelper.createInfoFile(_sPrintFilename, _aGTA, "msoffice");
+ TimeHelper.waitInSeconds(2, "Give Microsoft Office some time to print.");
+ }
+
+ public void realStartCommand(ArrayList _aStartCommand) throws OfficeException
+ {
+ if (_aStartCommand.isEmpty())
+ {
+ throw new OfficeException/*WrongEnvironmentException*/("Given list is empty.");
+ }
+
+ try
+ {
+ // Convert the StartCommand ArrayList to a String List
+ int nValues = _aStartCommand.size();
+ String[] aList = new String[nValues];
+ for (int i=0;i<nValues;i++)
+ {
+ String aStr = (String) _aStartCommand.get(i);
+ if (aStr == null)
+ {
+ aStr = "";
+ }
+ if (aStr.length() == 0)
+ {
+ aStr = "\"\"";
+ }
+ aList[i] = new String(aStr);
+ }
+
+ // This is really the latest point where we can check if we are running within windows environment
+ if (! OSHelper.isWindows())
+ {
+ // TODO: use a better Exception!!!
+ throw new WrongEnvironmentException("We doesn't work within windows environment.");
+ }
+
+
+ ProcessHandler aHandler = new ProcessHandler(aList);
+ boolean bBackValue = aHandler.executeSynchronously();
+ }
+ catch (IndexOutOfBoundsException e)
+ {
+ throw new WrongEnvironmentException("Given list is too short.");
+ }
+
+ // return aHandler.getExitCode();
+ }
+
+
+ private String getPerlExe()
+ {
+ final String sPerlExe = System.getProperty("perl.exe", "perl");
+ return sPerlExe;
+ }
+
+ ArrayList<String> createWordPrintHelper() throws java.io.IOException
+ {
+ // create a program in tmp file
+ String sTmpPath = util.utils.getUsersTempDir();
+ String ls = System.getProperty("line.separator");
+
+ String sPrintViaWord = "printViaWord.pl";
+
+ ArrayList<String> aList = searchLocalFile(sPrintViaWord);
+ if (aList.isEmpty() == false)
+ {
+ return aList;
+ }
+
+ String sFileName = FileHelper.appendPath(sTmpPath, sPrintViaWord);
+ File aFile = new File(sFileName);
+ FileWriter out = new FileWriter(aFile);
+
+
+ out.write( "eval 'exec perl -wS $0 ${1+\"$@\"}' " + ls );
+ out.write( " if 0; " + ls );
+ out.write( "use strict; " + ls );
+ out.write( "use Time::HiRes; " + ls );
+ out.write( "if ( $^O ne \"MSWin32\") " + ls );
+ out.write( "{ " + ls );
+ out.write( " print 'Windows only.\\n'; " + ls );
+ out.write( " print_usage(); " + ls );
+ out.write( " exit(1); " + ls );
+ out.write( "} " + ls );
+ out.write( " " + ls );
+ out.write( "use Win32::OLE; " + ls );
+ out.write( "use Win32::OLE::Const 'Microsoft Word'; " + ls );
+ out.write( " " + ls );
+ out.write( "# ------ usage ------ " + ls );
+ out.write( "sub print_usage() " + ls );
+ out.write( "{ " + ls );
+ out.write( " print STDERR \"Usage: word_print.pl <Word file> <name of printer> <output file> .\\n " + ls );
+ out.write( " Please use the same string for the name of the printer as you can find \\n " + ls );
+ out.write( " under Start-Control Panel-Printer and Faxes \\n " + ls );
+ out.write( " The name could look like the the following line: \\n " + ls );
+ out.write( " Apple LaserWriter II NT v47.0 \\n " + ls );
+ out.write( " Sample command line: \\n " + ls );
+ out.write( " execl_print.pl c:\\book1.doc Apple LaserWriter II NT v47.0 c:\\output\\book1.ps \\n\"; " + ls );
+ out.write( "} " + ls );
+ out.write( " " + ls );
+ out.write( " " + ls );
+ out.write( "if ($#ARGV != 2) " + ls );
+ out.write( "{ " + ls );
+ out.write( " print 'Too less arguments.\\n'; " + ls );
+ out.write( " print_usage(); " + ls );
+ out.write( " exit(1); " + ls );
+ out.write( "} " + ls );
+ out.write( " " + ls );
+ out.write( "my $startWordTime = Time::HiRes::time(); " + ls );
+ out.write( "my $Word = Win32::OLE->new('Word.Application'); " + ls );
+ out.write( "my $stopWordTime = Time::HiRes::time() - $startWordTime; " + ls );
+ out.write( "# $Word->{'Visible'} = 1; # if you want to see what's going on " + ls );
+ out.write( "# , ReadOnly => 1})" + ls );
+ out.write(ls);
+ out.write( "my $startLoadWordTime = Time::HiRes::time(); " + ls );
+ out.write( "$Word->Documents->Open({Filename => $ARGV[0]}) " + ls );
+ out.write( " || die('Unable to open document ', Win32::OLE->LastError()); " + ls );
+ out.write( "my $stopLoadWordTime = Time::HiRes::time() - $startLoadWordTime; " + ls );
+ out.write(ls);
+ out.write( "my $startPrintWordTime = Time::HiRes::time(); " + ls);
+ out.write( "my $oldActivePrinte = $Word->{ActivePrinter} ; " + ls );
+ out.write( "$Word->{ActivePrinter} = $ARGV[1]; " + ls );
+ out.write( "$Word->ActiveDocument->PrintOut({ " + ls );
+ out.write( " Background => 0, " + ls );
+ out.write( " Append => 0, " + ls );
+ out.write( " Range => wdPrintAllDocument, " + ls );
+ out.write( " Item => wdPrintDocumentContent, " + ls );
+ out.write( " Copies => 1, " + ls );
+ out.write( " PageType => wdPrintAllPages, " + ls );
+ out.write( " PrintToFile => 1, " + ls );
+ out.write( " OutputFileName => $ARGV[2] " + ls );
+ out.write( " }); " + ls );
+ out.write( "$Word->{ActivePrinter} = $oldActivePrinte; " + ls );
+ out.write( "my $stopPrintWordTime = Time::HiRes::time() - $startPrintWordTime;" + ls);
+
+ out.write( "# ActiveDocument.Close(SaveChanges:=WdSaveOptions.wdDoNotSaveChanges)" + ls );
+ out.write( "my $sVersion = $Word->Application->Version();"+ls);
+ out.write( "$Word->ActiveDocument->Close({SaveChanges => 0}); " + ls );
+ out.write( "$Word->Quit(); " + ls );
+
+ out.write( "local *FILE;" + ls);
+ out.write( "if (open(FILE, \">$ENV{HOME}/msofficeloadtimes.txt\"))" + ls);
+ out.write( "{" + ls);
+ out.write( " print FILE \"name=$ARGV[0]\\n\";" + ls);
+ out.write( " print FILE \"WordVersion=$sVersion\\n\";" + ls);
+ out.write( " print FILE \"WordStartTime=$stopWordTime\\n\";" + ls);
+ out.write( " print FILE \"WordLoadTime=$stopLoadWordTime\\n\";" + ls);
+ out.write( " print FILE \"WordPrintTime=$stopPrintWordTime\\n\";" + ls);
+ out.write( " close(FILE);" + ls);
+ out.write( "}" + ls);
+ out.close();
+
+ aList.add(getPerlExe());
+ aList.add(sFileName);
+ return aList;
+ }
+
+ // TODO: Maybe give a possibility to say where search the script from outside
+
+ ArrayList<String> searchLocalFile(String _sScriptName)
+ {
+ String userdir = System.getProperty("user.dir");
+
+ ArrayList<String> aList = new ArrayList<String>();
+ String sFileName = FileHelper.appendPath(userdir, _sScriptName);
+ File aPerlScript = new File(sFileName);
+ if (FileHelper.isDebugEnabled())
+ {
+ GlobalLogWriter.println("Search for local existance of " + aPerlScript.getAbsolutePath());
+ }
+
+ if (aPerlScript.exists())
+ {
+ if (FileHelper.isDebugEnabled())
+ {
+ GlobalLogWriter.println("OK, found it, use this instead the internal one.");
+ }
+
+ String sName = aPerlScript.getAbsolutePath();
+ // String sCommand = "perl " + sName;
+ // System.out.println(sCommand);
+ aList.add("perl");
+ aList.add(sName);
+ return aList;
+ }
+ return aList;
+ }
+
+ ArrayList<String> createWordStoreHelper() throws java.io.IOException
+ {
+ // create a program in tmp file
+ String sTmpPath = util.utils.getUsersTempDir();
+ String ls = System.getProperty("line.separator");
+
+ // ArrayList aList = new ArrayList();
+ String sSaveViaWord = "saveViaWord.pl";
+
+ ArrayList<String> aList = searchLocalFile(sSaveViaWord);
+ if (aList.isEmpty() == false)
+ {
+ return aList;
+ }
+
+ String sName = FileHelper.appendPath(sTmpPath, sSaveViaWord);
+ if (FileHelper.isDebugEnabled())
+ {
+ GlobalLogWriter.println("No local found, create a perl script: " + sName);
+ }
+
+ File aFile = new File(sName);
+ FileWriter out = new FileWriter(aFile);
+
+ out.write( "eval 'exec perl -wS $0 ${1+\"$@\"}' " + ls );
+ out.write( " if 0; " + ls );
+ out.write( "use strict; " + ls );
+ out.write( " " + ls );
+ out.write( "if ( $^O ne \"MSWin32\") " + ls );
+ out.write( "{ " + ls );
+ out.write( " print 'Windows only.\\n'; " + ls );
+ out.write( " print_usage(); " + ls );
+ out.write( " exit(1); " + ls );
+ out.write( "} " + ls );
+ out.write( " " + ls );
+ out.write( "use Win32::OLE; " + ls );
+ out.write( "use Win32::OLE::Const 'Microsoft Word'; " + ls );
+ out.write( " " + ls );
+ out.write( "# ------ usage ------ " + ls );
+ out.write( "sub print_usage() " + ls );
+ out.write( "{ " + ls );
+ out.write( " print STDERR \"Usage: storeViaWord.pl <Word file> <output filer> <output file> \\n\" " + ls );
+ out.write( "} " + ls );
+ out.write( " " + ls );
+ out.write( " " + ls );
+ out.write( "if ($#ARGV != 2) " + ls );
+ out.write( "{ " + ls );
+ out.write( " print 'Too less arguments.\\n'; " + ls );
+ out.write( " print_usage(); " + ls );
+ out.write( " exit(1); " + ls );
+ out.write( "} " + ls );
+ out.write( " " + ls );
+ out.write( " " + ls );
+ out.write( "my $Word = Win32::OLE->new('Word.Application'); " + ls );
+ out.write( "# $Word->{'Visible'} = 1; # if you want to see what's going on " + ls );
+ out.write( "my $Book = $Word->Documents->Open($ARGV[0]) " + ls );
+ out.write( " || die('Unable to open document ', Win32::OLE->LastError()); " + ls );
+ out.write( "# my $oldActivePrinte = $Word->{ActivePrinter} ; " + ls );
+ out.write( "# $Word->{ActivePrinter} = $ARGV[1]; " + ls );
+ out.write( "# $Word->ActiveDocument->PrintOut({ " + ls );
+ out.write( "# Background => 0, " + ls );
+ out.write( "# Append => 0, " + ls );
+ out.write( "# Range => wdPrintAllDocument, " + ls );
+ out.write( "# Item => wdPrintDocumentContent, " + ls );
+ out.write( "# Copies => 1, " + ls );
+ out.write( "# PageType => wdPrintAllPages, " + ls );
+ out.write( "# PrintToFile => 1, " + ls );
+ out.write( "# OutputFileName => $ARGV[2] " + ls );
+ out.write( "# }); " + ls );
+ out.write( "# $Word->{ActivePrinter} = $oldActivePrinte; " + ls );
+ out.write( "$Book->savaAs($ARGV[2], $ARGV[1]); " + ls );
+ out.write( "# ActiveDocument.Close(SaveChanges:=WdSaveOptions.wdDoNotSaveChanges)" + ls );
+ out.write( "$Book->Close({SaveChanges => 0}); " + ls );
+ out.write( "$Word->Quit(); " + ls );
+ out.close();
+
+ aList.add(getPerlExe());
+ aList.add(sName);
+ return aList;
+ }
+
+
+ ArrayList<String> createExcelPrintHelper() throws java.io.IOException
+ {
+ // create a program in tmp file
+ String sTmpPath = util.utils.getUsersTempDir();
+ String ls = System.getProperty("line.separator");
+
+ String sPrintViaExcel = "printViaExcel.pl";
+
+ ArrayList<String> aList = searchLocalFile(sPrintViaExcel);
+ if (aList.isEmpty() == false)
+ {
+ return aList;
+ }
+ String sName = FileHelper.appendPath(sTmpPath, sPrintViaExcel);
+ if (FileHelper.isDebugEnabled())
+ {
+ GlobalLogWriter.println("No local found, create a perl script: " + sName);
+ }
+
+ File aFile = new File(sName);
+ FileWriter out = new FileWriter(aFile);
+
+ // out.write( "eval 'exec perl -wS $0 ${1+\"$@\"}' " + ls );
+ // out.write( " if 0; " + ls );
+ out.write("#BEGIN" + ls);
+ out.write("#{" + ls);
+ out.write("#" + ls);
+ out.write("# # insert HACK" + ls);
+ out.write("# unshift(@INC, '');" + ls);
+ out.write("#}" + ls);
+ out.write( "use strict; " + ls );
+ out.write( " " + ls );
+ out.write( "if ( $^O ne \"MSWin32\") " + ls );
+ out.write( "{ " + ls );
+ out.write( " print \"Windows only.\\n\"; " + ls );
+ out.write( " print_usage(); " + ls );
+ out.write( " exit(1); " + ls );
+ out.write( "} " + ls );
+ out.write( " " + ls );
+ out.write( " " + ls );
+ out.write( "use Win32::OLE qw(in with); " + ls );
+ out.write( "use Win32::OLE::Const 'Microsoft Excel'; " + ls );
+ out.write( " " + ls );
+ out.write( "# ------ usage ------ " + ls );
+ out.write( "sub print_usage() " + ls );
+ out.write( "{ " + ls );
+ out.write( " print STDERR \"Usage: printViaExcel.pl <Excel file> <name of printer> <output file> .\\n " + ls );
+ out.write( " Please use the same string for the name of the printer as you can find \\n " + ls );
+ out.write( " under Start-Control Panel-Printer and Faxes \\n " + ls );
+ out.write( " The name could look like the the following line: \\n " + ls );
+ out.write( " Apple LaserWriter II NT v47.0 \\n " + ls );
+ out.write( " Sample command line: \\n " + ls );
+ out.write( " execl_print.pl c:\\book1.xls Apple LaserWriter II NT v47.0 c:\\output\\book1.ps \\n\"; " + ls );
+ out.write( "} " + ls );
+ out.write( " " + ls );
+ out.write( " " + ls );
+ out.write( " " + ls );
+ out.write( "$Win32::OLE::Warn = 3; # die on errors... " + ls );
+ out.write( " " + ls );
+ out.write( " " + ls );
+ out.write( "if ($#ARGV != 2) " + ls );
+ out.write( "{ " + ls );
+ out.write( " print STDERR \"Too less arguments.\\n\"; " + ls );
+ out.write( " print STDERR \"ARGV[0] $ARGV[0]\\n\"; " + ls );
+ out.write( " print STDERR \"ARGV[1] $ARGV[1]\\n\"; " + ls );
+ out.write( " print STDERR \"ARGV[2] $ARGV[2]\\n\"; " + ls );
+ out.write( " print_usage(); " + ls );
+ out.write( " exit(1); " + ls );
+ out.write( "} " + ls );
+ out.write( " " + ls );
+ out.write( "my $Excel = Win32::OLE->GetActiveObject('Excel.Application') " + ls );
+ out.write( " || Win32::OLE->new('Excel.Application', 'Quit'); # get already active Excel " + ls );
+ out.write( " # application or open new " + ls );
+ out.write( " " + ls );
+ out.write( " " + ls );
+ out.write( " " + ls );
+ out.write( "my $Book = $Excel->Workbooks->Open( $ARGV[0] ); " + ls );
+ out.write( " $Book->PrintOut({Copies => 1, " + ls );
+ out.write( " ActivePrinter => $ARGV[1], " + ls );
+ out.write( " PrToFileName => $ARGV[2], " + ls );
+ out.write( " Collate => 1 " + ls );
+ out.write( " }); " + ls );
+ out.write( "# Close worksheets without store changes" + ls );
+ out.write( "# $Book->Close({SaveChanges => 0}); " + ls );
+ out.write( "my $sVersion = $Excel->Application->Version();"+ls);
+ out.write( "$Excel->Quit(); " + ls );
+ out.write( "local *FILE;" + ls);
+ out.write( "if (open(FILE, \">$ENV{HOME}/msofficeloadtimes.txt\"))" + ls);
+ out.write( "{" + ls);
+ out.write( " print FILE \"name=$ARGV[0]\\n\";" + ls);
+ out.write( " print FILE \"ExcelVersion=$sVersion\\n\";" + ls);
+// out.write( " print FILE \"WordStartTime=$stopWordTime\\n\";" + ls);
+// out.write( " print FILE \"WordLoadTime=$stopLoadWordTime\\n\";" + ls);
+// out.write( " print FILE \"WordPrintTime=$stopPrintWordTime\\n\";" + ls);
+ out.write( " close(FILE);" + ls);
+ out.write( "}" + ls);
+ out.close();
+
+ aList.add(getPerlExe());
+ aList.add(sName);
+ return aList;
+ }
+
+ ArrayList<String> createExcelStoreHelper() throws java.io.IOException
+ {
+ // create a program in tmp file
+ String sTmpPath = util.utils.getUsersTempDir();
+ String ls = System.getProperty("line.separator");
+
+ String sSaveViaExcel = "saveViaExcel.pl";
+
+ ArrayList<String> aList = searchLocalFile(sSaveViaExcel);
+ if (aList.isEmpty() == false)
+ {
+ return aList;
+ }
+ String sName = FileHelper.appendPath(sTmpPath, sSaveViaExcel);
+ if (FileHelper.isDebugEnabled())
+ {
+ GlobalLogWriter.println("No local found, create a script: " + sName);
+ }
+
+ File aFile = new File(sName);
+ FileWriter out = new FileWriter(aFile);
+
+ out.write( "eval 'exec perl -wS $0 ${1+\"$@\"}' " + ls );
+ out.write( " if 0; " + ls );
+ out.write( "use strict; " + ls );
+ out.write( "# This script is automatically created. " + ls );
+ out.write( " " + ls );
+ out.write( "use Win32::OLE qw(in with); " + ls );
+ out.write( "use Win32::OLE::Const 'Microsoft Excel'; " + ls );
+ out.write( " " + ls );
+ out.write( "# ------ usage ------ " + ls );
+ out.write( "sub print_usage() " + ls );
+ out.write( "{ " + ls );
+ out.write( " print STDERR \"Usage: savaViaExcel.pl <Excel file> <filefilter> <output file> .\\n " + ls );
+ out.write( " execl_print.pl c:\\book1.xls Apple LaserWriter II NT v47.0 c:\\output\\book1.ps \\n\"; " + ls );
+ out.write( "} " + ls );
+ out.write( " " + ls );
+ out.write( " " + ls );
+ out.write( " " + ls );
+ out.write( "$Win32::OLE::Warn = 3; # die on errors... " + ls );
+ out.write( " " + ls );
+ out.write( " " + ls );
+ out.write( "if ($#ARGV != 2) " + ls );
+ out.write( "{ " + ls );
+ out.write( " print \"Too less arguments.\\n\"; " + ls );
+ out.write( " print_usage(); " + ls );
+ out.write( " exit(1); " + ls );
+ out.write( "} " + ls );
+ out.write( " " + ls );
+ out.write( "my $Excel = Win32::OLE->GetActiveObject('Excel.Application') " + ls );
+ out.write( " || Win32::OLE->new('Excel.Application', 'Quit'); # get already active Excel " + ls );
+ out.write( " # application or open new " + ls );
+ out.write( "my $sFilterParameter = $ARGV[1]; " + ls );
+ out.write( "my $sFilterName = xlHTML; " + ls );
+ out.write( "if ($sFilterParameter eq 'xlXMLSpreadsheet') " + ls );
+ out.write( "{ " + ls );
+ out.write( " $sFilterName = xlXMLSpreadsheet; " + ls );
+ out.write( "} " + ls );
+ out.write( "elsif ($sFilterParameter eq 'xlHTML') " + ls );
+ out.write( "{ " + ls );
+ out.write( " $sFilterName = xlHTML; " + ls );
+ out.write( "} " + ls );
+ out.write( "else " + ls );
+ out.write( "{ " + ls );
+ out.write( " my $undefined; " + ls);
+ out.write( " $sFilterName = $undefined; " + ls );
+ out.write( "} " + ls );
+ out.write( " " + ls );
+ out.write( "my $Book = $Excel->Workbooks->Open( $ARGV[0] ); " + ls );
+ out.write( "$Excel->{DisplayAlerts} = 0; " + ls );
+ out.write( "$Book->saveAs($ARGV[2], " + ls );
+ out.write( " $sFilterName, " + ls );
+ out.write( " '', " + ls );
+ out.write( " '', " + ls );
+ out.write( " 0, " + ls );
+ out.write( " 0, " + ls );
+ out.write( " xlNoChange, " + ls );
+ out.write( " xlLocalSessionChanges, " + ls );
+ out.write( " 1); " + ls );
+ out.write( "# Close worksheets without store changes" + ls );
+ out.write( "# $Book->Close({SaveChanges => 0}); " + ls );
+ out.write( "$Excel->Quit(); " + ls );
+ out.close();
+
+ aList.add(getPerlExe());
+ aList.add(sName);
+ return aList;
+ }
+
+ ArrayList<String> createPowerPointPrintHelper() throws java.io.IOException
+ {
+ // create a program in tmp file
+ String sTmpPath = util.utils.getUsersTempDir();
+ String ls = System.getProperty("line.separator");
+
+ String sPrintViaPowerPoint = "printViaPowerPoint.pl";
+
+ ArrayList<String> aList = searchLocalFile(sPrintViaPowerPoint);
+ if (aList.isEmpty() == false)
+ {
+ return aList;
+ }
+ String sName = FileHelper.appendPath(sTmpPath, sPrintViaPowerPoint);
+ if (FileHelper.isDebugEnabled())
+ {
+ GlobalLogWriter.println("No local found, create a script: " + sName);
+ }
+
+ File aFile = new File(sName);
+ FileWriter out = new FileWriter(aFile);
+
+
+ out.write( "eval 'exec perl -wS $0 $1 $2 ' " + ls );
+ out.write( " if 0; " + ls );
+ out.write( "use strict; " + ls );
+ out.write( " " + ls );
+ out.write( "if ( $^O ne \"MSWin32\") " + ls );
+ out.write( "{ " + ls );
+ out.write( " print \"Windows only.\\n\"; " + ls );
+ out.write( " print_usage(); " + ls );
+ out.write( " exit(1); " + ls );
+ out.write( "} " + ls );
+ out.write( " " + ls );
+ out.write( " " + ls );
+ out.write( "use Win32::OLE qw(in with); " + ls );
+ out.write( "use Win32::OLE::Const 'Microsoft PowerPoint'; " + ls );
+ out.write( " " + ls );
+ out.write( "# ------ usage ------ " + ls );
+ out.write( "sub print_usage() " + ls );
+ out.write( "{ " + ls );
+ out.write( " print STDERR \"Usage: powerpoint_print.pl <PowerPoint file> <name of printer> <output file> .\\n " + ls );
+ out.write( " Please use the same string for the name of the printer as you can find \\n " + ls );
+ out.write( " under Start-Control Panel-Printer and Faxes \\n " + ls );
+ out.write( " The name could look like the the following line: \\n " + ls );
+ out.write( " Apple LaserWriter II NT v47.0 \\n " + ls );
+ out.write( " Sample command line: \\n " + ls );
+ out.write( " powerpoint_print.pl c:\\book.ppt Apple LaserWriter II NT v47.0 c:\\output\\book.ps \\n\"; " + ls );
+ out.write( "} " + ls );
+ out.write( " " + ls );
+ out.write( " " + ls );
+ out.write( " " + ls );
+ out.write( "$Win32::OLE::Warn = 3; # die on errors... " + ls );
+ out.write( " " + ls );
+ out.write( " " + ls );
+ out.write( "if ($#ARGV < 2) " + ls );
+ out.write( "{ " + ls );
+ out.write( " print \"Too less arguments.\\n\"; " + ls );
+ out.write( " print_usage(); " + ls );
+ out.write( " exit(1); " + ls );
+ out.write( "} " + ls );
+ out.write( " " + ls );
+ out.write( "my $PowerPoint = Win32::OLE->GetActiveObject('PowerPoint.Application') " + ls );
+ out.write( " || Win32::OLE->new('PowerPoint.Application', 'Quit'); # get already active Excel " + ls );
+ out.write( " # application or open new " + ls );
+ out.write( " " + ls );
+ out.write( " " + ls );
+ out.write( " " + ls );
+ out.write( " $PowerPoint->{'Visible'} = 1; " + ls );
+ out.write( " my $Presentation = $PowerPoint->Presentations->Add; " + ls );
+ out.write( " my $Presentation = $PowerPoint->Presentations->Open( $ARGV[0] ); " + ls );
+ out.write( "# we can't change active printer in powerpoint " + ls );
+ out.write( "# $Presentation->PrintOptions->{ActivePrinter} = $ARGV[1]; " + ls );
+ out.write( " print \"Active printer is: \" . $Presentation->PrintOptions->{ActivePrinter} . \"\\n\"; " + ls );
+ out.write( " $Presentation->PrintOptions->{PrintInBackground} = 0; " + ls );
+ out.write( " # PrintColorType = 1 means print in color and PrintColorType = 2 means print in gray " + ls );
+ out.write( " $Presentation->PrintOptions->{PrintColorType} = 1; " + ls );
+ out.write( " " + ls );
+ out.write( " $Presentation->PrintOut({PrintToFile => $ARGV[2]}); " + ls );
+ out.write( " sleep 5; " + ls );
+ out.write( " print \"Presentation has been printed\\n\"; " + ls );
+ out.write( "my $sVersion = $Presentation->Application->Version();"+ls);
+ out.write( " $PowerPoint->Quit(); " + ls );
+
+ out.write( "local *FILE;" + ls);
+ out.write( "if (open(FILE, \">$ENV{HOME}/msofficeloadtimes.txt\"))" + ls);
+ out.write( "{" + ls);
+ out.write( " print FILE \"name=$ARGV[0]\\n\";" + ls);
+ out.write( " print FILE \"PowerPointVersion=$sVersion\\n\";" + ls);
+// out.write( " print FILE \"WordStartTime=$stopWordTime\\n\";" + ls);
+// out.write( " print FILE \"WordLoadTime=$stopLoadWordTime\\n\";" + ls);
+// out.write( " print FILE \"WordPrintTime=$stopPrintWordTime\\n\";" + ls);
+ out.write( " close(FILE);" + ls);
+ out.write( "}" + ls);
+ out.close();
+
+ aList.add(getPerlExe());
+ aList.add(sName);
+ return aList;
+ }
+
+ /**
+ @param _sFilename a name to a ms office xml file
+ @return 'word' or 'excel' or '' if type not known
+ */
+ public String getOfficeType(String _sFilename)
+ {
+ File aFile = new File(_sFilename);
+ if (! aFile.exists())
+ {
+ GlobalLogWriter.println("couldn't find file " + _sFilename);
+ return "";
+ }
+ RandomAccessFile aReader = null;
+ String sOfficeType = "";
+ try
+ {
+ aReader = new RandomAccessFile(aFile,"r");
+ String aLine = "";
+ while (aLine != null)
+ {
+ aLine = aReader.readLine();
+ if (aLine != null)
+ {
+ aLine = aLine.trim();
+ if ( (! (aLine.length() < 2) ) &&
+ (! aLine.startsWith("#")) &&
+ (! aLine.startsWith(";")) )
+ {
+ int nIdx = aLine.indexOf("mso-application");
+ if (nIdx > 0)
+ {
+ if (aLine.indexOf("Word.Document") > 0)
+ {
+ sOfficeType = "word";
+ }
+ else if (aLine.indexOf("Excel") > 0)
+ {
+ sOfficeType = "excel";
+ }
+ else
+ {
+ GlobalLogWriter.println("Unknown/unsupported data file: " + aLine);
+ }
+ }
+ }
+ }
+ }
+ }
+ catch (java.io.FileNotFoundException fne)
+ {
+ System.out.println("couldn't open file " + _sFilename);
+ System.out.println("Message: " + fne.getMessage());
+ }
+ catch (java.io.IOException ie)
+ {
+ System.out.println("Exception while reading file " + _sFilename);
+ System.out.println("Message: " + ie.getMessage());
+ }
+ try
+ {
+ aReader.close();
+ }
+ catch (java.io.IOException ie)
+ {
+ System.out.println("Couldn't close file " + _sFilename);
+ System.out.println("Message: " + ie.getMessage());
+ }
+ return sOfficeType;
+ }
+
+ private static String getXMLDocumentFormat(String _sInputFile)
+ {
+ String sType = "word"; // default
+ try
+ {
+ // ---- Parse XML file ----
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ // factory.setNamespaceAware( true );
+ // factory.setValidating( true );
+ DocumentBuilder builder = factory.newDocumentBuilder();
+ Document document = builder.parse( new File (_sInputFile) );
+ Node rootNode = document.getDocumentElement();
+
+ // ---- Get list of nodes to given tag ----
+ // document.
+ // NodeList ndList = document.getElementsByTagName( sToSearch /* argv[2] */ );
+ // System.out.println( "\nNode list at the beginning:" );
+ String sRootNodeName = rootNode.getNodeName();
+ if (sRootNodeName.equals("w:wordDocument"))
+ {
+ sType = "word";
+ }
+ else if (sRootNodeName.equals("WorkBook"))
+ {
+ sType = "excel";
+ }
+ // there exists no powerpoint xml representation in MSOffice 2003
+ else
+ {
+ GlobalLogWriter.println("Error: unknown root node: '" + sRootNodeName + "' please check the document. Try to use Word as default.");
+ sType = "word"; // default
+ }
+ // printNodesFromList( ndList );
+ }
+ catch (java.lang.Exception e)
+ {
+ }
+ return sType;
+ }
+
+// public static void main(String [] _args)
+// {
+// String sTest = getXMLDocumentFormat("c:/cws/temp/input/Blah Fasel.xml");
+// }
+}
diff --git a/qadevOOo/runner/graphical/Office.java b/qadevOOo/runner/graphical/Office.java
new file mode 100644
index 000000000000..8ecee36cc742
--- /dev/null
+++ b/qadevOOo/runner/graphical/Office.java
@@ -0,0 +1,170 @@
+/*
+ * ************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ * ***********************************************************************
+ */
+
+package graphical;
+
+import java.util.ArrayList;
+
+/**
+ *
+ * @author ll93751
+ */
+public class Office implements IOffice
+{
+ private ParameterHelper m_aParameterHelper;
+ private String m_sDocumentName;
+ private String m_sResult;
+ private IOffice m_aOffice = null;
+
+ public Office(ParameterHelper _aParam, String _sResult)
+ {
+ m_aParameterHelper = _aParam;
+ m_sResult = _sResult;
+
+ if (_aParam.getReferenceType().toLowerCase().equals("ooo") ||
+ _aParam.getReferenceType().toLowerCase().equals("ps") ||
+ _aParam.getReferenceType().toLowerCase().equals("pdf"))
+ {
+ m_aOffice = new OpenOfficePostscriptCreator(_aParam, m_sResult);
+ }
+ else if (_aParam.getReferenceType().toLowerCase().equals("msoffice"))
+ {
+ m_aOffice = new MSOfficePostscriptCreator(_aParam, m_sResult);
+ }
+ }
+
+
+ /**
+ * Load a document with an already started Office.
+ * @param _sDocumentName
+ * @throws graphical.OfficeException
+ */
+ public void load(String _sDocumentName) throws OfficeException
+ {
+ m_sDocumentName = _sDocumentName;
+ // check if given file is a picture, then do nothing
+ String sDocumentSuffix = FileHelper.getSuffix(m_sDocumentName);
+ if (sDocumentSuffix.toLowerCase().endsWith(".png") ||
+ sDocumentSuffix.toLowerCase().endsWith(".gif") ||
+ sDocumentSuffix.toLowerCase().endsWith(".jpg") ||
+ sDocumentSuffix.toLowerCase().endsWith(".bmp"))
+ {
+ throw new OfficeException("The given document is not a document type.");
+ }
+
+ // TODO: we should start the office after we know if we really need an Office.
+ if (m_aOffice != null)
+ {
+ if (sDocumentSuffix.toLowerCase().endsWith(".odb"))
+ {
+ if (m_aParameterHelper.getReferenceType().toLowerCase().equals("msoffice"))
+ {
+ // we can't handle .odb with msoffice
+ return;
+ }
+ // TODO: run through all documents which exists as reports in odb files
+ OpenOfficeDatabaseReportExtractor aExtractor = new OpenOfficeDatabaseReportExtractor(m_aParameterHelper);
+ ArrayList aList = aExtractor.load(m_sDocumentName);
+ if (aList != null)
+ {
+ // remove the whole section about the 'name'.odb there are no information we need
+ // we will create a new one.
+ String sIniFile = FileHelper.appendPath(m_sResult, "index.ini");
+ IniFile aIniFile2 = new IniFile(sIniFile);
+ String sSection = FileHelper.getBasename(_sDocumentName); // name of the odb file
+ aIniFile2.removeSection(sSection);
+ aIniFile2.close();
+
+ for (int i=0; i<aList.size();i++)
+ {
+ String sDocumentName = (String)aList.get(i);
+ m_aOffice.load(sDocumentName);
+ m_aOffice.storeAsPostscript();
+
+
+ // foreach Report found in the .odb file, create an entry 'report'<number> in the original <name>.odb Section
+ // so it is possible to run through all reports by the given .odb name
+ IniFile aIniFile = new IniFile(sIniFile);
+ // String sSection = FileHelper.getBasename(_sDocumentName); // name of the odb file
+ int nFileCount = aIniFile.getIntValue(sSection, "reportcount", 0);
+ String sValue = FileHelper.getBasename(sDocumentName); // name of the corresponding report
+ aIniFile.insertValue(sSection, "report" + nFileCount, sValue);
+ aIniFile.insertValue(sSection, "reportcount", nFileCount + 1);
+ aIniFile.close();
+ }
+ }
+ else
+ {
+ throw new OfficeException("Can't open the document " + m_sDocumentName);
+ }
+ }
+ else
+ {
+ m_aOffice.load(_sDocumentName);
+ }
+ }
+ }
+
+ public void storeAsPostscript() throws OfficeException
+ {
+ if (m_aOffice != null)
+ {
+ if (m_sDocumentName.endsWith(".odb"))
+ {
+ // this has already be done by load() for odb files.
+ }
+ else
+ {
+ m_aOffice.storeAsPostscript();
+ }
+
+// FileHelper.addBasenameToIndex(sOutputFilename);
+ }
+ }
+
+ public void start() throws OfficeException
+ {
+ if (m_aOffice != null)
+ {
+ m_aOffice.start();
+ }
+ }
+
+ public void close() throws OfficeException
+ {
+ if (m_aOffice != null)
+ {
+ m_aOffice.close();
+ }
+ }
+
+
+
+
+}
diff --git a/qadevOOo/runner/graphical/OfficeException.java b/qadevOOo/runner/graphical/OfficeException.java
new file mode 100644
index 000000000000..bc5a24fd5b97
--- /dev/null
+++ b/qadevOOo/runner/graphical/OfficeException.java
@@ -0,0 +1,45 @@
+/*
+ * ************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ * ***********************************************************************
+ */
+
+package graphical;
+
+/**
+ *
+ * @author ll93751
+ * Exception which occur if something goes wrong at load document.
+ */
+
+public class OfficeException extends Exception
+{
+ public OfficeException(String _aMessage)
+ {
+ super(_aMessage);
+ }
+
+}
diff --git a/qadevOOo/runner/graphical/OpenOfficeDatabaseReportExtractor.java b/qadevOOo/runner/graphical/OpenOfficeDatabaseReportExtractor.java
new file mode 100644
index 000000000000..a0592d5ce143
--- /dev/null
+++ b/qadevOOo/runner/graphical/OpenOfficeDatabaseReportExtractor.java
@@ -0,0 +1,560 @@
+/*
+ * ************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ * ***********************************************************************
+ */
+
+package graphical;
+
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.container.XNameAccess;
+import com.sun.star.frame.FrameSearchFlag;
+import com.sun.star.frame.XComponentLoader;
+import com.sun.star.frame.XDesktop;
+import com.sun.star.frame.XModel;
+import com.sun.star.frame.XStorable;
+import com.sun.star.lang.XComponent;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.lang.XServiceInfo;
+import com.sun.star.sdb.XOfficeDatabaseDocument;
+import com.sun.star.sdb.XReportDocumentsSupplier;
+import com.sun.star.sdb.application.XDatabaseDocumentUI;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XInterface;
+import com.sun.star.util.XCloseable;
+import complexlib.Assurance;
+// import complexlib.ComplexTestCase.AssureException;
+import helper.OfficeProvider;
+import helper.PropertyHelper;
+import helper.URLHelper;
+import java.io.File;
+import java.util.ArrayList;
+
+/**
+ *
+ * @author ll93751
+ */
+
+class PropertySetHelper
+{
+ XPropertySet m_xPropertySet;
+ public PropertySetHelper(Object _aObj)
+ {
+ m_xPropertySet = UnoRuntime.queryInterface(XPropertySet.class, _aObj);
+ }
+
+ /**
+ get a property and don't convert it
+ @param _sName the string name of the property
+ @return the object value of the property without any conversion
+ */
+ public Object getPropertyValueAsObject(String _sName)
+ {
+ Object aObject = null;
+
+ if (m_xPropertySet != null)
+ {
+ try
+ {
+ aObject = m_xPropertySet.getPropertyValue(_sName);
+ }
+ catch (com.sun.star.beans.UnknownPropertyException e)
+ {
+ System.out.println("ERROR: UnknownPropertyException caught. '" + _sName + "'");
+ System.out.println("Message: " + e.getMessage());
+ }
+ catch (com.sun.star.lang.WrappedTargetException e)
+ {
+ System.out.println("ERROR: WrappedTargetException caught.");
+ System.out.println("Message: " + e.getMessage());
+ }
+ }
+ return aObject;
+ }
+}
+
+public class OpenOfficeDatabaseReportExtractor extends Assurance
+{
+ private ParameterHelper m_aParameterHelper;
+
+ public OpenOfficeDatabaseReportExtractor(ParameterHelper _aParameter)
+ {
+ m_aParameterHelper = _aParameter;
+ }
+
+ private XDesktop m_xDesktop = null;
+ private XDesktop getXDesktop()
+ {
+
+ if (m_xDesktop == null)
+ {
+ try
+ {
+ XInterface xInterface = (XInterface) getMultiServiceFactory().createInstance( "com.sun.star.frame.Desktop" );
+ m_xDesktop = UnoRuntime.queryInterface(XDesktop.class, xInterface);
+ }
+ catch (com.sun.star.uno.Exception e)
+ {
+ GlobalLogWriter.println("ERROR: uno.Exception caught");
+ GlobalLogWriter.println("Message: " + e.getMessage());
+ }
+ }
+ return m_xDesktop;
+ }
+
+ private void showElements(XNameAccess _xNameAccess)
+ {
+ if (_xNameAccess != null)
+ {
+ String[] sElementNames = _xNameAccess.getElementNames();
+ for(int i=0;i<sElementNames.length; i++)
+ {
+ System.out.println("Value: [" + i + "] := " + sElementNames[i]);
+ }
+ }
+ else
+ {
+ System.out.println("Warning: Given object is null.");
+ }
+ }
+
+
+ private OfficeProvider m_aProvider = null;
+ private XMultiServiceFactory m_xMultiServiceFactory = null;
+ private XMultiServiceFactory getMultiServiceFactory()
+ {
+ if (m_xMultiServiceFactory == null)
+ {
+ m_xMultiServiceFactory = m_aParameterHelper.getMultiServiceFactory();
+ }
+ return m_xMultiServiceFactory;
+ }
+// private void startOffice()
+// {
+// // int tempTime = m_aParameterHelper.getTestParameters().getInt("SingleTimeOut");
+// param.put("TimeOut", new Integer(300000));
+// System.out.println("TimeOut: " + param.getInt("TimeOut"));
+// System.out.println("ThreadTimeOut: " + param.getInt("ThreadTimeOut"));
+//
+// // OfficeProvider aProvider = null;
+// m_aProvider = new OfficeProvider();
+// m_xXMultiServiceFactory = (XMultiServiceFactory) m_aProvider.getManager(param);
+// param.put("ServiceFactory", m_xXMultiServiceFactory);
+// }
+//
+// private void stopOffice()
+// {
+// if (m_aProvider != null)
+// {
+// m_aProvider.closeExistingOffice(param, true);
+// m_aProvider = null;
+// }
+// TimeHelper.waitInSeconds(2, "Give close Office some time.");
+// }
+
+ private String m_sMailAddress = null;
+ private String m_sParentDistinct = null;
+
+ // private String m_sUPDMinor;
+ // private String m_sCWS_WORK_STAMP;
+
+ private static String m_sSourceVersion;
+ private static String m_sDestinationVersion;
+ private static String m_sSourceName;
+ private static String m_sDestinationName;
+
+ private static final int WRITER = 1;
+ private static final int CALC = 2;
+
+ /**
+ * This is the main test Function of current ReportDesignerTest
+ * @param _sDocument
+ * @return
+ */
+
+ public ArrayList<String> load(String _sDocument /*, int _nType*/)
+ {
+ // We need to copy the database file to a place where we have write access, NEVER use the docpool for this
+ String sOutputPath = m_aParameterHelper.getOutputPath();
+ File aOutputPath = new File(sOutputPath);
+ aOutputPath.mkdirs();
+
+ String sFilename = FileHelper.getBasename(_sDocument);
+ String sDestinationFile = FileHelper.appendPath(sOutputPath, sFilename);
+ FileHelper.copy(_sDocument, sDestinationFile);
+
+ // now the fix reference of the AbsoluteReferenceFile should exist.
+ assure("There exists no file: " + sDestinationFile, FileHelper.exists(sDestinationFile));
+
+ String sFileURL = URLHelper.getFileURLFromSystemPath(sDestinationFile);
+ GlobalLogWriter.println("File URL: " + sFileURL);
+
+ ArrayList<PropertyValue> aPropertyList = new ArrayList<PropertyValue>();
+
+ // FYI: it is not allowed to open the document read only
+// PropertyValue aReadOnly = new PropertyValue(); // always overwrite already exist files
+// aReadOnly.Name = "ReadOnly";
+// aReadOnly.Value = Boolean.TRUE;
+// aPropertyList.add(aReadOnly);
+
+ XComponent xDocComponent = loadComponent(sFileURL, getXDesktop(), aPropertyList);
+
+ GlobalLogWriter.println("Load done");
+// context = createUnoService("com.sun.star.sdb.DatabaseContext")
+// oDataBase = context.getByName("hh")
+// oDBDoc = oDataBase.DatabaseDocument
+//
+// dim args(1) as new com.sun.star.beans.PropertyValue
+// args(0).Name = "ActiveConnection"
+// args(0).Value = oDBDoc.getCurrentController().getPropertyValue("ActiveConnection")
+// reportContainer = oDBDoc.getReportDocuments()
+// report = reportContainer.loadComponentFromURL("Report40","",0,args)
+
+ ArrayList<String> aList = null;
+ try
+ {
+// XInterface x = (XInterface)getMultiServiceFactory().createInstance("com.sun.star.sdb.DatabaseContext");
+// assure("can't create instance of com.sun.star.sdb.DatabaseContext", x != null);
+// GlobalLogWriter.println("createInstance com.sun.star.sdb.DatabaseContext done");
+
+// XNameAccess xNameAccess = (XNameAccess) UnoRuntime.queryInterface(XNameAccess.class, x);
+// showElements(xNameAccess);
+// Object aObj = xNameAccess.getByName(sFileURL);
+// GlobalLogWriter.println("1");
+
+// PropertySetHelper aHelper = new PropertySetHelper(aObj);
+// XDocumentDataSource xDataSource = (XDocumentDataSource)UnoRuntime.queryInterface(XDocumentDataSource.class, aObj);
+// Object aDatabaseDocument = aHelper.getPropertyValueAsObject("DatabaseDocument");
+// XOfficeDatabaseDocument xOfficeDBDoc = xDataSource.getDatabaseDocument();
+
+ XOfficeDatabaseDocument xOfficeDBDoc = UnoRuntime.queryInterface(XOfficeDatabaseDocument.class, xDocComponent);
+
+// XOfficeDatabaseDocument xOfficeDBDoc = (XOfficeDatabaseDocument)UnoRuntime.queryInterface(XOfficeDatabaseDocument.class, xDataSource);
+ assure("can't access DatabaseDocument", xOfficeDBDoc != null);
+// GlobalLogWriter.println("2");
+
+ XModel xDBSource = UnoRuntime.queryInterface(XModel.class, xOfficeDBDoc);
+ Object aController = xDBSource.getCurrentController();
+ assure("Controller of xOfficeDatabaseDocument is empty!", aController != null);
+// GlobalLogWriter.println("3");
+
+ XDatabaseDocumentUI aDBDocUI = UnoRuntime.queryInterface(XDatabaseDocumentUI.class, aController);
+ aDBDocUI.connect();
+ boolean isConnect = aDBDocUI.isConnected();
+ if (isConnect)
+ {
+ GlobalLogWriter.println("Connection is true");
+ }
+ else
+ {
+ GlobalLogWriter.println("Connection is false");
+ }
+
+ // aHelper = new PropertySetHelper(aController);
+
+ XReportDocumentsSupplier xSupplier = UnoRuntime.queryInterface(XReportDocumentsSupplier.class, xOfficeDBDoc);
+ XNameAccess xNameAccess = xSupplier.getReportDocuments();
+ assure("xOfficeDatabaseDocument returns no Report Document", xNameAccess != null);
+// GlobalLogWriter.println("5");
+
+ showElements(xNameAccess);
+
+ // Object aActiveConnectionObj = aHelper.getPropertyValueAsObject("ActiveConnection");
+ Object aActiveConnectionObj = aDBDocUI.getActiveConnection();
+ assure("ActiveConnection is empty", aActiveConnectionObj != null);
+// GlobalLogWriter.println("5");
+
+ ArrayList<PropertyValue> aPropertyList2 = new ArrayList<PropertyValue>();
+
+ PropertyValue aActiveConnection = new PropertyValue();
+ aActiveConnection.Name = "ActiveConnection";
+ aActiveConnection.Value = aActiveConnectionObj;
+ aPropertyList2.add(aActiveConnection);
+
+ aList = loadAndStoreReports(xNameAccess, aPropertyList2 /*, _nType*/ );
+ createDBEntry(/*_nType*/);
+ }
+ catch(Exception/*com.sun.star.uno.Exception*/ e)
+ {
+ GlobalLogWriter.println("ERROR: Exception caught");
+ GlobalLogWriter.println("Message: " + e.getMessage());
+ }
+
+ // String mTestDocumentPath = (String) param.get("TestDocumentPath");
+ // System.out.println("mTestDocumentPath: '" + mTestDocumentPath + "'");
+ // // workaround for issue using deprecated "DOCPTH" prop
+ // System.setProperty("DOCPTH", mTestDocumentPath);
+
+ // Close the document
+ // util.utils.shortWait(2000);
+
+ closeComponent(xDocComponent);
+ return aList;
+ }
+
+ private String getDocumentPoolName(/*int _nType*/)
+ {
+ return "AutogenReportDesignTest";
+ // return getFileFormat(_nType);
+ }
+
+// -----------------------------------------------------------------------------
+ private void createDBEntry(/*int _nType*/)
+ {
+ // try to connect the database
+ String sDBConnection = (String)m_aParameterHelper.getTestParameters().get( convwatch.PropertyName.DB_CONNECTION_STRING );
+ if (sDBConnection != null && sDBConnection.length() > 0)
+ {
+ GlobalLogWriter.println("DBConnection: " + sDBConnection);
+// TODO: DB
+// DB.init(sDBConnection);
+
+ // String sFixRefSubDirectory = "ReportDesign_qa_complex_" + getFileFormat(_nType);
+ String sFixRefSubDirectory = "ReportDesignFixRef";
+
+ String sSourceVersion = m_sSourceVersion;
+ // String sSourceVersion = sFixRefSubDirectory;
+ String sSourceName = m_sSourceName;
+ // String sSourceCreatorType = "fixref";
+ String sSourceCreatorType = "";
+ String sDestinationVersion = m_sDestinationVersion;
+ // if (sDestinationVersion.length() == 0)
+ // {
+ // sDestinationVersion = m_sUPDMinor;
+ // }
+ String sDestinationName = m_sDestinationName;
+ String sDestinationCreatorType = "";
+ String sDocumentPoolDir = getOutputPath(/*_nType*/);
+ String sDocumentPoolName = getDocumentPoolName(/*_nType*/);
+ String sSpecial = "";
+
+// TODO: DB
+// DB.insertinto_documentcompare(sSourceVersion, sSourceName, sSourceCreatorType,
+// m_sDestinationVersion, sDestinationName, sDestinationCreatorType,
+// sDocumentPoolDir, sDocumentPoolName, m_sMailAddress,
+// sSpecial, m_sParentDistinct);
+ TimeHelper.waitInSeconds(1, "wait for DB.");
+ // DB.test();
+ // System.exit(1);
+ }
+ }
+
+ private ArrayList<String> loadAndStoreReports(XNameAccess _xNameAccess, ArrayList<PropertyValue> _aPropertyList /*, int _nType*/ )
+ {
+ ArrayList<String> aList = new ArrayList<String>();
+ if (_xNameAccess != null)
+ {
+ String[] sElementNames = _xNameAccess.getElementNames();
+ for(int i=0;i<sElementNames.length; i++)
+ {
+ String sReportName = sElementNames[i];
+ XComponent xDoc = loadComponent(sReportName, _xNameAccess, _aPropertyList);
+// util.utils.shortWait(1000);
+ // print? or store?
+ String sDocumentPathName = storeComponent(sReportName, xDoc /*, _nType*/);
+ aList.add(sDocumentPathName);
+// util.utils.shortWait(1000);
+ closeComponent(xDoc);
+// util.utils.shortWait(1000);
+ // sBackPath contains the path where to find the extracted ODB Document
+ }
+ }
+ return aList;
+ }
+
+ private String getFormatExtension(Object _xComponent /* int _nType*/ )
+ {
+ String sExtension;
+ XServiceInfo xServiceInfo = UnoRuntime.queryInterface( XServiceInfo.class, _xComponent );
+ if ( xServiceInfo.supportsService( "com.sun.star.sheet.SpreadsheetDocument" ) )
+ {
+ // calc
+ sExtension = ".ods";
+ }
+ else if (xServiceInfo.supportsService("com.sun.star.text.TextDocument"))
+ {
+ //writer
+ sExtension = ".odt";
+ }
+ else
+ {
+ sExtension = ".UNKNOWN";
+ }
+ return sExtension;
+ }
+
+ // switch(_nType)
+ // {
+ // case WRITER:
+ // sExtension = ".odt";
+ // break;
+ // case CALC:
+ // sExtension = ".ods";
+ // break;
+ // default:
+ // sExtension = ".UNKNOWN";
+ // }
+ // return sExtension;
+ // }
+ // private String getFileFormat(int _nType)
+ // {
+ // String sFileType;
+ // switch(_nType)
+ // {
+ // case WRITER:
+ // sFileType = "writer8";
+ // break;
+ // case CALC:
+ // sFileType = "calc8";
+ // break;
+ // default:
+ // sFileType = "UNKNOWN";
+ // }
+ // return sFileType;
+ // }
+
+ private String m_sOutputPath = null;
+
+ private String getOutputPath(/*int _nType*/)
+ {
+ if (m_sOutputPath == null)
+ {
+ String sOutputPath = (String)m_aParameterHelper.getTestParameters().get( convwatch.PropertyName.DOC_COMPARATOR_OUTPUT_PATH );
+ sOutputPath = helper.StringHelper.removeQuoteIfExists(sOutputPath);
+
+ // sOutputPath += "tmp_123";
+ sOutputPath = FileHelper.appendPath(sOutputPath, DateHelper.getDateTimeForFilename());
+ // sOutputPath += System.getProperty("file.separator");
+
+ // sOutputPath += getFileFormat(_nType);
+ // sOutputPath += System.getProperty("file.separator");
+
+ File aOutputFile = new File(sOutputPath); // create the directory of the given output path
+ aOutputFile.mkdirs();
+ m_sOutputPath = sOutputPath;
+ }
+ return m_sOutputPath;
+ }
+
+ /*
+ store given _xComponent under the given Name in DOC_COMPARATOR_INPUTPATH
+ */
+ private String storeComponent(String _sName, Object _xComponent /*, int _nType*/ )
+ {
+ String sOutputPath = getOutputPath(/*_nType*/);
+
+// // add DocumentPoolName
+// sOutputPath = FileHelper.appendPath(sOutputPath, getDocumentPoolName(/*_nType*/));
+// // sOutputPath += System.getProperty("file.separator");
+//
+// File aOutputFile = new File(sOutputPath); // create the directory of the given output path
+// aOutputFile.mkdirs();
+
+
+ String sName = _sName + getFormatExtension(_xComponent /*_nType*/);
+ sOutputPath = FileHelper.appendPath(sOutputPath, sName);
+
+ // we need the name and path
+ String sBackPathName = sOutputPath;
+
+ String sOutputURL = URLHelper.getFileURLFromSystemPath(sOutputPath);
+
+ ArrayList<PropertyValue> aPropertyList = new ArrayList<PropertyValue>(); // set some properties for storeAsURL
+
+ // PropertyValue aFileFormat = new PropertyValue();
+ // aFileFormat.Name = "FilterName";
+ // aFileFormat.Value = getFileFormat(_nType);
+ // aPropertyList.add(aFileFormat);
+
+ PropertyValue aOverwrite = new PropertyValue(); // always overwrite already exist files
+ aOverwrite.Name = "Overwrite";
+ aOverwrite.Value = Boolean.TRUE;
+ aPropertyList.add(aOverwrite);
+
+ // store the document in an other directory
+ XStorable aStorable = UnoRuntime.queryInterface( XStorable.class, _xComponent);
+ if (aStorable != null)
+ {
+ GlobalLogWriter.println("store document as URL: '" + sOutputURL + "'");
+ try
+ {
+ aStorable.storeAsURL(sOutputURL, PropertyHelper.createPropertyValueArrayFormArrayList(aPropertyList));
+ }
+ catch (com.sun.star.io.IOException e)
+ {
+ GlobalLogWriter.println("ERROR: Exception caught");
+ GlobalLogWriter.println("Can't write document URL: '" + sOutputURL + "'");
+ GlobalLogWriter.println("Message: " + e.getMessage());
+ }
+ }
+ return sBackPathName;
+ }
+
+ private XComponent loadComponent(String _sName, Object _xComponent, ArrayList _aPropertyList)
+ {
+ XComponent xDocComponent = null;
+ XComponentLoader xComponentLoader = UnoRuntime.queryInterface( XComponentLoader.class, _xComponent );
+
+ try
+ {
+ PropertyValue[] aLoadProperties = PropertyHelper.createPropertyValueArrayFormArrayList(_aPropertyList);
+ GlobalLogWriter.println("Load component: '" + _sName + "'");
+ xDocComponent = xComponentLoader.loadComponentFromURL(_sName, "_blank", FrameSearchFlag.ALL, aLoadProperties);
+ GlobalLogWriter.println("Load component: '" + _sName + "' done");
+ }
+ catch (com.sun.star.io.IOException e)
+ {
+ GlobalLogWriter.println("ERROR: Exception caught");
+ GlobalLogWriter.println("Can't load document '" + _sName + "'");
+ GlobalLogWriter.println("Message: " + e.getMessage());
+ }
+ catch (com.sun.star.lang.IllegalArgumentException e)
+ {
+ GlobalLogWriter.println("ERROR: Exception caught");
+ GlobalLogWriter.println("Illegal Arguments given to loadComponentFromURL.");
+ GlobalLogWriter.println("Message: " + e.getMessage());
+ }
+ return xDocComponent;
+ }
+
+ private void closeComponent(XComponent _xDoc)
+ {
+ // Close the document
+ XCloseable xCloseable = UnoRuntime.queryInterface(XCloseable.class, _xDoc);
+ try
+ {
+ xCloseable.close(true);
+ }
+ catch (com.sun.star.util.CloseVetoException e)
+ {
+ GlobalLogWriter.println("ERROR: CloseVetoException caught");
+ GlobalLogWriter.println("CloseVetoException occured Can't close document.");
+ GlobalLogWriter.println("Message: " + e.getMessage());
+ }
+ }
+
+}
diff --git a/qadevOOo/runner/graphical/OpenOfficePostscriptCreator.java b/qadevOOo/runner/graphical/OpenOfficePostscriptCreator.java
new file mode 100644
index 000000000000..d918634f8d30
--- /dev/null
+++ b/qadevOOo/runner/graphical/OpenOfficePostscriptCreator.java
@@ -0,0 +1,1427 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package graphical;
+
+import com.sun.star.frame.FrameSearchFlag;
+import com.sun.star.util.XCloseable;
+import helper.OfficeProvider;
+import helper.OfficeWatcher;
+import java.util.ArrayList;
+
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.document.XTypeDetection;
+import com.sun.star.container.XNameAccess;
+import com.sun.star.frame.XDesktop;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.frame.XComponentLoader;
+import com.sun.star.lang.XComponent;
+import com.sun.star.frame.XStorable;
+import com.sun.star.view.XPrintable;
+import com.sun.star.lang.XServiceInfo;
+import com.sun.star.frame.XModel;
+import com.sun.star.uno.AnyConverter;
+
+import helper.URLHelper;
+import helper.PropertyHelper;
+import helper.OSHelper;
+
+// import helper.Parameter;
+import java.io.File;
+
+/**
+ * This Object is to print a given document with OpenOffice.org / StarOffice
+ * over the normal printer driver
+ * or over it's pdf exporter
+ */
+public class OpenOfficePostscriptCreator implements IOffice
+{
+ private ParameterHelper m_aParameterHelper;
+ private String m_sOutputURL;
+ private String m_sBasename;
+ private String m_sDocumentName;
+ private XComponent m_aDocument;
+
+ public OpenOfficePostscriptCreator(ParameterHelper _aParam, String _sResult)
+ {
+ m_aParameterHelper = _aParam;
+ String sOutputURL = _sResult;
+ if (! sOutputURL.startsWith("file:"))
+ {
+ sOutputURL = URLHelper.getFileURLFromSystemPath(_sResult);
+ }
+ m_sOutputURL = sOutputURL;
+ m_aDocument = null;
+ }
+
+
+ public void load(String _sDocumentName) throws OfficeException
+ {
+ m_sDocumentName = _sDocumentName;
+
+ String sInputFileURL = URLHelper.getFileURLFromSystemPath(m_sDocumentName);
+ m_aDocument = loadFromURL(m_aParameterHelper, sInputFileURL);
+ if (m_aDocument == null)
+ {
+ GlobalLogWriter.println("loadDocumentFromURL() failed with document: " + sInputFileURL);
+ throw new OfficeException("load(): failed with document" + sInputFileURL);
+ }
+
+ m_sBasename = FileHelper.getBasename(m_sDocumentName);
+ }
+
+ public void storeAsPostscript() throws OfficeException
+ {
+ if (m_aDocument != null)
+ {
+ String sDocumentName = FileHelper.appendPath(m_sOutputURL, m_sBasename);
+ if (m_aParameterHelper.getReferenceType().toLowerCase().equals("ooo") ||
+ m_aParameterHelper.getReferenceType().toLowerCase().equals("ps") )
+ {
+ String sPrintURL = sDocumentName + ".ps";
+
+ impl_printToFileWithOOo(m_aParameterHelper, m_aDocument, sDocumentName, sPrintURL /*_sPrintFileURL*/);
+ String sBasename = FileHelper.getBasename(sPrintURL);
+ FileHelper.addBasenameToIndex(m_sOutputURL, sBasename, "OOo", "postscript", m_sDocumentName);
+ }
+ else if (m_aParameterHelper.getReferenceType().toLowerCase().equals("pdf"))
+ {
+ String sPDFURL = sDocumentName + ".pdf";
+ storeAsPDF(m_aParameterHelper, m_aDocument, sPDFURL);
+
+ String sBasename = FileHelper.getBasename(sPDFURL);
+ FileHelper.addBasenameToIndex(m_sOutputURL, sBasename, "pdf", "pdf-export", m_sDocumentName);
+ }
+ else
+ {
+ throw new OfficeException("unknown reference type");
+ }
+ GlobalLogWriter.println("Close document.");
+ m_aDocument.dispose();
+ }
+ }
+
+ public void start() throws OfficeException
+ {
+ startOffice();
+ }
+
+ public void close() throws OfficeException
+ {
+ stopOffice();
+ }
+
+
+
+
+
+ private void showProperty(PropertyValue _aValue)
+ {
+ String sName = _aValue.Name;
+ String sValue;
+ try
+ {
+ sValue = AnyConverter.toString(_aValue.Value);
+ GlobalLogWriter.println("Property " + sName + ":=" + sValue);
+ }
+ catch (com.sun.star.lang.IllegalArgumentException e)
+ {
+ GlobalLogWriter.println("showProperty: can't convert a object to string. " + e.getMessage());
+ }
+ }
+
+ /**
+ * shows the FilterName and MediaType from the given XComponent
+ */
+ private String getDocumentType( XComponent _aDoc )
+ {
+ XModel xModel = UnoRuntime.queryInterface( XModel.class, _aDoc);
+ PropertyValue[] aArgs = xModel.getArgs();
+ for (int i=0;i<aArgs.length;i++)
+ {
+ PropertyValue aValue = aArgs[i];
+ // System.out.print("Property: '" + aValue.Name);
+ // System.out.println("' := '" + aValue.Value + "'");
+ if (aValue.Name.equals("FilterName") ||
+ aValue.Name.equals("MediaType"))
+ {
+ String sNameValue = "'" + aValue.Name + "' := '" + aValue.Value + "'";
+ return sNameValue;
+ }
+ }
+ return "";
+ }
+
+ private void showDocumentType( XComponent _aDoc )
+ {
+ String sNameValue = getDocumentType(_aDoc);
+ GlobalLogWriter.println(" Property: '" + sNameValue);
+ }
+ /**
+ * load a OpenOffice.org document from a given URL (_sInputURL)
+ * the ParameterHelper must contain a living MultiServiceFactory object
+ * or we crash here.
+ * Be aware, the ownership of the document gets to you, you have to close it.
+ */
+ private XComponent loadFromURL(ParameterHelper _aGTA,
+ String _sInputURL)
+ {
+ XComponent aDoc = null;
+ try
+ {
+ if (_aGTA.getMultiServiceFactory() == null)
+ {
+ GlobalLogWriter.println("MultiServiceFactory in GraphicalTestArgument not set.");
+ return null;
+ }
+ Object oDsk = _aGTA.getMultiServiceFactory().createInstance("com.sun.star.frame.Desktop");
+ XDesktop aDesktop = UnoRuntime.queryInterface(XDesktop.class, oDsk);
+
+ if (aDesktop != null)
+ {
+ GlobalLogWriter.println("com.sun.star.frame.Desktop created.");
+ // String sInputURL = aCurrentParameter.sInputURL;
+ // String sOutputURL = aCurrentParameter.sOutputURL;
+ // String sPrintFileURL = aCurrentParameter.sPrintToFileURL;
+ // System.out.println(_sInputURL);
+
+
+ // set here the loadComponentFromURL() properties
+ // at the moment only 'Hidden' is set, so no window is opened at work
+
+ ArrayList<PropertyValue> aPropertyList = new ArrayList<PropertyValue>();
+
+ // check which properties should set and count it.
+ // if (_aGTA.isHidden())
+ // {
+ // nPropertyCount ++;
+ // }
+ // if (_aGTA.getImportFilterName() != null && _aGTA.getImportFilterName().length() > 0)
+ // {
+ // nPropertyCount ++;
+ // }
+
+ // initialize the propertyvalue
+ // int nPropertyIndex = 0;
+ // aProps = new PropertyValue[ nPropertyCount ];
+
+ // set all property values
+ if (_aGTA.isHidden())
+ {
+ PropertyValue Arg = new PropertyValue();
+ Arg.Name = "Hidden";
+ Arg.Value = Boolean.TRUE;
+ aPropertyList.add(Arg);
+ showProperty(Arg);
+ }
+ if (_aGTA.getImportFilterName() != null && _aGTA.getImportFilterName().length() > 0)
+ {
+ PropertyValue Arg = new PropertyValue();
+ Arg.Name = "FilterName";
+ Arg.Value = _aGTA.getImportFilterName();
+ aPropertyList.add(Arg);
+ showProperty(Arg);
+ }
+ PropertyValue ReadOnly = new PropertyValue();
+ ReadOnly.Name = "ReadOnly";
+ ReadOnly.Value = Boolean.TRUE;
+ aPropertyList.add(ReadOnly);
+ showProperty(ReadOnly);
+
+ GlobalLogWriter.println(DateHelper.getDateTimeForHumanreadableLog() + " Load document");
+ // GlobalLogWriter.flush();
+
+ XComponentLoader aCompLoader = UnoRuntime.queryInterface( XComponentLoader.class, aDesktop);
+
+ // XComponent aDoc = null;
+
+ _aGTA.getPerformance().startTime(PerformanceContainer.Load);
+ aDoc = aCompLoader.loadComponentFromURL(_sInputURL, "_blank", FrameSearchFlag.ALL, PropertyHelper.createPropertyValueArrayFormArrayList(aPropertyList) );
+ _aGTA.getPerformance().stopTime(PerformanceContainer.Load);
+ if (aDoc != null)
+ {
+ GlobalLogWriter.println(DateHelper.getDateTimeForHumanreadableLog() + " Load document done.");
+ showDocumentType(aDoc);
+ _aGTA.setDocumentType(getDocumentType(aDoc));
+// TODO: TimeHelper.waitInSeconds(20, "Wait after load document. Maybe helps due to layouting problems.");
+ }
+ else
+ {
+ GlobalLogWriter.println(" Load document failed.");
+ if (_aGTA.getImportFilterName() != null && _aGTA.getImportFilterName().length() > 0)
+ {
+ GlobalLogWriter.println(" Please check FilterName := '" + _aGTA.getImportFilterName() + "'");
+ }
+ GlobalLogWriter.println("");
+ }
+ }
+ else
+ {
+ GlobalLogWriter.println("com.sun.star.frame.Desktop failed.");
+ }
+ }
+ catch ( com.sun.star.uno.Exception e )
+ {
+ // Some exception occures.FAILED
+ GlobalLogWriter.println("UNO Exception caught.");
+ GlobalLogWriter.println("Message: " + e.getMessage());
+ e.printStackTrace();
+ aDoc = null;
+ }
+ return aDoc;
+ }
+
+ private boolean exportToPDF(XComponent _xComponent, String _sDestinationName)
+ {
+ XServiceInfo xServiceInfo =
+ UnoRuntime.queryInterface(
+ XServiceInfo.class, _xComponent
+ );
+
+ ArrayList<PropertyValue> aPropertyList = new ArrayList<PropertyValue>();
+ PropertyValue aFiltername = new PropertyValue();
+ aFiltername.Name = "FilterName";
+ aFiltername.Value = getFilterName_forPDF(xServiceInfo);
+ aPropertyList.add(aFiltername);
+ showProperty(aFiltername);
+ boolean bWorked = true;
+
+// TODO: TimeHelper.waitInSeconds(20, "Wait before storeToURL. Maybe helps due to layouting problems.");
+ try
+ {
+ XStorable store =
+ UnoRuntime.queryInterface(
+ XStorable.class, _xComponent
+ );
+ store.storeToURL(_sDestinationName, PropertyHelper.createPropertyValueArrayFormArrayList(aPropertyList));
+ }
+ catch (com.sun.star.io.IOException e)
+ {
+ GlobalLogWriter.println("IO Exception caught.");
+ GlobalLogWriter.println("Message: " + e.getMessage());
+ bWorked = false;
+ }
+
+ return bWorked;
+ }
+
+
+ private String getFilterName_forPDF(XServiceInfo xServiceInfo)
+ {
+ String filterName = "";
+
+ if (xServiceInfo.supportsService("com.sun.star.text.TextDocument"))
+ {
+ //writer
+ filterName = "writer_pdf_Export";
+ }
+ else if ( xServiceInfo.supportsService( "com.sun.star.sheet.SpreadsheetDocument" ) )
+ {
+ //calc
+ filterName = "calc_pdf_Export";
+ }
+ else if ( xServiceInfo.supportsService( "com.sun.star.drawing.DrawingDocument" ) )
+ {
+ //draw
+ filterName = "draw_pdf_Export";
+ }
+ else if ( xServiceInfo.supportsService( "com.sun.star.presentation.PresentationDocument" ) )
+ {
+ //impress
+ filterName = "impress_pdf_Export";
+ }
+ else if (xServiceInfo.supportsService("com.sun.star.text.WebDocument"))
+ {
+ //html document
+ filterName = "writer_web_pdf_Export";
+ }
+ else if ( xServiceInfo.supportsService("com.sun.star.text.GlobalDocument") )
+ {
+ //master document
+ filterName = "writer_globaldocument_pdf_Export";
+ }
+ else if ( xServiceInfo.supportsService( "com.sun.star.formulaFormulaProperties" ) )
+ {
+ //math document
+ filterName = "math_pdf_Export";
+ }
+
+ return filterName;
+ }
+
+ // -----------------------------------------------------------------------------
+
+// public boolean storeAsPDF(ParameterHelper _aGTA,
+// String _sInputURL,
+// String _sOutputURL)
+// {
+// boolean bBack = false;
+// XComponent aDoc = loadFromURL(_aGTA, _sInputURL);
+//
+// if (aDoc == null)
+// {
+// GlobalLogWriter.println("Can't load document.");
+// return bBack;
+// }
+// bBack = storeAsPDF(_aGTA, aDoc, _sOutputURL);
+// FileHelper.createInfoFile(_sOutputURL, _aGTA, "as pdf");
+//
+// GlobalLogWriter.println("Close document.");
+// aDoc.dispose();
+// return bBack;
+// }
+
+ public boolean storeAsPDF(ParameterHelper _aGTA,
+ XComponent _aDoc,
+ String _sOutputURL) throws OfficeException
+ {
+ // try {
+ boolean bBack = true;
+ _aGTA.getPerformance().startTime(PerformanceContainer.StoreAsPDF);
+ bBack = exportToPDF(_aDoc, _sOutputURL);
+ _aGTA.getPerformance().stopTime(PerformanceContainer.StoreAsPDF);
+
+ if (!bBack)
+ {
+ GlobalLogWriter.println("Can't store document as PDF.");
+// bBack = false;
+ throw new OfficeException("Can't store document as PDF");
+ }
+ else
+ {
+ FileHelper.createInfoFile(_sOutputURL, _aGTA, "as pdf");
+ }
+ return bBack;
+ }
+
+ // -----------------------------------------------------------------------------
+
+ /**
+ * print the document found in file (_sInputURL) to as postscript to file (_sPrintFileURL)
+ * Due to the fact we use a printer to convert the file to postscript, the default printer
+ * to create such postscript format must be installed, this is not tested here.
+ *
+ * @return true, if print has been done.
+ * Be careful, true means only print returns with no errors, to be sure print is really done
+ * check existance of _sPrintFileURL
+ */
+
+// public boolean printToFileWithOOo(ParameterHelper _aGTA,
+// String _sInputURL,
+// String _sOutputURL,
+// String _sPrintFileURL)
+// {
+// // waitInSeconds(1);
+// boolean bBack = false;
+//
+// XComponent aDoc = loadFromURL(_aGTA, _sInputURL);
+// if (aDoc != null)
+// {
+// if ( _sInputURL.equals(_sOutputURL) )
+// {
+// // don't store document
+// // input and output are equal OR
+// GlobalLogWriter.println("Warning: Inputpath and Outputpath are equal. Document will not stored again.");
+// disallowStore();
+// }
+// bBack = impl_printToFileWithOOo(_aGTA, aDoc, _sOutputURL, _sPrintFileURL);
+//
+// GlobalLogWriter.println("Close document.");
+// aDoc.dispose();
+// }
+// else
+// {
+// GlobalLogWriter.println("loadDocumentFromURL() failed with document: " + _sInputURL);
+// }
+// return bBack;
+// }
+
+
+
+ // -----------------------------------------------------------------------------
+ private boolean impl_printToFileWithOOo(ParameterHelper _aGTA,
+ XComponent _aDoc,
+ String _sOutputURL,
+ String _sPrintFileURL)
+ {
+ boolean bBack = false;
+ boolean bFailed = true; // always be a pessimist,
+ if (_aDoc == null)
+ {
+ GlobalLogWriter.println("No document is given.");
+ return bBack;
+ }
+
+ try
+ {
+ if (_sOutputURL != null)
+ {
+ if (isStoreAllowed())
+ {
+ // store the document in an other directory
+ XStorable aStorable = UnoRuntime.queryInterface( XStorable.class, _aDoc);
+ if (aStorable != null)
+ {
+ PropertyValue [] szEmptyArgs = new PropertyValue [0];
+
+ GlobalLogWriter.println(DateHelper.getDateTimeForHumanreadableLog() + " Store document.");
+ _aGTA.getPerformance().startTime(PerformanceContainer.Store);
+ aStorable.storeAsURL(_sOutputURL, szEmptyArgs);
+ _aGTA.getPerformance().stopTime(PerformanceContainer.Store);
+
+ GlobalLogWriter.println(DateHelper.getDateTimeForHumanreadableLog() + " Store document done.");
+ // TimeHelper.waitInSeconds(1, "After store as URL to:" + _sOutputURL);
+ GlobalLogWriter.println("Reload stored file test.");
+ XComponent aDoc = loadFromURL(_aGTA, _sOutputURL);
+ if (aDoc == null)
+ {
+ GlobalLogWriter.println("Reload stored file test failed, can't reload file: " + _sOutputURL);
+ }
+ else
+ {
+ XCloseable xClose = UnoRuntime.queryInterface(XCloseable.class, aDoc);
+ if (xClose != null)
+ {
+ xClose.close(true);
+ }
+ else
+ {
+ aDoc.dispose();
+ }
+ // TimeHelper.waitInSeconds(1, "after close temp document");
+ }
+ }
+ }
+ else
+ {
+ // make sure to create the directory in
+ String sOutputFilename = FileHelper.getSystemPathFromFileURL(_sOutputURL);
+ String sOutputPath = FileHelper.getPath(sOutputFilename);
+ File aFile = new File(sOutputPath);
+ aFile.mkdirs();
+ }
+ }
+ }
+ catch ( com.sun.star.uno.Exception e )
+ {
+ // Some exception occures.FAILED
+ GlobalLogWriter.println("UNO Exception caught.");
+ GlobalLogWriter.println("Message: " + e.getMessage());
+
+ e.printStackTrace();
+ bBack = false;
+ }
+
+ try
+ {
+
+ // System.out.println("Document loaded.");
+ // Change Pagesettings to DIN A4
+
+ GlobalLogWriter.println(DateHelper.getDateTimeForHumanreadableLog() + " Print document.");
+ XPrintable aPrintable = UnoRuntime.queryInterface( XPrintable.class, _aDoc);
+ if (aPrintable != null)
+ {
+ // System.out.println(" Set PaperFormat to DIN A4");
+ // {
+ // PropertyValue[] aPrinterProps = aPrintable.getPrinter();
+ // System.out.println("PrinterProps size: " + String.valueOf(aPrinterProps.length));
+ // int nPropIndex = 0;
+ // while (!"PaperFormat".equals(aPrinterProps[nPropIndex].Name))
+ // {
+ // // System.out.println(aPrinterProps[nPropIndex].Name);
+ // nPropIndex++;
+ // }
+ // aPrinterProps[nPropIndex].Value = com.sun.star.view.PaperFormat.A4;
+ // aPrintable.setPrinter(aPrinterProps);
+ // }
+
+ // configure Office to allow to execute macos
+
+// TODO: We need a possiblity to set the printer name also for StarOffice/OpenOffice
+ if (OSHelper.isWindows())
+ {
+ if (_aGTA.getPrinterName() != null)
+ {
+ ArrayList<PropertyValue> aPropertyList = new ArrayList<PropertyValue>();
+ // PropertyValue [] aPrintProps = new PropertyValue[1];
+ PropertyValue Arg = new PropertyValue();
+ Arg.Name = "Name";
+ Arg.Value = _aGTA.getPrinterName();
+ aPropertyList.add(Arg);
+ showProperty(Arg);
+ // GlobalLogWriter.println("Printername is not null, so set to " + _aGTA.getPrinterName());
+ aPrintable.setPrinter(PropertyHelper.createPropertyValueArrayFormArrayList(aPropertyList));
+ }
+ }
+
+ // set property values for XPrintable.print()
+ // more can be found at "http://api.openoffice.org/docs/common/ref/com/sun/star/view/PrintOptions.html"
+
+ // int nProperties = 1; // default for 'FileName' property
+ // if (_aGTA.printAllPages() == false)
+ // {
+ // // we don't want to print all pages, build Pages string by ourself
+ // nProperties ++;
+ // }
+ // int nPropsCount = 0;
+
+ // If we are a SpreadSheet (calc), we need to set PrintAllSheets property to 'true'
+ XServiceInfo xServiceInfo = UnoRuntime.queryInterface( XServiceInfo.class, _aDoc );
+ if ( xServiceInfo.supportsService( "com.sun.star.sheet.SpreadsheetDocument" ) )
+ {
+ XMultiServiceFactory xMSF = _aGTA.getMultiServiceFactory();
+ Object aSettings = xMSF.createInstance( "com.sun.star.sheet.GlobalSheetSettings" );
+ if (aSettings != null)
+ {
+ XPropertySet xPropSet = UnoRuntime.queryInterface( XPropertySet.class, aSettings );
+ xPropSet.setPropertyValue( "PrintAllSheets", new Boolean( true ) );
+ GlobalLogWriter.println("PrintAllSheets := true");
+ }
+ }
+
+ ArrayList<PropertyValue> aPrintProps = new ArrayList<PropertyValue>();
+ // GlobalLogWriter.println("Property FileName:=" + _sPrintFileURL);
+
+ // PropertyValue [] aPrintProps = new PropertyValue[nProperties];
+ PropertyValue Arg = new PropertyValue();
+ Arg.Name = "FileName";
+ Arg.Value = _sPrintFileURL;
+ // aPrintProps[nPropsCount ++] = Arg;
+ aPrintProps.add(Arg);
+ showProperty(Arg);
+
+
+ // generate pages string
+ if (_aGTA.printAllPages() == false)
+ {
+ String sPages = "";
+ if (_aGTA.getMaxPages() > 0)
+ {
+ sPages = "1-" + String.valueOf(_aGTA.getMaxPages());
+ }
+ if (_aGTA.getOnlyPages().length() != 0)
+ {
+ if (sPages.length() != 0)
+ {
+ sPages += ";";
+ }
+ sPages += String.valueOf(_aGTA.getOnlyPages());
+ }
+
+ Arg = new PropertyValue();
+ Arg.Name = "Pages";
+ Arg.Value = sPages;
+ aPrintProps.add(Arg);
+ showProperty(Arg);
+ }
+
+ // GlobalLogWriter.println("Start printing.");
+
+ _aGTA.getPerformance().startTime(PerformanceContainer.Print);
+ aPrintable.print(PropertyHelper.createPropertyValueArrayFormArrayList(aPrintProps));
+ TimeHelper.waitInSeconds(1, "Start waiting for print ready.");
+
+ GlobalLogWriter.println("Wait until document is printed.");
+ boolean isBusy = true;
+ int nPrintCount = 0;
+ while (isBusy)
+ {
+ PropertyValue[] aPrinterProps = aPrintable.getPrinter();
+ int nPropIndex = 0;
+ while (!"IsBusy".equals(aPrinterProps[nPropIndex].Name))
+ {
+ // System.out.println(aPrinterProps[nPropIndex].Name);
+ nPropIndex++;
+ }
+ isBusy = (aPrinterProps[nPropIndex].Value == Boolean.TRUE) ? true : false;
+ TimeHelper.waitInSeconds(1, "is print ready?");
+ nPrintCount++;
+ if (nPrintCount > 3600)
+ {
+ // we will never wait >1h until print is ready!
+ GlobalLogWriter.println("ERROR: Cancel print due to too long wait.");
+ throw new com.sun.star.uno.Exception("Convwatch exception, wait too long for printing.");
+ }
+ }
+// TODO:
+// TimeHelper.waitInSeconds(40, "Start waiting after print ready.");
+
+ _aGTA.getPerformance().stopTime(PerformanceContainer.Print);
+ GlobalLogWriter.println(DateHelper.getDateTimeForHumanreadableLog() + " Print document done.");
+
+ // Create a .info file near the printed '.ps' or '.prn' file.
+ FileHelper.createInfoFile(_sPrintFileURL, _aGTA);
+ }
+ else
+ {
+ GlobalLogWriter.println("Can't get XPrintable interface.");
+ }
+ bFailed = false;
+ bBack = true;
+ }
+ catch ( com.sun.star.uno.Exception e )
+ {
+ // Some exception occures.FAILED
+ GlobalLogWriter.println("UNO Exception caught.");
+ GlobalLogWriter.println("Message: " + e.getMessage());
+
+ e.printStackTrace();
+ bBack = false;
+ }
+
+ if (bFailed == true)
+ {
+ GlobalLogWriter.println("convwatch.OfficePrint: FAILED");
+ }
+ else
+ {
+ GlobalLogWriter.println("convwatch.OfficePrint: OK");
+ }
+ return bBack;
+ }
+
+
+ /**
+ * @param _aGTA
+ * @param _sAbsoluteOutputPath
+ * @param _sAbsoluteInputFile
+ * @return true, if the reference (*.prrn file) based on given output path and given input path exist.
+ * If OVERWRITE_REFERENCE is set, always return false.
+ */
+ public boolean isReferenceExists(ParameterHelper _aGTA,
+ String _sAbsoluteOutputPath,
+ String _sAbsoluteInputFile)
+ {
+ if (! FileHelper.exists(_sAbsoluteInputFile))
+ {
+ // throw new ConvWatchCancelException("Input file: " + _sAbsoluteInputFile + " does not exist.");
+ return false;
+ }
+
+ // String fs = System.getProperty("file.separator");
+
+ // String sInputFileURL = URLHelper.getFileURLFromSystemPath(_sAbsoluteInputFile);
+
+ String sInputFileBasename = FileHelper.getBasename(_sAbsoluteInputFile);
+ // String sOutputFileURL = null;
+ String sOutputPath;
+ if (_sAbsoluteOutputPath != null)
+ {
+ sOutputPath = _sAbsoluteOutputPath;
+ // FileHelper.makeDirectories("", sOutputPath);
+ }
+ else
+ {
+ String sInputPath = FileHelper.getPath(_sAbsoluteInputFile);
+ sOutputPath = sInputPath;
+ }
+ // sOutputFileURL = URLHelper.getFileURLFromSystemPath(sOutputPath + fs + sInputFileBasename);
+ // sOutputFileURL = null;
+
+ String sPrintFilename = FileHelper.getNameNoSuffix(sInputFileBasename);
+ // String sPrintFileURL;
+
+ String sAbsolutePrintFilename = FileHelper.appendPath(sOutputPath, sPrintFilename + ".prn");
+ if (FileHelper.exists(sAbsolutePrintFilename) && _aGTA.getOverwrite() == false)
+ {
+ GlobalLogWriter.println("Reference already exist, don't overwrite. Set " + PropertyName.DOC_COMPARATOR_OVERWRITE_REFERENCE + "=true to force overwrite.");
+ return true;
+ }
+ return false;
+ }
+
+ // -----------------------------------------------------------------------------
+ /**
+ * create a reference file
+ * _sAbsoluteInputPath contains the source file, if not exists, return with failure.
+ * _sAbsoluteOutputPath contains the destination, where the file will store after load with StarOffice/OpenOffice.org
+ * if is null, print only near the Input file path
+ * _sPrintType ".prn" Print input file with StarOffice/OpenOffice.org and the default printer as PostScript
+ *
+ * @param _aGTA
+ * @return
+ */
+// public static boolean buildReference(ParameterHelper _aGTA,
+// String _sAbsoluteOutputPath,
+// String _sAbsoluteInputFile)
+// throws OfficeException
+// {
+// if (! FileHelper.exists(_sAbsoluteInputFile))
+// {
+// throw new OfficeException("buildReference(): Input file: " + _sAbsoluteInputFile + " does not exist.");
+// }
+//
+// String fs = System.getProperty("file.separator");
+//
+// String sInputFileURL = URLHelper.getFileURLFromSystemPath(_sAbsoluteInputFile);
+//
+// String sInputFileBasename = FileHelper.getBasename(_sAbsoluteInputFile);
+// String sOutputFileURL = null;
+// String sOutputPath;
+// if (_sAbsoluteOutputPath != null)
+// {
+// sOutputPath = _sAbsoluteOutputPath;
+// FileHelper.makeDirectories("", sOutputPath);
+// }
+// else
+// {
+// String sInputPath = FileHelper.getPath(_sAbsoluteInputFile);
+// sOutputPath = sInputPath;
+// }
+// // sOutputFileURL = URLHelper.getFileURLFromSystemPath(sOutputPath + fs + sInputFileBasename);
+// sOutputFileURL = null;
+//
+// String sPrintFilename = FileHelper.getNameNoSuffix(sInputFileBasename);
+// String sPrintFileURL;
+//
+// String sAbsolutePrintFilename = sOutputPath + fs + sPrintFilename + ".prn";
+// if (FileHelper.exists(sAbsolutePrintFilename) && _aGTA.getOverwrite() == false)
+// {
+// GlobalLogWriter.println("Reference already exist, don't overwrite. Set " + PropertyName.DOC_COMPARATOR_OVERWRITE_REFERENCE + "=true to force overwrite.");
+// return true;
+// }
+//
+// if (_aGTA.getReferenceType().toLowerCase().equals("msoffice"))
+// {
+// sPrintFileURL = URLHelper.getFileURLFromSystemPath(sAbsolutePrintFilename);
+// }
+// else if (_aGTA.getReferenceType().toLowerCase().equals("pdf"))
+// {
+//// TODO: If we rename the stored file to *.pdf, we have to be sure that we use *.pdf also as a available reference
+// sPrintFileURL = URLHelper.getFileURLFromSystemPath(sAbsolutePrintFilename );
+// }
+// else if (_aGTA.getReferenceType().toLowerCase().equals("ooo"))
+// {
+// sPrintFileURL = URLHelper.getFileURLFromSystemPath(sAbsolutePrintFilename );
+// }
+// else
+// {
+// GlobalLogWriter.println("OfficePrint.buildreference(): Unknown print type.");
+// return false;
+// }
+// return printToFile(_aGTA, sInputFileURL, sOutputFileURL, sPrintFileURL);
+// }
+
+
+
+ // TODO: Das Teil muss hier raus!
+
+
+// public static boolean printToFile(ParameterHelper _aGTA,
+// String _sInputFileURL,
+// String _sOutputFileURL,
+// String _sPrintFileURL) throws OfficeException
+// {
+// boolean bBack = false;
+// String sPrintFileURL = null;
+//
+//
+// // remember the current timer, to know how long a print process need.
+// // startTimer();
+//
+// if (_aGTA.getReferenceType().toLowerCase().equals("ooo"))
+// {
+// bBack = printToFileWithOOo(_aGTA, _sInputFileURL, _sOutputFileURL, _sPrintFileURL);
+// }
+// else if (_aGTA.getReferenceType().toLowerCase().equals("pdf"))
+// {
+// GlobalLogWriter.println("USE PDF AS EXPORT FORMAT.");
+// bBack = storeAsPDF(_aGTA, _sInputFileURL, _sPrintFileURL);
+// }
+// else if (_aGTA.getReferenceType().toLowerCase().equals("msoffice"))
+// {
+// if (MSOfficePostscriptCreator.isMSOfficeDocumentFormat(_sInputFileURL))
+// {
+// GlobalLogWriter.println("USE MSOFFICE AS EXPORT FORMAT.");
+// MSOfficePostscriptCreator a = new MSOfficePostscriptCreator();
+// try
+// {
+// a.printToFileWithMSOffice(_aGTA, FileHelper.getSystemPathFromFileURL(_sInputFileURL),
+// FileHelper.getSystemPathFromFileURL(_sPrintFileURL));
+// }
+// catch(OfficeException e)
+// {
+// e.printStackTrace();
+// GlobalLogWriter.println(e.getMessage());
+// throw new OfficeException("Exception caught. Problem with MSOffice printer methods.");
+// }
+// catch(java.io.IOException e)
+// {
+// GlobalLogWriter.println(e.getMessage());
+// throw new OfficeException("IOException caught. Problem with MSOffice printer methods.");
+// }
+// bBack = true;
+// }
+// else
+// {
+// GlobalLogWriter.println("This document type is not recognized as MSOffice format, as default fallback StarOffice/OpenOffice.org instead is used.");
+// bBack = printToFileWithOOo(_aGTA, _sInputFileURL, _sOutputFileURL, _sPrintFileURL);
+// }
+// }
+// else
+// {
+// // System.out.println("");
+// throw new OfficeException("OfficePrint.printToFile(): Unknown print type.");
+// }
+// return bBack;
+// }
+
+ // -----------------------------------------------------------------------------
+ // TODO: move this away!
+ // -----------------------------------------------------------------------------
+ void showType(String _sInputURL, XMultiServiceFactory _xMSF)
+ {
+ if (_sInputURL.length() == 0)
+ {
+ return;
+ }
+
+ if (_xMSF == null)
+ {
+ GlobalLogWriter.println("MultiServiceFactory not set.");
+ return;
+ }
+ XTypeDetection aTypeDetection = null;
+ try
+ {
+ Object oObj = _xMSF.createInstance("com.sun.star.document.TypeDetection");
+ aTypeDetection = UnoRuntime.queryInterface(XTypeDetection.class, oObj);
+ }
+ catch(com.sun.star.uno.Exception e)
+ {
+ GlobalLogWriter.println("Can't get com.sun.star.document.TypeDetection.");
+ return;
+ }
+ if (aTypeDetection != null)
+ {
+ String sType = aTypeDetection.queryTypeByURL(_sInputURL);
+ GlobalLogWriter.println("Type is: " + sType);
+ }
+ }
+
+
+ // -----------------------------------------------------------------------------
+ public String getInternalFilterName(String _sFilterName, XMultiServiceFactory _xMSF)
+ {
+ if (_sFilterName.length() == 0)
+ {
+ // System.out.println("No FilterName set.");
+ return null;
+ }
+
+ if (_xMSF == null)
+ {
+ GlobalLogWriter.println("MultiServiceFactory not set.");
+ return null;
+ }
+ // XFilterFactory aFilterFactory = null;
+ Object aObj = null;
+ try
+ {
+ aObj = _xMSF.createInstance("com.sun.star.document.FilterFactory");
+ }
+ catch(com.sun.star.uno.Exception e)
+ {
+ GlobalLogWriter.println("Can't get com.sun.star.document.FilterFactory.");
+ return null;
+ }
+ if (aObj != null)
+ {
+ XNameAccess aNameAccess = UnoRuntime.queryInterface(XNameAccess.class, aObj);
+ if (aNameAccess != null)
+ {
+
+ // if (_sFilterName.toLowerCase().equals("help"))
+ // {
+ // System.out.println("Show all possible ElementNames from current version." );
+ // String[] aElementNames = aNameAccess.getElementNames();
+ // for (int i = 0; i<aElementNames.length; i++)
+ // {
+ // System.out.println(aElementNames[i]);
+ // }
+ // System.out.println("Must quit.");
+ // System.out.exit(1);
+ // }
+
+ if (! aNameAccess.hasByName(_sFilterName))
+ {
+ GlobalLogWriter.println("FilterFactory.hasByName() says there exist no '" + _sFilterName + "'" );
+ return null;
+ }
+
+ Object[] aElements = null;
+ String[] aExtensions;
+ try
+ {
+ aElements = (Object[]) aNameAccess.getByName(_sFilterName);
+ if (aElements != null)
+ {
+ String sInternalFilterName = null;
+ // System.out.println("getByName().length: " + String.valueOf(aElements.length));
+ for (int i=0;i<aElements.length; i++)
+ {
+ PropertyValue aPropertyValue = (PropertyValue)aElements[i];
+ // System.out.println("PropertyValue.Name: " + aPropertyValue.Name);
+ if (aPropertyValue.Name.equals("Type"))
+ {
+ String sValue = (String)aPropertyValue.Value;
+ // System.out.println("Type: " + sValue);
+ sInternalFilterName = sValue;
+ }
+ }
+ return sInternalFilterName;
+ }
+ else
+ {
+ GlobalLogWriter.println("There are no elements for FilterName '" + _sFilterName + "'");
+ return null;
+ }
+ }
+ catch (com.sun.star.container.NoSuchElementException e)
+ {
+ GlobalLogWriter.println("NoSuchElementException caught. " + e.getMessage());
+ }
+ catch (com.sun.star.lang.WrappedTargetException e)
+ {
+ GlobalLogWriter.println("WrappedTargetException caught. " + e.getMessage());
+ }
+ }
+ }
+ return null;
+ }
+
+ // -----------------------------------------------------------------------------
+
+ String getServiceNameFromFilterName(String _sFilterName, XMultiServiceFactory _xMSF)
+ {
+ if (_sFilterName.length() == 0)
+ {
+ // System.out.println("No FilterName set.");
+ return null;
+ }
+
+ if (_xMSF == null)
+ {
+ GlobalLogWriter.println("MultiServiceFactory not set.");
+ return null;
+ }
+ // XFilterFactory aFilterFactory = null;
+ Object aObj = null;
+ try
+ {
+ aObj = _xMSF.createInstance("com.sun.star.document.FilterFactory");
+ }
+ catch(com.sun.star.uno.Exception e)
+ {
+ GlobalLogWriter.println("Can't get com.sun.star.document.FilterFactory.");
+ return null;
+ }
+ if (aObj != null)
+ {
+ XNameAccess aNameAccess = UnoRuntime.queryInterface(XNameAccess.class, aObj);
+ if (aNameAccess != null)
+ {
+ if (! aNameAccess.hasByName(_sFilterName))
+ {
+ GlobalLogWriter.println("FilterFactory.hasByName() says there exist no '" + _sFilterName + "'" );
+ return null;
+ }
+
+ Object[] aElements = null;
+ String[] aExtensions;
+ try
+ {
+ aElements = (Object[]) aNameAccess.getByName(_sFilterName);
+ if (aElements != null)
+ {
+ String sServiceName = null;
+ // System.out.println("getByName().length: " + String.valueOf(aElements.length));
+ for (int i=0;i<aElements.length; i++)
+ {
+ PropertyValue aPropertyValue = (PropertyValue)aElements[i];
+ if (aPropertyValue.Name.equals("DocumentService"))
+ {
+ String sValue = (String)aPropertyValue.Value;
+ // System.out.println("DocumentService: " + sValue);
+ sServiceName = sValue;
+ break;
+ }
+ }
+ return sServiceName;
+ }
+ else
+ {
+ GlobalLogWriter.println("There are no elements for FilterName '" + _sFilterName + "'");
+ return null;
+ }
+ }
+ catch (com.sun.star.container.NoSuchElementException e)
+ {
+ GlobalLogWriter.println("NoSuchElementException caught. " + e.getMessage());
+ }
+ catch (com.sun.star.lang.WrappedTargetException e)
+ {
+ GlobalLogWriter.println("WrappedTargetException caught. " + e.getMessage());
+ }
+ }
+ }
+ return null;
+ }
+ // -----------------------------------------------------------------------------
+
+ public static String getFileExtension(String _sInternalFilterName, XMultiServiceFactory _xMSF)
+ {
+ if (_sInternalFilterName.length() == 0)
+ {
+ // System.out.println("No FilterName set.");
+ return null;
+ }
+
+ if (_xMSF == null)
+ {
+ GlobalLogWriter.println("MultiServiceFactory not set.");
+ return null;
+ }
+ XTypeDetection aTypeDetection = null;
+ try
+ {
+ Object oObj = _xMSF.createInstance("com.sun.star.document.TypeDetection");
+ aTypeDetection = UnoRuntime.queryInterface(XTypeDetection.class, oObj);
+ }
+ catch(com.sun.star.uno.Exception e)
+ {
+ GlobalLogWriter.println("Can't get com.sun.star.document.TypeDetection.");
+ return null;
+ }
+ if (aTypeDetection != null)
+ {
+ XNameAccess aNameAccess = UnoRuntime.queryInterface(XNameAccess.class, aTypeDetection);
+ if (aNameAccess != null)
+ {
+
+ // System.out.println("Show ElementNames" );
+ // String[] aElementNames = aNameAccess.getElementNames();
+ // for (int i = 0; i<aElementNames.length; i++)
+ // {
+ // System.out.println(aElementNames[i]);
+ // }
+
+ if (! aNameAccess.hasByName(_sInternalFilterName))
+ {
+ GlobalLogWriter.println("TypeDetection.hasByName() says there exist no '" + _sInternalFilterName + "'" );
+ return null;
+ }
+
+ Object[] aElements = null;
+ String[] aExtensions;
+ try
+ {
+ aElements = (Object[]) aNameAccess.getByName(_sInternalFilterName);
+ if (aElements != null)
+ {
+ String sExtension = null;
+ // System.out.println("getByName().length: " + String.valueOf(aElements.length));
+ for (int i=0;i<aElements.length; i++)
+ {
+ PropertyValue aPropertyValue = (PropertyValue)aElements[i];
+ // System.out.println("PropertyValue.Name: " + aPropertyValue.Name);
+ if (aPropertyValue.Name.equals("Extensions"))
+ {
+ aExtensions = (String[])aPropertyValue.Value;
+ GlobalLogWriter.println(" Possible extensions are: " + String.valueOf(aExtensions.length));
+ if (aExtensions.length > 0)
+ {
+ for (int j=0;j<aExtensions.length;j++)
+ {
+ GlobalLogWriter.println(" " + aExtensions[j]);
+ }
+ sExtension = aExtensions[0];
+ GlobalLogWriter.println("");
+ }
+ }
+ }
+ return sExtension;
+ }
+ else
+ {
+ GlobalLogWriter.println("There are no elements for FilterName '" + _sInternalFilterName + "'");
+ return null;
+ }
+ }
+ catch (com.sun.star.container.NoSuchElementException e)
+ {
+ GlobalLogWriter.println("NoSuchElementException caught. " + e.getMessage());
+ }
+ catch (com.sun.star.lang.WrappedTargetException e)
+ {
+ GlobalLogWriter.println("WrappedTargetException caught. " + e.getMessage());
+ }
+}
+ }
+ return null;
+ }
+
+ // -----------------------------------------------------------------------------
+ public void convertDocument(String _sInputFile, String _sOutputPath, ParameterHelper _aGTA) throws OfficeException
+ {
+ XMultiServiceFactory xMSF = _aGTA.getMultiServiceFactory();
+ if (xMSF == null)
+ {
+ GlobalLogWriter.println("MultiServiceFactory in GraphicalTestArgument not set.");
+ return;
+ }
+
+ String sInputURL = URLHelper.getFileURLFromSystemPath(_sInputFile);
+ // showType(sInputURL, xMSF);
+ XComponent aDoc = loadFromURL( _aGTA, sInputURL);
+ if (aDoc == null)
+ {
+ GlobalLogWriter.println("Can't load document '"+ sInputURL + "'");
+ return;
+ }
+
+ if (_sOutputPath == null)
+ {
+ GlobalLogWriter.println("Outputpath not set.");
+ return;
+ }
+
+ if (! isStoreAllowed())
+ {
+ GlobalLogWriter.println("It's not allowed to store, check Input/Output path.");
+ return;
+ }
+// TODO: Do we need to wait?
+// TimeHelper.waitInSeconds(1, "wait after loadFromURL.");
+
+ XServiceInfo xServiceInfo = UnoRuntime.queryInterface( XServiceInfo.class, aDoc );
+ // String sFilter = getFilterName_forExcel(xServiceInfo);
+ // System.out.println("Filter is " + sFilter);
+
+ // store the document in an other directory
+ XStorable xStorable = UnoRuntime.queryInterface( XStorable.class, aDoc);
+ if (xStorable == null)
+ {
+ GlobalLogWriter.println("com.sun.star.frame.XStorable is null");
+ return;
+ }
+
+ String sFilterName = _aGTA.getExportFilterName();
+
+ // check how many Properties should initialize
+ int nPropertyCount = 0;
+ // if (sFilterName != null && sFilterName.length() > 0)
+ // {
+ // nPropertyCount ++;
+ // }
+
+ // initialize PropertyArray
+ // PropertyValue [] aStoreProps = new PropertyValue[ nPropertyCount ];
+ // int nPropertyIndex = 0;
+ ArrayList<PropertyValue> aPropertyList = new ArrayList<PropertyValue>();
+
+ String sExtension = "";
+
+ if (sFilterName != null && sFilterName.length() > 0)
+ {
+ String sInternalFilterName = getInternalFilterName(sFilterName, xMSF);
+ String sServiceName = getServiceNameFromFilterName(sFilterName, xMSF);
+
+ GlobalLogWriter.println("Filter detection:");
+ // check if service name from file filter is the same as from the loaded document
+ boolean bServiceFailed = false;
+ if (sServiceName == null || sInternalFilterName == null)
+ {
+ GlobalLogWriter.println("Given FilterName '" + sFilterName + "' seems to be unknown.");
+ bServiceFailed = true;
+ }
+ if (! xServiceInfo.supportsService(sServiceName))
+ {
+ GlobalLogWriter.println("Service from FilterName '" + sServiceName + "' is not supported by loaded document.");
+ bServiceFailed = true;
+ }
+ if (bServiceFailed == true)
+ {
+ GlobalLogWriter.println("Please check '" + PropertyName.DOC_CONVERTER_EXPORT_FILTER_NAME + "' in the property file.");
+ return;
+ }
+
+ if (sInternalFilterName != null && sInternalFilterName.length() > 0)
+ {
+ // get the FileExtension, by the filter name, if we don't get a file extension
+ // we assume the is also no right filter name.
+ sExtension = getFileExtension(sInternalFilterName, xMSF);
+ if (sExtension == null)
+ {
+ GlobalLogWriter.println("Can't found an extension for filtername, take it from the source.");
+ }
+ }
+
+ PropertyValue Arg = new PropertyValue();
+ Arg.Name = "FilterName";
+ Arg.Value = sFilterName;
+ // aStoreProps[nPropertyIndex ++] = Arg;
+ aPropertyList.add(Arg);
+ showProperty(Arg);
+ GlobalLogWriter.println("FilterName is set to: " + sFilterName);
+ }
+
+ String sOutputURL = "";
+ try
+ {
+ // create the new filename with the extension, which is ok to the file format
+ String sInputFileBasename = FileHelper.getBasename(_sInputFile);
+ // System.out.println("InputFileBasename " + sInputFileBasename);
+ String sInputFileNameNoSuffix = FileHelper.getNameNoSuffix(sInputFileBasename);
+ // System.out.println("InputFilename no suffix " + sInputFileNameNoSuffix);
+ String fs = System.getProperty("file.separator");
+ String sOutputFile = _sOutputPath;
+ if (! sOutputFile.endsWith(fs))
+ {
+ sOutputFile += fs;
+ }
+ if (sExtension != null && sExtension.length() > 0)
+ {
+ sOutputFile += sInputFileNameNoSuffix + "." + sExtension;
+ }
+ else
+ {
+ sOutputFile += sInputFileBasename;
+ }
+
+ if (FileHelper.exists(sOutputFile) && _aGTA.getOverwrite() == false)
+ {
+ GlobalLogWriter.println("File already exist, don't overwrite. Set " + PropertyName.DOC_COMPARATOR_OVERWRITE_REFERENCE + "=true to force overwrite.");
+ return;
+ }
+
+ sOutputURL = URLHelper.getFileURLFromSystemPath(sOutputFile);
+
+ GlobalLogWriter.println("Store document as '" + sOutputURL + "'");
+ xStorable.storeAsURL(sOutputURL, PropertyHelper.createPropertyValueArrayFormArrayList(aPropertyList));
+ GlobalLogWriter.println("Document stored.");
+ }
+ catch (com.sun.star.io.IOException e)
+ {
+ GlobalLogWriter.println("Can't store document '" + sOutputURL + "'. Message is :'" + e.getMessage() + "'");
+ }
+// TODO: Do we need to wait?
+// TimeHelper.waitInSeconds(1, "unknown in OfficePrint.convertDocument()");
+
+ }
+
+ /**
+ *
+ * @return false, if 'NoOffice=yes' is given
+ */
+// private boolean shouldOfficeStart()
+// {
+// String sNoOffice = (String)m_aParameterHelper.getTestParameters().get( "NoOffice" );
+// if (sNoOffice != null)
+// {
+// if (sNoOffice.toLowerCase().startsWith("t") || sNoOffice.toLowerCase().startsWith("y"))
+// {
+// return false;
+// }
+// }
+// return true;
+// }
+
+ OfficeProvider m_aProvider = null;
+ private void startOffice()
+ {
+ // SimpleFileSemaphore aSemaphore = new SimpleFileSemaphore();
+// if (shouldOfficeStart())
+// {
+ // if (OSHelper.isWindows())
+ // {
+ // aSemaphore.P(aSemaphore.getSemaphoreFile());
+ // }
+ m_aParameterHelper.getTestParameters().put(util.PropertyName.DONT_BACKUP_USERLAYER, Boolean.TRUE);
+
+ m_aParameterHelper.getPerformance().startTime(PerformanceContainer.OfficeStart);
+ m_aProvider = new OfficeProvider();
+ XMultiServiceFactory xMSF = (XMultiServiceFactory) m_aProvider.getManager(m_aParameterHelper.getTestParameters());
+ m_aParameterHelper.getTestParameters().put("ServiceFactory", xMSF);
+ m_aParameterHelper.getPerformance().stopTime(PerformanceContainer.OfficeStart);
+
+ long nStartTime = m_aParameterHelper.getPerformance().getTime(PerformanceContainer.OfficeStart);
+ // aGTA = getParameterHelper(); // get new TestArguments
+ m_aParameterHelper.getPerformance().setTime(PerformanceContainer.OfficeStart, nStartTime);
+// }
+
+ // Watcher Object is need in log object to give a simple way to say if a running office is alive.
+ // As long as a log comes, it pings the Watcher and says the office is alive, if not an
+ // internal counter increase and at a given point (300 seconds) the office is killed.
+ GlobalLogWriter.println("Set office watcher");
+ if (GlobalLogWriter.get().getWatcher() == null)
+ {
+ OfficeWatcher aWatcher = (OfficeWatcher)m_aParameterHelper.getTestParameters().get("Watcher");
+ GlobalLogWriter.get().setWatcher(aWatcher);
+ }
+ }
+
+ private void stopOffice()
+ {
+ // Office shutdown
+ if (m_aProvider != null)
+ {
+ String sAppExecCmd = (String)m_aParameterHelper.getTestParameters().get("AppExecutionCommand");
+ if (sAppExecCmd != null && sAppExecCmd.length() > 0)
+ {
+ m_aProvider.closeExistingOffice(m_aParameterHelper.getTestParameters(), true);
+ }
+ // if (OSHelper.isWindows())
+ // {
+ // aSemaphore.V(aSemaphore.getSemaphoreFile());
+ // aSemaphore.sleep(2);
+ // // wait some time maybe an other process will take the semaphore
+ // // I know, this is absolutly dirty, but the whole convwatch is dirty and need a big cleanup.
+ // }
+ }
+ }
+
+ private boolean m_bStoreFile;
+ public void disallowStore()
+ {
+ m_bStoreFile = false;
+ }
+ public void allowStore()
+ {
+ m_bStoreFile = true;
+ }
+ public boolean isStoreAllowed()
+ {
+ return false;
+ // return m_bStoreFile;
+ }
+
+}
+
diff --git a/qadevOOo/runner/graphical/ParameterHelper.java b/qadevOOo/runner/graphical/ParameterHelper.java
new file mode 100644
index 000000000000..598ee6c53007
--- /dev/null
+++ b/qadevOOo/runner/graphical/ParameterHelper.java
@@ -0,0 +1,433 @@
+/*
+ * ************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ * ***********************************************************************
+ */
+
+package graphical;
+
+import com.sun.star.lang.XMultiServiceFactory;
+import lib.TestParameters;
+
+/**
+ * This class object is more a Helper or Controller.
+ * It stores information like:
+ * - How to create a document (with a OpenOffice.org method, or with MS Word, or with OpenOffice.org as pdf)
+ * - some more infos for OpenOffice.org method
+ * - a service factory pointer
+ * - if hidden mode should use
+ * - target name
+ *
+ * - printer name
+ *
+ * - how to handle .xml files, which in Microsoft could be Excel or Word documents
+ *
+ * HOWTO USE:
+ * For OOo,
+ * create an ParameterHelper with a set of TestParameters
+ * ParameterHelper a = new ParameterHelper(params);
+ *
+ * If you wish to use pdf export instead of normal printer output, set also the reference type to 'pdf'
+ * a.setReferenceType("pdf");
+ *
+ *
+ * For MS Office:
+ * create a ParameterHelper and set the reference type to 'msoffice'
+ * ParameterHelper a = new ParameterHelper(params);
+ * a.setReferenceType("msoffice");
+ *
+ * within windows it's better to set also a printer name so it's simply possible to use for normal work the default printer
+ * and for such tests with ConvWatch a extra printer.
+ * a.setPrinterName("CrossOffice Printer");
+ *
+ */
+
+public class ParameterHelper
+{
+ /*
+ TODO:
+ Possible reference types are currently
+ // ooo
+ // pdf
+ // msoffice
+ */
+ private String m_sReferenceType = null;
+
+ // private String m_sTargetFrameName = "_blank";
+
+ private String m_sPrinterName = null;
+
+ private int m_nResolutionInDPI = 180;
+
+ private boolean m_bIncludeSubdirectories;
+
+ private String m_sInputPath = null;
+ private String m_sOutputPath = null;
+// private String m_sReferencePath = null;
+
+ private TestParameters m_aCurrentParams;
+
+ // private GlobalLogWriter m_aLog;
+
+ // CONSTRUCTOR
+ private ParameterHelper(){}
+
+ public ParameterHelper(TestParameters param)
+ {
+ m_aCurrentParams = param;
+ // m_aLog = log;
+ // interpretReferenceType();
+ // interpretPrinterName();
+ }
+
+
+ protected TestParameters getTestParameters()
+ {
+ return m_aCurrentParams;
+ }
+
+ /**
+ * return the input path, if given.
+ * @return
+ */
+ public String getInputPath()
+ {
+ if (m_sInputPath == null)
+ {
+ String sInputPath = (String)getTestParameters().get( PropertyName.DOC_COMPARATOR_INPUT_PATH );
+ if (sInputPath == null || sInputPath.length() == 0)
+ {
+ GlobalLogWriter.println("Please set input path (path to documents) " + PropertyName.DOC_COMPARATOR_INPUT_PATH + "=path.");
+ }
+ else
+ {
+ m_sInputPath = helper.StringHelper.removeQuoteIfExists(sInputPath);
+ }
+ }
+ return m_sInputPath;
+ }
+
+ public String getOutputPath()
+ {
+ if (m_sOutputPath == null)
+ {
+ String sOutputPath = (String)getTestParameters().get( PropertyName.DOC_COMPARATOR_OUTPUT_PATH );
+ if (sOutputPath == null || sOutputPath.length() == 0)
+ {
+ GlobalLogWriter.println("Please set output path (path where to store document results) " + PropertyName.DOC_COMPARATOR_OUTPUT_PATH + "=path.");
+ }
+ else
+ {
+ m_sOutputPath = helper.StringHelper.removeQuoteIfExists(sOutputPath);
+ }
+ }
+ return m_sOutputPath;
+ }
+
+// public String getReferencePath()
+// {
+// if (m_sReferencePath == null)
+// {
+// String sReferencePath = (String)getTestParameters().get( PropertyName.DOC_COMPARATOR_REFERENCE_PATH );
+// if (sReferencePath == null || sReferencePath.length() == 0)
+// {
+// GlobalLogWriter.println("Please set reference path (path to reference documents) " + PropertyName.DOC_COMPARATOR_REFERENCE_PATH + "=path.");
+// }
+// else
+// {
+// m_sReferencePath = sReferencePath;
+// }
+// }
+// return m_sReferencePath;
+// }
+
+
+ public boolean isIncludeSubDirectories()
+ {
+ m_bIncludeSubdirectories = true;
+ String sRECURSIVE = (String)getTestParameters().get( PropertyName.DOC_COMPARATOR_INCLUDE_SUBDIRS );
+// TODO: I need to get the boolean value with get("name") because, if it is not given getBool() returns
+// with a default of 'false' which is not very helpful if the default should be 'true'
+// maybe a getBoolean("name", true) could be a better choise.
+ if (sRECURSIVE == null)
+ {
+ sRECURSIVE = "true";
+ }
+ if (sRECURSIVE.toLowerCase().equals("no") ||
+ sRECURSIVE.toLowerCase().equals("false"))
+ {
+ m_bIncludeSubdirectories = false;
+ }
+ return m_bIncludeSubdirectories;
+ }
+
+ public String getReferenceType()
+ {
+ if (m_sReferenceType == null)
+ {
+ // REFERENCE_TYPE ----------
+
+ String sReferenceType = (String)getTestParameters().get( PropertyName.DOC_COMPARATOR_REFERENCE_TYPE );
+ if (sReferenceType == null || sReferenceType.length() == 0)
+ {
+ m_sReferenceType = "ps";
+ }
+ else
+ {
+ // log.println("found REFERENCE_TYPE " + sReferenceType );
+ m_sReferenceType = sReferenceType;
+ }
+ }
+ return m_sReferenceType;
+ }
+
+ public String getPrinterName()
+ {
+ if (m_sPrinterName == null)
+ {
+ // PRINTER_NAME ----------
+
+ String sPrinterName = (String)getTestParameters().get( PropertyName.DOC_COMPARATOR_PRINTER_NAME );
+ if (sPrinterName == null || sPrinterName.length() == 0)
+ {
+ m_sPrinterName = "";
+ }
+ else
+ {
+ // log.println("found PRINTER_NAME " + sPrinterName );
+ m_sPrinterName = sPrinterName;
+ }
+ }
+ return m_sPrinterName;
+ }
+
+ PerformanceContainer m_aPerformanceContainer = null;
+ /**
+ * helper class for performance analyser features
+ * @return
+ */
+ public PerformanceContainer getPerformance()
+ {
+ if (m_aPerformanceContainer == null)
+ {
+ m_aPerformanceContainer = new PerformanceContainer();
+ }
+ return m_aPerformanceContainer;
+ }
+
+ /**
+ * Helper function to get the buildid of the current used OpenOffice.org
+ * out of the AppExecutionCommand the build ID
+ * @return
+ */
+ public String getBuildID()
+ {
+ String sAPP = (String)m_aCurrentParams.get(util.PropertyName.APP_EXECUTION_COMMAND);
+ // return getBuildID(sAPP);
+// TODO: here we need the getBuildID(string) method
+ String sBuildID = BuildID.getBuildID(sAPP);
+ return sBuildID;
+ }
+
+ /**
+ * @return integer value, which contain resolution in DPI.
+ */
+ public int getResolutionInDPI()
+ {
+ return m_nResolutionInDPI;
+ }
+ // get methods
+ public XMultiServiceFactory getMultiServiceFactory()
+ {
+ XMultiServiceFactory xMSF = (XMultiServiceFactory)m_aCurrentParams.getMSF();
+
+ // check if MultiServiceFactory is given
+ if (getReferenceType().toLowerCase().equals("pdf") ||
+ getReferenceType().toLowerCase().equals("ps") ||
+ getReferenceType().toLowerCase().equals("ooo"))
+ {
+ if (xMSF == null)
+ {
+ GlobalLogWriter.println("ERROR! MultiServiceFactory not given.");
+ }
+ }
+ return xMSF;
+ }
+
+ // Hidden = true hiddes a used OpenOffice.org, all code is executed in the background
+ // This parameter is not used for RefType: msoffice
+ // boolean m_bHidden = true;
+
+
+ public boolean isHidden()
+ {
+ // HIDDEN
+
+ String sOfficeViewable = (String)m_aCurrentParams.get(PropertyName.OFFICE_VIEWABLE);
+ if (sOfficeViewable != null)
+ {
+ if (sOfficeViewable.toLowerCase().equals("yes") ||
+ sOfficeViewable.toLowerCase().equals("true"))
+ {
+ return false; // setViewable();
+ }
+ else
+ {
+ return true; // setHidden();
+ }
+ }
+ return true; /* default: hidden */
+ }
+
+ // get/set for FilterName
+ // get the right Filtername (internal Name) from
+ // http://framework.openoffice.org/files/documents/25/897/filter_description.html
+
+ String m_sImportFilterName = "";
+ String m_sExportFilterName = "";
+ public void setImportFilterName(String _sImportFilterName)
+ {
+ m_sImportFilterName = _sImportFilterName;
+ }
+ public String getImportFilterName()
+ {
+ return m_sImportFilterName;
+ }
+ public void setExportFilterName(String _sExportFilterName)
+ {
+ m_sExportFilterName = _sExportFilterName;
+ }
+ public String getExportFilterName()
+ {
+ return m_sExportFilterName;
+ }
+ String m_sDocumentType = "";
+ public void setDocumentType(String _sName)
+ {
+ m_sDocumentType = _sName;
+ }
+ public String getDocumentType()
+ {
+ return m_sDocumentType;
+ }
+
+
+// String m_sDefaultXMLFormatApplication = null;
+// public String getDefaultXMLFormatApp()
+// {
+// if (m_sDefaultXMLFormatApplication == null)
+// {
+// // DEFAULT_XML_FORMAT_APP ------
+//
+// String sDefaultXMLFormatApp = (String)m_aCurrentParams.get( PropertyName.DOC_COMPARATOR_DEFAULT_XML_FORMAT_APP );
+// if (sDefaultXMLFormatApp == null || sDefaultXMLFormatApp.length() == 0)
+// {
+// m_sDefaultXMLFormatApplication = "word";
+// }
+// else
+// {
+// m_sDefaultXMLFormatApplication = sDefaultXMLFormatApp;
+// }
+// }
+// return m_sDefaultXMLFormatApplication;
+// }
+
+
+ // Pages -------------------------------------------------------------------
+
+ /**
+ * @return the number of pages to be print
+ */
+ public int getMaxPages()
+ {
+ // default is 0 (print all pages)
+ int nMaxPages = m_aCurrentParams.getInt( PropertyName.DOC_COMPARATOR_PRINT_MAX_PAGE );
+ return nMaxPages;
+ }
+
+ /**
+ * @return as string, which pages should be print, e.g. '1-4;6' here, page 1 to 4 and page 6.
+ */
+ public String getOnlyPages()
+ {
+ // default is null, there is no page which we want to print only.
+ String sOnlyPage = (String)m_aCurrentParams.get(PropertyName.DOC_COMPARATOR_PRINT_ONLY_PAGE);
+ if (sOnlyPage == null)
+ {
+ sOnlyPage = "";
+ }
+ return sOnlyPage;
+ }
+
+ /**
+ * @return true, if there should not print all pages at all, use getMaxPages() and or getOnlyPages() to get which pages to print
+ */
+ public boolean printAllPages()
+ {
+ if ( (getMaxPages() > 0) ||
+ (getOnlyPages().length() != 0))
+ {
+ return false;
+ }
+ return true;
+ }
+
+ public boolean getOverwrite()
+ {
+ boolean bOverwrite = m_aCurrentParams.getBool( PropertyName.DOC_COMPARATOR_OVERWRITE_REFERENCE);
+ return bOverwrite;
+ }
+
+ private String m_sHTMLPrefix = null;
+ public String getHTMLPrefix()
+ {
+ if (m_sHTMLPrefix == null)
+ {
+ String sPrefix = (String)getTestParameters().get( PropertyName.DOC_COMPARATOR_HTML_OUTPUT_PREFIX );
+ if (sPrefix == null || sPrefix.length() == 0)
+ {
+ GlobalLogWriter.println("Please set html prefix " + PropertyName.DOC_COMPARATOR_HTML_OUTPUT_PREFIX + "=prefix.");
+ }
+ else
+ {
+ m_sHTMLPrefix = sPrefix;
+ }
+ }
+ return m_sHTMLPrefix;
+ }
+
+ public boolean createSmallPictures()
+ {
+ // boolean bCreateSmallPictures = true;
+ boolean bNoSmallPictures = m_aCurrentParams.getBool( PropertyName.NO_SMALL_PICTURES);
+ if (bNoSmallPictures == true)
+ {
+ return false;
+ }
+ return true;
+ }
+
+}
diff --git a/qadevOOo/runner/graphical/PerformanceContainer.java b/qadevOOo/runner/graphical/PerformanceContainer.java
new file mode 100644
index 000000000000..ab3b292926e5
--- /dev/null
+++ b/qadevOOo/runner/graphical/PerformanceContainer.java
@@ -0,0 +1,271 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package graphical;
+
+import java.io.File;
+// import java.io.FileWriter;
+// import java.io.OutputStream;
+// import java.io.PrintStream;
+import java.io.PrintStream;
+import java.io.RandomAccessFile;
+// import java.io.StringWriter;
+// import java.lang.Double;
+
+
+public class PerformanceContainer /* extends *//* implements */ {
+ private long m_nStartTime;
+
+ /*
+ simple helper functions to start/stop a timer, to know how long a process need in milliseconds
+ */
+ public long getStartTime()
+ {
+ return System.currentTimeMillis();
+ }
+ public void setStartTime(long _nStartTime)
+ {
+ m_nStartTime = _nStartTime;
+ }
+
+ /*
+ return the time, which is done until last startTime()
+ */
+ private long meanTime(long _nCurrentTimer)
+ {
+ if (_nCurrentTimer == 0)
+ {
+ GlobalLogWriter.println("Forgotten to initialise a start timer.");
+ return 0;
+ }
+ long nMeanTime = System.currentTimeMillis();
+ return nMeanTime - _nCurrentTimer;
+ }
+
+ /*
+ public long stopTimer()
+ {
+ if (m_nStartTime == 0)
+ {
+ System.out.println("Forgotten to initialise start timer.");
+ return 0;
+ }
+ long nStopTime = System.currentTimeMillis();
+ return nStopTime - m_nStartTime;
+ }
+ */
+
+ final static int Load = 0;
+ final static int Store = 1;
+ final static int Print = 2;
+ final static int OfficeStart = 3;
+ final static int StoreAsPDF = 4;
+ final static int OfficeStop = 5;
+ final static int AllTime = 6;
+ final static int LAST_VALUE = 7; // THIS MUST BE ALWAYS THE LAST AND THE BIGGEST VALUE!
+
+ private long m_nTime[];
+ private String m_sMSOfficeVersion;
+
+ public PerformanceContainer()
+ {
+ m_nTime = new long[LAST_VALUE];
+ // @todo: is this need?
+ for (int i=0;i<LAST_VALUE;i++)
+ {
+ m_nTime[i] = 0;
+ }
+ }
+
+ public void setTime(int _nIndex, long _nValue)
+ {
+ m_nTime[_nIndex] = _nValue;
+ }
+ public long getTime(int _nIndex)
+ {
+ return m_nTime[_nIndex];
+ }
+
+ public void startTime(int _nIndex)
+ {
+ m_nTime[_nIndex] = getStartTime();
+ }
+
+ public void stopTime(int _nIndex)
+ {
+ m_nTime[_nIndex] = meanTime(m_nTime[_nIndex]);
+ }
+
+ public String getMSOfficeVersion()
+ {
+ return m_sMSOfficeVersion;
+ }
+
+ public void print(PrintStream out)
+ {
+ // String ls = System.getProperty("line.separator");
+ // out.
+ out.println("loadtime=" + String.valueOf(m_nTime[ Load ]));
+ out.println("storetime=" + String.valueOf(m_nTime[ Store ]));
+ out.println("printtime=" + String.valueOf(m_nTime[ Print ]));
+ out.println("officestarttime=" + String.valueOf(m_nTime[ OfficeStart ]));
+ out.println("officestoptime=" + String.valueOf(m_nTime[ OfficeStop ]));
+ out.println("storeaspdftime=" + String.valueOf(m_nTime[ StoreAsPDF ]));
+ out.println("alltime=" + String.valueOf(m_nTime[ AllTime ]));
+ }
+
+ public void print(IniFile _aIniFile, String _sSection)
+ {
+ // String ls = System.getProperty("line.separator");
+ // out.
+ _aIniFile.insertValue(_sSection, "loadtime" , String.valueOf(m_nTime[ Load ]));
+ _aIniFile.insertValue(_sSection, "storetime" , String.valueOf(m_nTime[ Store ]));
+ _aIniFile.insertValue(_sSection, "printtime" , String.valueOf(m_nTime[ Print ]));
+ _aIniFile.insertValue(_sSection, "officestarttime" , String.valueOf(m_nTime[ OfficeStart ]));
+ _aIniFile.insertValue(_sSection, "officestoptime" , String.valueOf(m_nTime[ OfficeStop ]));
+ _aIniFile.insertValue(_sSection, "storeaspdftime" , String.valueOf(m_nTime[ StoreAsPDF ]));
+ _aIniFile.insertValue(_sSection, "alltime" , String.valueOf(m_nTime[ AllTime ]));
+ }
+
+ public static double stringToDouble(String _sStr)
+ {
+ double nValue = 0;
+ try
+ {
+ nValue = Double.parseDouble( _sStr );
+ }
+ catch (NumberFormatException e)
+ {
+ GlobalLogWriter.println("Can't convert string to double " + _sStr);
+ }
+ return nValue;
+ }
+
+ public static long secondsToMilliSeconds(double _nSeconds)
+ {
+ return (long)(_nSeconds * 1000.0);
+ }
+
+ /*
+ Helper function, which read some values from a given file
+
+ sample of wordinfofile
+ name=c:\doc-pool\wntmsci\samples\msoffice\word\LineSpacing.doc
+ WordVersion=11.0
+ WordStartTime=0.340490102767944
+ WordLoadTime=0.650935888290405
+ WordPrintTime=0.580835103988647
+ */
+ public void readWordValuesFromFile(String sFilename)
+ {
+ File aFile = new File(sFilename);
+ if (! aFile.exists())
+ {
+ GlobalLogWriter.println("couldn't find file " + sFilename);
+ return;
+ }
+
+ RandomAccessFile aRandomAccessFile = null;
+ try
+ {
+ aRandomAccessFile = new RandomAccessFile(aFile,"r");
+ String sLine = "";
+ while (sLine != null)
+ {
+ sLine = aRandomAccessFile.readLine();
+ if ( (sLine != null) &&
+ (! (sLine.length() < 2) ) &&
+ (! sLine.startsWith("#")))
+ {
+ if (sLine.startsWith("WordStartTime="))
+ {
+ String sTime = sLine.substring(14);
+ m_nTime[OfficeStart] = secondsToMilliSeconds(stringToDouble(sTime));
+ }
+ else if (sLine.startsWith("WordLoadTime="))
+ {
+ String sTime = sLine.substring(13);
+ m_nTime[Load] = secondsToMilliSeconds(stringToDouble(sTime));
+ }
+ else if (sLine.startsWith("WordPrintTime="))
+ {
+ String sTime = sLine.substring(14);
+ m_nTime[Print] = secondsToMilliSeconds(stringToDouble(sTime));
+ }
+ else if (sLine.startsWith("WordVersion="))
+ {
+ String sMSOfficeVersion = sLine.substring(12);
+ m_sMSOfficeVersion = "Word:" + sMSOfficeVersion;
+ }
+ else if (sLine.startsWith("ExcelVersion="))
+ {
+ String sMSOfficeVersion = sLine.substring(13);
+ m_sMSOfficeVersion = "Excel:" + sMSOfficeVersion;
+ }
+ else if (sLine.startsWith("PowerPointVersion="))
+ {
+ String sMSOfficeVersion = sLine.substring(18);
+ m_sMSOfficeVersion = "PowerPoint:" + sMSOfficeVersion;
+ }
+ }
+ }
+ }
+ catch (java.io.FileNotFoundException fne)
+ {
+ GlobalLogWriter.println("couldn't open file " + sFilename);
+ GlobalLogWriter.println("Message: " + fne.getMessage());
+ }
+ catch (java.io.IOException ie)
+ {
+ GlobalLogWriter.println("Exception while reading file " + sFilename);
+ GlobalLogWriter.println("Message: " + ie.getMessage());
+ }
+ try
+ {
+ aRandomAccessFile.close();
+ }
+ catch (java.io.IOException ie)
+ {
+ GlobalLogWriter.println("Couldn't close file " + sFilename);
+ GlobalLogWriter.println("Message: " + ie.getMessage());
+ }
+ }
+
+// public static void main(String[] args)
+// {
+// BorderRemover a = new BorderRemover();
+// try
+// {
+// a.createNewImageWithoutBorder(args[0], args[1]);
+// }
+// catch(java.io.IOException e)
+// {
+// System.out.println("Exception caught.");
+// }
+//
+// }
+}
diff --git a/qadevOOo/runner/graphical/PixelCounter.java b/qadevOOo/runner/graphical/PixelCounter.java
new file mode 100644
index 000000000000..e625c2a75b12
--- /dev/null
+++ b/qadevOOo/runner/graphical/PixelCounter.java
@@ -0,0 +1,247 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package graphical;
+
+
+// -----------------------------------------------------------------------------
+abstract class CountPixel
+{
+ protected int m_nCount = 0;
+ public int getCount() {return m_nCount;}
+ public abstract void count(int _nRGB);
+}
+
+// -----------------------------------------------------------------------------
+class CountNotWhite extends CountPixel
+{
+ public CountNotWhite()
+ {
+ // System.out.println("CountWhite()");
+ }
+
+ public void countold(final int pixel)
+ {
+ // final int alpha = (pixel >> 24) & 0xff;
+ final int red = (pixel >> 16) & 0xff;
+ final int green = (pixel >> 8) & 0xff;
+ final int blue = (pixel ) & 0xff;
+
+ // System.out.println(String.valueOf(red) + ":" + String.valueOf(green) + ":" + String.valueOf(blue));
+ if (red == 0xff && green == 0xff && blue == 0xff)
+ {
+ return;
+ }
+ ++m_nCount;
+ }
+ public void count(final int pixel)
+ {
+ // final int alpha = (pixel >> 24) & 0xff;
+ final int blue = (pixel ) & 0xff;
+ if (blue != 0xff)
+ {
+ ++m_nCount;
+ return;
+ }
+ final int green = (pixel >> 8) & 0xff;
+ if (green != 0xff)
+ {
+ ++m_nCount;
+ return;
+ }
+ final int red = (pixel >> 16) & 0xff;
+ if (red != 0xff)
+ {
+ ++m_nCount;
+ return;
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+class CountNotBlack extends CountPixel
+{
+ public CountNotBlack()
+ {
+ // System.out.println("CountBlack()");
+ }
+
+ public void countold(final int pixel)
+ {
+ // final int alpha = (pixel >> 24) & 0xff;
+ final int red = (pixel >> 16) & 0xff;
+ final int green = (pixel >> 8) & 0xff;
+ final int blue = (pixel ) & 0xff;
+
+ if (red == 0x00 && green == 0x00 && blue == 0x00)
+ {
+ return;
+ }
+ ++m_nCount;
+ }
+ public void count(final int pixel)
+ {
+ // final int alpha = (pixel >> 24) & 0xff;
+ final int blue = (pixel ) & 0xff;
+ if (blue != 0x00)
+ {
+ ++m_nCount;
+ return;
+ }
+ final int green = (pixel >> 8) & 0xff;
+ if (green != 0x00)
+ {
+ ++m_nCount;
+ return;
+ }
+ final int red = (pixel >> 16) & 0xff;
+ if (red != 0x00)
+ {
+ ++m_nCount;
+ return;
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+class graphics_stuff
+{
+// public int stuff()
+// {
+//// (1) decoding
+// int rgba = 0; // ...; // comes from PixelGrabber, BufferedImage.getRGB etc.
+// int red = (rgba >> 16) & 0xff;
+// int green = (rgba >> 8) & 0xff;
+// int blue = rgba & 0xff;
+// int alpha = (rgba >> 24) & 0xff;
+//// (2) now modify red, green, blue and alpha as you like;
+//// make sure that each of the four values stays in the
+//// interval 0 to 255
+//// ...
+//// (3) and encode back to an int, e.g. to give it to MemoryImageSource or
+//// BufferedImage.setRGB
+// rgba = (alpha << 24) | (red << 16) | (green << 8) | blue;
+// return 0;
+// }
+
+// public static void handlesinglepixel(int x, int y, int pixel)
+// {
+// int alpha = (pixel >> 24) & 0xff;
+// int red = (pixel >> 16) & 0xff;
+// int green = (pixel >> 8) & 0xff;
+// int blue = (pixel ) & 0xff;
+// // Deal with the pixel as necessary...
+// }
+
+ public static void countPixel(ImageHelper img, int _x, int _y, int _w, int _h, CountPixel _aPixelCounter)
+ {
+ for (int y = 0; y < _h; y++) {
+ for (int x = 0; x < _w; x++) {
+ // handlesinglepixel(x+i, y+j, pixels[j * w + i]);
+ _aPixelCounter.count(img.getPixel(x,y));
+ }
+ }
+ }
+ public static int countNotWhitePixel(ImageHelper _aImage)
+ {
+ final int w = _aImage.getWidth();
+ final int h = _aImage.getHeight();
+
+ CountPixel aCountNotWhite = new CountNotWhite();
+ countPixel(_aImage, 0, 0, w, h, aCountNotWhite);
+ return aCountNotWhite.getCount();
+ }
+
+ public static int countNotBlackPixel(ImageHelper _aImage)
+ {
+ final int w = _aImage.getWidth();
+ final int h = _aImage.getHeight();
+
+ CountPixel aCountNotBlack = new CountNotBlack();
+ countPixel(_aImage, 0, 0, w, h, aCountNotBlack);
+ return aCountNotBlack.getCount();
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+public class PixelCounter {
+ // private Image m_aImage;
+ // ImageHelper m_aImage;
+
+
+ public int countNotWhitePixel(String _sFile)
+ throws java.io.IOException
+ {
+ ImageHelper aImage = ImageHelper.createImageHelper(_sFile);
+ final int nw = graphics_stuff.countNotWhitePixel(aImage);
+ return nw;
+ }
+
+ public int countNotBlackPixel(String _sFile)
+ throws java.io.IOException
+ {
+ ImageHelper aImage = ImageHelper.createImageHelper(_sFile);
+ final int nw = graphics_stuff.countNotBlackPixel(aImage);
+ return nw;
+ }
+
+ public static int countNotWhitePixelsFromImage(String _sFile)
+ throws java.io.IOException
+ {
+ PixelCounter a = new PixelCounter();
+ return a.countNotWhitePixel(_sFile);
+ }
+
+ public static int countNotBlackPixelsFromImage(String _sFile)
+ throws java.io.IOException
+ {
+ PixelCounter a = new PixelCounter();
+ return a.countNotBlackPixel(_sFile);
+ }
+
+ // -----------------------------------------------------------------------------
+
+// public static void main(String[] args) {
+//
+// String a = helper.StringHelper.createValueString(10, 4);
+// int dummy = 1;
+///*
+// BorderRemover a = new BorderRemover();
+// try
+// {
+// a.createNewImageWithoutBorder(args[0], args[1]);
+// }
+// catch(java.io.IOException e)
+// {
+// System.out.println("Exception caught.");
+// }
+// */
+// }
+}
+
+
diff --git a/qadevOOo/runner/graphical/PostscriptCreator.java b/qadevOOo/runner/graphical/PostscriptCreator.java
new file mode 100644
index 000000000000..ab7ad4536fa6
--- /dev/null
+++ b/qadevOOo/runner/graphical/PostscriptCreator.java
@@ -0,0 +1,137 @@
+/*
+ * ************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ * ***********************************************************************
+ */
+
+package graphical;
+
+
+/**
+ *
+ * @author ll93751
+ */
+public class PostscriptCreator extends EnhancedComplexTestCase
+{
+
+ // @Override
+ public String[] getTestMethodNames()
+ {
+ return new String[]{"DocumentToPostscript"};
+ }
+
+ /**
+ * test function.
+ */
+ public void DocumentToPostscript()
+ {
+ GlobalLogWriter.set(log);
+ ParameterHelper aParam = new ParameterHelper(param);
+
+ param.put(util.PropertyName.OFFICE_CLOSE_TIME_OUT, 2000);
+ // run through all documents found in Inputpath
+ foreachDocumentinInputPath(aParam);
+ }
+
+
+ public void checkOneFile(String _sDocumentName, String _sResult, ParameterHelper _aParams) throws OfficeException
+ {
+ GlobalLogWriter.println("Document: " + _sDocumentName + " results: " + _sResult);
+ IOffice aOffice = new Office(_aParams, _sResult);
+
+ PerformanceContainer a = new PerformanceContainer();
+ a.startTime(PerformanceContainer.AllTime);
+
+ // _aParams.getTestParameters().put(util.PropertyName.DEBUG_IS_ACTIVE, Boolean.TRUE);
+ a.startTime(PerformanceContainer.OfficeStart);
+ aOffice.start();
+ a.stopTime(PerformanceContainer.OfficeStart);
+
+ // _aParams.getTestParameters().put(util.PropertyName.DEBUG_IS_ACTIVE, Boolean.FALSE);
+
+ // This force an error! _sDocumentName = helper.StringHelper.doubleQuote(_sDocumentName);
+ try
+ {
+ a.startTime(PerformanceContainer.Load);
+ aOffice.load(_sDocumentName);
+ a.stopTime(PerformanceContainer.Load);
+
+ a.startTime(PerformanceContainer.Print);
+ aOffice.storeAsPostscript();
+ a.stopTime(PerformanceContainer.Print);
+ }
+ finally
+ {
+ a.startTime(PerformanceContainer.OfficeStop);
+ aOffice.close();
+ a.stopTime(PerformanceContainer.OfficeStop);
+
+ a.stopTime(PerformanceContainer.AllTime);
+
+ a.print( System.out );
+ }
+ }
+
+
+
+
+// public static void main(String [] _args)
+// {
+// String args[] = {
+// "-TimeOut", "3600000",
+// "-tb", "java_complex",
+// "-o", "graphical.PostscriptCreator",
+//// "-DOC_COMPARATOR_INPUT_PATH", "D:\\temp\\input",
+//// "-DOC_COMPARATOR_OUTPUT_PATH", "D:\\temp\\output",
+//// "-DOC_COMPARATOR_REFERENCE_PATH", "D:\\temp\\output\\ref",
+//// "-DOC_COMPARATOR_PRINT_MAX_PAGE", "9999",
+//// "-DOC_COMPARATOR_GFX_OUTPUT_DPI_RESOLUTION", "180",
+//// "-DOC_COMPARATOR_HTML_OUTPUT_PREFIX", "http://so-gfxcmp-lin.germany.sun.com/gfxcmp_ui/cw.php?inifile=",
+////// "-DOC_COMPARATOR_REFERENCE_CREATOR_TYPE", "PDF", /* default: "OOo" */
+////// "-DOC_COMPARATOR_REFERENCE_CREATOR_TYPE", "msoffice", /* default: "OOo" */
+////// "-OFFICE_VIEWABLE", "false",
+//// "-AppExecutionCommand", "\"C:/home/ll93751/staroffice9_DEV300_m25/Sun/StarOffice 9/program/soffice.exe\" -norestore -nocrashreport -accept=pipe,name=ll93751;urp;",
+////// "-NoOffice"
+// "-DOC_COMPARATOR_PRINT_MAX_PAGE","9999",
+// "-DOC_COMPARATOR_GFX_OUTPUT_DPI_RESOLUTION","180",
+// "-DOC_COMPARATOR_HTML_OUTPUT_PREFIX","http://so-gfxcmp.germany.sun.com/gfxcmp_ui/cw.php?inifile=",
+// "-DOC_COMPARATOR_REFERENCE_CREATOR_TYPE","OOo",
+// "-DOC_COMPARATOR_DB_INFO_STRING","p:DEV300_m18,c:,d:LLA_test,src:DEV300_m18,dest:,doc:LLA_test,id:34715,distinct:2008-06-27_13-39-09_d6f22d4c-958d-10",
+// "-DISTINCT","2008-06-27_13-39-09_d6f22d4c-958d-10",
+// "-TEMPPATH","//so-gfxcmp-lin/gfxcmp-data/wntmsci/temp/2008-06-27_13-39-09_d6f22d4c-958d-10/34715",
+//// "ConnectionString","socket,host=localhost,port=8101",
+// "-OFFICE_VIEWABLE","true",
+// "-wntmsci.DOC_COMPARATOR_INPUT_PATH","\\\\so-gfxcmp-lin\\doc-pool\\LLA_test\\issue_79214.odb",
+// "-wntmsci.DOC_COMPARATOR_OUTPUT_PATH","\\\\so-gfxcmp-lin\\gfxcmp-data\\wntmsci\\convwatch-output\\LLA_test\\DEV300_m11",
+// "-wntmsci.AppExecutionCommand","\"C:\\gfxcmp\\programs\\staroffice8_DEV300_m11\\Sun\\StarOffice 9\\program\\soffice.exe\" -norestore -nocrashreport -accept=pipe,name=ll93751;urp;",
+// "-wntmsci.AppKillCommand","\"C:\\bin\\pskill.exe soffice.bin;C:\\bin\\pskill.exe winword;C:\\bin\\pskill.exe excel\"",
+//
+// };
+//
+// org.openoffice.Runner.main(args);
+// }
+
+}
diff --git a/qadevOOo/runner/graphical/PropertyName.java b/qadevOOo/runner/graphical/PropertyName.java
new file mode 100644
index 000000000000..729fd0c33c38
--- /dev/null
+++ b/qadevOOo/runner/graphical/PropertyName.java
@@ -0,0 +1,73 @@
+/*
+ * ************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ * ***********************************************************************
+ */
+
+package graphical;
+
+/**
+ *
+ * @author ll93751
+ */
+public interface PropertyName
+{
+ final public static String DOC_COMPARATOR_INPUT_PATH = "DOC_COMPARATOR_INPUT_PATH";
+ final public static String DOC_COMPARATOR_OUTPUT_PATH = "DOC_COMPARATOR_OUTPUT_PATH";
+// final public static String DOC_COMPARATOR_DIFF_PATH = "DOC_COMPARATOR_DIFF_PATH";
+// final public static String DOC_COMPARATOR_REFERENCE_PATH = "DOC_COMPARATOR_REFERENCE_PATH";
+// final public static String DOC_COMPARATOR_REFERENCE_INPUT_PATH = "DOC_COMPARATOR_REFERENCE_INPUT_PATH";
+ final public static String DOC_COMPARATOR_REFERENCE_TYPE = "DOC_COMPARATOR_REFERENCE_CREATOR_TYPE";
+ final public static String DOC_COMPARATOR_PRINTER_NAME = "DOC_COMPARATOR_PRINTER_NAME";
+// final public static String DOC_COMPARATOR_DEFAULT_XML_FORMAT_APP = "DOC_COMPARATOR_DEFAULT_XML_FORMAT_APP";
+ final public static String DOC_COMPARATOR_INCLUDE_SUBDIRS = "DOC_COMPARATOR_INCLUDE_SUBDIRS";
+ final public static String DOC_COMPARATOR_PRINT_MAX_PAGE = "DOC_COMPARATOR_PRINT_MAX_PAGE";
+ final public static String DOC_COMPARATOR_PRINT_ONLY_PAGE = "DOC_COMPARATOR_PRINT_ONLY_PAGE";
+ final public static String DOC_COMPARATOR_GFX_OUTPUT_DPI_RESOLUTION = "DOC_COMPARATOR_GFX_OUTPUT_DPI_RESOLUTION";
+ final public static String DOC_COMPARATOR_OVERWRITE_REFERENCE = "DOC_COMPARATOR_OVERWRITE_REFERENCE";
+
+ final public static String DOC_COMPARATOR_HTML_OUTPUT_PREFIX = "DOC_COMPARATOR_HTML_OUTPUT_PREFIX";
+// final public static String DOC_COMPARATOR_GFXCMP_WITH_BORDERMOVE = "DOC_COMPARATOR_GFXCMP_WITH_BORDERMOVE";
+
+ final public static String DOC_CONVERTER_IMPORT_FILTER_NAME = "DOC_CONVERTER_IMPORT_FILTER_NAME";
+ final public static String DOC_CONVERTER_EXPORT_FILTER_NAME = "DOC_CONVERTER_EXPORT_FILTER_NAME";
+ final public static String DOC_CONVERTER_OFFICE_PROGRAM = "DOC_CONVERTER_OFFICE_PROGRAM";
+// final public static String DOC_CONVERTER_REUSE_OFFICE = "DOC_CONVERTER_REUSE_OFFICE";
+
+ final public static String DOC_COMPARATOR_LEAVE_OUT_FILES = "DOC_COMPARATOR_LEAVE_OUT_FILES";
+
+ final public static String DOC_COMPARATOR_DB_INFO_STRING = "DOC_COMPARATOR_DB_INFO_STRING";
+
+// final public static String TEMPPATH = "TEMPPATH";
+
+ // set this variable to "true" or "yes" and loadComponentFromURL works with property Hidden=false
+ final public static String OFFICE_VIEWABLE = "OFFICE_VIEWABLE";
+
+// final public static String DB_CONNECTION_STRING = "DB_CONNECTION_STRING";
+// final public static String CHECK_NEED_TOOLS = "CHECK_NEED_TOOLS";
+// final public static String CREATE_DEFAULT = "CREATE_DEFAULT_REFERENCE";
+ final public static String NO_SMALL_PICTURES = "NoSmallPictures";
+}
diff --git a/qadevOOo/runner/graphical/TimeHelper.java b/qadevOOo/runner/graphical/TimeHelper.java
new file mode 100644
index 000000000000..057f9cd19494
--- /dev/null
+++ b/qadevOOo/runner/graphical/TimeHelper.java
@@ -0,0 +1,91 @@
+/*
+ * ************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ * ***********************************************************************
+ */
+
+package graphical;
+
+import java.util.Calendar;
+
+/**
+ *
+ * @author ll93751
+ */
+public class TimeHelper
+{
+ /*
+ wait a second the caller don't need to handle the interruptexception
+ @param _nSeconds how long should we wait
+ @param _sReason give a good reason, why we have to wait
+ */
+ static void waitInSeconds(int _nSeconds, String _sReason)
+ {
+ GlobalLogWriter.println("Wait 0.25 * " + String.valueOf(_nSeconds) + " sec. Reason: " + _sReason);
+ try {
+ java.lang.Thread.sleep(_nSeconds * 250);
+ } catch (java.lang.InterruptedException e2) {}
+ }
+
+ private int m_nSeconds;
+ private int m_nMilliSeconds;
+ private long m_nRealMilliSeconds;
+
+ private boolean m_bIsStopped = false;
+
+ public TimeHelper()
+ {}
+
+ public void start()
+ {
+ m_bIsStopped = false;
+ Calendar cal = Calendar.getInstance();
+ m_nSeconds = cal.get(Calendar.SECOND);
+ m_nMilliSeconds = cal.get(Calendar.MILLISECOND);
+ }
+ public void stop()
+ {
+ Calendar cal = Calendar.getInstance();
+ m_bIsStopped = true;
+ int nSeconds = cal.get(Calendar.SECOND);
+ m_nSeconds = nSeconds - m_nSeconds;
+ if (m_nSeconds < 0)
+ {
+ // add a minute
+ m_nSeconds += 60;
+ }
+
+ int nMilliSeconds = cal.get(Calendar.MILLISECOND);
+ m_nMilliSeconds = nMilliSeconds - m_nMilliSeconds;
+ m_nRealMilliSeconds = m_nSeconds * 1000 + m_nMilliSeconds;
+ }
+
+ public String getTime()
+ {
+ return String.valueOf(m_nRealMilliSeconds);
+ }
+
+}
diff --git a/qadevOOo/runner/graphical/Tolerance.java b/qadevOOo/runner/graphical/Tolerance.java
new file mode 100644
index 000000000000..90e853c9124c
--- /dev/null
+++ b/qadevOOo/runner/graphical/Tolerance.java
@@ -0,0 +1,23 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package graphical;
+
+/**
+ *
+ * @author ll93751
+ */
+public class Tolerance
+{
+ private int m_nTolerance;
+ public Tolerance(int _nAccept)
+ {
+ m_nTolerance = _nAccept;
+ }
+ public int getAccept()
+ {
+ return m_nTolerance;
+ }
+}
diff --git a/qadevOOo/runner/graphical/WrongEnvironmentException.java b/qadevOOo/runner/graphical/WrongEnvironmentException.java
new file mode 100644
index 000000000000..24ab5532b2e7
--- /dev/null
+++ b/qadevOOo/runner/graphical/WrongEnvironmentException.java
@@ -0,0 +1,42 @@
+/*
+ * ************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ * ***********************************************************************
+ */
+
+package graphical;
+
+/**
+ *
+ * @author ll93751
+ */
+public class WrongEnvironmentException extends OfficeException
+{
+ public WrongEnvironmentException(String _aMessage)
+ {
+ super(_aMessage);
+ }
+}
diff --git a/qadevOOo/runner/graphical/WrongSuffixException.java b/qadevOOo/runner/graphical/WrongSuffixException.java
new file mode 100644
index 000000000000..d8632ea50e72
--- /dev/null
+++ b/qadevOOo/runner/graphical/WrongSuffixException.java
@@ -0,0 +1,42 @@
+/*
+ * ************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ * ***********************************************************************
+ */
+
+package graphical;
+
+/**
+ *
+ * @author ll93751
+ */
+public class WrongSuffixException extends OfficeException
+{
+ public WrongSuffixException(String _aMessage)
+ {
+ super(_aMessage);
+ }
+}
diff --git a/qadevOOo/runner/graphical/makefile.mk b/qadevOOo/runner/graphical/makefile.mk
new file mode 100644
index 000000000000..4e1b0e98cba1
--- /dev/null
+++ b/qadevOOo/runner/graphical/makefile.mk
@@ -0,0 +1,76 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+PRJ=..$/..
+
+PRJNAME = OOoRunner
+PACKAGE = convwatch
+TARGET = runner_convwatch
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+# --- Files --------------------------------------------------------
+
+JARFILES = ridl.jar unoil.jar jurt.jar juh.jar jut.jar java_uno.jar
+JAVAFILES = \
+BuildID.java \
+DateHelper.java \
+DirectoryHelper.java \
+EnhancedComplexTestCase.java \
+FileHelper.java \
+GlobalLogWriter.java \
+HTMLResult.java \
+IDocument.java \
+IOffice.java \
+ImageHelper.java \
+IniFile.java \
+JPEGComparator.java \
+JPEGCreator.java \
+JPEGEvaluator.java \
+MSOfficePostscriptCreator.java \
+Office.java \
+OfficeException.java \
+OpenOfficeDatabaseReportExtractor.java \
+OpenOfficePostscriptCreator.java \
+ParameterHelper.java \
+PerformanceContainer.java \
+PixelCounter.java \
+PostscriptCreator.java \
+PropertyName.java \
+TimeHelper.java \
+WrongEnvironmentException.java \
+WrongSuffixException.java \
+Tolerance.java
+
+# GraphicalComparator.java
+
+JAVACLASSFILES= $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class)
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
diff --git a/qadevOOo/runner/helper/APIDescGetter.java b/qadevOOo/runner/helper/APIDescGetter.java
new file mode 100644
index 000000000000..9e980b273896
--- /dev/null
+++ b/qadevOOo/runner/helper/APIDescGetter.java
@@ -0,0 +1,985 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package helper;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.StringTokenizer;
+
+import share.DescEntry;
+import share.DescGetter;
+
+/**
+ * This is the Office-API specific DescGetter<br>
+ * <br>
+ * Examples:<br><br>
+ * -o sw.SwXBodyText<br>
+ * runs the module test of <B>Sw.SwXBodyText</B><br>
+ * <br>
+ * -o sw.SwXBodyText::com::sun::star::text::Text<br>
+ * runs only the interface test <B>com.sun.star.textText</B> of the module <B>Sw.SwXBodyText</B><br>
+ * <br>
+ * -o sw.SwXBodyText::com::sun::star::text::Text,com::sun::star::text::XSimpleText<br>
+ * runs only the interfaces test <B>com.sun.star.textText</B> and <B>com.sun.star.text.XSimpleText</B> of the module <B>Sw.SwXBodyText</B><br>
+ * <br>
+ * -p sw<br>
+ * runs all modules of the project <B>sw</B><br>
+ * <br>
+ * -p listall<br>
+ * lists all known module tests<br>
+ * <br>
+ * -sce SCENARIO_FILE<br>
+ * A scenario file is a property file which could cotain <B>-o</B> and <B>-p</B> properties<br>
+ * <br>
+ * -sce sw.SwXBodyText,sw.SwXBookmark<br>
+ * runs the module test of <B>Sw.SwXBodyText</B> and <B>sw.SwXBookmark</B><br>
+ */
+public class APIDescGetter extends DescGetter
+{
+
+ private static String fullJob = null;
+
+ /*
+ * gets the needed information about a StarOffice component
+ * @param descPath Path to the ComponentDescription
+ * @param entry contains the entry name, e.g. sw.SwXBodyText
+ * @param debug if true some debug information is displayed on standard out
+ */
+ public DescEntry[] getDescriptionFor(String job, String descPath,
+ boolean debug)
+ {
+
+ if (job.startsWith("-o"))
+ {
+ job = job.substring(3, job.length()).trim();
+
+ if (job.indexOf(".") < 0)
+ {
+ return null;
+ }
+
+ // special in case several Interfaces are given comma separated
+ if (job.indexOf(",") < 0)
+ {
+ DescEntry entry = getDescriptionForSingleJob(job, descPath,
+ debug);
+
+ if (entry != null)
+ {
+ return new DescEntry[]
+ {
+ entry
+ };
+ }
+ else
+ {
+ return null;
+ }
+ }
+ else
+ {
+ ArrayList subs = getSubInterfaces(job);
+ String partjob = job.substring(0, job.indexOf(",")).trim();
+ DescEntry entry = getDescriptionForSingleJob(partjob, descPath,
+ debug);
+
+ if (entry != null)
+ {
+ for (int i = 0; i < entry.SubEntryCount; i++)
+ {
+ String subEntry = entry.SubEntries[i].longName;
+ int cpLength = entry.longName.length();
+ subEntry = subEntry.substring(cpLength + 2,
+ subEntry.length());
+
+ if (subs.contains(subEntry))
+ {
+ entry.SubEntries[i].isToTest = true;
+ }
+ }
+
+ return new DescEntry[]
+ {
+ entry
+ };
+ }
+ else
+ {
+ return null;
+ }
+ }
+ }
+
+ if (job.startsWith("-p"))
+ {
+ job = job.substring(3, job.length()).trim();
+
+ String[] scenario = createScenario(descPath, job, debug);
+ if (scenario == null)
+ {
+ return null;
+ }
+ DescEntry[] entries = new DescEntry[scenario.length];
+ for (int i = 0; i < scenario.length; i++)
+ {
+ entries[i] = getDescriptionForSingleJob(
+ scenario[i].substring(3).trim(), descPath, debug);
+ }
+ if (job.equals("listall"))
+ {
+ util.dbg.printArray(scenario);
+ System.exit(0);
+ }
+ return entries;
+ }
+
+ if (job.startsWith("-sce"))
+ {
+ job = job.substring(5, job.length()).trim();
+
+ File sceFile = new File(job);
+ if (sceFile.exists())
+ {
+ return getScenario(job, descPath, debug);
+ }
+ else
+ {
+ //look the scenarion like this? :
+ // sw.SwXBodyText,sw.SwXTextCursor
+ ArrayList subs = getSubObjects(job);
+ DescEntry[] entries = new DescEntry[subs.size()];
+
+ for (int i = 0; i < subs.size(); i++)
+ {
+ entries[i] = getDescriptionForSingleJob(
+ (String) subs.get(i), descPath, debug);
+ }
+ return entries;
+ }
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ protected DescEntry getDescriptionForSingleJob(String job, String descPath,
+ boolean debug)
+ {
+ boolean isSingleInterface = job.indexOf("::") > 0;
+ fullJob = job;
+
+ if (isSingleInterface)
+ {
+ job = job.substring(0, job.indexOf("::"));
+ }
+
+ if (job.startsWith("bugs"))
+ {
+ DescEntry Entry = new DescEntry();
+ Entry.entryName = job;
+ Entry.longName = job;
+ Entry.EntryType = "bugdoc";
+ Entry.isOptional = false;
+ Entry.isToTest = true;
+ Entry.SubEntryCount = 0;
+ Entry.hasErrorMsg = false;
+ Entry.State = "non possible";
+
+ return Entry;
+ }
+
+ DescEntry entry = null;
+
+ if (descPath != null)
+ {
+ if (debug)
+ {
+ System.out.println("## reading from File " + descPath);
+ }
+
+ entry = getFromDirectory(descPath, job, debug);
+ }
+ else
+ {
+ if (debug)
+ {
+ System.out.println("## reading from jar");
+ }
+
+ entry = getFromClassPath(job, debug);
+ }
+
+ boolean foundInterface = false;
+
+ if (isSingleInterface && (entry != null))
+ {
+ for (int i = 0; i < entry.SubEntryCount; i++)
+ {
+ if (!(entry.SubEntries[i].longName).equals(fullJob))
+ {
+ entry.SubEntries[i].isToTest = false;
+ }
+ else
+ {
+ foundInterface = true;
+ entry.SubEntries[i].isToTest = true;
+ }
+ }
+ }
+
+ if (isSingleInterface && !foundInterface || entry == null)
+ {
+ return setErrorDescription(entry,
+ "couldn't find a description for test '" + fullJob + "'");
+ }
+
+ return entry;
+ }
+
+ protected static DescEntry[] getSubEntries(BufferedReader cvsFile,
+ DescEntry parent, boolean debug)
+ {
+ String line = "";
+ String old_ifc_name = "";
+ ArrayList ifc_names = new ArrayList();
+ ArrayList meth_names = new ArrayList();
+ DescEntry ifcDesc = null;
+
+ while (line != null)
+ {
+ try
+ {
+ line = cvsFile.readLine();
+ if (line == null)
+ {
+ continue;
+ }
+ if (line.startsWith("#"))
+ {
+ continue;
+ }
+ if (line.length() <= 0)
+ {
+ continue;
+ }
+// TODO Probleme here
+ // int nFirstSemicolon = line.indexOf(";");
+ // int nLastSemicolon = line.lastIndexOf(";");
+
+ String unknown;
+ String ifc_name = ""; // = line.substring(line.indexOf(";") + 2, line.lastIndexOf(";") - 1);
+ String meth_name = ""; // = line.substring(line.lastIndexOf(";") + 2, line.length() - 1);
+ StringTokenizer aToken = new StringTokenizer(line, ";");
+ if (aToken.countTokens() < 3)
+ {
+ System.out.println("Wrong format: Line '" + line + "' is not supported.");
+ continue;
+ }
+ if (aToken.hasMoreTokens())
+ {
+ unknown = StringHelper.removeQuoteIfExists(aToken.nextToken());
+ }
+ if (aToken.hasMoreTokens())
+ {
+ ifc_name = StringHelper.removeQuoteIfExists(aToken.nextToken());
+ }
+ if (aToken.hasMoreTokens())
+ {
+ meth_name = StringHelper.removeQuoteIfExists(aToken.nextToken());
+ }
+
+ // String ifc_name = line.substring(line.indexOf(";") + 2, line.lastIndexOf(";") - 1);
+ // String meth_name = line.substring(line.lastIndexOf(";") + 2, line.length() - 1);
+
+ DescEntry methDesc = createDescEntry(meth_name, ifc_name, parent);
+
+ if (!ifc_name.equals(old_ifc_name))
+ {
+ if (ifcDesc != null)
+ {
+ ifcDesc.SubEntries = getDescArray(meth_names.toArray());
+ ifcDesc.SubEntryCount = meth_names.size();
+
+ //mark service/interface as optional if all methods/properties are optional
+ boolean allOptional = true;
+
+ for (int k = 0; k < ifcDesc.SubEntryCount; k++)
+ {
+ if (!ifcDesc.SubEntries[k].isOptional)
+ {
+ allOptional = false;
+ }
+ }
+
+ if (!ifcDesc.isOptional && allOptional)
+ {
+ ifcDesc.isOptional = allOptional;
+ }
+
+ meth_names.clear();
+ ifc_names.add(ifcDesc);
+ }
+
+ ifcDesc = new DescEntry();
+ ifcDesc.isToTest = true;
+ old_ifc_name = ifc_name;
+
+ if (ifc_name.indexOf("#optional") > 0)
+ {
+ ifcDesc.isOptional = true;
+ ifc_name = ifc_name.substring(0, ifc_name.indexOf("#"));
+ }
+
+ String className = createClassName(ifc_name);
+
+ ifcDesc.EntryType = entryType;
+ ifcDesc.entryName = "ifc" + className;
+ ifcDesc.longName = parent.entryName + "::" + ifc_name;
+ }
+ meth_names.add(methDesc);
+
+ }
+ catch (java.io.IOException ioe)
+ {
+ parent.hasErrorMsg = true;
+ parent.ErrorMsg = "IOException while reading the description";
+
+ return null;
+ }
+ }
+
+ ifcDesc.SubEntries = getDescArray(meth_names.toArray());
+ ifcDesc.SubEntryCount = meth_names.size();
+
+ //mark service/interface as optional if all methods/properties are optional
+ boolean allOptional = true;
+
+ for (int k = 0; k < ifcDesc.SubEntryCount; k++)
+ {
+ if (!ifcDesc.SubEntries[k].isOptional)
+ {
+ allOptional = false;
+ }
+ }
+
+ if (!ifcDesc.isOptional && allOptional)
+ {
+ ifcDesc.isOptional = allOptional;
+ }
+
+ ifc_names.add(ifcDesc);
+
+ return getDescArray(makeArray(ifc_names));
+ }
+ private static String createClassName(String _ifc_name)
+ {
+ StringTokenizer st = new StringTokenizer(_ifc_name, ":");
+ String className = "";
+
+ int count = 3;
+
+ if (_ifc_name.startsWith("drafts"))
+ {
+ count = 4;
+ }
+
+ for (int i = 0; st.hasMoreTokens(); i++)
+ {
+ String token = st.nextToken();
+
+ // skipping (drafts.)com.sun.star
+ if (i >= count)
+ {
+ if (!st.hasMoreTokens())
+ {
+ // inserting '_' before the last token
+ token = "_" + token;
+ }
+
+ className += ("." + token);
+ }
+ }
+ return className;
+ }
+
+ private static String entryType;
+
+ private static DescEntry createDescEntry(String meth_name, String ifc_name, DescEntry parent)
+ {
+ entryType = "service";
+ DescEntry methDesc = new DescEntry();
+
+ if (meth_name.indexOf("#optional") > 0)
+ {
+ methDesc.isOptional = true;
+ meth_name = meth_name.substring(0, meth_name.indexOf("#"));
+ }
+
+ if (meth_name.endsWith("()"))
+ {
+ methDesc.EntryType = "method";
+ entryType = "interface";
+ }
+ else
+ {
+ methDesc.EntryType = "property";
+ entryType = "service";
+ }
+
+ methDesc.entryName = meth_name;
+ methDesc.isToTest = true;
+
+
+ String withoutHash = ifc_name;
+
+ if (ifc_name.indexOf("#optional") > 0)
+ {
+ withoutHash = ifc_name.substring(0, ifc_name.indexOf("#"));
+ }
+
+ methDesc.longName = parent.entryName + "::" + withoutHash + "::" + meth_name;
+
+ return methDesc;
+ }
+
+ private static void createIfcName(String ifc_name, ArrayList meth_names, DescEntry ifcDesc)
+ {
+ }
+
+ /**
+ * This method ensures that XComponent will be the last in the list of interfaces
+ */
+ protected static Object[] makeArray(ArrayList entries)
+ {
+ Object[] entriesArray = entries.toArray();
+ ArrayList returnArray = new ArrayList();
+ Object addAtEnd = null;
+
+ for (int k = 0; k < entriesArray.length; k++)
+ {
+ DescEntry entry = (DescEntry) entriesArray[k];
+
+ if (entry.entryName.equals("ifc.lang._XComponent"))
+ {
+ addAtEnd = entry;
+ }
+ else
+ {
+ returnArray.add(entry);
+ }
+ }
+
+ if (addAtEnd != null)
+ {
+ returnArray.add(addAtEnd);
+ }
+
+ return returnArray.toArray();
+ }
+
+ protected static DescEntry setErrorDescription(DescEntry entry,
+ String ErrorMsg)
+ {
+ if (entry == null)
+ {
+ entry = new DescEntry();
+ }
+ entry.hasErrorMsg = true;
+ entry.ErrorMsg = "Error while getting description for test '" +
+ fullJob + "' as an API test: " + ErrorMsg;
+
+ return entry;
+ }
+
+ protected static DescEntry[] getDescArray(Object[] list)
+ {
+ DescEntry[] entries = new DescEntry[list.length];
+
+ for (int i = 0; i < list.length; i++)
+ {
+ entries[i] = (DescEntry) list[i];
+ }
+
+ return entries;
+ }
+
+ protected DescEntry getFromClassPath(String aEntry, boolean debug)
+ {
+ int dotindex = aEntry.indexOf('.');
+
+ if (dotindex == -1)
+ {
+ return null;
+ }
+
+ String module = null;
+ String shortName = null;
+
+ if (aEntry.indexOf(".uno") == -1)
+ {
+ module = aEntry.substring(0, aEntry.indexOf('.'));
+ shortName = aEntry.substring(aEntry.indexOf('.') + 1);
+ }
+ else
+ {
+ module = aEntry.substring(0, aEntry.lastIndexOf('.'));
+ shortName = aEntry.substring(aEntry.lastIndexOf('.') + 1);
+ }
+
+ DescEntry theEntry = new DescEntry();
+ theEntry.entryName = aEntry;
+ theEntry.longName = aEntry;
+ theEntry.isOptional = false;
+ theEntry.EntryType = "component";
+ theEntry.isToTest = true;
+
+ BufferedReader csvFile = null;
+
+ java.net.URL url = this.getClass().getResource("/objdsc/" + module);
+
+ if (url == null)
+ {
+ return setErrorDescription(theEntry,
+ "couldn't find module '" + module + "'");
+ }
+
+ try
+ {
+ java.net.URLConnection con = url.openConnection();
+
+ String sEndsWithCSVName = "." + shortName.trim() + ".csv";
+ if (con instanceof java.net.JarURLConnection)
+ {
+ // get Jar file from connection
+ java.util.jar.JarFile f = ((java.net.JarURLConnection) con).getJarFile();
+
+ // Enumerate over all entries
+ java.util.Enumeration e = f.entries();
+
+ String sStartModule = "/" + module + "/";
+ while (e.hasMoreElements())
+ {
+
+ String entry = e.nextElement().toString();
+
+// if (debug) {
+// System.out.println("### Read from connetion: " + entry);
+// }
+
+ if ((entry.lastIndexOf(sStartModule) != -1) &&
+ entry.endsWith(sEndsWithCSVName))
+ {
+ InputStream input = this.getClass().getResourceAsStream("/" + entry);
+ csvFile = new BufferedReader(new InputStreamReader(input));
+ break;
+ }
+ }
+ }
+ else
+ {
+ InputStream in = con.getInputStream();
+ java.io.BufferedReader buf = new java.io.BufferedReader(new InputStreamReader(in));
+ boolean found = false;
+
+ while (buf.ready() && !found)
+ {
+ String entry = buf.readLine();
+
+ if (entry.endsWith(sEndsWithCSVName))
+ {
+ System.out.println("FOUND ####");
+ InputStream input = this.getClass().getResourceAsStream("/objdsc/" +
+ module +
+ "/" +
+ entry);
+ csvFile = new BufferedReader(
+ new InputStreamReader(input));
+ found = true;
+ }
+ }
+
+ buf.close();
+ }
+ }
+ catch (java.io.IOException e)
+ {
+ e.printStackTrace();
+ }
+
+ if (csvFile == null)
+ {
+ return setErrorDescription(theEntry,
+ "couldn't find component '" +
+ theEntry.entryName + "'");
+ }
+
+ DescEntry[] subEntries = getSubEntries(csvFile, theEntry, debug);
+
+ theEntry.SubEntryCount = subEntries.length;
+ theEntry.SubEntries = subEntries;
+
+ return theEntry;
+ }
+
+ protected static DescEntry getFromDirectory(String descPath, String entry,
+ boolean debug)
+ {
+ int dotindex = entry.indexOf('.');
+
+ if (dotindex == -1)
+ {
+ return null;
+ }
+
+ String fs = System.getProperty("file.separator");
+ String module = null;
+ String shortName = null;
+
+ if (entry.indexOf(".uno") == -1)
+ {
+ module = entry.substring(0, entry.indexOf('.'));
+ shortName = entry.substring(entry.indexOf('.') + 1);
+ }
+ else
+ {
+ module = entry.substring(0, entry.lastIndexOf('.'));
+ shortName = entry.substring(entry.lastIndexOf('.') + 1);
+ }
+
+ DescEntry aEntry = new DescEntry();
+ aEntry.entryName = entry;
+ aEntry.longName = entry;
+ aEntry.isOptional = false;
+ aEntry.EntryType = "component";
+ aEntry.isToTest = true;
+
+ if (debug)
+ {
+ System.out.println("Parsing Description Path: " + descPath);
+ System.out.println("Searching module: " + module);
+ System.out.println("For the Component " + shortName);
+ }
+
+ File modPath = new File(descPath + fs + module);
+
+ if (!modPath.exists())
+ {
+ return setErrorDescription(aEntry,
+ "couldn't find module '" + module + "'");
+ }
+
+ String[] files = modPath.list();
+ String found = "none";
+
+ for (int i = 0; i < files.length; i++)
+ {
+ if (files[i].endsWith("." + shortName + ".csv"))
+ {
+ found = files[i];
+ System.out.println("found " + found);
+ break;
+ }
+ }
+
+ if (found.equals("none"))
+ {
+ return setErrorDescription(aEntry,
+ "couldn't find component '" + entry + "'");
+ }
+
+ String aUrl = descPath + fs + module + fs + found;
+
+ BufferedReader csvFile = null;
+
+ try
+ {
+ csvFile = new BufferedReader(new FileReader(aUrl));
+ }
+ catch (java.io.FileNotFoundException fnfe)
+ {
+ return setErrorDescription(aEntry, "couldn't find file '" + aUrl + "'");
+ }
+
+ DescEntry[] subEntries = getSubEntries(csvFile, aEntry, debug);
+
+ aEntry.SubEntryCount = subEntries.length;
+ aEntry.SubEntries = subEntries;
+
+ return aEntry;
+ }
+
+ protected ArrayList getSubInterfaces(String job)
+ {
+ ArrayList namesList = new ArrayList();
+ StringTokenizer st = new StringTokenizer(job, ",");
+
+ for (int i = 0; st.hasMoreTokens(); i++)
+ {
+ String token = st.nextToken();
+
+ if (token.indexOf(".") < 0)
+ {
+ namesList.add(token);
+ }
+ }
+
+ return namesList;
+ }
+
+ protected ArrayList getSubObjects(String job)
+ {
+ ArrayList namesList = new ArrayList();
+ StringTokenizer st = new StringTokenizer(job, ",");
+
+ for (int i = 0; st.hasMoreTokens(); i++)
+ {
+ namesList.add(st.nextToken());
+ }
+
+ return namesList;
+ }
+
+ protected String[] createScenario(String descPath, String job,
+ boolean debug)
+ {
+ String[] scenario = null;
+
+ if (descPath != null)
+ {
+ if (debug)
+ {
+ System.out.println("## reading from File " + descPath);
+ }
+
+ scenario = getScenarioFromDirectory(descPath, job, debug);
+ }
+ else
+ {
+ if (debug)
+ {
+ System.out.println("## reading from jar");
+ }
+
+ scenario = getScenarioFromClassPath(job, debug);
+ }
+
+ return scenario;
+ }
+
+ protected String[] getScenarioFromDirectory(String descPath, String job,
+ boolean debug)
+ {
+ String[] modules = null;
+ ArrayList componentList = new ArrayList();
+
+ if (!job.equals("unknown") && !job.equals("listall"))
+ {
+ modules = new String[]
+ {
+ job
+ };
+ }
+ else
+ {
+ File dirs = new File(descPath);
+
+ if (!dirs.exists())
+ {
+ modules = null;
+ }
+ else
+ {
+ modules = dirs.list();
+ }
+ }
+
+ for (int i = 0; i < modules.length; i++)
+ {
+ if (!isUnusedModule(modules[i]))
+ {
+ File moduleDir = new File(descPath + System.getProperty("file.separator") + modules[i]);
+ if (moduleDir.exists())
+ {
+ String[] components = moduleDir.list();
+ for (int j = 0; j < components.length; j++)
+ {
+ if (components[j].endsWith(".csv"))
+ {
+ String toAdd = getComponentForString(components[j], modules[i]);
+ toAdd = "-o " + modules[i] + "." + toAdd;
+ componentList.add(toAdd);
+ }
+ }
+ }
+ }
+ }
+
+ String[] scenario = new String[componentList.size()];
+ Collections.sort(componentList);
+
+ for (int i = 0; i < componentList.size(); i++)
+ {
+ scenario[i] = (String) componentList.get(i);
+ }
+
+ return scenario;
+
+ }
+
+ protected String[] getScenarioFromClassPath(String job, boolean debug)
+ {
+ String subdir = "/";
+
+ if (!job.equals("unknown") && !job.equals("listall"))
+ {
+ subdir += job;
+ }
+
+ java.net.URL url = this.getClass().getResource("/objdsc" + subdir);
+
+ if (url == null)
+ {
+ return null;
+ }
+
+ ArrayList scenarioList = new ArrayList();
+
+ try
+ {
+ java.net.URLConnection con = url.openConnection();
+
+ if (con instanceof java.net.JarURLConnection)
+ {
+ // get Jar file from connection
+ java.util.jar.JarFile f = ((java.net.JarURLConnection) con).getJarFile();
+
+ // Enumerate over all entries
+ java.util.Enumeration e = f.entries();
+
+ while (e.hasMoreElements())
+ {
+ String entry = e.nextElement().toString();
+
+ if (entry.startsWith("objdsc" + subdir) &&
+ (entry.indexOf("CVS") < 0) &&
+ !entry.endsWith("/"))
+ {
+ int startMod = entry.indexOf("/");
+ int endMod = entry.lastIndexOf("/");
+ String module = entry.substring(startMod + 1, endMod);
+ String component = getComponentForString(
+ entry.substring(endMod + 1,
+ entry.length()),
+ module);
+
+ if (!isUnusedModule(module))
+ {
+ scenarioList.add("-o " + module + "." +
+ component);
+ }
+ }
+ }
+ }
+ }
+ catch (java.io.IOException e)
+ {
+ e.printStackTrace();
+ }
+
+ String[] scenario = new String[scenarioList.size()];
+ Collections.sort(scenarioList);
+
+ for (int i = 0; i < scenarioList.size(); i++)
+ {
+ scenario[i] = (String) scenarioList.get(i);
+ }
+
+ return scenario;
+ }
+
+ protected String getComponentForString(String full, String module)
+ {
+ String component = "";
+
+
+ //cutting .csv
+ full = full.substring(0, full.length() - 4);
+
+ //cutting component
+ int lastdot = full.lastIndexOf(".");
+ component = full.substring(lastdot + 1, full.length());
+
+ if (module.equals("file") || module.equals("xmloff"))
+ {
+ String withoutComponent = full.substring(0, lastdot);
+ int preLastDot = withoutComponent.lastIndexOf(".");
+ component = withoutComponent.substring(preLastDot + 1,
+ withoutComponent.length()) +
+ "." + component;
+ }
+
+ return component;
+ }
+
+ protected boolean isUnusedModule(String moduleName)
+ {
+ ArrayList removed = new ArrayList();
+ removed.add("acceptor");
+ removed.add("brdgfctr");
+ removed.add("connectr");
+ removed.add("corefl");
+ removed.add("cpld");
+ removed.add("defreg");
+ removed.add("dynamicloader");
+ removed.add("impreg");
+ removed.add("insp");
+ removed.add("inv");
+ removed.add("invadp");
+ removed.add("javaloader");
+ removed.add("jen");
+ removed.add("namingservice");
+ removed.add("proxyfac");
+ removed.add("rdbtdp");
+ removed.add("remotebridge");
+ removed.add("simreg");
+ removed.add("smgr");
+ removed.add("stm");
+ removed.add("tcv");
+ removed.add("tdmgr");
+ removed.add("ucprmt");
+ removed.add("uuresolver");
+
+ return removed.contains(moduleName);
+ }
+}
diff --git a/qadevOOo/runner/helper/AppProvider.java b/qadevOOo/runner/helper/AppProvider.java
new file mode 100644
index 000000000000..f8cf7e9737db
--- /dev/null
+++ b/qadevOOo/runner/helper/AppProvider.java
@@ -0,0 +1,55 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package helper;
+
+/**
+ *
+ * Interface to get a Manager to access the application to check
+ */
+public interface AppProvider {
+
+ /**
+ * Method to get the desired Manager
+ */
+ public Object getManager(lib.TestParameters param);
+
+ /**
+ * Method to dispose the desired Manager
+ */
+ public boolean disposeManager(lib.TestParameters param);
+
+ /**
+ * Close an office.
+ * @param param The test parameters.
+ * @param closeIfPossible If true, close even if
+ * it was running before the test
+ * @return True, if close worked.
+ */
+ public boolean closeExistingOffice(lib.TestParameters param,
+ boolean closeIfPossible);
+}
diff --git a/qadevOOo/runner/helper/BuildEnvTools.java b/qadevOOo/runner/helper/BuildEnvTools.java
new file mode 100644
index 000000000000..296b56877717
--- /dev/null
+++ b/qadevOOo/runner/helper/BuildEnvTools.java
@@ -0,0 +1,195 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package helper;
+
+import java.io.File;
+import java.io.PrintWriter;
+import lib.TestParameters;
+import share.LogWriter;
+import util.*;
+
+/**
+ * This class support you to execute some shell commands in a buld environment. At ervery call of commands
+ * a build environment was created and the commands will be executed.
+ *
+ */
+public class BuildEnvTools {
+
+ private final TestParameters param;
+ private final LogWriter log;
+ private final boolean mDebug;
+ private final String mPlatform;
+ private final String mShell;
+ private boolean mCygwin;
+
+ /**
+ * This constructor creates an instance of BuildEncTools. It is verifying for all neccesarry
+ * parameters in <CODE>TestParameters</CODE> This must be:
+ * <ul>
+ * <li>OperatingSystem: Fill this parameter with an operating system like unxsols, unxsoli, unxlngi or wntmsci.
+ * </li>
+ * <li> Shell: Fill this parameter with a shell f.e '/bin/tcsh'
+ * or 'c:\\myShell\\myShell.exe'
+ * </li>
+ * @param param
+ * @param log
+ * @throws helper.ParameterNotFoundException
+ */
+ public BuildEnvTools(TestParameters param, LogWriter log) throws ParameterNotFoundException {
+ this.param = param;
+ this.log = log;
+ mDebug = param.getBool(PropertyName.DEBUG_IS_ACTIVE);
+
+ boolean error = false;
+
+ String msg = "\nERROR: the following parameter must be set before executing the test:\n\n";
+
+ mPlatform = (String) param.get(PropertyName.OPERATING_SYSTEM);
+ if (mDebug) {
+ log.println("### " + mPlatform);
+ }
+ if (mPlatform == null){
+ msg += PropertyName.OPERATING_SYSTEM + "\nFill this parameter with an operating system like unxsols," +
+ " unxsoli, unxlngi, unxmacxi or wntmsci. \n\n";
+ }
+ if(
+ (!mPlatform.equalsIgnoreCase(PropertyName.UNXSOLS)) &&
+ (!mPlatform.equalsIgnoreCase(PropertyName.UNXSOLI)) &&
+ (!mPlatform.equalsIgnoreCase(PropertyName.UNXLNGI)) &&
+ (!mPlatform.equalsIgnoreCase(PropertyName.UNXMACXI))&&
+ (!mPlatform.equalsIgnoreCase(PropertyName.WNTMSCI)) ){
+
+ msg += PropertyName.OPERATING_SYSTEM + ":" + mPlatform + "\nFill this parameter with an operating system like unxsols," +
+ " unxsoli, unxlngi, unxmacxi or wntmsci. \n\n";
+ error = true;
+ }
+
+ mShell = (String) param.get(PropertyName.SHELL);
+ if (mShell == null) {
+ msg += PropertyName.SHELL + "\nFill this parameter with a shell" +
+ "\n\t/bin/tcsh c:\\myShell\\myShell.exe\n\n";
+ error = true;
+ }
+
+ mCygwin = (param.getBool(PropertyName.CYGWIN));
+
+ if (error) {
+ throw new ParameterNotFoundException(msg);
+ }
+ }
+
+ /**
+ * Executes the given commands in OOo-Environment shell.
+ * @param commands
+ * @param workDir
+ * @param shortWait
+ * @return the processHandler of the commands
+ * @see helper.ProcessHandler
+ */
+ public ProcessHandler runCommandsInEnvironmentShell(String[] commands, File workDir, int shortWait) {
+
+ final String[] cmdLines = getCmdLinesWithCommand(commands);
+ final ProcessHandler pHdl = new ProcessHandler(cmdLines, (PrintWriter) log, workDir, shortWait, param);
+ pHdl.runCommand();
+ return pHdl;
+ }
+
+ public String getSrcRoot() {
+
+ String sSrcRoot = (String) param.get(PropertyName.SRC_ROOT);
+
+ if (sSrcRoot == null) {
+ String[] cmdLines = null;
+ if (mPlatform.equals(PropertyName.WNTMSCI) && ! mCygwin) {
+ cmdLines = new String[]{mShell, "/C", "echo SRC_ROOT=%SRC_ROOT"};
+ } else {
+ cmdLines = new String[]{mShell, "--login ", "-c ", "echo \"SRC_ROOT=$SRC_ROOT\""};
+ }
+
+ final ProcessHandler procHdl = new ProcessHandler(cmdLines, (PrintWriter) log, null, 5000, param);
+ procHdl.runCommand();
+
+ if (mDebug) {
+ log.println("---> Output of command:");
+ log.println(procHdl.getOutputText());
+ log.println("<--- Output of command:");
+ log.println("---> Error output of command");
+ log.println(procHdl.getErrorText());
+ log.println("<--- Error output of command");
+ }
+ final String output = procHdl.getOutputText();
+ final String[] outs = output.split("\n");
+
+ for (int i = 0; i < outs.length; i++) {
+ final String line = outs[i];
+ if (line.startsWith("SRC_ROOT")) {
+ sSrcRoot = getEnvValue(line);
+ }
+ }
+ }
+ return sSrcRoot;
+ }
+
+ private String[] getCmdLinesWithCommand(String[] commands) {
+ String[] cmdLines = null;
+ log.println("prepare command for platform " + mPlatform);
+
+ String seperator = "";
+ if (mPlatform.equals(PropertyName.WNTMSCI)) {
+ seperator = mCygwin ? ";" : "^";
+ } else {
+ seperator = ";";
+ }
+
+ String command = "";
+ for (int i = 0; i < commands.length; i++) {
+ if (i != 0) {
+ command += seperator;
+ }
+ command += commands[i];
+ }
+
+ if (mPlatform.equals(PropertyName.WNTMSCI)){
+ if (mCygwin){
+ String srcRoot = (String) param.get(PropertyName.SRC_ROOT);
+ String envSet = "export cyg_src_root=`cygpath '" + srcRoot.replaceAll("\\\\", "\\\\\\\\")+ "'`; source $cyg_src_root/winenv.set.sh;";
+ command = envSet + command;
+ cmdLines = new String[]{mShell, "--login", "-c", "\"" + command + "\""};
+ } else {
+ cmdLines = new String[]{mShell, "/C", "\"" + command + "\""};
+ }
+ } else {
+ cmdLines = new String[]{mShell, "-c", command};
+ }
+ return cmdLines;
+ }
+
+ private String getEnvValue(String line) {
+ final String[] split = line.split("=");
+ return split[1];
+ }
+}
diff --git a/qadevOOo/runner/helper/CfgParser.java b/qadevOOo/runner/helper/CfgParser.java
new file mode 100644
index 000000000000..f4f919c5cfc4
--- /dev/null
+++ b/qadevOOo/runner/helper/CfgParser.java
@@ -0,0 +1,192 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package helper;
+
+import lib.TestParameters;
+import java.util.Properties;
+import java.util.Enumeration;
+import java.io.FileInputStream;
+import util.PropertyName;
+
+/**
+ * This class parses the ini files and stores the data
+ * <br>
+ * inside TestParameters
+ */
+public class CfgParser
+{
+
+ protected boolean debug = false;
+ protected String iniFile = "";
+
+ public CfgParser(String ini)
+ {
+ if (ini != null)
+ {
+ this.iniFile = ini;
+ }
+ }
+
+ public void getIniParameters(TestParameters param)
+ {
+ debug = param.DebugIsActive;
+ Properties cfg = null;
+ if (iniFile.equals(""))
+ {
+ //no iniFile given, search one in the users home directory
+ cfg = getProperties(getDefaultFileName(true));
+ //try to search the user dir if no iniFile could be found yet
+ if (cfg == null)
+ {
+ cfg = getProperties(getDefaultFileName(false));
+ }
+ }
+ else
+ {
+ cfg = getProperties(iniFile);
+ }
+
+ if (cfg != null)
+ {
+ Enumeration cfgEnum = cfg.keys();
+ while (cfgEnum.hasMoreElements())
+ {
+ String pName = (String) cfgEnum.nextElement();
+ Object pValue = cfg.getProperty(pName);
+
+ if (pValue instanceof String)
+ {
+ pValue = ((String) pValue).trim();
+ }
+
+ param.put(pName.trim(), pValue);
+
+ if (pName.equals(PropertyName.TEST_DOCUMENT_PATH))
+ {
+
+ param.put("DOCPTH", (String) pValue);
+ System.setProperty("DOCPTH", (String) pValue);
+
+ }
+ else if (pName.equals(PropertyName.SRC_ROOT))
+ {
+
+ System.setProperty(pName, (String) pValue);
+
+ }
+ }
+ }
+
+ debug = param.DebugIsActive;
+
+ //check for platform dependend parameters
+ //this would have a $OperatingSystem as prefix
+ String os = (String) param.get(PropertyName.OPERATING_SYSTEM);
+ if (os != null && os.length() > 1)
+ {
+
+ //found something that could be a prefex
+ //check all parameters for this
+ Enumeration keys = param.keys();
+ while (keys.hasMoreElements())
+ {
+ String key = (String) keys.nextElement();
+ if (key.startsWith(os))
+ {
+ Object oldValue = param.get(key);
+ String newKey = key.substring(os.length() + 1);
+ param.remove(key);
+ param.put(newKey, oldValue);
+ }
+ }
+
+ }
+ }
+
+ protected Properties getProperties(String name)
+ {
+ // get the resource file
+ Properties prop = new Properties();
+ if (debug)
+ {
+ System.out.println("Looking for " + name);
+ }
+ try
+ {
+ FileInputStream propFile = new FileInputStream(name);
+ prop.load(propFile);
+ System.out.println("Parsing properties from " + name);
+ propFile.close();
+ }
+ catch (Exception e)
+ {
+ try
+ {
+ java.net.URL url = this.getClass().getResource("/" + name);
+ if (url != null)
+ {
+ System.out.println("Parsing properties from " + name);
+ java.net.URLConnection connection = url.openConnection();
+ java.io.InputStream in = connection.getInputStream();
+ prop.load(in);
+ }
+ }
+ catch (Exception ex)
+ {
+ //Exception while reading prop-file, returning null
+ return null;
+ }
+ }
+
+ return prop;
+ }
+
+ protected String getDefaultFileName(boolean home)
+ {
+ String fileSeparator = System.getProperty("file.separator");
+ String path = "";
+ if (home)
+ {
+ //look inside the home directory
+ path = System.getProperty("user.home");
+ }
+ else
+ {
+ path = System.getProperty("user.dir");
+ }
+ if (fileSeparator.equals("/"))
+ {
+ //suppose I'm on Unix-platform
+ return path + fileSeparator + ".runner.props";
+ }
+ else
+ {
+ //suppose I'm on Windows
+ return path + fileSeparator + "runner.props";
+ }
+ }
+}
diff --git a/qadevOOo/runner/helper/ClParser.java b/qadevOOo/runner/helper/ClParser.java
new file mode 100644
index 000000000000..583aea56f977
--- /dev/null
+++ b/qadevOOo/runner/helper/ClParser.java
@@ -0,0 +1,193 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package helper;
+
+import java.io.File;
+import java.util.Properties;
+
+import lib.TestParameters;
+import util.PropertyName;
+import util.utils;
+
+/**
+ * This class parses commandline Argument and stores <br>
+ * them into TestParameter
+ */
+public class ClParser
+{
+ /*
+ * Parses the commandline argument and puts them<br>
+ * into the TestParameters
+ */
+
+ public void getCommandLineParameter(TestParameters param, String[] args)
+ {
+ Properties mapping = getMapping();
+
+ for (int i = 0; i < args.length;)
+ {
+ String pName = getParameterFor(mapping, args[i]).trim();
+ String pValue = "";
+ if (pName.equals("TestJob"))
+ {
+ if (args.length > (i + 1))
+ {
+ pValue = args[i].trim() + " " + args[i + 1].trim();
+ i += 2;
+ }
+ else
+ {
+ pValue = args[i].trim() + " unknown";
+ i += 2;
+ }
+ }
+ else
+ {
+ if ((i + 1) < args.length)
+ {
+ pValue = args[i + 1].trim();
+
+ if (pValue.startsWith("-"))
+ {
+ i++;
+ pValue = "yes";
+ }
+ else if (pValue.startsWith("'"))
+ {
+ i++;
+ while (!pValue.endsWith("'"))
+ {
+ i++;
+ pValue = pValue + " " + args[i].trim();
+
+ }
+ pValue = utils.replaceAll13(pValue, "'", "");
+ i++;
+ }
+ else
+ {
+ i += 2;
+ }
+
+ if (pName.equals("TestDocumentPath"))
+ {
+ System.setProperty(
+ "DOCPTH", new File(pValue).getAbsolutePath());
+ }
+ else if (pName.equals(PropertyName.SRC_ROOT))
+ {
+ System.setProperty(pName, pValue);
+
+ }
+ }
+ else
+ {
+ pValue = "yes";
+ i++;
+ }
+ }
+
+ param.put(pName, pValue);
+ }
+ }
+
+ /*
+ * This method returns the path to a Configuration file <br>
+ * if defined as command line parameter, an empty String elsewhere
+ */
+ public String getIniPath(String[] args)
+ {
+ String iniFile = "";
+
+ for (int i = 0; i < args.length; i++)
+ {
+ if (args[i].equals("-ini"))
+ {
+ iniFile = args[i + 1];
+ break;
+ }
+ }
+
+ return iniFile;
+ }
+
+ /*
+ * This method returns the path to a Configuration file <br>
+ * if defined as command line parameter, an empty String elsewhere
+ */
+ public String getRunnerIniPath(String[] args)
+ {
+ String iniFile = "";
+
+ for (int i = 0; i < args.length; i++)
+ {
+ if (args[i].equals("-runnerini"))
+ {
+ iniFile = args[i + 1];
+ break;
+ }
+ }
+
+ return iniFile;
+ }
+
+ /*
+ * This method maps commandline Parameters to TestParameters
+ */
+ protected Properties getMapping()
+ {
+ Properties map = new Properties();
+ map.setProperty("-cs", "ConnectionString");
+ map.setProperty("-tb", "TestBase");
+ map.setProperty("-tdoc", "TestDocumentPath");
+ map.setProperty("-objdsc", "DescriptionPath");
+ map.setProperty("-cmd", "AppExecutionCommand");
+ map.setProperty("-o", "TestJob");
+ map.setProperty("-sce", "TestJob");
+ map.setProperty("-p", "TestJob");
+ map.setProperty("-aca", "AdditionalConnectionArguments");
+ map.setProperty("-xcl", "ExclusionList");
+ map.setProperty("-debug", "DebugIsActive");
+ map.setProperty("-log", "LoggingIsActive");
+ map.setProperty("-dbout", "DataBaseOut");
+ map.setProperty("-nca", "NoCwsAttach");
+
+ return map;
+ }
+
+ protected String getParameterFor(Properties map, String name)
+ {
+ String ret = map.getProperty(name);
+
+ if (ret == null)
+ {
+ ret = name.substring(1);
+ }
+
+ return ret;
+ }
+} \ No newline at end of file
diff --git a/qadevOOo/runner/helper/ComplexDescGetter.java b/qadevOOo/runner/helper/ComplexDescGetter.java
new file mode 100644
index 000000000000..287c0402fb77
--- /dev/null
+++ b/qadevOOo/runner/helper/ComplexDescGetter.java
@@ -0,0 +1,194 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package helper;
+
+import complexlib.ComplexTestCase;
+import util.DynamicClassLoader;
+import share.DescEntry;
+import share.DescGetter;
+import share.ComplexTest;
+import java.util.Vector;
+import share.LogWriter;
+
+/**
+ *
+ */
+public class ComplexDescGetter extends DescGetter
+{
+
+ ComplexTest testClass;
+
+ /** Creates new ComplexDescGetter */
+ public ComplexDescGetter()
+ {
+ testClass = null;
+ }
+
+ public DescEntry[] getDescriptionFor(String entry, String DescPath,
+ boolean debug)
+ {
+ // read scenario file
+ if (entry.startsWith("-sce"))
+ {
+ DescEntry[] entries = getScenario(entry.substring(5), null, debug);
+ return entries;
+ }
+ // one single job
+ else if (entry.startsWith("-o"))
+ {
+ DescEntry dEntry = getDescriptionForSingleJob(entry.substring(3), null, debug);
+ if (dEntry != null)
+ {
+ return new DescEntry[]
+ {
+ dEntry
+ };
+ }
+ }
+ System.out.println("Could not get a testjob with parameter '" + entry + "'");
+ // no job available
+ return null;
+ }
+
+ protected DescEntry getDescriptionForSingleJob(String className, String descPath, boolean debug)
+ {
+ DynamicClassLoader dcl = new DynamicClassLoader();
+ String methodNames[] = null;
+
+ if (debug)
+ {
+ System.out.println("Searching Class: " + className);
+ }
+
+ int index = className.indexOf("::");
+ if (index != -1)
+ {
+ // case1: method()
+ // case2: method(param1,param2)
+ // case3: method1(param1,param2),method2(param1,param2)
+ String method = className.substring(index + 2);
+ className = className.substring(0, index);
+ Vector methods = new Vector();
+
+ String[] split = method.split("(?<=\\)),(?=\\w+)");
+
+ for (int i = 0; i < split.length; i++)
+ {
+ String meth = split[i];
+
+ if (meth.endsWith("()"))
+ {
+ meth = meth.substring(0, meth.length() - 2);
+ }
+
+ methods.add(meth);
+ }
+
+ methodNames = new String[methods.size()];
+ methodNames = (String[]) methods.toArray(methodNames);
+ }
+
+ // create an instance
+ try
+ {
+ testClass = (ComplexTestCase) dcl.getInstance(className);
+ }
+ catch (java.lang.IllegalArgumentException e)
+ {
+ System.out.println("Error while getting description for test '" + className + "' as a Complex test.");
+ return null;
+ }
+ catch (java.lang.ClassCastException e)
+ {
+ System.out.println("The given class '" + className + "' is not a Complex test.");
+ return null;
+ }
+
+
+ if (debug)
+ {
+ System.out.println("Got test: " + ((Object) testClass).toString());
+ }
+
+ String testObjectName = className;
+ String[] testMethodNames = null;
+
+ if (testMethodNames == null)
+ {
+ testMethodNames = testClass.getTestMethodNames();
+ }
+ if (methodNames != null)
+ {
+ testMethodNames = methodNames;
+ }
+
+ DescEntry dEntry = createTestDesc(testObjectName, className, testMethodNames, null);
+
+ return dEntry;
+ }
+
+ /**
+ * Creates a description exntry for the given parameter
+ * @param testObjectName the name of the object
+ * @param className the class name of the class to load
+ * @param testMethodNames list of all methods to test
+ * @param log
+ * @return filled description entry
+ */
+ public DescEntry createTestDesc(String testObjectName, String className, String[] testMethodNames, LogWriter log)
+ {
+
+ DescEntry dEntry = new DescEntry();
+
+ dEntry.entryName = testObjectName;
+ dEntry.longName = className;
+ dEntry.isOptional = false;
+ dEntry.EntryType = "unit";
+ dEntry.isToTest = true;
+ dEntry.Logger = log;
+ dEntry.SubEntryCount = testMethodNames.length;
+ dEntry.SubEntries = new DescEntry[dEntry.SubEntryCount];
+ for (int i = 0; i < dEntry.SubEntryCount; i++)
+ {
+ DescEntry aEntry = new DescEntry();
+ aEntry.entryName = testMethodNames[i];
+ aEntry.longName = testObjectName + "::" + aEntry.entryName;
+ aEntry.isOptional = false;
+ aEntry.EntryType = "method";
+ aEntry.isToTest = true;
+ dEntry.SubEntries[i] = aEntry;
+ dEntry.Logger = log;
+ }
+
+ return dEntry;
+ }
+
+ protected String[] createScenario(String descPath, String job, boolean debug)
+ {
+ return new String[] {};
+ }
+}
diff --git a/qadevOOo/runner/helper/ConfigHelper.java b/qadevOOo/runner/helper/ConfigHelper.java
new file mode 100644
index 000000000000..088b927376f6
--- /dev/null
+++ b/qadevOOo/runner/helper/ConfigHelper.java
@@ -0,0 +1,348 @@
+package helper;
+
+import com.sun.star.uno.*;
+import com.sun.star.lang.*;
+import com.sun.star.container.*;
+import com.sun.star.beans.*;
+import com.sun.star.util.*;
+
+/**
+ * This <CODE>ConfigHelper</CODE> makes it possible to access the
+ * configuration and change their content.<P>
+ * <P>
+ * Example: <P>
+ * Listing of the <CODE>Configuration</CODE> Views.xcu:<P>
+ * &lt;oor:component-data xmlns:oor=&quot;http://openoffice.org/2001/registry&quot; xmlns:xs=&quot;http://www.w3.org/2001/XMLSchema&quot; oor:name=&quot;Views&quot; oor:package=&quot;org.openoffice.Office&quot;&gt;<p>
+ * &lt;node oor:name=&quot;Windows&quot;&gt;<P>
+ * <&lt;node oor:name=&quot;SplitWindow0&quot; oor:op=&quot;replace&quot;&gt;<P>
+ * &lt;prop oor:name=&quot;Visible&quot; oor:type=&quot;xs:boolean&quot;&gt;<P>
+ * &lt;value&gt;false&lt;/value&gt;<P>
+ * &lt;/prop&gt;<P>
+ * &lt;prop oor:name=&quot;WindowState&quot; oor:type=&quot;xs:string&quot;&gt;<P>
+ * &lt;value/&gt;<P>
+ * &lt;/prop&gt;<P>
+ * &lt;node oor:name=&quot;UserData&quot;&gt;<P>
+ * &lt;prop oor:name=&quot;UserItem&quot; oor:op=&quot;replace&quot;
+ * oor:type=&quot;xs:string&quot;&gt;<P>
+ * &lt;value&gt;V1,2,0&lt;/value&gt;<P>
+ * &lt;/prop&gt;<P>
+ * &lt;/node&gt;<P>
+ * &lt;/node&gt;<P>
+ * &lt;/node&gt;<P>
+ * <P>
+ * <CODE>Definition</CODE><P>
+ * <ul>
+ * <li><CODE>&lt;node oor:name=&quot;Windows&quot;&gt;</CODE>
+ * represents a <CODE>Set</CODE> and is a <CODE>XNameContainer</CODE></LI>
+ * <li><CODE>&lt;node oor:name=&quot;SplitWindow0&quot;&gt;</CODE>
+ * represents a <CODE>Group</CODE> and is a <CODE>XNameReplace</CODE></LI>
+ * <li><CODE>&lt;prop oor:name=&quot;Visible&quot;&gt;</CODE>
+ * represents a pr<CODE></CODE>operty of the group</li>
+ * <li><CODE>&lt;node oor:name=&quot;UserData&quot;&gt;</CODE>
+ * represents a <CODE>extensible group</CODE> and is a <CODE>XNameContainer</CODE></LI>
+ * <li><CODE>&lt;prop oor:name=&quot;UserItem&quot;&gt;</CODE>
+ * represents a <CODE>property</CODE> of the extensible group</LI>
+ * </UL>
+ * We assume in the following examples the existance of:<P>
+ * <CODE>ConfigHelper aConfig = new ConfigHelper(xMSF, "org.openoffice.Office.Views", false);</CODE>
+ * <ul>
+ * <li>If you like to insert a new <CODE>Group</CODE> into the <CODE>Set</CODE> "Windows":<p>
+ * <CODE>XNameReplace xMyGroup = aConfig.getOrInsertGroup("Windows", "myGroup");</CODE><P>
+ * The method <CODE>getOrInsertGroup()</CODE> uses the
+ * <CODE>XSingleServiceFactory</CODE> to create the skeleton of a new group.
+ *
+ * </li>
+ * <li>If you like to change the property "WindowState" of "myGroup"
+ * of the Set "Windows"<p>
+ * <CODE>aConfig.updateGroupProperty(
+ * "Windows","myGroup", "WindowState", "952,180,244,349;1;0,0,0,0;");</CODE>
+ * </li>
+ * <li>If you like to change the property "myProp" of the extensible group
+ * "myExtGroup" which is an extensible group of "my2ndGroup" of the
+ * Set "Windows":<p>
+ * <CODE>aConfig.insertOrUpdateExtensibleGroupProperty(
+ * "Windows", "my2ndGroup", "myExtGroup", "myProp","TheValue");</CODE>
+ * </li>
+ * </ul>
+ */
+public class ConfigHelper
+{
+ private XMultiServiceFactory m_xSMGR = null;
+ private XHierarchicalNameAccess m_xConfig = null;
+
+ //-----------------------------------------------
+ public ConfigHelper(XMultiServiceFactory xSMGR ,
+ String sConfigPath ,
+ boolean bReadOnly )
+ throws com.sun.star.uno.Exception
+ {
+ m_xSMGR = xSMGR;
+
+ XMultiServiceFactory xConfigRoot = (XMultiServiceFactory)
+ UnoRuntime.queryInterface(
+ XMultiServiceFactory.class,
+ m_xSMGR.createInstance(
+ "com.sun.star.configuration.ConfigurationProvider"));
+
+ PropertyValue[] lParams = new PropertyValue[1];
+ lParams[0] = new PropertyValue();
+ lParams[0].Name = "nodepath";
+ lParams[0].Value = sConfigPath;
+
+ Object aConfig;
+ if (bReadOnly)
+ aConfig = xConfigRoot.createInstanceWithArguments(
+ "com.sun.star.configuration.ConfigurationAccess",
+ lParams);
+ else
+ aConfig = xConfigRoot.createInstanceWithArguments(
+ "com.sun.star.configuration.ConfigurationUpdateAccess",
+ lParams);
+
+ m_xConfig = (XHierarchicalNameAccess)UnoRuntime.queryInterface(
+ XHierarchicalNameAccess.class,
+ aConfig);
+
+ if (m_xConfig == null)
+ throw new com.sun.star.uno.Exception("Could not open configuration \""+sConfigPath+"\"");
+ }
+
+ //-----------------------------------------------
+ public Object readRelativeKey(String sRelPath,
+ String sKey )
+ throws com.sun.star.container.NoSuchElementException
+ {
+ try
+ {
+ XPropertySet xPath = (XPropertySet)UnoRuntime.queryInterface(
+ XPropertySet.class,
+ m_xConfig.getByHierarchicalName(sRelPath));
+ return xPath.getPropertyValue(sKey);
+ }
+ catch(com.sun.star.uno.Exception ex)
+ {
+ throw new com.sun.star.container.NoSuchElementException(ex.getMessage());
+ }
+ }
+
+ //-----------------------------------------------
+ public void writeRelativeKey(String sRelPath,
+ String sKey ,
+ Object aValue )
+ throws com.sun.star.container.NoSuchElementException
+ {
+ try
+ {
+ XPropertySet xPath = (XPropertySet)UnoRuntime.queryInterface(
+ XPropertySet.class,
+ m_xConfig.getByHierarchicalName(sRelPath));
+ xPath.setPropertyValue(sKey, aValue);
+ }
+ catch(com.sun.star.uno.Exception ex)
+ {
+ throw new com.sun.star.container.NoSuchElementException(ex.getMessage());
+ }
+ }
+
+ //-----------------------------------------------
+ /**
+ * Updates the configuration.<p>
+ * This must be called after you have changed the configuration
+ * else you changes will be lost.
+ */
+ public void flush()
+ {
+ try
+ {
+ XChangesBatch xBatch = (XChangesBatch)UnoRuntime.queryInterface(
+ XChangesBatch.class,
+ m_xConfig);
+ xBatch.commitChanges();
+ }
+ catch(com.sun.star.uno.Exception ex)
+ {}
+ }
+
+ //-----------------------------------------------
+ public static Object readDirectKey(XMultiServiceFactory xSMGR ,
+ String sConfigFile,
+ String sRelPath ,
+ String sKey )
+ throws com.sun.star.uno.Exception
+ {
+ ConfigHelper aConfig = new ConfigHelper(xSMGR, sConfigFile, true);
+ return aConfig.readRelativeKey(sRelPath, sKey);
+ }
+
+ //-----------------------------------------------
+ public static void writeDirectKey(XMultiServiceFactory xSMGR ,
+ String sConfigFile,
+ String sRelPath ,
+ String sKey ,
+ Object aValue )
+ throws com.sun.star.uno.Exception
+ {
+ ConfigHelper aConfig = new ConfigHelper(xSMGR, sConfigFile, false);
+ aConfig.writeRelativeKey(sRelPath, sKey, aValue);
+ aConfig.flush();
+ }
+
+
+ /**
+ * Insert a structured node (group) in a name container (set)
+ * or else update it and retrun the <CODE>XNameReplace</CODE> of it.<P>
+ * The <CODE>XSingleServiceFacttory</CODE> of the <CODE>set</CODE> will be used
+ * to create a new group. This group is specific to its set and
+ * creates defined entries.
+ * @return The [inserted] group of the set
+ * @param groupName The name of the goup which should be returned
+ * @param setName The name of the set
+ * @throws com.sun.star.uno.Exception throws
+ * <CODE>com.sun.star.uno.Exeception</CODE> on any error.
+ */
+ public XNameReplace getOrInsertGroup(String setName, String groupName)
+ throws com.sun.star.uno.Exception
+
+ {
+ XNameContainer xSetCont = this.getSet(setName);
+
+ XNameReplace xChildAccess = null;
+
+ try {
+ Object xChild=xSetCont.getByName(groupName);
+ xChildAccess = (XNameReplace) UnoRuntime.queryInterface(
+ XNameReplace.class,xSetCont);
+ } catch(com.sun.star.container.NoSuchElementException e) {
+ // proceed with inserting
+ }
+
+ if (xChildAccess == null) {
+ XSingleServiceFactory xChildfactory = (XSingleServiceFactory)
+ UnoRuntime.queryInterface(XSingleServiceFactory.class,xSetCont);
+
+ Object xNewChild = xChildfactory.createInstance();
+
+ xSetCont.insertByName(groupName, xNewChild);
+
+ xChildAccess = (XNameReplace)
+ UnoRuntime.queryInterface(XNameContainer.class,xNewChild);
+ }
+
+ return xChildAccess;
+ }
+
+ /**
+ * Update a property of a group container of a set container
+ * @param setName the name of the <CODE>set</CODE> which containes the <CODE>group</CODE>
+ * @param groupName the name of the <CODE>group</CODE> which property should be changed
+ * @param propName the name of the property which should be changed
+ * @param propValue the value the property should get
+ * @throws com.sun.star.uno.Exception throws <CODE>com.sun.star.uno.Exeception</CODE> on any error.
+ */
+ public void updateGroupProperty(String setName,
+ String groupName,
+ String propName,
+ Object propValue)
+ throws com.sun.star.uno.Exception
+ {
+ XNameContainer xSetCont = this.getSet(setName);
+
+ XPropertySet xProp = null;
+ try {
+ xProp = (XPropertySet)UnoRuntime.queryInterface(
+ XPropertySet.class,
+ xSetCont.getByName(groupName));
+ } catch (com.sun.star.container.NoSuchElementException e){
+ throw new com.sun.star.uno.Exception(
+ "could not get group '" + groupName +
+ "' from set '"+ setName +"':\n" + e.toString());
+ }
+ try{
+ xProp.setPropertyValue(propName, propValue);
+ } catch (com.sun.star.uno.Exception e) {
+ throw new com.sun.star.uno.Exception(
+ "could not set property '" + propName +
+ "' from group '"+ groupName +
+ "' from set '"+ setName +"':\n" + e.toString());
+ }
+ }
+
+
+ /**
+ * Insert a property in an extensible group container or else update it
+ * @param setName the name of the <CODE>set</CODE> which containes the <CODE>group</CODE>
+ * @param group The name of the <CODE>group</CODE> which conatins the <CODE>extensible group</CODE>.
+ * @param extGroup The name of the <CODE>extensible group</CODE> which
+ * [should] contain the property
+ * @param propName The name of the property.
+ * @param propValue The value of the property.
+ * @throws com.sun.star.uno.Exception throws <CODE>com.sun.star.uno.Exeception</CODE> on any error.
+ */
+ public void insertOrUpdateExtensibleGroupProperty(
+ String setName,
+ String group,
+ String extGroup,
+ String propName,
+ Object propValue)
+ throws com.sun.star.uno.Exception
+ {
+ XNameContainer xSetCont = this.getSet(setName);
+
+ XNameReplace xGroupAccess = null;
+ XNameContainer xExtGroupCont = null;
+
+ try {
+ Object xGroup=xSetCont.getByName(group);
+ xGroupAccess = (XNameReplace) UnoRuntime.queryInterface(
+ XNameReplace.class,xGroup);
+ } catch(com.sun.star.container.NoSuchElementException e) {
+ throw new com.sun.star.uno.Exception(
+ "could not get group '" + group +
+ "' from set '"+ setName +"':\n" + e.toString());
+ }
+
+ try {
+ Object xGroup=xGroupAccess.getByName(extGroup);
+ xExtGroupCont = (XNameContainer) UnoRuntime.queryInterface(
+ XNameContainer.class,xGroup);
+ } catch(com.sun.star.container.NoSuchElementException e) {
+ throw new com.sun.star.uno.Exception(
+ "could not get extensilbe group '"+extGroup+
+ "' from group '"+ group +
+ "' from set '"+ setName +"':\n" + e.toString());
+ }
+
+ try {
+ xExtGroupCont.insertByName(propName, propValue);
+ }
+ catch(com.sun.star.container.ElementExistException e) {
+ xExtGroupCont .replaceByName(propName, propValue);
+ }
+
+ }
+
+
+ /**
+ * Returns a <CODE>XNameContainer</CODE> of the <CODE>Set</CODE>
+ * of the <CODE>Configuration</CODE>
+ * @param setName the name of the Set which sould be returned
+ * @throws com.sun.star.uno.Exception on any error
+ * @return A XNameContainer of the Set
+ */
+ public XNameContainer getSet(String setName)
+ throws com.sun.star.uno.Exception
+ {
+ XNameReplace xCont = (XNameReplace)
+ UnoRuntime.queryInterface(XNameReplace.class, m_xConfig);
+
+ Object oSet = xCont.getByName(setName);
+
+ if (oSet == null)
+ throw new com.sun.star.uno.Exception(
+ "could not get set '" + setName + ": null");
+
+ return (XNameContainer) UnoRuntime.queryInterface(
+ XNameContainer.class, oSet);
+
+ }
+}
diff --git a/qadevOOo/runner/helper/ConfigurationRead.java b/qadevOOo/runner/helper/ConfigurationRead.java
new file mode 100644
index 000000000000..e82fe6141b72
--- /dev/null
+++ b/qadevOOo/runner/helper/ConfigurationRead.java
@@ -0,0 +1,141 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package helper;
+
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.container.XHierarchicalNameAccess;
+import com.sun.star.container.XNameAccess;
+import com.sun.star.container.NoSuchElementException;
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.beans.PropertyState;
+import com.sun.star.uno.UnoRuntime;
+
+/**
+ * Read configuration settings.
+ */
+public class ConfigurationRead {
+
+ XHierarchicalNameAccess root = null;
+
+ /**
+ * Creates new ConfigurationRead
+ * @param xMSF An instance of service
+ * "com.sun.star.configuration.ConfigurationProvider"
+ * @param rootnode The root of the configuration nodes.
+ */
+ public ConfigurationRead(XMultiServiceFactory xMSF, String rootnode) {
+
+ PropertyValue [] nodeArgs = new PropertyValue [1];
+ PropertyValue nodepath = new PropertyValue();
+ nodepath.Name = "nodepath";
+ nodepath.Value = rootnode;
+ nodepath.Handle = -1;
+ nodepath.State = PropertyState.DEFAULT_VALUE;
+ nodeArgs[0]=nodepath;
+
+ try {
+ Object rootObject = xMSF.createInstanceWithArguments(
+ "com.sun.star.configuration.ConfigurationAccess",
+ nodeArgs);
+
+ root = (XHierarchicalNameAccess)
+ UnoRuntime.queryInterface(
+ XHierarchicalNameAccess.class, rootObject);
+ }
+ catch(com.sun.star.uno.Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Creates new ConfigurationRead. This uses "org.openoffice.Setup"
+ * as default root name.
+ * @param xMSF An instance of service
+ * "com.sun.star.configuration.ConfigurationProvider"
+ */
+ public ConfigurationRead(XMultiServiceFactory xMSF) {
+ this(xMSF, "org.openoffice.Setup");
+ }
+
+ /**
+ * Does the node with this hierarchical name exist?
+ * @param name The hierarchical name of a subnode.
+ * @return True, if the node exists.
+ */
+ public boolean hasByHieracrhicalName(String name) throws NoSuchElementException,
+ com.sun.star.lang.WrappedTargetException {
+
+ return root.hasByHierarchicalName(name);
+
+ }
+
+
+ /**
+ * Get the elements of the root node.
+ * @return All elements of the root node.
+ */
+ public String[] getRootNodeNames() {
+
+ XNameAccess xName = (XNameAccess)
+ UnoRuntime.queryInterface(XNameAccess.class, root);
+ String[]names = xName.getElementNames();
+ return names;
+ }
+
+ /**
+ * Get all elements of this node
+ * @param name The name of the node
+ * @return All elements of this node (as hierarchical names).
+ */
+ public String[] getSubNodeNames(String name) {
+ String[]names = null;
+ try {
+
+ Object next = root.getByHierarchicalName(name);
+ XNameAccess x = (XNameAccess)UnoRuntime.queryInterface(
+ XNameAccess.class, next);
+ names = x.getElementNames();
+ for (int i=0; i< names.length; i++) {
+ names[i] = name + "/" + names[i];
+ }
+ }
+ catch(Exception e) {
+ //just return null, if there are no further nodes
+ }
+ return names;
+ }
+
+ /**
+ * Get contents of a node by its hierarchical name.
+ * @param The hierarchical name of the node.
+ * @return The contents as an object
+ */
+ public Object getByHierarchicalName(String name) throws NoSuchElementException {
+ return root.getByHierarchicalName(name);
+ }
+
+}
diff --git a/qadevOOo/runner/helper/ContextMenuInterceptor.java b/qadevOOo/runner/helper/ContextMenuInterceptor.java
new file mode 100644
index 000000000000..a14685365c74
--- /dev/null
+++ b/qadevOOo/runner/helper/ContextMenuInterceptor.java
@@ -0,0 +1,140 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+package helper;
+
+import com.sun.star.beans.UnknownPropertyException;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.container.XIndexContainer;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.ui.ActionTriggerSeparatorType;
+import com.sun.star.ui.ContextMenuInterceptorAction;
+import com.sun.star.ui.XContextMenuInterceptor;
+import com.sun.star.uno.UnoRuntime;
+
+public class ContextMenuInterceptor implements XContextMenuInterceptor {
+
+ public ContextMenuInterceptorAction notifyContextMenuExecute(
+ com.sun.star.ui.ContextMenuExecuteEvent aEvent ) throws RuntimeException {
+ try {
+ // Retrieve context menu container and query for service factory to
+ // create sub menus, menu entries and separators
+ XIndexContainer xContextMenu = aEvent.ActionTriggerContainer;
+ XMultiServiceFactory xMenuElementFactory =
+ (XMultiServiceFactory)UnoRuntime.queryInterface(
+ XMultiServiceFactory.class, xContextMenu );
+
+ if ( xMenuElementFactory != null ) {
+
+ // create root menu entry for sub menu and sub menu
+ XPropertySet xRootMenuEntry =
+ (XPropertySet)UnoRuntime.queryInterface(
+ XPropertySet.class,
+ xMenuElementFactory.createInstance("com.sun.star.ui.ActionTrigger" ));
+
+ // create a line separator for our new help sub menu
+ XPropertySet xSeparator =
+ (XPropertySet)UnoRuntime.queryInterface(
+ XPropertySet.class,
+ xMenuElementFactory.createInstance("com.sun.star.ui.ActionTriggerSeparator" ) );
+ Short aSeparatorType = new Short( ActionTriggerSeparatorType.LINE );
+ xSeparator.setPropertyValue( "SeparatorType", (Object)aSeparatorType );
+
+ // query sub menu for index container to get access
+ XIndexContainer xSubMenuContainer =
+ (XIndexContainer)UnoRuntime.queryInterface(
+ XIndexContainer.class,
+ xMenuElementFactory.createInstance("com.sun.star.ui.ActionTriggerContainer" ));
+
+ // intialize root menu entry "Help"
+ xRootMenuEntry.setPropertyValue( "Text", new String( "Help" ));
+ xRootMenuEntry.setPropertyValue( "CommandURL", new String( "slot:5410" ));
+ xRootMenuEntry.setPropertyValue( "HelpURL", new String( "5410" ));
+ xRootMenuEntry.setPropertyValue( "SubContainer", (Object)xSubMenuContainer );
+
+ // create menu entries for the new sub menu
+ // intialize help/content menu entry
+ // entry "Content"
+ XPropertySet xMenuEntry = (XPropertySet)UnoRuntime.queryInterface(
+ XPropertySet.class, xMenuElementFactory.createInstance(
+ "com.sun.star.ui.ActionTrigger" ));
+ xMenuEntry.setPropertyValue( "Text", new String( "Content" ));
+ xMenuEntry.setPropertyValue( "CommandURL", new String( "slot:5401" ));
+ xMenuEntry.setPropertyValue( "HelpURL", new String( "5401" ));
+
+ // insert menu entry to sub menu
+ xSubMenuContainer.insertByIndex( 0, (Object)xMenuEntry );
+
+ // intialize help/help agent
+ // entry "Help Agent"
+ xMenuEntry = (XPropertySet)UnoRuntime.queryInterface(
+ XPropertySet.class,
+ xMenuElementFactory.createInstance("com.sun.star.ui.ActionTrigger" ));
+ xMenuEntry.setPropertyValue( "Text", new String( "Help Agent" ));
+ xMenuEntry.setPropertyValue( "CommandURL", new String( "slot:5962" ));
+ xMenuEntry.setPropertyValue( "HelpURL", new String( "5962" ));
+
+ // insert menu entry to sub menu
+ xSubMenuContainer.insertByIndex( 1, (Object)xMenuEntry );
+ // intialize help/tips
+ // entry "Tips"
+ xMenuEntry = (XPropertySet)UnoRuntime.queryInterface(
+ XPropertySet.class,
+ xMenuElementFactory.createInstance("com.sun.star.ui.ActionTrigger" ));
+ xMenuEntry.setPropertyValue( "Text", new String( "Tips" ));
+ xMenuEntry.setPropertyValue( "CommandURL", new String( "slot:5404" ));
+ xMenuEntry.setPropertyValue( "HelpURL", new String( "5404" ));
+
+ // insert menu entry to sub menu
+ xSubMenuContainer.insertByIndex( 2, (Object)xMenuEntry );
+
+ // add separator into the given context menu
+ xContextMenu.insertByIndex( 1, (Object)xSeparator );
+
+ // add new sub menu into the given context menu
+ xContextMenu.insertByIndex( 1, (Object)xRootMenuEntry );
+
+ // The controller should execute the modified context menu and stop notifying other
+ // interceptors.
+ return ContextMenuInterceptorAction.EXECUTE_MODIFIED ;
+ }
+ } catch ( UnknownPropertyException ex ) {
+ // do something useful
+ // we used a unknown property
+ } catch ( IndexOutOfBoundsException ex ) {
+ // do something useful
+ // we used an invalid index for accessing a container
+ } catch ( Exception ex ) {
+ // something strange has happend!
+ } catch ( Throwable ex ) {
+ // catch java exceptions and do something useful
+ }
+
+ return ContextMenuInterceptorAction.IGNORED;
+ }
+} \ No newline at end of file
diff --git a/qadevOOo/runner/helper/CwsDataExchangeImpl.java b/qadevOOo/runner/helper/CwsDataExchangeImpl.java
new file mode 100644
index 000000000000..15292f20d725
--- /dev/null
+++ b/qadevOOo/runner/helper/CwsDataExchangeImpl.java
@@ -0,0 +1,157 @@
+/*
+ *************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package helper;
+
+import java.io.FileWriter;
+import java.io.IOException;
+import java.util.ArrayList;
+import lib.TestParameters;
+import share.CwsDataExchange;
+import share.LogWriter;
+import util.PropertyName;
+import util.utils;
+
+/**
+ * Implementaion of the interface CwsDataExchange
+ * @see share.CwsDataExchange
+ */
+public class CwsDataExchangeImpl implements CwsDataExchange
+{
+
+ private final String cwsName;
+ private final TestParameters param;
+ private final LogWriter log;
+ private final BuildEnvTools bet;
+ private final boolean mDebug;
+
+ public CwsDataExchangeImpl(String cwsName, TestParameters param, LogWriter log) throws ParameterNotFoundException
+ {
+ this.cwsName = cwsName;
+ this.param = param;
+ this.log = log;
+ this.bet = new BuildEnvTools(param, log);
+ mDebug = param.getBool(PropertyName.DEBUG_IS_ACTIVE);
+ }
+
+ public ArrayList getModules()
+ {
+ // the cwstouched command send its version information to StdErr.
+ // A piping from StdErr to SdtOut the tcsh does not support.
+ // To find the output easily the echo command is used
+ final String[] commands =
+ {
+ "echo cwstouched starts here",
+ "cwstouched",
+ "echo cwstouched ends here"
+ };
+
+ final ProcessHandler procHdl = bet.runCommandsInEnvironmentShell(commands, null, 20000);
+
+ if (mDebug)
+ {
+ log.println("---> Output of getModules:");
+ log.println(procHdl.getOutputText());
+ log.println("<--- Output of getModules");
+ log.println("---> Error output of getModules");
+ log.println(procHdl.getErrorText());
+ log.println("<--- Error output of getModules");
+ }
+
+ final String[] outs = procHdl.getOutputText().split("\n");
+
+ final ArrayList<String> moduleNames = new ArrayList<String>();
+ boolean bStart = false;
+ for (int i = 0; i < outs.length; i++)
+ {
+ final String line = outs[i];
+ if (line.startsWith("cwstouched starts here"))
+ {
+ bStart = true;
+ continue;
+ }
+ if (line.startsWith("cwstouched ends here"))
+ {
+ bStart = false;
+ continue;
+ }
+ if (bStart && line.length() > 1)
+ {
+ moduleNames.add(line);
+ }
+ }
+
+ return moduleNames;
+ }
+
+ public void setUnoApiCwsStatus(boolean status)
+ {
+
+ FileWriter out = null;
+ String statusFile = null;
+ try
+ {
+
+ final String stat = status ? ".PASSED.OK" : ".PASSED.FAILED";
+
+ statusFile = utils.getUsersTempDir() +
+ System.getProperty("file.separator") +
+ "UnoApiCwsStatus." +
+ (String) param.get(PropertyName.VERSION) +
+ "_" + param.get(PropertyName.OPERATING_SYSTEM) + stat + ".txt";
+
+ out = new FileWriter(statusFile);
+
+ out.write(stat);
+ out.flush();
+ out.close();
+
+ final String[] commands =
+ {
+ "cwsattach " + statusFile
+ };
+
+ bet.runCommandsInEnvironmentShell(commands, null, 5000);
+
+ }
+ catch (IOException ex)
+ {
+ System.out.println("ERROR: could not attach file '" + statusFile + "' to cws\n" + ex.toString());
+ }
+ finally
+ {
+ try
+ {
+ out.close();
+ }
+ catch (IOException ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+ }
+}
diff --git a/qadevOOo/runner/helper/FileTools.java b/qadevOOo/runner/helper/FileTools.java
new file mode 100644
index 000000000000..0a6b4dd96577
--- /dev/null
+++ b/qadevOOo/runner/helper/FileTools.java
@@ -0,0 +1,160 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package helper;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+
+/**
+ * This class deliver some functionality to copy files.
+ */
+public class FileTools {
+
+ /**
+ * Copies all files under srcDir to dstDir.
+ * If dstDir does not exist, it will be created.
+ * @param srcDir the source directory
+ * @param dstDir the destination direcotry
+ * @throws java.io.IOException throws java.io.IOException if something failes
+ */
+ public static void copyDirectory(File srcDir, File dstDir)
+ throws java.io.IOException {
+ copyDirectory(srcDir, dstDir, new String[]{});
+ }
+ /**
+ * Copies all files under srcDir to dstDir except Files given in the
+ * ignore list. This files will not be copied.
+ * If dstDir does not exist, it will be created.
+ * @param srcDir the source directory
+ * @param dstDir the destination direcotry
+ * @param ignore a list of files which should not be copied
+ * @throws java.io.IOException throws java.io.IOException if something failes
+ */
+ public static void copyDirectory(File srcDir, File dstDir, String[] ignore)
+ throws java.io.IOException {
+
+ for (int i=0; i<ignore.length;i++){
+ if (srcDir.getName().endsWith(ignore[i])) {
+ return;
+ }
+ }
+
+ if (srcDir.isDirectory()) {
+ if (!dstDir.exists()) {
+ dstDir.mkdir();
+ }
+
+ String[] files = srcDir.list();
+ for (int i=0; i< files.length; i++) {
+ copyDirectory(new File(srcDir, files[i]), new File(dstDir, files[i]), ignore);
+ }
+ } else {
+ // This method is implemented in e1071 Copying a File
+ copyFile(srcDir, dstDir);
+ }
+ }
+
+ /**
+ * Copies src file to dst file. If the dst file does not exist, it is created
+ * @param src the source file
+ * @param dst the destination file
+ * @throws java.io.IOException throws java.io.IOException if something failes
+ */
+ public static void copyFile(File src, File dst) throws java.io.IOException {
+ InputStream in = new FileInputStream(src);
+ OutputStream out = new FileOutputStream(dst);
+
+ // Transfer bytes from in to out
+ byte[] buf = new byte[1024];
+ int len;
+ while ((len = in.read(buf)) > 0) {
+ out.write(buf, 0, len);
+ }
+ in.close();
+ out.close();
+ }
+ /**
+ * Deletes all files and subdirectories under dir and the directory itself.
+ * Returns true if all deletions were successful.
+ * If the deletion fails, the method the method continues to delete rest
+ * of the files and returns false.
+ * @return Returns true if all deletions were successful, else false.
+ * @param dir the directory to delete
+ */
+ public static boolean deleteDir(File dir) {
+
+ // if (! cleanDir(dir)) return false;
+
+ // The directory is now empty so delete it
+ // return dir.delete();
+ return cleanDir(dir);
+ }
+
+ /**
+ * Deletes all files and subdirectories under dir.
+ * Returns true if all deletions were successful.
+ * If a deletion fails, the method continues to delete rest of the files.
+ * @return Returns true if all deletions were successful, else false.
+ * @param dir the directory to clean from content
+ */
+ // public static boolean cleanDir(File dir){
+ //
+ // boolean success = true;
+ // if (dir.isDirectory()){
+ // File [] theFiles = dir.listFiles();
+ //
+ // if (theFiles.length != 0 )
+ // for (int i = 0; i < theFiles.length; i++){
+ // success &= theFiles[i].delete();
+ // }
+ // }
+ // return success;
+ // }
+
+ public static boolean cleanDir(File dir)
+ {
+ if (dir.isDirectory())
+ {
+ String[] children = dir.list();
+ for (int i=0; i<children.length; i++)
+ {
+ boolean success = cleanDir(new File(dir, children[i]));
+ if (!success)
+ {
+ return false;
+ }
+ }
+ }
+
+ // The directory is now empty so delete it
+ return dir.delete();
+ }
+}
diff --git a/qadevOOo/runner/helper/InetTools.java b/qadevOOo/runner/helper/InetTools.java
new file mode 100644
index 000000000000..56c964c8f4db
--- /dev/null
+++ b/qadevOOo/runner/helper/InetTools.java
@@ -0,0 +1,88 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package helper;
+
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.uno.UnoRuntime;
+
+// access the implementations via names
+import com.sun.star.util.XChangesBatch;
+
+import lib.TestParameters;
+
+
+public class InetTools {
+ /**
+ * Helper method: sets the HTTP-Proxy to values from
+ * <code>lib.TestParameters</code>
+ */
+ public static boolean setHTTPProxy(TestParameters param){
+ XMultiServiceFactory xMSF = (XMultiServiceFactory) param.getMSF();
+ PropertyValue[] ProvArgs = new PropertyValue[1];
+ PropertyValue Arg = new PropertyValue();
+ Arg.Name = "nodepath";
+ Arg.Value = "/org.openoffice.Inet/Settings";
+ ProvArgs[0] = Arg;
+
+ try {
+ Object oProvider = xMSF.createInstance(
+ "com.sun.star.configuration.ConfigurationProvider");
+
+ XMultiServiceFactory oProviderMSF = (XMultiServiceFactory) UnoRuntime.queryInterface(
+ XMultiServiceFactory.class,
+ oProvider);
+
+ Object oInet = oProviderMSF.createInstanceWithArguments(
+ "com.sun.star.configuration.ConfigurationUpdateAccess",
+ ProvArgs);
+
+ XPropertySet oInetProps = (XPropertySet) UnoRuntime.queryInterface(
+ XPropertySet.class, oInet);
+
+ String HTTPProxyName = (String)param.get("HTTPProxyName");
+ String HTTPProxyPort = (String)param.get("HTTPProxyPort");
+
+ if ((HTTPProxyName == null) || (HTTPProxyPort == null)) {
+ return false;
+ }
+
+ oInetProps.setPropertyValue("ooInetHTTPProxyName", HTTPProxyName);
+ oInetProps.setPropertyValue("ooInetHTTPProxyPort", HTTPProxyPort);
+ oInetProps.setPropertyValue("ooInetProxyType", new Long(2));
+
+ XChangesBatch oSecureChange = (XChangesBatch) UnoRuntime.queryInterface(
+ XChangesBatch.class, oInet);
+ oSecureChange.commitChanges();
+ }
+ catch(com.sun.star.uno.Exception e) {
+ e.printStackTrace();
+ }
+ return true;
+ }
+}
diff --git a/qadevOOo/runner/helper/LoggingThread.java b/qadevOOo/runner/helper/LoggingThread.java
new file mode 100644
index 000000000000..39536179545c
--- /dev/null
+++ b/qadevOOo/runner/helper/LoggingThread.java
@@ -0,0 +1,96 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package helper;
+
+import share.*;
+import lib.TestParameters;
+import util.PropertyName;
+import util.utils;
+
+/**
+ * This class is printing to a <CODE>LogWriter</CODE>. This could be usefull if a UNO-API
+ * function runns longer the the time out. To avoid the assumption of death applikation
+ * a simple string is logged for 100 times of time out.</br>
+ * Example:</br>
+ * logger = new LoggingThread((LogWriter)log, tParam);
+ * logger.start();
+ * oObj.longRunningFunction();
+ * logger.finish();
+ *
+ */
+public class LoggingThread extends Thread {
+
+ TestParameters param;
+ LogWriter log = null;
+ boolean finished = false;
+ boolean debug = false;
+
+ /**
+ *
+ * @param log
+ * @param tParam
+ */
+ public LoggingThread(LogWriter log, TestParameters tParam) {
+ this.log = log;
+ this.param = tParam;
+ this.debug = tParam.getBool(PropertyName.DEBUG_IS_ACTIVE);
+ }
+
+ public void run() {
+ final int timeOut = param.getInt(PropertyName.TIME_OUT) / 2;
+ int count = 0;
+ finished = false;
+ if (debug) log.println("TimeOutLogger: " + utils.getDateTime() + " start");
+ while (!finished && count < 200) {
+ try {
+ if (debug) log.println("TimeOutLogger: "+utils.getDateTime() + count);
+ synchronized (this) {
+ wait(timeOut);
+ }
+ count++;
+ } catch (InterruptedException ex) {
+ }
+ }
+ if (debug) log.println("TimeOutLogger: " + utils.getDateTime() + " finished");
+ }
+
+ /**
+ * finished the LoggingThread
+ */
+ public void finish() {
+ try {
+ finished = true;
+ synchronized (this) {
+ notify();
+ }
+ if (debug) log.println("TimeOutLogger: " + utils.getDateTime() + " try to finish ");
+ sleep(1000);
+ } catch (InterruptedException ex) {
+ }
+ }
+}
diff --git a/qadevOOo/runner/helper/OSHelper.java b/qadevOOo/runner/helper/OSHelper.java
new file mode 100644
index 000000000000..d8e467ae4584
--- /dev/null
+++ b/qadevOOo/runner/helper/OSHelper.java
@@ -0,0 +1,88 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package helper;
+
+/**
+ * Helper object, to identify the current Operation System.
+ * @author ll93751
+ */
+public class OSHelper
+{
+ public static boolean isWindows()
+ {
+ String sOSName = System.getProperty("os.name");
+ if (sOSName.toLowerCase().startsWith("windows"))
+ {
+ return true;
+ }
+ return false;
+ }
+ // not need
+ // public static boolean isUnix()
+ public static boolean isSolarisIntel()
+ {
+ if ( ( System.getProperty("os.name").toLowerCase().startsWith("solaris") ||
+ System.getProperty("os.name").toLowerCase().startsWith("sunos") ) &&
+ System.getProperty("os.arch").equals("x86"))
+ {
+ return true;
+ }
+ return false;
+ }
+ public static boolean isSolarisSparc()
+ {
+ if ( ( System.getProperty("os.name").toLowerCase().startsWith("solaris") ||
+ System.getProperty("os.name").toLowerCase().startsWith("sunos") ) &&
+ System.getProperty("os.arch").equals("sparc"))
+ {
+ return true;
+ }
+ return false;
+ }
+ public static boolean isLinuxIntel()
+ {
+ if (System.getProperty("os.name").toLowerCase().startsWith("linux") &&
+ System.getProperty("os.arch").equals("i386"))
+ {
+ return true;
+ }
+ return false;
+ }
+
+ public static boolean isUnix()
+ {
+ if (isLinuxIntel() ||
+ isSolarisIntel() ||
+ isSolarisSparc())
+ {
+ return true;
+ }
+ return false;
+ }
+
+}
diff --git a/qadevOOo/runner/helper/ObjectInspectorModelImpl.java b/qadevOOo/runner/helper/ObjectInspectorModelImpl.java
new file mode 100644
index 000000000000..5075c50e795b
--- /dev/null
+++ b/qadevOOo/runner/helper/ObjectInspectorModelImpl.java
@@ -0,0 +1,145 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************
+ */
+
+package helper;
+
+import com.sun.star.inspection.PropertyCategoryDescriptor;
+import com.sun.star.inspection.XObjectInspectorModel;
+
+/**
+ * This is an implementation of <CODE>ObjectInspectorModel</CODE>.
+ * @see com.sun.star.inspection.XObjectInspectorModel
+ */
+public class ObjectInspectorModelImpl implements XObjectInspectorModel{
+
+ /**
+ * class variable which contains the implementations of
+ * <CODE>PropertyCategoryDescriptor</CODE>
+ * @see com.sun.star.inspection.PropertyCategoryDescriptor
+ */
+ PropertyCategoryDescriptor[] m_Categories;
+
+ /**
+ * class variable which contains the count of implementations of
+ * <CODE>PropertyCategoryDescriptor</CODE>
+ */
+ int m_count;
+
+ /**
+ * Creates a new instance of ObjectInspectorModelImpl
+ * For every count given in parameter <CODE>count</CODE> an
+ * <CODE>PropertyCategoryDescriptor</CODE> was created an filled with valuable content.
+ * @param count count of <CODE>PropertyCategoryDescriptor</CODE> to create
+ */
+ public ObjectInspectorModelImpl(int count) {
+ m_count = count;
+ m_Categories = new PropertyCategoryDescriptor[m_count];
+ int CategoryMem = 0;
+ int inCat = 0;
+ for (int n=0; n < m_count; n++ ){
+
+ m_Categories[n] = new PropertyCategoryDescriptor();
+
+ int category = n / 2;
+ inCat =(CategoryMem == category)? ++inCat: 1;
+ CategoryMem = category;
+
+ //System.out.println("Category" + category + "Number" + inCat);
+ m_Categories[n].ProgrammaticName = "Category" + category;
+ m_Categories[n].UIName = "Category" + category + "Number" + inCat;
+ m_Categories[n].HelpURL = "h:" + n;
+ }
+ }
+
+ /**
+ * returns the catrgories
+ * @return returns the catrgories
+ */
+ public PropertyCategoryDescriptor[] describeCategories() {
+ return m_Categories;
+ }
+
+ /**
+ * returns currently nothing
+ * @return nothing
+ */
+ public Object[] getHandlerFactories() {
+ return null;
+ }
+
+ /** determines whether the object inspector should have a help section
+ @return false
+ */
+ public boolean getHasHelpSection() {
+ return false;
+ }
+
+ /** returns minimum number of lines in the help text section.
+ @return 3
+ */
+ public int getMinHelpTextLines() {
+ return 3;
+ };
+
+ /** returns maximum number of lines in the help text section.
+ @return 8
+ */
+ public int getMaxHelpTextLines() {
+ return 8;
+ };
+
+ /** returns whether or not the inspector's UI should be read-only
+ */
+ public boolean getIsReadOnly() {
+ return false;
+ }
+
+ /** sets the inspector's read-only state
+ */
+ public void setIsReadOnly( boolean _IsReadOnly ) {
+ // not supported, and not used so far in our test cases
+ }
+
+ /**
+ * retrieves an index in a global property ordering, for a given property name
+ * @param UIName the property whose global order index should be retrieved
+ * @throws com.sun.star.beans.UnknownPropertyException if the given property is unknown
+ * @return the global order index of PropertyName
+ */
+ public int getPropertyOrderIndex(String UIName) {
+ int index = 0;
+ for (int n=0; n < m_Categories.length; n++){
+ if (m_Categories[n].UIName.equals(UIName)){
+ index = n;
+ break;
+ }
+ }
+ return index;
+ }
+
+ }
diff --git a/qadevOOo/runner/helper/OfficeProvider.java b/qadevOOo/runner/helper/OfficeProvider.java
new file mode 100644
index 000000000000..8589de47ea82
--- /dev/null
+++ b/qadevOOo/runner/helper/OfficeProvider.java
@@ -0,0 +1,833 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package helper;
+
+//import com.sun.star.bridge.UnoUrlResolver;
+import com.sun.star.beans.XFastPropertySet;
+import com.sun.star.bridge.XUnoUrlResolver;
+import com.sun.star.container.XEnumeration;
+import com.sun.star.container.XEnumerationAccess;
+import com.sun.star.frame.XDesktop;
+import com.sun.star.lang.XMultiComponentFactory;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XComponentContext;
+import com.sun.star.util.XCloseable;
+import com.sun.star.util.XStringSubstitution;
+
+import java.io.File;
+import java.io.PrintWriter;
+import java.util.StringTokenizer;
+
+import lib.TestParameters;
+
+import share.DescEntry;
+import share.LogWriter;
+
+import util.DynamicClassLoader;
+import util.PropertyName;
+import util.utils;
+
+/**
+ * This class will connect the office and start it if possible
+ *
+ */
+public class OfficeProvider implements AppProvider
+{
+
+ protected static boolean debug = false;
+
+ /**
+ * copy the user layer to a safe place, usualy to $TMP/user_backup$USER
+ * @param param
+ * @param msf
+ */
+ public void backupUserLayer(TestParameters param, XMultiServiceFactory msf)
+ {
+ try
+ {
+ final XStringSubstitution sts = createStringSubstitution(msf);
+ debug = param.getBool(PropertyName.DEBUG_IS_ACTIVE);
+
+ String userLayer = sts.getSubstituteVariableValue("$(user)");
+ userLayer = getDirSys(userLayer);
+ param.put("userLayer", userLayer);
+
+ final String copyLayer = util.utils.getUsersTempDir() + System.getProperty("file.separator") +
+ "user_backup" +
+ System.getProperty("user.name");
+ param.put("copyLayer", copyLayer);
+
+
+ dbg(" copy '" + userLayer + "' ->" + copyLayer + "'");
+ // Slow machines the copy job could spend some time. To avoid activating of OfficeWatcher it must be pinged
+ OfficeWatcherPing owp = new OfficeWatcherPing((OfficeWatcher) param.get(PropertyName.OFFICE_WATCHER));
+ owp.start();
+
+ deleteFilesAndDirector (new File(copyLayer));
+ FileTools.copyDirectory(new File(userLayer), new File(copyLayer), new String[]
+ {
+ "temp"
+ });
+
+ owp.finish();
+
+ }
+ catch (com.sun.star.container.NoSuchElementException e)
+ {
+ System.out.println("User Variable '$(user)' not defined.");
+ }
+ catch (java.io.IOException e)
+ {
+ System.out.println("Couldn't backup user layer");
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Dispose the office.
+ * This method can only be used, if the office was connected in the first
+ * place: getManager() was called first.
+ * @param param
+ * @return return true if desktop is terminates, else false
+ */
+ public boolean disposeManager(lib.TestParameters param)
+ {
+
+ XMultiServiceFactory msf = (XMultiServiceFactory) param.getMSF();
+
+ if (msf == null)
+ {
+ return true;
+ }
+ else
+ {
+ XDesktop desk = null;
+
+ try
+ {
+ desk = UnoRuntime.queryInterface(XDesktop.class, msf.createInstance("com.sun.star.frame.Desktop"));
+ }
+ catch (com.sun.star.uno.Exception ue)
+ {
+ return false;
+ }
+
+ msf = null;
+
+ if (desk != null)
+ {
+ desk.terminate();
+
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ }
+
+ /**
+ * Method to get the ServiceManager of an Office
+ * @param param
+ * @return
+ */
+ public Object getManager(lib.TestParameters param)
+ {
+ String errorMessage = null;
+ boolean bAppExecutionHasWarning = false;
+ debug = param.getBool(PropertyName.DEBUG_IS_ACTIVE);
+
+ String additionalArgs = (String) param.get(
+ "AdditionalConnectionArguments");
+
+ if (additionalArgs == null)
+ {
+ additionalArgs = ";";
+ }
+ else
+ {
+ additionalArgs = "," + additionalArgs + ";";
+ }
+
+ final String cncstr = "uno:" + param.get("ConnectionString") + ";urp" +
+ additionalArgs + "StarOffice.ServiceManager";
+
+ System.out.println("Connecting the Office with " + cncstr);
+
+ XMultiServiceFactory msf = connectOffice(cncstr);
+
+ // if the office is running and the office crashes while testing it could
+ // be usesfull to restart the office if possible and continuing the tests.
+ // Example: The UNO-API-Tests in the projects will be executed by calling
+ // 'damke'. This connects to an existing office. If the office crashes
+ // it is usefull to restart the office and continuing the tests.
+ if ((param.getBool(util.PropertyName.AUTO_RESTART)) && (msf != null))
+ {
+ makeAppExecCommand(msf, param);
+ }
+
+ if (msf == null)
+ {
+ String exc = "";
+ Exception exConnectFailed = null;
+ boolean isExecutable = false;
+ boolean isAppKnown = ((cncstr.indexOf("host=localhost") > 0) || (cncstr.indexOf("pipe,name=") > 0));
+ isAppKnown &= !((String) param.get("AppExecutionCommand")).equals("");
+
+ if (isAppKnown)
+ {
+ dbg("Local Connection trying to start the Office");
+
+ //ensure that a pending officewatcher gets finished before a new
+ //office is started
+ final OfficeWatcher ow_old = (OfficeWatcher) param.get("Watcher");
+
+ if (ow_old != null)
+ {
+ ow_old.finish = true;
+ }
+
+ final String cmd = (String) param.get("AppExecutionCommand");
+ dbg("AppExecutionCommand: " + cmd);
+ // validate the AppExecutionCommand, but try it out anyway.
+ // keep the error message for later.
+ errorMessage =
+ util.utils.validateAppExecutionCommand(cmd, (String) param.get("OperatingSystem"));
+ if (errorMessage.startsWith("Error"))
+ {
+ System.out.println(errorMessage);
+ return null;
+ }
+ bAppExecutionHasWarning = !errorMessage.equals("OK");
+
+ final DynamicClassLoader dcl = new DynamicClassLoader();
+ final LogWriter log = (LogWriter) dcl.getInstance(
+ (String) param.get("LogWriter"));
+
+ //create empty entry
+ final DescEntry Entry = new DescEntry();
+ Entry.entryName = "office";
+ Entry.longName = "office";
+ Entry.EntryType = "placebo";
+ Entry.isOptional = false;
+ Entry.isToTest = false;
+ Entry.SubEntryCount = 0;
+ Entry.hasErrorMsg = false;
+ Entry.State = "non possible";
+ Entry.UserDefinedParams = param;
+
+ log.initialize(Entry, debug);
+
+ final ProcessHandler ph = new ProcessHandler(cmd, (PrintWriter) log);
+ isExecutable = ph.executeAsynchronously();
+
+ if (isExecutable)
+ {
+ param.put("AppProvider", ph);
+ final OfficeWatcher ow = new OfficeWatcher(param);
+ param.put("Watcher", ow);
+ ow.start();
+ ow.ping();
+ }
+
+ int k = 0;
+
+ // wait up to 21 seconds to get an office connection
+ while ((k < 42) && (msf == null))
+ {
+ try
+ {
+ msf = connect(cncstr);
+ }
+ catch (com.sun.star.uno.Exception ue)
+ {
+ exConnectFailed = ue;
+ exc = ue.getMessage();
+ }
+ catch (java.lang.Exception je)
+ {
+ exConnectFailed = je;
+ exc = je.getMessage();
+ }
+ if (msf == null)
+ {
+ try
+ {
+ Thread.sleep(k * 500);
+ }
+ catch (InterruptedException ex)
+ {
+ }
+ }
+ k++;
+ }
+
+ if (msf == null)
+ {
+ System.out.println("Exception while connecting.\n" + exConnectFailed);
+ if (exc != null)
+ {
+ System.out.println(exc);
+ }
+ if (bAppExecutionHasWarning)
+ {
+ System.out.println(errorMessage);
+ }
+ }
+ else if (isExecutable)
+ {
+ if (!param.getBool(util.PropertyName.DONT_BACKUP_USERLAYER))
+ {
+ backupUserLayer(param, msf);
+ }
+ }
+ }
+ else
+ {
+ System.out.println("Could not connect an Office and cannot start one.\n".concat("please start an office with following parameter:\n").
+ concat("\nsoffice -accept=").concat((String) param.get("ConnectionString")).concat(";urp;\n"));
+ if (bAppExecutionHasWarning)
+ {
+ System.out.println(errorMessage);
+ }
+ }
+ }
+
+ return msf;
+ }
+
+ /**
+ * Connect an Office
+ * @param connectStr
+ * @return
+ * @throws com.sun.star.uno.Exception
+ * @throws com.sun.star.uno.RuntimeException
+ * @throws com.sun.star.connection.NoConnectException
+ * @throws Exception
+ */
+ protected static XMultiServiceFactory connect(String connectStr)
+ throws com.sun.star.uno.Exception,
+ com.sun.star.uno.RuntimeException,
+ com.sun.star.connection.NoConnectException,
+ Exception
+ {
+
+ // Get component context
+ final XComponentContext xcomponentcontext = com.sun.star.comp.helper.Bootstrap.createInitialComponentContext(null);
+
+ // initial serviceManager
+ final XMultiComponentFactory xLocalServiceManager = xcomponentcontext.getServiceManager();
+
+ // create a connector, so that it can contact the office
+// XUnoUrlResolver urlResolver = UnoUrlResolver.create(xcomponentcontext);
+ final Object xUrlResolver = xLocalServiceManager.createInstanceWithContext("com.sun.star.bridge.UnoUrlResolver", xcomponentcontext);
+ final XUnoUrlResolver urlResolver = UnoRuntime.queryInterface(XUnoUrlResolver.class, xUrlResolver);
+
+ final Object rInitialObject = urlResolver.resolve(connectStr);
+
+ XMultiServiceFactory xMSF = null;
+
+ if (rInitialObject != null)
+ {
+ debug = true;
+ dbg("resolved url");
+
+ xMSF = UnoRuntime.queryInterface(XMultiServiceFactory.class, rInitialObject);
+ }
+
+ return xMSF;
+ }
+
+ /**
+ * Close an office.
+ * @param param The test parameters.
+ * @param closeIfPossible If true, close even if
+ * it was running before the test
+ */
+ public boolean closeExistingOffice(lib.TestParameters param, boolean closeIfPossible)
+ {
+
+ XMultiServiceFactory msf = (XMultiServiceFactory) param.getMSF();
+ final boolean alreadyConnected = (msf != null);
+ debug = param.getBool(PropertyName.DEBUG_IS_ACTIVE);
+
+ if (alreadyConnected)
+ {
+ dbg("try to get ProcessHandler");
+
+ final ProcessHandler ph = (ProcessHandler) param.get("AppProvider");
+
+ if (ph != null)
+ {
+ dbg("ProcessHandler != null");
+
+ disposeOffice(msf, param);
+
+ // dispose watcher in case it's still running.
+ dbg("try to get OfficeWatcher");
+
+ final OfficeWatcher ow = (OfficeWatcher) param.get("Watcher");
+
+ if ((ow != null) && ow.isAlive())
+ {
+ dbg("OfficeWatcher will be finished");
+ ow.finish = true;
+ }
+ else
+ {
+ dbg("OfficeWatcher seems to be finished");
+ }
+
+ return true;
+ }
+ else
+ {
+ if (closeIfPossible)
+ {
+ return disposeOffice(msf, param);
+ }
+ }
+ }
+ else
+ {
+ final String cncstr = "uno:" + param.get("ConnectionString") +
+ ";urp;StarOffice.ServiceManager";
+ dbg("try to connect office");
+ msf = connectOffice(cncstr);
+
+ if (closeIfPossible)
+ {
+ return disposeOffice(msf, param);
+ }
+ }
+ dbg("closeExistingOffice finished");
+ return true;
+ }
+
+ private XMultiServiceFactory connectOffice(String cncstr)
+ {
+ XMultiServiceFactory msf = null;
+ String exc = "";
+ debug = true;
+
+ dbg("trying to connect to " + cncstr);
+
+ try
+ {
+ msf = connect(cncstr);
+ }
+ catch (com.sun.star.uno.Exception ue)
+ {
+ exc = ue.getMessage();
+ }
+ catch (java.lang.Exception je)
+ {
+ exc = je.getMessage();
+ }
+
+ if (debug && exc != null && exc.length() != 0)
+ {
+ if (exc == null)
+ {
+ exc = "";
+ }
+ dbg("Could not connect an Office. " + exc);
+ }
+
+ return msf;
+ }
+
+ private synchronized boolean disposeOffice(XMultiServiceFactory msf,
+ TestParameters param)
+ {
+ XDesktop desk = null;
+
+ debug = param.getBool(PropertyName.DEBUG_IS_ACTIVE);
+
+ boolean result = true;
+
+ if (msf != null)
+ {
+
+ // disable QuickStarter
+ try
+ {
+ Object quickStarter = msf.createInstance("com.sun.star.office.Quickstart");
+ XFastPropertySet fps = UnoRuntime.queryInterface(XFastPropertySet.class, quickStarter);
+ fps.setFastPropertyValue(0, false);
+ }
+ catch (com.sun.star.uno.Exception ex)
+ {
+ dbg("ERROR: Could not disable QuickStarter: " + ex.toString());
+ }
+
+ try
+ {
+ desk = UnoRuntime.queryInterface(XDesktop.class, msf.createInstance("com.sun.star.frame.Desktop"));
+ msf = null;
+
+ if (desk != null)
+ {
+ final boolean allClosed = closeAllWindows(desk);
+
+ if (!allClosed)
+ {
+ dbg("Couldn't close all office windows!");
+ }
+
+ dbg("Trying to terminate the desktop");
+
+ desk.terminate();
+ dbg("Desktop terminated");
+
+ try
+ {
+ final int closeTime = param.getInt(util.PropertyName.OFFICE_CLOSE_TIME_OUT);
+ dbg("the Office has " + closeTime / 1000 + " seconds for closing...");
+ Thread.sleep(closeTime);
+ }
+ catch (java.lang.InterruptedException e)
+ {
+ }
+ }
+ }
+ catch (com.sun.star.uno.Exception ue)
+ {
+ result = false;
+ }
+ catch (com.sun.star.lang.DisposedException ue)
+ {
+ result = false;
+ }
+ }
+
+ final String AppKillCommand = (String) param.get(util.PropertyName.APP_KILL_COMMAND);
+ if (AppKillCommand != null)
+ {
+ String sAppKillCommand = StringHelper.removeSurroundQuoteIfExists(AppKillCommand);
+ final StringTokenizer aKillCommandToken = new StringTokenizer(sAppKillCommand, ";");
+ while (aKillCommandToken.hasMoreTokens())
+ {
+ final String sKillCommand = aKillCommandToken.nextToken();
+ dbg("User defined an application to destroy the started process. Trying to execute: " + sKillCommand);
+
+ final ProcessHandler pHdl = new ProcessHandler(sKillCommand, 1000); // 3000 seems to be too long
+ pHdl.runCommand();
+
+ pHdl.kill();
+ }
+ }
+
+ final ProcessHandler ph = (ProcessHandler) param.get("AppProvider");
+
+ if (ph != null)
+ {
+ // dispose watcher in case it's still running.
+ final OfficeWatcher ow = (OfficeWatcher) param.get("Watcher");
+
+ if ((ow != null) && ow.isAlive())
+ {
+ ow.finish = true;
+ }
+
+ ph.kill();
+ }
+
+ param.remove("AppProvider");
+ param.remove("ServiceFactory");
+
+ if (!param.getBool(util.PropertyName.DONT_BACKUP_USERLAYER))
+ {
+ //copy user_backup into user layer
+ try
+ {
+ final String userLayer = (String) param.get("userLayer");
+ final String copyLayer = (String) param.get("copyLayer");
+ if (userLayer != null && copyLayer != null)
+ {
+ deleteFilesAndDirector(new File(userLayer));
+ final File copyFile = new File(copyLayer);
+ dbg("copy '" + copyFile + "' -> '" + userLayer + "'");
+ FileTools.copyDirectory(copyFile, new File(userLayer), new String[]
+ {
+ "temp"
+ });
+ dbg("copy '" + copyFile + "' -> '" + userLayer + "' finished");
+
+ // remove all user_backup folder in temp dir
+ // this is for the case the runner was killed and some old backup folder still stay in temp dir
+
+
+ }
+ else
+ {
+ System.out.println("Cannot copy layer: '" + copyLayer + "' back to user layer: '" + userLayer + "'");
+ }
+ }
+ catch (java.io.IOException e)
+ {
+ dbg("Couldn't recover from backup\n" + e.getMessage());
+ }
+ }
+ return result;
+ }
+
+ protected boolean closeAllWindows(XDesktop desk)
+ {
+ final XEnumerationAccess compEnumAccess = desk.getComponents();
+ final XEnumeration compEnum = compEnumAccess.createEnumeration();
+ boolean res = true;
+
+ try
+ {
+ while (compEnum.hasMoreElements())
+ {
+ final XCloseable closer = UnoRuntime.queryInterface(XCloseable.class, compEnum.nextElement());
+
+ if (closer != null)
+ {
+ closer.close(true);
+ }
+ }
+ }
+ catch (com.sun.star.util.CloseVetoException cve)
+ {
+ res = false;
+ }
+ catch (com.sun.star.container.NoSuchElementException nsee)
+ {
+ res = false;
+ }
+ catch (com.sun.star.lang.WrappedTargetException wte)
+ {
+ res = false;
+ }
+
+ return res;
+ }
+
+ public static XStringSubstitution createStringSubstitution(XMultiServiceFactory xMSF)
+ {
+ Object xPathSubst = null;
+
+ try
+ {
+ xPathSubst = xMSF.createInstance(
+ "com.sun.star.util.PathSubstitution");
+ }
+ catch (com.sun.star.uno.Exception e)
+ {
+ e.printStackTrace();
+ }
+
+ if (xPathSubst != null)
+ {
+ return UnoRuntime.queryInterface(XStringSubstitution.class, xPathSubst);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ /**
+ * converts directory without 'file:///' prefix.
+ * and System dependend file separator
+ * @param dir
+ * @return
+ */
+ public static String getDirSys(String dir)
+ {
+ String sysDir = "";
+
+ final int idx = dir.indexOf("file://");
+
+ final int idx2 = dir.indexOf("file:///");
+
+ // remove leading 'file://'
+ if (idx < 0)
+ {
+ sysDir = dir;
+ }
+ else
+ {
+ sysDir = dir.substring("file://".length());
+ }
+
+ sysDir = utils.replaceAll13(sysDir, "%20", " ");
+
+ // append '/' if not there (e.g. linux)
+ if (sysDir.charAt(sysDir.length() - 1) != '/')
+ {
+ sysDir += "/";
+ }
+
+ // remove leading '/' and replace others with '\' on windows machines
+ final String sep = System.getProperty("file.separator");
+
+ if (sep.equalsIgnoreCase("\\"))
+ {
+ if (!(idx2 < 0))
+ {
+ sysDir = sysDir.substring(1);
+ }
+ else
+ {
+ //network path
+ sysDir = "//" + sysDir;
+ }
+ sysDir = sysDir.replace('/', '\\');
+ }
+
+ return sysDir;
+ }
+
+ /**
+ * If the office is connected but the <CODE>AppExecutionCommand</CODE> is not set,
+ * this function asks the office for its location and fill the
+ * <CODE>AppExecutionCommand</CODE> with valid contet.
+ * This function was only called if parameter <CODE>AutoRestart</CODE> is set.
+ * @param msf the <CODE>MultiServiceFactory</CODE>
+ * @param param the <CODE>TestParameters</CODE>
+ */
+ private static void makeAppExecCommand(XMultiServiceFactory msf, TestParameters param)
+ {
+ debug = param.getBool(PropertyName.DEBUG_IS_ACTIVE);
+
+ // get existing AppExecutionCommand if available, else empty string
+ String command = (String) param.get(util.PropertyName.APP_EXECUTION_COMMAND);
+
+ String connectionString;
+ if (param.getBool(util.PropertyName.USE_PIPE_CONNECTION) == true)
+ {
+ // This is the default behaviour
+ connectionString = (String) param.get(util.PropertyName.PIPE_CONNECTION_STRING);
+ }
+ else
+ {
+ // is used if UsePipeConnection=false
+ connectionString = (String) param.get(util.PropertyName.CONNECTION_STRING);
+ }
+
+ String sysBinDir = "";
+
+ try
+ {
+ sysBinDir = utils.getSystemURL(utils.expandMacro(msf, "$SYSBINDIR"));
+ }
+ catch (java.lang.Exception e)
+ {
+ dbg("could not get system binary directory");
+ return;
+ }
+
+ // does the existing command show to the connected office?
+ if (command.indexOf(sysBinDir) == -1)
+ {
+ command = sysBinDir + System.getProperty("file.separator") + "soffice" +
+ " -norestore -accept=" + connectionString + ";urp;";
+ }
+
+ dbg("update AppExecutionCommand: " + command);
+
+ param.put(util.PropertyName.APP_EXECUTION_COMMAND, command);
+ }
+
+ private static void dbg(String message)
+ {
+ if (debug)
+ {
+ System.out.println(utils.getDateTime() + "OfficeProvider: " + message);
+ }
+
+ }
+
+ private class OfficeWatcherPing extends Thread
+ {
+
+ private final OfficeWatcher ow;
+ private boolean bStop = false;
+
+ public OfficeWatcherPing(OfficeWatcher ow)
+ {
+ this.ow = ow;
+ }
+
+ @Override
+ public void run()
+ {
+ System.out.println(utils.getDateTime() + "OfficeProvider:Owp: start ");
+
+ while (!bStop)
+ {
+ System.out.println(utils.getDateTime() + "OfficeProvider:Owp: ping ");
+ ow.ping();
+ try
+ {
+ System.out.println(utils.getDateTime() + "OfficeProvider:Owp: sleep ");
+ OfficeWatcherPing.sleep(1000); // 5000
+ }
+ catch (InterruptedException ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+
+ }
+
+ public void finish()
+ {
+ synchronized(this)
+ {
+ bStop = true;
+ System.out.println(utils.getDateTime() + "OfficeProvider:Owp: stop ");
+
+ notify();
+ }
+ }
+ }
+
+private void deleteFilesAndDirector(File file)
+ {
+ File f = file;
+ if(f.isDirectory())
+ {
+ File files[] = f.listFiles();
+ for(int i = 0; i < files.length; i++)
+ {
+ deleteFilesAndDirector(files[i]);
+ }
+ f.delete();
+ }
+ else if (f.isFile())
+ {
+ f.delete();
+ }
+ }
+}
diff --git a/qadevOOo/runner/helper/OfficeWatcher.java b/qadevOOo/runner/helper/OfficeWatcher.java
new file mode 100644
index 000000000000..2068a7f5246c
--- /dev/null
+++ b/qadevOOo/runner/helper/OfficeWatcher.java
@@ -0,0 +1,132 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package helper;
+
+import lib.TestParameters;
+import java.util.StringTokenizer;
+import util.utils;
+
+public class OfficeWatcher extends Thread implements share.Watcher {
+
+ public boolean finish;
+ private TestParameters params;
+ private int StoredPing = 0;
+ private boolean debug = false;
+
+ /** Creates new OfficeWatcher
+ * @param param
+ */
+ public OfficeWatcher(TestParameters param) {
+ finish = false;
+ this.params = param;
+ debug = params.getBool(util.PropertyName.DEBUG_IS_ACTIVE);
+ }
+
+ /**
+ * pings the office watcher to check for changes
+ */
+ public void ping() {
+ try {
+ StoredPing++;
+ } catch (Exception e) {
+ StoredPing = 0;
+ }
+ }
+
+ /**
+ * returns the amount of pings
+ * @return returns the amount of pings
+ */
+ public int getPing() {
+ return StoredPing;
+ }
+
+ public void run() {
+ dbg("started");
+ boolean isDone = false;
+ final ProcessHandler ph = (ProcessHandler) params.get("AppProvider");
+ int timeOut = params.getInt("TimeOut");
+ if (ph == null) {
+ isDone = true;
+ }
+ while (!isDone) {
+ timeOut = params.getInt("TimeOut");
+ final int previous = StoredPing;
+ shortWait(timeOut == 0 ? 30000 : timeOut);
+ // a timeout with value 0 lets watcher not react.
+ if ((StoredPing == previous) && timeOut != 0) {
+ isDone = true;
+ }
+ // execute in case the watcher is not needed anymore
+ if (finish) {
+ return;
+ }
+ }
+ if (ph != null) {
+ dbg("the Office is idle for " + timeOut / 1000 +
+ " seconds, it probably hangs and is killed NOW.");
+ final String AppKillCommand = (String) params.get(util.PropertyName.APP_KILL_COMMAND);
+ if (AppKillCommand != null) {
+ final StringTokenizer aKillCommandToken = new StringTokenizer(AppKillCommand, ";");
+ while (aKillCommandToken.hasMoreTokens()) {
+ final String sKillCommand = aKillCommandToken.nextToken();
+
+ dbg("User defined an application to destroy the started process.");
+ dbg("Trying to execute: " + sKillCommand);
+
+ final ProcessHandler pHdl = new ProcessHandler(sKillCommand);
+ pHdl.executeSynchronously();
+// dbg("---> Output of killoffice:");
+// dbg(pHdl.getOutputText());
+// dbg("<--- Output of killoffice");
+// dbg("---> Error output of killoffice:");
+// dbg(pHdl.getErrorText());
+// dbg("<--- Error output of killoffice");
+
+ }
+ }
+ ph.kill();
+ } else {
+ dbg("reaeched timeout but ProcessHandler is NULL");
+ }
+ shortWait(timeOut == 0 ? 30000 : timeOut);
+ dbg("finished");
+ }
+
+ protected void shortWait(int timeOut) {
+ try {
+ OfficeWatcher.sleep(timeOut);
+ } catch (java.lang.InterruptedException ie) {
+ }
+ }
+
+ protected void dbg(String message) {
+ if (debug) {
+ System.out.println(utils.getDateTime() + "OfficeWatcher: " + message);
+ }
+ }
+}
diff --git a/qadevOOo/runner/helper/ParameterNotFoundException.java b/qadevOOo/runner/helper/ParameterNotFoundException.java
new file mode 100644
index 000000000000..f1ea980e1533
--- /dev/null
+++ b/qadevOOo/runner/helper/ParameterNotFoundException.java
@@ -0,0 +1,39 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package helper;
+
+/**
+ * This exception is thrown when a parameter could not be found.
+ *
+ */
+public class ParameterNotFoundException extends Exception {
+ public ParameterNotFoundException(String message){
+ super (message);
+ }
+
+}
diff --git a/qadevOOo/runner/helper/ProcessHandler.java b/qadevOOo/runner/helper/ProcessHandler.java
new file mode 100644
index 000000000000..c414accd44ac
--- /dev/null
+++ b/qadevOOo/runner/helper/ProcessHandler.java
@@ -0,0 +1,824 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package helper;
+
+import java.io.InputStream;
+import java.io.File;
+import java.io.PrintWriter;
+import java.io.PrintStream;
+import java.io.LineNumberReader;
+import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+import lib.TestParameters;
+import util.PropertyName;
+import util.utils;
+
+/**
+ * Class collect information from input stream in
+ * background (sparate thread) and outputs it to
+ * some log stream. I helps to avoid buffer overflow
+ * when output stream has small buffer size (e.g.
+ * in case when handling stdout from external
+ * <code>Process</code>)
+ *
+ * This class is currently used by ProcesHandler
+ * internally only.
+ */
+class Pump extends Thread
+{
+
+ private LineNumberReader reader;
+ private String pref;
+ private StringBuffer buf = new StringBuffer(256);
+ private PrintWriter log;
+
+ /**
+ * Creates Pump for specified <code>InputStream</code>.
+ * This Pump also synchronously output text read to
+ * log by prefixed lines. Constructor immediately
+ * starts reading in a separate thread.
+ *
+ * @param is Stream which requires permanent reading.
+ * @param log Writer where prefixed text lines to be output
+ * @param outPrefix A prefix which is printed at the
+ * beginning of each output line.
+ */
+ public Pump(InputStream is, PrintWriter log, String outPrefix)
+ {
+ this.pref = (outPrefix == null) ? "" : outPrefix;
+ reader = new LineNumberReader(new InputStreamReader(is));
+ this.log = log;
+ start();
+ }
+
+ public void run()
+ {
+ try
+ {
+ String line = reader.readLine();
+ while (line != null)
+ {
+ log.println(pref + line);
+ log.flush();
+ buf.append(line).append('\n');
+ line = reader.readLine();
+ }
+ }
+ catch (java.io.IOException e)
+ {
+ log.println(pref + "Exception occured: " + e);
+ }
+ }
+
+ /**
+ * Returns the text collected from input stream.
+ */
+ public String getStringBuffer()
+ {
+ return buf.toString();
+ }
+}
+
+/**
+ * Class provides convenient way for running external program
+ * handle its standard streams, control execution and check results.
+ * Instance of this class must be created only for a single
+ * execution. If you need to execute the same command again you
+ * should create a new instance for this.
+ */
+public class ProcessHandler
+{
+
+ private String cmdLine;
+ private String[] cmdLineArray;
+ private String[] envVars = null;
+ private File workDir = null;
+ private PrintWriter log;
+ private int exitValue = -1;
+ private boolean isFinished = false;
+ private boolean isStarted = false;
+ private boolean mbTimedOut = false;
+ private long mTimeOut = 0;
+ private String stdInBuff = "";
+ private Pump stdout = null;
+ private Pump stderr = null;
+ private PrintStream stdIn = null;
+ private Process m_aProcess = null;
+ private TestParameters param = null;
+ private boolean debug = false;
+
+ /**
+ * Creates instance with specified external command.
+ * Debug info and output
+ * of external command is printed to stdout.
+ * @param cmdLine
+ */
+ public ProcessHandler(String cmdLine)
+ {
+ this(cmdLine, null, null, null, 0);
+ }
+
+ /**
+ * Creates instance with specified external command
+ * including parameters as an array.
+ * Debug info and output
+ * of external command is printed to stdout.
+ * @param cmdLines
+ */
+ public ProcessHandler(String[] cmdLines)
+ {
+ this(null, null, null, null, 0);
+ cmdLineArray = cmdLines;
+ }
+
+ /**
+ * Creates instance with specified external command
+ * including parameters as an array, with environment
+ * variables.
+ * Debug info and output
+ * of external command is printed to stdout.
+ * @param cmdLines
+ * @param envVars
+ * @see java.lang.Runtime exec(String[], String[])
+ */
+ public ProcessHandler(String[] cmdLines, String[] envVars)
+ {
+ this(null, null, null, envVars, 0);
+ cmdLineArray = cmdLines;
+ }
+
+ /**
+ * Creates instance with specified external command
+ * including parameters as an array, with environment
+ * variables. The command will be started in workDir.
+ * Debug info and output
+ * of external command is printed to stdout.
+ * @param cmdLines
+ * @param workDir
+ */
+ public ProcessHandler(String[] cmdLines, File workDir)
+ {
+ this(null, null, workDir, null, 0);
+ cmdLineArray = cmdLines;
+
+ }
+
+ /**
+ * Creates instance with specified external command and
+ * log stream where debug info and output
+ * of external command is printed out. The command will be started in workDir.
+ * @param cmdLines
+ * @param log
+ * @param workDir
+ */
+ public ProcessHandler(String[] cmdLines, PrintWriter log, File workDir)
+ {
+ this(null, log, workDir, null, 0);
+ cmdLineArray = cmdLines;
+ }
+
+ /**
+ * Creates instance with specified external command and
+ * log stream where debug info and output
+ * of external command is printed out.
+ * @param cmdLine
+ * @param log
+ */
+ public ProcessHandler(String cmdLine, PrintWriter log)
+ {
+ this(cmdLine, log, null, null, 0);
+ }
+
+ /**
+ * Creates instance with specified external command and set the time out for the command.
+ * @param cmdLine
+ * @param timeOut
+ */
+ public ProcessHandler(String cmdLine, int timeOut)
+ {
+ this(cmdLine, null, null, null, timeOut);
+ }
+
+ /**
+ * Creates instance with specified external command which
+ * will be executed in the some work directory.
+ * Debug info and output
+ * of external commandis printed to stdout.
+ * @param cmdLine
+ * @param workDir
+ */
+ public ProcessHandler(String cmdLine, File workDir)
+ {
+ this(cmdLine, null, workDir, null, 0);
+ }
+
+ /**
+ * Creates instance with specified external command which
+ * will be executed in the some work directory.
+ * Debug info and output printed in log stream.
+ * @param cmdLine
+ * @param log
+ * @param workDir
+ */
+ public ProcessHandler(String cmdLine, PrintWriter log, File workDir)
+ {
+ this(cmdLine, log, workDir, null, 0);
+ }
+
+ /**
+ * Creates instance with specified external command which
+ * will be executed in the some work directory and
+ * log stream where debug info and output
+ * of external command is printed .
+ * The specified environment variables are set for the new process.
+ * If log stream is null, logging is printed to stdout.
+ * @param cmdLine
+ * @param log
+ * @param workDir
+ * @param envVars
+ */
+ public ProcessHandler(String cmdLine, PrintWriter log, File workDir, String[] envVars)
+ {
+ this(cmdLine, log, workDir, envVars, 0);
+ }
+
+ /**
+ * Creates instance with specified external command which
+ * will be executed in the some work directory and
+ *
+ * @param cmdLine the command to be executed
+ * @param log log stream where debug info and output
+ * of external command is printed .
+ * @param workDir The working directory of the new process
+ * @param envVars The specified environment variables are
+ * set for the new process.
+ * If log stream is null, logging is printed to stdout.
+ * @param timeOut When started sychronisly, the maximum time the
+ * process will live. When the process being destroyed
+ * a log will be written out. It can be asked on
+ * <code>isTimedOut()</code> if it has been terminated.
+ *
+ * timeOut > 0
+ * Waits specified time in miliSeconds for
+ * process to exit and return its status.
+ *
+ * timeOut = 0
+ * Waits for the process to end regulary
+ *
+ * timeOut < 0
+ * Kills the process immediately
+ *
+ *
+ */
+ public ProcessHandler(String cmdLine, PrintWriter log, File workDir, String[] envVars, long timeOut)
+ {
+ this.cmdLine = cmdLine;
+ this.workDir = workDir;
+ this.log = log;
+ this.cmdLine = cmdLine;
+ this.envVars = envVars;
+ if (log == null)
+ {
+ this.log = new PrintWriter(new OutputStreamWriter(System.out));
+ }
+ else
+ {
+ this.log = log;
+ }
+ this.mTimeOut = timeOut;
+ }
+
+ /**
+ * Creates instance with specified external command which
+ * will be executed in the some work directory and
+ * log stream where debug info and output of external command is printed.
+ * If log stream is null, logging is printed to stdout.
+ * From the <CODE>TestParameters</CODE> the <CODE>OfficeWachter</CODE> get a ping.
+ * @param commands
+ * @param log
+ * @param workDir
+ * @param shortWait If this parameter is ture the <CODE>mTimeOut</CODE> is set to 5000 ms, else it is set to
+ * half of time out from parameter timeout.
+ * @param param the TestParameters
+ * @see lib.TestParameters
+ * @see helper.OfficeWatcher
+ */
+ public ProcessHandler(String[] commands, PrintWriter log, File workDir, int shortWait, TestParameters param)
+ {
+ this(null, log, workDir, null, 0);
+ this.cmdLineArray = commands;
+ this.param = param;
+ if (shortWait != 0)
+ {
+ this.mTimeOut = shortWait;
+ }
+ else
+ {
+ this.mTimeOut = (long) (param.getInt(PropertyName.TIME_OUT) / 1.3);
+ }
+ debug = param.getBool(PropertyName.DEBUG_IS_ACTIVE);
+
+ }
+
+ /**
+ * This method do an asynchronous execution of the commands. To avoid a interruption on long running processes
+ * caused by <CODE>OfficeWatcher</CODE>, the OfficeWatcher get frequently a ping.
+ * @see helper.OfficeWatcher
+ */
+ public void runCommand()
+ {
+
+ boolean changedText = true;
+ int count = 0;
+ String memText = "";
+
+ this.executeAsynchronously();
+
+ OfficeWatcher ow = null;
+ if (param != null)
+ {
+ ow = (OfficeWatcher) param.get(PropertyName.OFFICE_WATCHER);
+ }
+ if (ow != null)
+ {
+ ow.ping();
+ }
+
+ int hangcheck = 10;
+ while (!this.isFinished() && changedText)
+ {
+ count++;
+ // dbg("runCommand: waiting " + mTimeOut / 1000 + " seconds while command execution is ongoing... " + count);
+ // shortWait(mTimeOut);
+ // shortWait(2000); // wait 2 seconds.
+ //waitFor(mTimeOut);
+ waitFor(2000, false); // wait but don't kill
+
+ if (ow != null)
+ {
+ ow.ping();
+ }
+ // check for changes in the output stream. If there are no changes, the process maybe hangs
+ if (!this.isFinished())
+ {
+ hangcheck--;
+ if (hangcheck < 0)
+ {
+ String sOutputText = getOutputText();
+ if (sOutputText.length() == memText.length())
+ {
+ changedText = false;
+ // dbg("runCommand Could not detect changes in output stream!!!");
+ }
+ hangcheck = 10;
+ memText = this.getOutputText();
+ }
+ }
+ }
+
+ if (!this.isFinished())
+ {
+ dbg("runCommand Process ist not finished but there are no changes in output stream.");
+ this.kill();
+ }
+ }
+
+ public boolean isTimedOut()
+ {
+ return mbTimedOut;
+ }
+
+ private void setTimedOut(boolean bTimedOut)
+ {
+ mbTimedOut = bTimedOut;
+ }
+
+ /**
+ * Executes the command and returns only when the process
+ * exits.
+ *
+ * @return <code>true</code> if process was successfully
+ * started and correcly exits (exit code doesn't affect
+ * to this result).
+ */
+ public boolean executeSynchronously()
+ {
+ execute();
+ return waitFor(mTimeOut);
+ }
+
+ /**
+ * Executes the command immediately returns. The process
+ * remains in running state. Control of its state should
+ * be made by <code>waitFor</code> methods.
+ *
+ * @return <code>true</code> if process was successfully
+ * started.
+ */
+ public boolean executeAsynchronously()
+ {
+ execute();
+ return isStarted();
+ }
+
+ public synchronized void kill()
+ {
+ if (!isStarted())
+ {
+ return;
+ }
+ boolean exit = false;
+ int counter = 1;
+ while (counter < 3 && !exit)
+ {
+ m_aProcess.destroy();
+
+ try
+ {
+ Thread.sleep(1000 * counter); // 5000
+ }
+ catch (java.lang.InterruptedException e)
+ {
+ }
+ try
+ {
+ final int exit_Value = m_aProcess.exitValue();
+ if (exit_Value < 1)
+ {
+ exit = true;
+ }
+ else
+ {
+ counter++;
+ }
+ dbg("kill: process closed with exit code " + exit_Value);
+ }
+ catch (java.lang.IllegalThreadStateException e)
+ {
+ if (counter < 3)
+ {
+ dbg("kill: Couldn't close process after " + counter + " attempts, trying again");
+ }
+ counter++;
+ }
+ }
+ isStarted = false;
+ }
+
+ /**
+ * Returns the time in seconds since 1st January 1970
+ * @return
+ */
+ public static long getSystemTime()
+ {
+ // Calendar cal = new GregorianCalendar();
+ // final long nTime = cal.getTimeInMillis();
+ final long nTime = System.currentTimeMillis();
+ return nTime;
+ }
+ private long m_nExactStartTimeInMillisec;
+
+ private void initialExactStartTime()
+ {
+ m_nExactStartTimeInMillisec = getSystemTime();
+ }
+
+ public long getProcessStartTime()
+ {
+ return m_nExactStartTimeInMillisec;
+ }
+
+ protected void execute()
+ {
+ if (isStarted())
+ {
+ throw new RuntimeException(
+ "The process handler has already been executed.");
+ }
+ final Runtime runtime = Runtime.getRuntime();
+ try
+ {
+ if (cmdLine == null)
+ {
+ log.print(utils.getDateTime() + "execute: Starting command from array: ");
+ for (int i = 0; i < cmdLineArray.length; i++)
+ {
+ log.print(cmdLineArray[i]);
+ log.print(" ");
+ }
+ log.println("");
+ initialExactStartTime();
+ m_aProcess = runtime.exec(cmdLineArray, envVars);
+ }
+ else
+ {
+ if (workDir != null)
+ {
+ log.println(utils.getDateTime() + "execute: Starting command: " + cmdLine + " " +
+ workDir.getAbsolutePath());
+ m_aProcess = runtime.exec(cmdLine, envVars, workDir);
+ }
+ else
+ {
+ log.println(utils.getDateTime() + "execute: Starting command: " + cmdLine);
+ m_aProcess = runtime.exec(cmdLine, envVars);
+ }
+ }
+ isStarted = true;
+ }
+ catch (java.io.IOException e)
+ {
+ if (cmdLine == null)
+ {
+ log.println(utils.getDateTime() + "execute: The command array can't be started: " + e);
+ }
+ else
+ {
+ log.println(utils.getDateTime() + "execute: The command " + cmdLine + " can't be started: " + e);
+ }
+ return;
+ }
+ dbg("execute: pump io-streams");
+ stdout = new Pump(m_aProcess.getInputStream(), log, "out > ");
+ stderr = new Pump(m_aProcess.getErrorStream(), log, "err > ");
+ stdIn = new PrintStream(m_aProcess.getOutputStream());
+
+ // int nExitValue = m_aProcess.exitValue();
+ // int dummy = 0;
+
+ dbg("execute: flush io-streams");
+
+ flushInput();
+ }
+
+ /**
+ * This method is useful when the process was executed
+ * asynchronously. Waits for process to exit and return
+ * its result.
+ *
+ * @return <code>true</code> if process correctly exited
+ * (exit code doesn't affect to this result).
+ */
+ public boolean waitFor()
+ {
+ return waitFor(0);
+ }
+
+ /**
+ * This method is useful when the process was executed
+ * asynchronously. Waits during specified time for process
+ * to exit and return its status.
+ *
+ * @param timeout > 0
+ * Waits specified time in miliSeconds for
+ * process to exit and return its status.
+ *
+ * = 0
+ * Waits for the process to end regulary
+ *
+ * < 0
+ * Kills the process immediately
+ *
+ * @return <code>true</code> if process correctly exited
+ * (exit code doesn't affect to this result).
+ */
+ public boolean waitFor(long timeout)
+ {
+ return waitFor(timeout, true);
+ }
+
+ private boolean waitFor(long timeout, boolean bKillProcessAfterTimeout)
+ {
+ if (isFinished())
+ {
+ return true;
+ }
+ if (!isStarted())
+ {
+ return false;
+ }
+
+ if (timeout == 0)
+ {
+ try
+ {
+ m_aProcess.waitFor();
+ }
+ catch (InterruptedException e)
+ {
+ log.println("The process was interrupted: " + e);
+ }
+ isFinished = true;
+ try
+ {
+ exitValue = m_aProcess.exitValue();
+ }
+ catch (IllegalThreadStateException e)
+ {
+ }
+ }
+ else
+ {
+ try
+ {
+ while (!isFinished && timeout > 0)
+ {
+ isFinished = true;
+ Thread.sleep(1000);
+ timeout -= 1000;
+ try
+ {
+ exitValue = m_aProcess.exitValue(); // throws exception if not finished
+ }
+ catch (IllegalThreadStateException e)
+ {
+ isFinished = false;
+ }
+ }
+ if (timeout < 0)
+ {
+ setTimedOut(true);
+ log.println("The process has timed out!");
+ }
+ }
+ catch (InterruptedException ex)
+ {
+ log.println("The process was interrupted: " + ex);
+ }
+ }
+
+ if (bKillProcessAfterTimeout == true)
+ {
+ if (!isFinished)
+ {
+ log.println("Going to destroy the process!!");
+ m_aProcess.destroy();
+ log.println("Process has been destroyed!");
+ }
+ }
+// Removed as hung up in SDK test 'PathSettings'
+// try {
+// stdout.join();
+// stderr.join();
+// } catch (InterruptedException e) {}
+
+ return isFinished();
+ }
+
+ protected void flushInput()
+ {
+ if (stdIn == null)
+ {
+ return;
+ }
+
+ synchronized(stdInBuff)
+ {
+ stdIn.print(stdInBuff);
+ stdIn.flush();
+ stdInBuff = "";
+ }
+ }
+
+ /**
+ * Returns the text output by external command to stdout.
+ * @return the text output by external command to stdout
+ */
+ public String getOutputText()
+ {
+ if (stdout == null)
+ {
+ return "";
+ }
+ else
+ {
+ return stdout.getStringBuffer();
+ }
+ }
+
+ /**
+ * Returns the text output by external command to stderr.
+ * @return the text output by external command to stderr
+ */
+ public String getErrorText()
+ {
+ if (stderr == null)
+ {
+ return "";
+ }
+ else
+ {
+ return stderr.getStringBuffer();
+ }
+ }
+
+ /**
+ * Prints the string specified to sdtin of external
+ * command. '\n' is not added so if you need you
+ * should terminate the string with '\n'. <p>
+ *
+ * The method can also be called before the command
+ * starts its execution. Then the text is buffered
+ * and transfered to command when it will be started.
+ * @param str
+ */
+ public void printInputText(String str)
+ {
+ stdInBuff += str;
+ flushInput();
+ }
+
+ /**
+ * Returns information about was the command started or
+ * not.
+ *
+ * @return <code>true</code> if the external command was
+ * found and successfully started.
+ */
+ public boolean isStarted()
+ {
+ return isStarted;
+ }
+
+ /**
+ * Returns the information about the final state of command
+ * execution.
+ *
+ * @return <code>true</code> if the command correctly starts,
+ * exits and was not interrupted due to timeout.
+ */
+ public boolean isFinished()
+ {
+ return isFinished;
+ }
+
+ /**
+ * Returns exit code of the external command.
+ *
+ * @return exit code of command if it was finished,
+ * -1 if not.
+ */
+ public int getExitCode()
+ {
+ try
+ {
+ exitValue = m_aProcess.exitValue();
+ }
+ catch (Exception e)
+ {
+ //System.out.println("No ExitValue available");
+ }
+
+ return exitValue;
+ }
+
+ /** Causes the thread to sleep some time.
+ * @param milliseconds
+ */
+ public static void shortWait(long milliseconds)
+ {
+ try
+ {
+ Thread.sleep(milliseconds);
+ }
+ catch (InterruptedException e)
+ {
+ System.out.println("While waiting :" + e);
+ }
+ }
+
+ private void dbg(String message)
+ {
+ if (debug)
+ {
+ log.println(utils.getDateTime() + "PH." + message);
+ }
+ }
+}
diff --git a/qadevOOo/runner/helper/PropertyHandlerFactroy.java b/qadevOOo/runner/helper/PropertyHandlerFactroy.java
new file mode 100644
index 000000000000..1dcdd3d3b2b3
--- /dev/null
+++ b/qadevOOo/runner/helper/PropertyHandlerFactroy.java
@@ -0,0 +1,49 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************
+ */
+
+package helper;
+
+import com.sun.star.lang.XSingleComponentFactory;
+
+public class PropertyHandlerFactroy implements XSingleComponentFactory{
+
+ /** Creates a new instance of PropertyHandlerFactroy */
+ public PropertyHandlerFactroy() {
+ }
+
+ public Object createInstanceWithArgumentsAndContext(Object[] obj, com.sun.star.uno.XComponentContext xComponentContext)
+ throws com.sun.star.uno.Exception {
+ return new PropertyHandlerImpl();
+ }
+
+ public Object createInstanceWithContext(com.sun.star.uno.XComponentContext xComponentContext)
+ throws com.sun.star.uno.Exception {
+ return new PropertyHandlerImpl();
+ }
+
+}
diff --git a/qadevOOo/runner/helper/PropertyHandlerImpl.java b/qadevOOo/runner/helper/PropertyHandlerImpl.java
new file mode 100644
index 000000000000..01ab88e05e6b
--- /dev/null
+++ b/qadevOOo/runner/helper/PropertyHandlerImpl.java
@@ -0,0 +1,258 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package helper;
+
+import com.sun.star.beans.UnknownPropertyException;
+import com.sun.star.inspection.LineDescriptor;
+import com.sun.star.inspection.XPropertyControlFactory;
+import com.sun.star.inspection.XPropertyHandler;
+
+/**
+ * This implementation of <CODE>PropertyHandler</CODE> do currently nothig.
+ * All methods are implemented, but not filled with content.
+ * @see com.sun.star.inspection.XPropertyHandler
+ */
+public class PropertyHandlerImpl implements XPropertyHandler{
+
+ /** Creates a new instance of PropertyHandlerImpl */
+ public PropertyHandlerImpl() {
+ }
+
+ /**
+ * This method currently do nothig
+ * @param ActuatingPropertyName the id of the actuating property.
+ * @param NewValue the new value of the property
+ * @param OldValue the old value of the property
+ * @param InspectorUI a callback for updating the object inspector UI
+ * @param FirstTimeInit If true , the method is called for the first-time update of the respective property, that is, when the property browser is just initializing with the properties of the introspected object.
+ * If false , there was a real ::com::sun::star::beans::XPropertyChangeListener::propertyChange event which triggered the call.
+ *
+ * In some cases it may be necessary to differentiate between both situations. For instance, if you want to set the value of another property when an actuating property's value changed, you should definately not do this when FirstTimeInit is true .
+ * @throws com.sun.star.lang.NullPointerException ::com::sun::star::lang::NullPointerException if InspectorUI is NULL
+ */
+ public void actuatingPropertyChanged(
+ String ActuatingPropertyName,
+ Object NewValue,
+ Object OldValue,
+ com.sun.star.inspection.XObjectInspectorUI InspectorUI,
+ boolean FirstTimeInit)
+ throws com.sun.star.lang.NullPointerException {
+ }
+
+ /**
+ * This method currently do nothig
+ * @param xEventListener the listener to notify about changes
+ */
+ public void addEventListener(com.sun.star.lang.XEventListener xEventListener) {
+ }
+
+ /**
+ * This method currently do nothig
+ * @param xPropertyChangeListener the listener to notify about property changes
+ * @throws com.sun.star.lang.NullPointerException com::sun::star::lang::NullPointerException if the listener is NULL
+ */
+ public void addPropertyChangeListener(com.sun.star.beans.XPropertyChangeListener xPropertyChangeListener) throws com.sun.star.lang.NullPointerException {
+ }
+
+ /**
+ * This method currently do nothig
+ * @param PropertyName The name of the property whose value is to be converted.
+ * @param PropertyValue The to-be-converted property value.
+ * @param ControlValueType The target type of the conversion. This type is determined by the control which is used to display the property, which in turn is determined by the handler itself in describePropertyLine .
+ * Speaking strictly, this is passed for convenience only, since every XPropertyHandler implementation should know exactly which type to expect, since it implicitly determined this type in describePropertyLine by creating an appropriate XPropertyControl .
+ *
+ * @throws com.sun.star.beans.UnknownPropertyException ::com::sun::star::beans::UnknownPropertyException if the given property is not supported by the property handler
+ * @return null
+ */
+ public Object convertToControlValue(
+ String PropertyName,
+ Object PropertyValue,
+ com.sun.star.uno.Type ControlValueType)
+ throws com.sun.star.beans.UnknownPropertyException {
+ return null;
+ }
+
+ /**
+ * This method currently do nothig
+ * @param PropertyName The name of the conversion's target property.
+ * @param ControlValue The to-be-converted control value. This value has been obtained from an XPropertyControl , using its Value attribute.
+ * @throws com.sun.star.beans.UnknownPropertyException ::com::sun::star::beans::UnknownPropertyException if the given property is not supported by the property handler
+ * @return null
+ */
+ public Object convertToPropertyValue(String PropertyName, Object ControlValue) throws com.sun.star.beans.UnknownPropertyException {
+ return null;
+ }
+
+ /**
+ * This method currently do nothig
+ * @param PropertyName the name of the property whose user interface is to be described
+ * @param out_Descriptor the descriptor of the property line, to be filled by the XPropertyHandler implementation
+ * @param ControlFactory a factory for creating XPropertyControl instances. Must not be NULL .
+ * @throws com.sun.star.beans.UnknownPropertyException ::com::sun::star::beans::UnknownPropertyException if the given property is not supported by this handler
+ *
+ * @throws com.sun.star.lang.NullPointerException ::com::sun::star::lang::NullPointerException if ControlFactory is NULL .
+ */
+ public LineDescriptor describePropertyLine(
+ String PropertyName,
+ com.sun.star.inspection.XPropertyControlFactory ControlFactory)
+ throws com.sun.star.beans.UnknownPropertyException,
+ com.sun.star.lang.NullPointerException {
+ return null;
+ }
+
+ /**
+ * This method currently do nothig
+ */
+ public void dispose() {
+ }
+
+ /**
+ * This method currently do nothig
+ * @return null
+ */
+ public String[] getActuatingProperties() {
+ return null;
+ }
+
+ /**
+ * This method currently do nothig
+ * @param PropertyName the name of the property whose state is to be retrieved
+ * @throws com.sun.star.beans.UnknownPropertyException ::com::sun::star::beans::UnknownPropertyException if the given property is not supported by the property handler
+ * @return null
+ */
+ public com.sun.star.beans.PropertyState getPropertyState(String PropertyName)
+ throws com.sun.star.beans.UnknownPropertyException {
+ return null;
+ }
+
+ /**
+ * This method currently do nothig
+ * @param PropertyName the name of the property whose value is to be retrieved
+ * @throws com.sun.star.beans.UnknownPropertyException ::com::sun::star::beans::UnknownPropertyException if the given property is not supported by the property handler
+ * @return null
+ */
+ public Object getPropertyValue(String PropertyName) throws com.sun.star.beans.UnknownPropertyException {
+ return null;
+ }
+
+ /**
+ * This method currently do nothig
+ * @return null
+ */
+ public String[] getSupersededProperties() {
+ return null;
+ }
+
+ /**
+ * This method currently do nothig
+ * @return null
+ */
+ public com.sun.star.beans.Property[] getSupportedProperties() {
+ return null;
+ }
+
+ /**
+ * This method currently do nothig
+ * @param Component the component to inspect. Must not be NULL
+ * @throws com.sun.star.lang.NullPointerException com::sun::star::lang::NullPointerException if the component is NULL
+ */
+ public void inspect(Object Component) throws com.sun.star.lang.NullPointerException {
+ }
+
+ /**
+ * This method currently do nothig
+ * @param PropertyName the name of the property whose composability is to be determined
+ * @throws com.sun.star.beans.UnknownPropertyException ::com::sun::star::beans::UnknownPropertyException if the given property is not supported by the property handler
+ *
+ *
+ * @return null
+ */
+ public boolean isComposable(String PropertyName) throws com.sun.star.beans.UnknownPropertyException {
+ return false;
+ }
+
+ /**
+ * This method currently do nothig
+ * @param PropertyName The name of the property whose browse button has been clicked
+ * @param Primary true if and only if the primary button has been clicked, false otherwise
+ * @param out_Data If the method returns InteractiveSelectionResult::ObtainedValue , then _rData contains the value which has been interactively obtained from the user, and which still needs to be set at the inspected component.
+ * @param InspectorUI provides access to the object inspector UI. Implementations should use this if the property selection requires non-modal user input. In those cases, onInteractivePropertySelection should return InteractiveSelectionResult::Pending , and the UI for (at least) the property whose input is still pending should be disabled.
+ *
+ * @throws com.sun.star.beans.UnknownPropertyException ::com::sun::star::beans::UnknownPropertyException if the given property is not supported by the property handler
+ * @throws com.sun.star.lang.NullPointerException ::com::sun::star::lang::NullPointerException if InspectorUI is NULL
+ * @return null
+ */
+ public com.sun.star.inspection.InteractiveSelectionResult onInteractivePropertySelection(
+ String PropertyName,
+ boolean Primary,
+ Object[] out_Data,
+ com.sun.star.inspection.XObjectInspectorUI InspectorUI)
+ throws com.sun.star.beans.UnknownPropertyException,
+ com.sun.star.lang.NullPointerException {
+ return null;
+ }
+
+ /**
+ * This method currently do nothig
+ * @param xEventListener the listener to be revoked
+ */
+ public void removeEventListener(com.sun.star.lang.XEventListener xEventListener) {
+ }
+
+ /**
+ * This method currently do nothig
+ * @param xPropertyChangeListener the listener to be revoke
+ */
+ public void removePropertyChangeListener(com.sun.star.beans.XPropertyChangeListener xPropertyChangeListener) {
+ }
+
+ /**
+ * This method currently do nothig
+ * @param PropertyName the name of the property whose value is to be set
+ * @param Value the property value to set
+ * @throws com.sun.star.beans.UnknownPropertyException ::com::sun::star::beans::UnknownPropertyException if the given property is not supported by the property handler
+ */
+ public void setPropertyValue(String PropertyName, Object Value) throws com.sun.star.beans.UnknownPropertyException {
+ }
+
+ /**
+ * This method currently do nothig
+ * @param Suspend Whether the handler is to be suspended true or reactivated ( false ). The latter happens if a handler was successfully suspended, but an external instance vetoed the whole suspension process.
+ * @return false
+ */
+ public boolean suspend(boolean Suspend) {
+ return false;
+ }
+
+ /**
+ * This method currently do nothig
+ */
+
+ public void describePropertyLine(String string, LineDescriptor[] lineDescriptor, XPropertyControlFactory xPropertyControlFactory) throws UnknownPropertyException, com.sun.star.lang.NullPointerException {
+ }
+
+}
diff --git a/qadevOOo/runner/helper/PropertyHelper.java b/qadevOOo/runner/helper/PropertyHelper.java
new file mode 100755
index 000000000000..1b2bdbb9f175
--- /dev/null
+++ b/qadevOOo/runner/helper/PropertyHelper.java
@@ -0,0 +1,81 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package helper;
+
+import java.util.ArrayList;
+
+import com.sun.star.beans.PropertyValue;
+
+public class PropertyHelper
+{
+ /**
+ Create a PropertyValue[] from a ArrayList
+ @param _aArrayList
+ @return a PropertyValue[]
+ */
+ public static PropertyValue[] createPropertyValueArrayFormArrayList(ArrayList _aPropertyList)
+ {
+ // copy the whole PropertyValue List to an PropertyValue Array
+ PropertyValue[] aSaveProperties = null;
+
+ if (_aPropertyList == null)
+ {
+ aSaveProperties = new PropertyValue[0];
+ }
+ else
+ {
+ aSaveProperties = (PropertyValue[])_aPropertyList.toArray(new PropertyValue[_aPropertyList.size()]);
+ // old java 1.4
+// if (_aPropertyList.size() > 0)
+// {
+// aSaveProperties = new PropertyValue[_aPropertyList.size()];
+// for (int i = 0;i<_aPropertyList.size(); i++)
+// {
+// aSaveProperties[i] = (PropertyValue) _aPropertyList.get(i);
+// }
+// }
+// else
+// {
+// aSaveProperties = new PropertyValue[0];
+// }
+
+// show properties?
+// if (_aPropertyList.size() > 0)
+// {
+// // aSaveProperties = new PropertyValue[_aPropertyList.size()];
+// for (int i = 0;i<_aPropertyList.size(); i++)
+// {
+// PropertyValue aProp = (PropertyValue) _aPropertyList.get(i);
+// showProperty(aProp);
+// }
+// }
+
+ }
+ return aSaveProperties;
+ }
+}
diff --git a/qadevOOo/runner/helper/SimpleMailSender.java b/qadevOOo/runner/helper/SimpleMailSender.java
new file mode 100644
index 000000000000..221de9a75027
--- /dev/null
+++ b/qadevOOo/runner/helper/SimpleMailSender.java
@@ -0,0 +1,171 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package helper;
+
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
+
+import java.net.InetAddress;
+import java.net.Socket;
+import java.net.UnknownHostException;
+
+
+public class SimpleMailSender {
+ private String m_MailServer = "unknown";
+ private String m_Sender = "unknown";
+ private String m_Recipient = "unknown";
+ private String m_Subject = "unknown";
+ private String m_Message = "unknown";
+
+
+ public String getMailServer() {
+ return m_MailServer;
+ }
+
+ public void setMailServer(String server) {
+ m_MailServer = server;
+ }
+
+ public String getSender() {
+ return m_Sender;
+ }
+
+ public void setSender(String sender) {
+ m_Sender = sender;
+ }
+
+ public String getRecipient() {
+ return m_Recipient;
+ }
+
+ public void setRecipient(String recipient) {
+ m_Recipient = recipient;
+ }
+
+ public String getSubject() {
+ return m_Subject;
+ }
+
+ public void setSubject(String subject) {
+ m_Subject = subject;
+ }
+
+ public String getMessage() {
+ return m_Message;
+ }
+
+ public void setMessage(String msg) {
+ m_Message = msg;
+ }
+
+ public void sendMail() {
+ if (m_MailServer.equals ("unknown")) {
+ System.out.println("No Mailserver given ... exiting");
+ return;
+ }
+ if (m_Recipient.equals ("unknown")) {
+ System.out.println("No Recipient given ... exiting");
+ return;
+ }
+ sendMail(m_MailServer,m_Sender,m_Recipient,m_Subject,m_Message);
+ }
+
+ public void sendMail(String server, String sender,
+ String recipient, String subject, String msg) {
+ //setting member variables for reuse
+ m_MailServer = server;
+ m_Sender = sender;
+ m_Recipient = recipient;
+ m_Subject = subject;
+ m_Message = msg;
+
+ try {
+ Socket socket = new Socket(m_MailServer, 25);
+ BufferedReader input =
+ new BufferedReader(new InputStreamReader(
+ socket.getInputStream(), "8859_1"));
+ BufferedWriter output =
+ new BufferedWriter(new OutputStreamWriter(
+ socket.getOutputStream(), "8859_1"));
+
+ sendline(input, output, "HELO " + getHostName());
+ sendline(input, output, "MAIL FROM: " + m_Sender);
+ sendline(input, output, "RCPT TO: <" + m_Recipient + ">");
+ sendline(input, output, "DATA");
+ sendline(output, "MIME-Version: 1.0");
+ sendline(output, "Subject: " + m_Subject);
+ sendline(output, "From: " + m_Sender);
+ sendline(output, "To: " + m_Recipient);
+ sendline(output,
+ "Content-Type: text/html; charset=\"us-ascii\"\r\n");
+
+ // Send the body
+ sendline(output, m_Message);
+
+ sendline(input, output, ".");
+ sendline(input, output, "QUIT");
+ socket.close();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ private void sendline(BufferedReader input,
+ BufferedWriter output, String line) {
+ try {
+ output.write(line + "\r\n");
+ output.flush();
+ line = input.readLine();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ private void sendline(BufferedWriter output, String line) {
+ try {
+ output.write(line + "\r\n");
+ output.flush();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ private String getHostName() {
+ String hostname = "";
+
+ try {
+ InetAddress addr = InetAddress.getLocalHost();
+
+ hostname = addr.getHostName();
+ } catch (UnknownHostException e) {
+ }
+
+ return hostname;
+ }
+}
diff --git a/qadevOOo/runner/helper/StreamSimulator.java b/qadevOOo/runner/helper/StreamSimulator.java
new file mode 100644
index 000000000000..5e6554943e41
--- /dev/null
+++ b/qadevOOo/runner/helper/StreamSimulator.java
@@ -0,0 +1,533 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package helper;
+
+import com.sun.star.uno.UnoRuntime;
+
+
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.ucb.XSimpleFileAccess;
+
+/**
+ * It simulates an input and output stream and
+ * implements the interfaces XInputStream, XOutputStream.
+ * So it can be used for testing loading/saving of documents
+ * using streams instead of URLs.
+ *
+ */
+public class StreamSimulator implements com.sun.star.io.XInputStream ,
+ com.sun.star.io.XOutputStream ,
+ com.sun.star.io.XSeekable
+{
+ //_________________________________
+ /**
+ * @member m_sFileName name of the corrsponding file on disk
+ * @member m_xInStream the internal input stream for reading
+ * @member m_xOutStream the internal input stream for writing
+ * @member m_xSeek points at runtime to m_xInStream or m_xOutStream and make it seekable
+ *
+ * @member //m_aProtocol the external set protocol object for logging messages
+ * @member m_bInWasUsed indicates, that the input stream interface was used
+ * @member m_bOutWasUsed indicates, that the output stream interface was used
+ */
+
+ private String m_sFileName ;
+ private com.sun.star.io.XInputStream m_xInStream ;
+ private com.sun.star.io.XOutputStream m_xOutStream ;
+ private com.sun.star.io.XSeekable m_xSeek ;
+
+ //public ComplexTestEnvironment //m_aProtocol ;
+ public boolean m_bInWasUsed ;
+ public boolean m_bOutWasUsed ;
+
+ //_________________________________
+ /**
+ * construct a new instance of this class
+ * It set the name of the correspojnding file on disk, which
+ * should be source or target for the following operations on
+ * this object. And it regulate if it should function as
+ * input or output stream.
+ *
+ * @param sFileName
+ * name of the file on disk
+ * Will be used as source (if param bInput==true)
+ * or as target (if param bInput==false).
+ *
+ * @param bInput
+ * it specify, which interface should work at this object.
+ * <TRUE/> => we simulate an input stream
+ * <FALSE/> => we simulate an output stream
+ *
+ * @throw com.sun.star.io.NotConnectedException
+ * in case the internal streams to the file on disk couldn't established.
+ * They are neccessary. Otherwhise this simulator can't realy work.
+ */
+ public StreamSimulator( String sFileName , boolean bInput ,
+ lib.TestParameters param ) throws com.sun.star.io.NotConnectedException
+ {
+ ////m_aProtocol = new ComplexTestEnvironment();
+ m_sFileName = sFileName ;
+ m_bInWasUsed = false ;
+ m_bOutWasUsed = false ;
+
+ try
+ {
+ XSimpleFileAccess xHelper = (XSimpleFileAccess)
+ UnoRuntime.queryInterface(XSimpleFileAccess.class,
+ ((XMultiServiceFactory)param.getMSF()).createInstance("com.sun.star.ucb.SimpleFileAccess"));
+/* com.sun.star.ucb.XSimpleFileAccess xHelper = (com.sun.star.ucb.XSimpleFileAccess)OfficeConnect.createRemoteInstance(
+ com.sun.star.ucb.XSimpleFileAccess.class,
+ "com.sun.star.ucb.SimpleFileAccess");*/
+
+ if (xHelper == null)
+ throw new com.sun.star.io.NotConnectedException("ucb helper not available. Can't create streams.");
+
+ if (bInput)
+ {
+ m_xInStream = xHelper.openFileRead(m_sFileName);
+ m_xSeek = (com.sun.star.io.XSeekable)UnoRuntime.queryInterface(
+ com.sun.star.io.XSeekable.class,
+ m_xInStream);
+ }
+ else
+ {
+ m_xOutStream = xHelper.openFileWrite(m_sFileName);
+ m_xSeek = (com.sun.star.io.XSeekable)UnoRuntime.queryInterface(
+ com.sun.star.io.XSeekable.class,
+ m_xOutStream);
+ }
+ }
+ catch(com.sun.star.uno.Exception exUno)
+ {
+ ////m_aProtocol.log("\tstream not open. throw NotConnectedException\n\n\tfailed\n}\n");
+ throw new com.sun.star.io.NotConnectedException("Could not open the file.");
+ }
+ }
+
+/* public void finalize()
+ {
+ ////m_aProtocol.log("finalize was called. Please check if it was right or not.\n");
+ } */
+
+ //_________________________________
+ /**
+ * following methods simulates the XInputStream.
+ * The notice all actions inside the internal protocol
+ * and try to map all neccessary functions to the internal
+ * open in-stream.
+ */
+ public int readBytes( /*OUT*/ byte[][] lData ,
+ /*IN*/ int nBytesToRead ) throws com.sun.star.io.NotConnectedException ,
+ com.sun.star.io.BufferSizeExceededException,
+ com.sun.star.io.IOException
+ {
+ //m_aProtocol.log("readBytes(lData["+lData.length+"]["+lData[0]+"],"+nBytesToRead+")\n{\n");
+ m_bInWasUsed = true;
+
+ if (m_xInStream == null)
+ {
+ //m_aProtocol.log("\tstream not open. throw NotConnectedException\n\n\tfailed\n}\n");
+ throw new com.sun.star.io.NotConnectedException("stream not open");
+ }
+
+ int nRead = 0;
+ try
+ {
+ nRead = m_xInStream.readBytes(lData,nBytesToRead);
+ }
+ catch (com.sun.star.io.NotConnectedException exConnect) { //m_aProtocol.log("\tgot NotConnectedException\n\tfailed\n}\n" ); throw exConnect;
+ }
+ catch (com.sun.star.io.BufferSizeExceededException exBuffer ) { //m_aProtocol.log("\tgot BufferSizeExceededException\n\tfailed\n}\n"); throw exBuffer;
+ }
+ catch (com.sun.star.io.IOException exIO ) { //m_aProtocol.log("\tgot IOException\n\tfailed\n}\n" ); throw exIO;
+ }
+ catch (com.sun.star.uno.RuntimeException exRuntime) { //m_aProtocol.log("\tgot RuntimeException\n\tfailed\n}\n" ); throw exRuntime;
+ }
+ catch (com.sun.star.uno.Exception exUno ) { //m_aProtocol.log("\tgot Exception\n\tfailed\n}\n" );
+ }
+
+ //m_aProtocol.log("\treads "+nRead+" bytes\n\tOK\n}\n");
+
+ //if (nRead != nBytesToRead)
+ //m_aProtocol.log("there are some missing bytes for reading!\n");
+
+ return nRead;
+ }
+
+ //_________________________________
+
+ public int readSomeBytes( /*OUT*/ byte[][] lData ,
+ /*IN*/ int nMaxBytesToRead ) throws com.sun.star.io.NotConnectedException ,
+ com.sun.star.io.BufferSizeExceededException ,
+ com.sun.star.io.IOException
+ {
+ //m_aProtocol.log("readSomeBytes(lData["+lData.length+"]["+lData[0]+"],"+nMaxBytesToRead+")\n{\n");
+ m_bInWasUsed = true;
+
+ if (m_xInStream == null)
+ {
+ //m_aProtocol.log("\tstream not open. throw NotConnectedException\n\tfailed\n}\n");
+ throw new com.sun.star.io.NotConnectedException("stream not open");
+ }
+
+ int nRead = 0;
+ try
+ {
+ nRead = m_xInStream.readSomeBytes(lData,nMaxBytesToRead);
+ }
+ catch (com.sun.star.io.NotConnectedException exConnect) { //m_aProtocol.log("\tgot NotConnectedException\n\tfailed\n}\n" ); throw exConnect;
+ }
+ catch (com.sun.star.io.BufferSizeExceededException exBuffer ) { //m_aProtocol.log("\tgot BufferSizeExceededException\n\tfailed\n}\n"); throw exBuffer;
+ }
+ catch (com.sun.star.io.IOException exIO ) { //m_aProtocol.log("\tgot IOException\n\tfailed\n}\n" ); throw exIO;
+ }
+ catch (com.sun.star.uno.RuntimeException exRuntime) { //m_aProtocol.log("\tgot RuntimeException\n\tfailed\n}\n" ); throw exRuntime;
+ }
+ catch (com.sun.star.uno.Exception exUno ) { //m_aProtocol.log("\tgot Exception\n\tfailed\n}\n" );
+ }
+
+ //m_aProtocol.log("\treads "+nRead+" bytes\n\tOK\n}\n");
+
+ //if (nRead != nMaxBytesToRead)
+ //m_aProtocol.log("there are some missing bytes for reading!");
+
+ return nRead;
+ }
+
+ //_________________________________
+
+ public void skipBytes( /*IN*/ int nBytesToSkip ) throws com.sun.star.io.NotConnectedException ,
+ com.sun.star.io.BufferSizeExceededException ,
+ com.sun.star.io.IOException
+ {
+ //m_aProtocol.log("skipBytes("+nBytesToSkip+")\n{\n");
+ m_bInWasUsed = true;
+
+ if (m_xInStream == null)
+ {
+ //m_aProtocol.log("\tstream not open. throw NotConnectedException\n\tfailed\n}\n");
+ throw new com.sun.star.io.NotConnectedException("stream not open");
+ }
+
+ try
+ {
+ m_xInStream.skipBytes(nBytesToSkip);
+ }
+ catch (com.sun.star.io.NotConnectedException exConnect) { //m_aProtocol.log("\tgot NotConnectedException\n\tfailed\n}\n" ); throw exConnect;
+ }
+ catch (com.sun.star.io.BufferSizeExceededException exBuffer ) { //m_aProtocol.log("\tgot BufferSizeExceededException\n\tfailed\n}\n"); throw exBuffer;
+ }
+ catch (com.sun.star.io.IOException exIO ) { //m_aProtocol.log("\tgot IOException\n\tfailed\n}\n" ); throw exIO;
+ }
+ catch (com.sun.star.uno.RuntimeException exRuntime) { //m_aProtocol.log("\tgot RuntimeException\n\tfailed\n}\n" ); throw exRuntime;
+ }
+ catch (com.sun.star.uno.Exception exUno ) { //m_aProtocol.log("\tgot Exception\n\tfailed\n}\n" );
+ }
+
+ //m_aProtocol.log("\tOK\n}\n");
+ }
+
+ //_________________________________
+
+ public int available() throws com.sun.star.io.NotConnectedException,
+ com.sun.star.io.IOException
+ {
+ //m_aProtocol.log("available()\n{\n");
+ m_bInWasUsed = true;
+
+ if (m_xInStream == null)
+ {
+ //m_aProtocol.log("\tstream not open. throw NotConnectedException\n\tfailed\n}\n");
+ throw new com.sun.star.io.NotConnectedException("stream not open");
+ }
+
+ int nAvailable = 0;
+ try
+ {
+ nAvailable = m_xInStream.available();
+ }
+ catch (com.sun.star.io.NotConnectedException exConnect) { //m_aProtocol.log("\tgot NotConnectedException\n\tfailed\n}\n"); throw exConnect;
+ }
+ catch (com.sun.star.io.IOException exIO ) { //m_aProtocol.log("\tgot IOException\n\tfailed\n}\n" ); throw exIO;
+ }
+ catch (com.sun.star.uno.RuntimeException exRuntime) { //m_aProtocol.log("\tgot RuntimeException\n\tfailed\n}\n" ); throw exRuntime;
+ }
+ catch (com.sun.star.uno.Exception exUno ) { //m_aProtocol.log("\tgot Exception\n\tfailed\n}\n" );
+ }
+
+ //m_aProtocol.log("\treturns "+nAvailable+" bytes\n\tOK\n}\n");
+ return nAvailable;
+ }
+
+ //_________________________________
+
+ public void closeInput() throws com.sun.star.io.NotConnectedException,
+ com.sun.star.io.IOException
+ {
+ //m_aProtocol.log("closeInput()\n{\n");
+ m_bInWasUsed = true;
+
+ if (m_xInStream == null)
+ {
+ //m_aProtocol.log("\tstream not open. throw NotConnectedException\n\tfailed\n}\n");
+ throw new com.sun.star.io.NotConnectedException("stream not open");
+ }
+
+ try
+ {
+ m_xInStream.closeInput();
+ }
+ catch (com.sun.star.io.NotConnectedException exConnect) { //m_aProtocol.log("\tgot NotConnectedException\n\tfailed\n}\n"); throw exConnect;
+ }
+ catch (com.sun.star.io.IOException exIO ) { //m_aProtocol.log("\tgot IOException\n\tfailed\n}\n" ); throw exIO;
+ }
+ catch (com.sun.star.uno.RuntimeException exRuntime) { //m_aProtocol.log("\tgot RuntimeException\n\tfailed\n}\n" ); throw exRuntime;
+ }
+ catch (com.sun.star.uno.Exception exUno ) { //m_aProtocol.log("\tgot Exception\n\tfailed\n}\n" );
+ }
+
+ //m_aProtocol.log("\tOK\n}\n");
+ }
+
+ //_________________________________
+ /**
+ * following methods simulates the XOutputStream.
+ * The notice all actions inside the internal protocol
+ * and try to map all neccessary functions to the internal
+ * open out-stream.
+ */
+ public void writeBytes( /*IN*/byte[] lData ) throws com.sun.star.io.NotConnectedException ,
+ com.sun.star.io.BufferSizeExceededException ,
+ com.sun.star.io.IOException
+ {
+ //m_aProtocol.log("writeBytes(lData["+lData.length+"])\n{\n");
+ m_bOutWasUsed = true;
+
+ if (m_xOutStream == null)
+ {
+ //m_aProtocol.log("\tstream not open. throw NotConnectedException\n\tfailed\n}\n");
+ throw new com.sun.star.io.NotConnectedException("stream not open");
+ }
+
+ try
+ {
+ m_xOutStream.writeBytes(lData);
+ }
+ catch (com.sun.star.io.NotConnectedException exConnect) { //m_aProtocol.log("\tgot NotConnectedException\n\tfailed\n}\n" ); throw exConnect;
+ }
+ catch (com.sun.star.io.BufferSizeExceededException exBuffer ) { //m_aProtocol.log("\tgot BufferSizeExceededException\n\tfailed\n}\n"); throw exBuffer;
+ }
+ catch (com.sun.star.io.IOException exIO ) { //m_aProtocol.log("\tgot IOException\n\tfailed\n}\n" ); throw exIO;
+ }
+ catch (com.sun.star.uno.RuntimeException exRuntime) { //m_aProtocol.log("\tgot RuntimeException\n\tfailed\n}\n" ); throw exRuntime;
+ }
+ catch (com.sun.star.uno.Exception exUno ) { //m_aProtocol.log("\tgot Exception\n\tfailed\n}\n" );
+ }
+
+ //m_aProtocol.log("\tOK\n}\n");
+ }
+
+ //_________________________________
+
+ public void flush() throws com.sun.star.io.NotConnectedException ,
+ com.sun.star.io.BufferSizeExceededException ,
+ com.sun.star.io.IOException
+ {
+ //m_aProtocol.log("flush()\n{\n");
+ m_bOutWasUsed = true;
+
+ if (m_xOutStream == null)
+ {
+ //m_aProtocol.log("\tstream not open. throw NotConnectedException\n\tfailed\n}\n");
+ throw new com.sun.star.io.NotConnectedException("stream not open");
+ }
+
+ try
+ {
+ m_xOutStream.flush();
+ }
+ catch (com.sun.star.io.NotConnectedException exConnect) { //m_aProtocol.log("\tgot NotConnectedException\n\tfailed\n}\n" ); throw exConnect;
+ }
+ catch (com.sun.star.io.BufferSizeExceededException exBuffer ) { //m_aProtocol.log("\tgot BufferSizeExceededException\n\tfailed\n}\n"); throw exBuffer;
+ }
+ catch (com.sun.star.io.IOException exIO ) { //m_aProtocol.log("\tgot IOException\n\tfailed\n}\n" ); throw exIO;
+ }
+ catch (com.sun.star.uno.RuntimeException exRuntime) { //m_aProtocol.log("\tgot RuntimeException\n\tfailed\n}\n" ); throw exRuntime;
+ }
+ catch (com.sun.star.uno.Exception exUno ) { //m_aProtocol.log("\tgot Exception\n\tfailed\n}\n" );
+ }
+ //m_aProtocol.log("\tOK\n}\n");
+ }
+
+ //_________________________________
+
+ public void closeOutput() throws com.sun.star.io.NotConnectedException ,
+ com.sun.star.io.BufferSizeExceededException,
+ com.sun.star.io.IOException
+ {
+ //m_aProtocol.log("closeOutput()\n{\n");
+ m_bOutWasUsed = true;
+
+ if (m_xOutStream == null)
+ {
+ //m_aProtocol.log("\tstream not open. throw NotConnectedException\n\tfailed\n}\n");
+ throw new com.sun.star.io.NotConnectedException("stream not open");
+ }
+
+ try
+ {
+ m_xOutStream.closeOutput();
+ }
+ catch (com.sun.star.io.NotConnectedException exConnect) { //m_aProtocol.log("\tgot NotConnectedException\n\tfailed\n}\n" ); throw exConnect;
+ }
+ catch (com.sun.star.io.BufferSizeExceededException exBuffer ) { //m_aProtocol.log("\tgot BufferSizeExceededException\n\tfailed\n}\n"); throw exBuffer;
+ }
+ catch (com.sun.star.io.IOException exIO ) { //m_aProtocol.log("\tgot IOException\n\tfailed\n}\n" ); throw exIO;
+ }
+ catch (com.sun.star.uno.RuntimeException exRuntime) { //m_aProtocol.log("\tgot RuntimeException\n\tfailed\n}\n" ); throw exRuntime;
+ }
+ catch (com.sun.star.uno.Exception exUno ) { //m_aProtocol.log("\tgot Exception\n\tfailed\n}\n" );
+ }
+
+ //m_aProtocol.log("\tOK\n}\n");
+ }
+
+ //_________________________________
+ /**
+ * following methods simulates the XSeekable.
+ * The notice all actions inside the internal protocol
+ * and try to map all neccessary functions to the internal
+ * open stream.
+ */
+ public void seek( /*IN*/long nLocation ) throws com.sun.star.lang.IllegalArgumentException,
+ com.sun.star.io.IOException
+ {
+ //m_aProtocol.log("seek("+nLocation+")\n{\n");
+
+ if (m_xInStream != null)
+ m_bInWasUsed = true;
+ else
+ if (m_xOutStream != null)
+ m_bOutWasUsed = true;
+ else
+ //m_aProtocol.log("\tno stream open!\n");
+
+ if (m_xSeek == null)
+ {
+ //m_aProtocol.log("\tstream not seekable. throw IOException\n\tfailed\n}\n");
+ throw new com.sun.star.io.IOException("stream not seekable");
+ }
+
+ try
+ {
+ m_xSeek.seek(nLocation);
+ }
+ catch (com.sun.star.lang.IllegalArgumentException exArg ) { //m_aProtocol.log("\tgot IllegalArgumentException\n\tfailed\n}\n" ); throw exArg;
+ }
+ catch (com.sun.star.io.IOException exIO ) { //m_aProtocol.log("\tgot IOException\n\tfailed\n}\n" ); throw exIO;
+ }
+ catch (com.sun.star.uno.RuntimeException exRuntime) { //m_aProtocol.log("\tgot RuntimeException\n\tfailed\n}\n" ); throw exRuntime;
+ }
+ catch (com.sun.star.uno.Exception exUno ) { //m_aProtocol.log("\tgot Exception\n\tfailed\n}\n" );
+ }
+
+ //m_aProtocol.log("\tOK\n}\n");
+ }
+
+ //_________________________________
+
+ public long getPosition() throws com.sun.star.io.IOException
+ {
+ //m_aProtocol.log("getPosition()\n{\n");
+
+ if (m_xInStream != null)
+ m_bInWasUsed = true;
+ else
+ if (m_xOutStream != null)
+ m_bOutWasUsed = true;
+ else
+ //m_aProtocol.log("\tno stream open!\n");
+
+ if (m_xSeek == null)
+ {
+ //m_aProtocol.log("\tstream not seekable. throw IOException\n\tfailed\n}\n");
+ throw new com.sun.star.io.IOException("stream not seekable");
+ }
+
+ long nPos = 0;
+ try
+ {
+ nPos = m_xSeek.getPosition();
+ }
+ catch (com.sun.star.io.IOException exIO ) { //m_aProtocol.log("\tgot IOException\n\tfailed\n}\n" ); throw exIO;
+ }
+ catch (com.sun.star.uno.RuntimeException exRuntime) { //m_aProtocol.log("\tgot RuntimeException\n\tfailed\n}\n"); throw exRuntime;
+ }
+ catch (com.sun.star.uno.Exception exUno ) { //m_aProtocol.log("\tgot Exception\n\tfailed\n}\n" );
+ }
+
+ //m_aProtocol.log("\treturns pos="+nPos+"\n\tOK\n}\n");
+ return nPos;
+ }
+
+ //_________________________________
+
+ public long getLength() throws com.sun.star.io.IOException
+ {
+ //m_aProtocol.log("getLength()\n{\n");
+
+ if (m_xInStream != null)
+ m_bInWasUsed = true;
+ else
+ if (m_xOutStream != null)
+ m_bOutWasUsed = true;
+ else
+ //m_aProtocol.log("\tno stream open!\n");
+
+ if (m_xSeek == null)
+ {
+ //m_aProtocol.log("\tstream not seekable. throw IOException\n\tfailed\n}\n");
+ throw new com.sun.star.io.IOException("stream not seekable");
+ }
+
+ long nLen = 0;
+ try
+ {
+ nLen = m_xSeek.getLength();
+ }
+ catch (com.sun.star.io.IOException exIO ) { //m_aProtocol.log("\tgot IOException\n\tfailed\n}\n" ); throw exIO;
+ }
+ catch (com.sun.star.uno.RuntimeException exRuntime) { //m_aProtocol.log("\tgot RuntimeException\n\tfailed\n}\n"); throw exRuntime;
+ }
+ catch (com.sun.star.uno.Exception exUno ) { //m_aProtocol.log("\tgot Exception\n\tfailed\n}\n" );
+ }
+
+ //m_aProtocol.log("\treturns len="+nLen+"\n\tOK\n}\n");
+ return nLen;
+ }
+}
diff --git a/qadevOOo/runner/helper/StringHelper.java b/qadevOOo/runner/helper/StringHelper.java
new file mode 100644
index 000000000000..d2eb41606844
--- /dev/null
+++ b/qadevOOo/runner/helper/StringHelper.java
@@ -0,0 +1,125 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package helper;
+
+public class StringHelper
+{
+
+ public static String doubleQuote(String _sStr)
+ {
+ return "\"" + _sStr + "\"";
+ }
+
+ public static String singleQuote(String _sStr)
+ {
+ return "'" + _sStr + "'";
+ }
+
+ /**
+ * removes quotes if both exists at start and at end
+ */
+ public static String removeSurroundQuoteIfExists(String _sPath)
+ {
+ String sNewPath = _sPath;
+ boolean bRemoveQuotes = false;
+ if (
+ (_sPath.startsWith("\"") && _sPath.endsWith("\"")) ||
+ (_sPath.startsWith("'") && _sPath.endsWith("'"))
+ )
+ {
+ // remove trailing quotes, if exists
+ sNewPath = sNewPath.substring(1);
+
+ // remove trailing quotes, if exists
+ sNewPath = sNewPath.substring(0, sNewPath.length() - 1);
+ }
+ return sNewPath;
+ }
+
+ public static String removeQuoteIfExists(String _sPath)
+ {
+ String sNewPath = _sPath;
+
+ if (_sPath.startsWith("\"") ||
+ _sPath.startsWith("'"))
+ {
+ // remove trailing quotes, if exists
+ sNewPath = sNewPath.substring(1);
+ }
+
+ if (_sPath.endsWith("\"") ||
+ _sPath.endsWith("'"))
+ {
+ // remove trailing quotes, if exists
+ sNewPath = sNewPath.substring(0, sNewPath.length() - 1);
+ }
+ return sNewPath;
+ }
+
+ public static String doubleQuoteIfNeed(String _sStr)
+ {
+ if (_sStr.startsWith("\"") && _sStr.endsWith("\""))
+ {
+ // don't quote twice
+ return _sStr;
+ }
+ if (_sStr.indexOf(" ") == -1)
+ {
+ // don't quote, if there is no space in name
+ return _sStr;
+ }
+ if (_sStr.indexOf("%") != -1)
+ {
+ return singleQuote(_sStr);
+ }
+
+ return doubleQuote(_sStr);
+ }
+
+ /**
+ * Convert a value to a string with a given length, if the len is greater the len of the value string representation
+ * fill it's front with '0'
+ * So ("5", 4) will result in a string "0005"
+ * @param _nValue
+ * @param _nLen
+ * @return
+ */
+ public static String createValueString(int _nValue, int _nLen)
+ {
+ String sValue = String.valueOf(_nValue);
+ StringBuffer a = new StringBuffer();
+ while (_nLen > sValue.length())
+ {
+ a.append('0');
+ _nLen --;
+ }
+ a.append(sValue);
+ return a.toString();
+ }
+
+}
diff --git a/qadevOOo/runner/helper/URLHelper.java b/qadevOOo/runner/helper/URLHelper.java
new file mode 100644
index 000000000000..39bff1485747
--- /dev/null
+++ b/qadevOOo/runner/helper/URLHelper.java
@@ -0,0 +1,292 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package helper;
+
+// __________ Imports __________
+
+// exceptions
+import java.net.MalformedURLException;
+
+// interfaces
+import com.sun.star.util.XURLTransformer;
+
+// others
+import java.io.File;
+import java.util.Vector;
+import java.util.Enumeration;
+
+
+/**
+ * It collects some static helper functons to handle URLs.
+ * Sometimes it's neccessary to convert URL from/to system pathes.
+ * Or from string to strutural notations (e.g. com.sun.star.util.URL).
+ * And sometimes java had another notation then the office it has.
+ *
+ */
+public class URLHelper
+{
+ // ____________________
+
+ /**
+ * Because the office need URLs for loading/saving documents
+ * we must convert used system pathes.
+ * And java use another notation for file URLs ... correct it.
+ *
+ * @param aSystemPath
+ * represent the file in system notation
+ *
+ * @return [String]
+ * a file url which represent the given system path
+ */
+ public static String getFileURLFromSystemPath( File aSystemPath )
+ {
+ String sFileURL = null;
+ try
+ {
+ //sFileURL = aSystemPath.toURI().toURL().toString();
+ sFileURL = aSystemPath.toURL().toString();
+ }
+ catch( MalformedURLException exWrong )
+ {
+ sFileURL = null;
+ }
+
+ // problem of java: file URL's are coded with 1 slash instead of 2 or 3 ones!
+ // => correct this problem first, otherwise office can't use these URL's
+ if(
+ (sFileURL != null ) &&
+ (sFileURL.startsWith("file:/") == true ) &&
+ (sFileURL.startsWith("file://") == false)
+ )
+ {
+ StringBuffer sWorkBuffer = new StringBuffer(sFileURL);
+ sWorkBuffer.insert(6,"//");
+ sFileURL = sWorkBuffer.toString();
+ }
+
+ return sFileURL;
+ }
+
+ // ____________________
+
+ /**
+ * The same as getFileURLFromSystemPath() before but uses string parameter instead
+ * of a File type. It exist to supress converting of neccessary parameters in the
+ * outside code. But of course getFileURLFromSystemPath(File) will be a little bit faster
+ * then this method ...
+ *
+ * @param sSystemPath
+ * represent the file in system notation
+ *
+ * @return [String]
+ * a file url which represent the given system path
+ */
+ public static String getFileURLFromSystemPath( String sSystemPath )
+ {
+ return getFileURLFromSystemPath(new File(sSystemPath));
+ }
+
+ // ____________________
+
+ /**
+ * Does the same as getFileURLFromSystemPath() before ... but uses
+ * the given protocol string (e.g."http://") insted of "file:///".
+ *
+ * @param aSystemPath
+ * represent the file in system notation
+ *
+ * @param aBasePath
+ * define the base path of the aSystemPath value,
+ * which must be replaced with the value of "sServerPath".
+ *
+ * @param sServerURL
+ * Will be used to replace sBasePath.
+ *
+ * @example
+ * System Path = "d:\test\file.txt"
+ * Base Path = "d:\test"
+ * Server Path = "http://alaska:8000"
+ * => "http://alaska:8000/file.txt"
+ *
+ * @return [String]
+ * an url which represent the given system path
+ * and uses the given protocol
+ */
+ public static String getURLWithProtocolFromSystemPath( File aSystemPath, File aBasePath, String sServerURL )
+ {
+ String sFileURL = URLHelper.getFileURLFromSystemPath(aSystemPath);
+ String sBaseURL = URLHelper.getFileURLFromSystemPath(aBasePath );
+
+ // cut last '/'!
+ if (sBaseURL.lastIndexOf('/')==(sBaseURL.length()-1))
+ sBaseURL = sBaseURL.substring(0,sBaseURL.length()-1);
+
+ // cut last '/'!
+ if (sServerURL.lastIndexOf('/')==(sServerURL.length()-1))
+ sServerURL = sServerURL.substring(0,sServerURL.length()-1);
+
+ int index = sFileURL.indexOf(sBaseURL);
+ String sURL = sFileURL.substring(0,index) + sServerURL +
+ sFileURL.substring(index+sBaseURL.length());
+ //String sURL = sFileURL.replaceFirst(sBaseURL,sServerURL);
+ return sURL;
+ }
+
+ // ____________________
+
+ /**
+ * The same as getURLWithProtocolFromSystemPath() before but uses string parameter instead
+ * of a File types. It exist to supress converting of neccessary parameters in the
+ * outside code. But of course getURLWithProtocolFromSystemPath(File,File,String) will be
+ * a little bit faster then this method ...
+ *
+ * @param sSystemPath
+ * represent the file in system notation
+ *
+ * @param sBasePath
+ * define the base path of the aSystemPath value,
+ * which must be replaced with the value of "sServerPath".
+ *
+ * @param sServerPath
+ * Will be used to replace sBasePath.
+ *
+ * @example
+ * System Path = "d:\test\file.txt"
+ * Base Path = "d:\test"
+ * Server Path = "http://alaska:8000"
+ * => "http://alaska:8000/file.txt"
+ *
+ * @return [String]
+ * an url which represent the given system path
+ * and uses the given protocol
+ */
+ public static String getURLWithProtocolFromSystemPath( String sSystemPath, String sBasePath, String sServerPath )
+ {
+ return getURLWithProtocolFromSystemPath(new File(sSystemPath), new File(sBasePath), sServerPath);
+ }
+
+ // ____________________
+
+ /**
+ * This convert an URL (formated as a string) to a struct com.sun.star.util.URL.
+ * It use a special service to do that: the URLTransformer.
+ * Because some API calls need it and it's not allowed to set "Complete"
+ * part of the util struct only. The URL must be parsed.
+ *
+ * @param sURL
+ * URL for parsing in string notation
+ *
+ * @return [com.sun.star.util.URL]
+ * URL in UNO struct notation
+ */
+ public static com.sun.star.util.URL parseURL(XURLTransformer xParser, String sURL)
+ {
+ com.sun.star.util.URL aURL = null;
+
+ if (sURL==null || sURL.equals(""))
+ return null;
+
+ try
+ {
+ // Create special service for parsing of given URL.
+/* com.sun.star.util.XURLTransformer xParser = (com.sun.star.util.XURLTransformer)OfficeConnect.createRemoteInstance(
+ com.sun.star.util.XURLTransformer.class,
+ "com.sun.star.util.URLTransformer");
+*/
+ // Because it's an in/out parameter we must use an array of URL objects.
+ com.sun.star.util.URL[] aParseURL = new com.sun.star.util.URL[1];
+ aParseURL[0] = new com.sun.star.util.URL();
+ aParseURL[0].Complete = sURL;
+
+ // Parse the URL
+ xParser.parseStrict(aParseURL);
+
+ aURL = aParseURL[0];
+ }
+ catch(com.sun.star.uno.RuntimeException exRuntime)
+ {
+ // Any UNO method of this scope can throw this exception.
+ // Reset the return value only.
+ aURL = null;
+ }
+
+ return aURL;
+ }
+
+ //_________________________________
+ /**
+ * Return a name list of all available files of a directory.
+ * We filter pure sub directories names. All other files
+ * are returned as full qualified URL strings. So they can be
+ * used for further purposes. One parameter define the start directory,
+ * another one describe the url protocol, which the return URL names should have.
+ *
+ * @param sDir
+ * the start directory, which should include all test files
+ *
+ * @return [Vector]
+ * a filtered list of java File objects of all available files of the start dir
+ * and all accessable sub directories.
+ */
+ public static Vector getSystemFilesFromDir(String sStartDir)
+ {
+ File aRoot = new File(sStartDir);
+
+ if (! aRoot.exists())
+ return null;
+
+ if (! aRoot.isDirectory())
+ return null;
+
+ File[] lAllFiles = aRoot.listFiles();
+ if (lAllFiles == null )
+ return null;
+
+ Vector lFilteredFiles = new Vector(lAllFiles.length);
+
+ for (int i=0; i<lAllFiles.length; ++i)
+ {
+ if (lAllFiles[i].isFile())
+ lFilteredFiles.add(lAllFiles[i]);
+ else
+ if (lAllFiles[i].isDirectory())
+ {
+ // recursion!
+ Vector lSubFiles = URLHelper.getSystemFilesFromDir(lAllFiles[i].getPath());
+ if (lSubFiles != null)
+ {
+ Enumeration aSnapshot = lSubFiles.elements();
+ while (aSnapshot.hasMoreElements())
+ lFilteredFiles.add(aSnapshot.nextElement());
+ }
+ }
+ }
+
+ return lFilteredFiles;
+ }
+}
diff --git a/qadevOOo/runner/helper/UnoProvider.java b/qadevOOo/runner/helper/UnoProvider.java
new file mode 100644
index 000000000000..c1c3e63f5ef3
--- /dev/null
+++ b/qadevOOo/runner/helper/UnoProvider.java
@@ -0,0 +1,165 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package helper;
+
+import com.sun.star.comp.helper.Bootstrap;
+import com.sun.star.lang.XMultiComponentFactory;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XComponentContext;
+import java.util.Hashtable;
+import lib.TestParameters;
+import util.PropertyName;
+import util.utils;
+
+/**
+ * Bootstrap UNO from a Java environment.
+ * Needed parameters:
+ * <ol>
+ * <li>
+ * <ul>
+ * <li>UNORC - complete path to the unorc file</li>
+ * </ul>
+ * </li>
+ * <li>
+ * <ul>
+ * <li>AppExecutionCommand - path to the soffice executable</li>
+ * <li>OS - the operating system in case it's Windows, because the
+ * unorc is called uno.ini</li>
+ * </ul>
+ * </li>
+ * </ol>
+ */
+public class UnoProvider implements AppProvider {
+
+ public UnoProvider(){
+
+ }
+
+ /**
+ * Close existing office: calls disposeManager()
+ * @param param The test parameters.
+ * @param closeIfPossible Not needed, since UNO is bootstrapped by this
+ * class in every case.
+ * @return True, if bootstrapping worked.
+ */
+ public boolean closeExistingOffice(TestParameters param,
+ boolean closeIfPossible) {
+ return disposeManager(param);
+ }
+
+ /**
+ * Dispose the UNO environment: just clears the bootstrapped
+ * MultiServiceFactory
+ * @param param The test parameters.
+ * @return True, if bootstrapping worked.
+ */
+ public boolean disposeManager(TestParameters param) {
+ XMultiServiceFactory xMSF =
+ (XMultiServiceFactory)param.remove("ServiceManager");
+ xMSF = null;
+ System.gc();
+ try {
+ Thread.sleep(1000);
+ }
+ catch(java.lang.InterruptedException e) {}
+ return true;
+ }
+
+ /**
+ * Bootstrap UNO and return the created MultiServiceFactory.
+ * @param param The test parameters.
+ * @return A created MultiServiceFactory.
+ */
+ public Object getManager(TestParameters param) {
+ XMultiServiceFactory xMSF = (XMultiServiceFactory)param.getMSF();
+ if (xMSF == null) {
+ // bootstrap UNO.
+ String unorcName = getUnorcName(param);
+ Hashtable env = new Hashtable();
+ env.put("SYSBINDIR", getSysBinDir(param));
+
+ XComponentContext xContext = null;
+ try {
+ xContext = Bootstrap.defaultBootstrap_InitialComponentContext(
+ unorcName, env);
+ }
+ catch(Exception e) {
+ e.printStackTrace();
+ System.out.println("Could not get XComponentContext. Maybe you must add program folder to LD_LIBRARY_PATH");
+ return null;
+ }
+ XMultiComponentFactory xMCF = xContext.getServiceManager();
+ xMSF = (XMultiServiceFactory)UnoRuntime.queryInterface(
+ XMultiServiceFactory.class, xMCF);
+ }
+ return xMSF;
+ }
+
+ private String getUnorcName(TestParameters param) {
+ String unorcName = (String)param.get("UNORC");
+ if (unorcName == null) {
+ String office = (String)param.get("AppExecutionCommand");
+ // determine unorc name: unorc or uno.ini on windows
+ String opSystem = (String)param.get(PropertyName.OPERATING_SYSTEM);
+ if ( opSystem != null && opSystem.equalsIgnoreCase(PropertyName.WNTMSCI)) {
+ unorcName = "uno.ini";
+ }
+ else {
+ unorcName = "unorc";
+ }
+ if (office == null)
+ return null;
+ // use '/', because this will be a URL in any case.
+ unorcName = office.substring(0, office.indexOf("program")+7) +
+ "/" + unorcName;
+ }
+ unorcName = utils.getFullURL(unorcName);
+ if (param.DebugIsActive) {
+ System.out.println("UnoUcr: " + unorcName);
+ }
+ return unorcName;
+ }
+
+ private String getSysBinDir(TestParameters param) {
+ String base = (String)param.get("AppExecutionCommand");
+ if (base == null)
+ base = (String)param.get("UNORC");
+
+ if (base == null)
+ return null;
+
+ String sysbindir = base.substring(0,
+ base.indexOf("program")+7);
+
+ sysbindir = utils.getFullURL(sysbindir);
+ if (param.DebugIsActive) {
+ System.out.println("SysBinDir: " + sysbindir);
+ }
+ return sysbindir;
+ }
+}
diff --git a/qadevOOo/runner/helper/WindowListener.java b/qadevOOo/runner/helper/WindowListener.java
new file mode 100644
index 000000000000..a19ae27c62c0
--- /dev/null
+++ b/qadevOOo/runner/helper/WindowListener.java
@@ -0,0 +1,78 @@
+/*
+ * WindowListener.java
+ *
+ * Created on 30. Juli 2002, 12:36
+ */
+
+package helper;
+
+/**
+ * An own implementation of a XWindowListener
+ *
+ */
+public class WindowListener implements com.sun.star.awt.XWindowListener {
+
+ // hidden called
+ public boolean hiddenTrigger;
+ // move called
+ public boolean movedTrigger;
+ // resize called
+ public boolean resizedTrigger;
+ // show called
+ public boolean shownTrigger;
+ // dispose called
+ public boolean disposeTrigger;
+
+ /**
+ * Creates a new WindowListener
+ */
+ public WindowListener() {
+ resetTrigger();
+ }
+
+ /**
+ * The window hidden event
+ */
+ public void windowHidden(com.sun.star.lang.EventObject eventObject) {
+ hiddenTrigger = true;
+ }
+
+ /**
+ * The window move event
+ */
+ public void windowMoved(com.sun.star.awt.WindowEvent windowEvent) {
+ movedTrigger = true;
+ }
+
+ /**
+ * The window resize event
+ */
+ public void windowResized(com.sun.star.awt.WindowEvent windowEvent) {
+ resizedTrigger = true;
+ }
+
+ /**
+ * The window show event
+ */
+ public void windowShown(com.sun.star.lang.EventObject eventObject) {
+ shownTrigger = true;
+ }
+
+ /**
+ * The dispose event
+ */
+ public void disposing(com.sun.star.lang.EventObject eventObject) {
+ disposeTrigger = true;
+ }
+
+ /**
+ * Reset all triggers to "not fired".
+ */
+ public void resetTrigger() {
+ hiddenTrigger = false;
+ movedTrigger = false;
+ resizedTrigger = false;
+ shownTrigger = false;
+ disposeTrigger = false;
+ }
+}
diff --git a/qadevOOo/runner/helper/makefile.mk b/qadevOOo/runner/helper/makefile.mk
new file mode 100644
index 000000000000..f5ad34c53ad6
--- /dev/null
+++ b/qadevOOo/runner/helper/makefile.mk
@@ -0,0 +1,65 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..
+
+PRJNAME = OOoRunner
+PACKAGE = helper
+TARGET = runner_helper
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+# --- Files --------------------------------------------------------
+
+JARFILES = ridl.jar jurt.jar juh.jar unoil.jar
+
+JAVAFILES = APIDescGetter.java \
+ ConfigurationRead.java \
+ StreamSimulator.java \
+ AppProvider.java \
+ URLHelper.java \
+ CfgParser.java \
+ SimpleMailSender.java \
+ WindowListener.java \
+ ClParser.java \
+ OfficeWatcher.java \
+ OfficeProvider.java \
+ ComplexDescGetter.java \
+ InetTools.java \
+ ProcessHandler.java \
+ ContextMenuInterceptor.java \
+ UnoProvider.java\
+ PropertyHelper.java\
+ FileTools.java
+
+JAVACLASSFILES= $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class)
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
diff --git a/qadevOOo/runner/lib/DynamicClassLoader.java b/qadevOOo/runner/lib/DynamicClassLoader.java
new file mode 100644
index 000000000000..2611ad965dfc
--- /dev/null
+++ b/qadevOOo/runner/lib/DynamicClassLoader.java
@@ -0,0 +1,94 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package lib ;
+
+import java.lang.reflect.Constructor;
+
+/**
+ * @deprecated: moved to util package.
+ */
+public class DynamicClassLoader {
+
+ /**
+ * This method returns a class created by it's name
+ * created by call to <code>Class.forName()</code>.<p>
+ * This method must be overloaded if another loading
+ * policy is required for Component and Interface
+ * testing classes.
+ */
+ public static Class forName(String className)
+ throws ClassNotFoundException {
+
+ return Class.forName(className) ;
+ }
+
+ public Object getInstance(String className)
+ throws IllegalArgumentException {
+ try {
+ Class cls = DynamicClassLoader.forName(className);
+ return cls.newInstance();
+ } catch ( ClassNotFoundException e ) {
+ throw new IllegalArgumentException("Couldn't find " + className
+ + " " + e);
+ } catch ( IllegalAccessException e ) {
+ throw new IllegalArgumentException("Couldn't access " + className
+ + " " + e);
+ } catch ( InstantiationException e ) {
+ throw new IllegalArgumentException("Couldn't instantiate " +
+ className + " " + e);
+ }
+ }
+
+ public Object getInstance(String className, Object[] ctorArgs)
+ throws IllegalArgumentException {
+ try {
+ Class cls = DynamicClassLoader.forName(className);
+ Class[] ctorType = new Class[ctorArgs.length];
+ for(int i=0; i<ctorType.length; i++) {
+ ctorType[i] = ctorArgs[i].getClass();
+ }
+ Constructor ctor = cls.getConstructor(ctorType);
+ return ctor.newInstance(ctorArgs);
+ } catch ( ClassNotFoundException e ) {
+ throw new IllegalArgumentException("Couldn't find " + className
+ + " " + e);
+ } catch ( IllegalAccessException e ) {
+ throw new IllegalArgumentException("Couldn't access " + className
+ + " " + e);
+ } catch ( NoSuchMethodException e ) {
+ throw new IllegalArgumentException("Couldn't find constructor for " + className
+ + " " + e);
+ } catch ( java.lang.reflect.InvocationTargetException e ) {
+ throw new IllegalArgumentException("Couldn't invoke " +
+ className + " " + e);
+ } catch ( InstantiationException e ) {
+ throw new IllegalArgumentException("Couldn't instantiate " +
+ className + " " + e);
+ }
+ }
+}
diff --git a/qadevOOo/runner/lib/ExceptionStatus.java b/qadevOOo/runner/lib/ExceptionStatus.java
new file mode 100644
index 000000000000..198bded1e895
--- /dev/null
+++ b/qadevOOo/runner/lib/ExceptionStatus.java
@@ -0,0 +1,48 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package lib;
+
+/**
+ * The class implements Status behaviour for exception runstate Status objects.
+ */
+class ExceptionStatus extends Status {
+
+ /**
+ * Creates an instance of Status object with EXCEPTION runstate.
+ *
+ * @param t the exception an activity terminated with.
+ */
+ ExceptionStatus( Throwable t ) {
+ super(EXCEPTION, FAILED);
+ String message = t.getMessage();
+ if (message != null)
+ runStateString = message;
+ else
+ runStateString = t.toString();
+ }
+} \ No newline at end of file
diff --git a/qadevOOo/runner/lib/MultiMethodTest.java b/qadevOOo/runner/lib/MultiMethodTest.java
new file mode 100644
index 000000000000..884059bcfd88
--- /dev/null
+++ b/qadevOOo/runner/lib/MultiMethodTest.java
@@ -0,0 +1,511 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package lib;
+
+import java.io.PrintWriter;
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.Vector;
+
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XInterface;
+
+import share.DescEntry;
+import lib.TestParameters;
+import stats.Summarizer;
+
+/**
+ * The class supports method based interface tests development.
+ *
+ * <p>There are some points that should be fulfilled in a subclass to work
+ * correctly in the multi-method framework:
+ *
+ * 1. each subclass schould define a public field named oObj of type tested
+ * by the subclass, e.g. 'public XText oObj;'. That field will be initialized
+ * by the MultiMethodTest code with the instance of the interface to test.
+ * In a case of service testing the field type should be XPropertySet.
+ *
+ * 2. for the test of each method of the tested interface(or a property in the
+ * case of service testing) should be method with the following signature
+ * provided: 'public void _<method name>()', e.g. 'public void _getText()'.
+ * The methods will be called by MultiMethodText code using reflection API
+ * for each method in the interface description.
+ *
+ * 3. to set status for a call 'tRes.tested(String method,
+ * boolean result)' should be used. For example 'tRes.tested("getText()",
+ * true)'. Also 'tRes.assert(String assertion, boolean result)' call can
+ * be used. Note, that one can call the methods not neccesarily from the
+ * test for the tested method, but from other method tests too (in the
+ * MultiMethodTest subclass). See also TestResult and MultiMethodTest.tRes
+ * documentation.
+ *
+ * 4. the before() and after() methods can be overriden to perform some
+ * actions, accordingly, before and after calling the test methods.
+ *
+ * 5. besides tRes, there are some fields initialized in the MultiMethodTest,
+ * that can be used for implementing tests:
+ *
+ * - tEnv contains the environment tested
+ * - tParam contains parameters of the test
+ * - log a writer to log information about the test
+ *
+ * @see TestResult
+ */
+public class MultiMethodTest
+{
+
+ /**
+ * Contains the TestEnvironment being tested, to allow for tests to access
+ * it.
+ */
+ protected TestEnvironment tEnv;
+ /**
+ * Contains the TestParameters for the tests, to allow for tests to access
+ * it.
+ */
+ protected TestParameters tParam;
+ /**
+ * Contains the Description for the test
+ * it.
+ */
+ protected DescEntry entry;
+ /**
+ * Contains a writer to log an information about the interface testing, to
+ * allows for tests to access it.
+ */
+ protected PrintWriter log;
+ /**
+ * Contains the TestResult instance for the interface test to collect
+ * information about methods test.
+ */
+ protected TestResult tRes;
+ /**
+ * Contains names of the methods have been alreadycalled
+ */
+ private Vector methCalled = new Vector(10);
+
+ /**
+ * Disposes the test environment, which was corrupted by the test.
+ *
+ * @param tEnv the environment to dispose
+ */
+ public void disposeEnvironment(TestEnvironment tEnv)
+ {
+ disposeEnvironment();
+ }
+
+ /**
+ * Disposes the current test environment, which was corrupted by the test.
+ *
+ * @see #disposeEnvironment(TestEnvironment)
+ */
+ public void disposeEnvironment()
+ {
+ tEnv.dispose();
+ TestCase tCase = tEnv.getTestCase();
+ tCase.disposeTestEnvironment(tEnv, tParam);
+ }
+
+ /**
+ * Runs the interface test: its method tests. First, it initializes some
+ * of MultiMethodTest fields, like tRes, log, tEnv, etc. Then, it queries
+ * the tested interface and initializes 'oObj' field (defined in a
+ * subclass). Before calling method tests, before() method calles to allow
+ * initialization of s stuff before testing. Then, the method tests are
+ * called. After them, after() method is called, to allow cleaning up the
+ * stuff initialized in before() and test methods.
+ *
+ * @param entry the interface test state
+ * @param tEnv the environment to test
+ * @param tParam the parameters of the test
+ *
+ * @see #before
+ * @see #after
+ */
+ public TestResult run(DescEntry entry, TestEnvironment tEnv, TestParameters tParam)
+ {
+
+ log = (PrintWriter) entry.Logger;
+
+ this.tEnv = tEnv;
+ this.tParam = tParam;
+ // this.log = log;
+ this.entry = entry;
+ this.tRes = new TestResult();
+ Class testedClass;
+
+ // Some fake code for a self test.
+ // For normal test we must not be a "ifc.qadevooo._SelfTest"
+ if (! entry.entryName.equals("ifc.qadevooo._SelfTest"))
+ {
+ String ifcName = getInterfaceName();
+ // System.out.println("checking : " + ifcName);
+ System.out.print("checking: [" + entry.longName + "]");
+
+ // defining a name of the class corresponding to the tested interface
+ // or service
+ String testedClassName;
+
+ testedClassName = getTestedClassName();
+
+ if (entry.EntryType.equals("service"))
+ {
+ testedClassName = "com.sun.star.beans.XPropertySet";
+ }
+
+ try
+ {
+ testedClass = Class.forName(testedClassName);
+ }
+ catch (ClassNotFoundException cnfE)
+ {
+ System.out.println();
+ cnfE.printStackTrace(log);
+ log.println("could not find a class : " + getTestedClassName());
+ return null;
+ }
+ System.out.println(" is iface: [" + testedClassName + "] testcode: [" + entry.entryName + "]");
+
+ // quering the tested interface from the tested object
+ XInterface tCase = tEnv.getTestObject();
+ Object oObj = UnoRuntime.queryInterface(testedClass, tEnv.getTestObject());
+
+ if (oObj == null)
+ {
+ if (entry.isOptional)
+ {
+ Summarizer.summarizeDown(entry, "Not supported but optional.OK");
+ }
+ else
+ {
+ Summarizer.summarizeDown(entry, "queryInterface returned null.FAILED");
+ entry.ErrorMsg = "queryInterface returned null";
+ entry.hasErrorMsg = true;
+ }
+
+ return null;
+ }
+
+ //setting the field oObj
+ setField("oObj", oObj);
+ }
+
+ // to perform some stuff before all method tests
+ try
+ {
+ before();
+ }
+ catch (Exception e)
+ {
+ setSubStates(e.toString());
+ return tRes;
+ }
+
+ // executing methods tests
+ for (int i = 0; i < entry.SubEntryCount; i++)
+ {
+ DescEntry aSubEntry = entry.SubEntries[i];
+ try
+ {
+ final String sEntryName = aSubEntry.entryName;
+ executeMethod(sEntryName);
+ }
+ catch (Exception e)
+ {
+ log.println("Exception while checking: " + aSubEntry.entryName + " : " + e.getMessage());
+ }
+ }
+
+ // to perform some stuff after all method tests
+ try
+ {
+ after();
+ }
+ catch (Exception e)
+ {
+ }
+
+ return tRes;
+ }
+
+ /**
+ * Is called before calling method tests, but after initialization.
+ * Subclasses may override to perform actions before method tests.
+ */
+ protected void before()
+ {
+ }
+
+ /**
+ * Is called after calling method tests. Subclasses may override
+ * to perform actions after method tests.
+ */
+ protected void after()
+ {
+ }
+
+ /**
+ * @return the name of the interface or the service tested.
+ */
+ protected String getTestedClassName()
+ {
+ String clsName = this.getClass().getName();
+
+ int firstDot = clsName.indexOf(".");
+ int lastDot = clsName.lastIndexOf(".");
+
+ String append = "com.sun.star.";
+
+ if (entry.longName.indexOf("::drafts::com::") > -1)
+ {
+ append = "drafts.com.sun.star.";
+ }
+
+ return append + clsName.substring(firstDot + 1, lastDot + 1) + clsName.substring(lastDot + 2);
+ }
+
+ /**
+ * Sets a method status.
+ *
+ * @param methName the method name to set status
+ * @param methStatus the status to set to the method
+ */
+ protected void setStatus(String methName, Status methStatus)
+ {
+ tRes.tested(methName, methStatus);
+ }
+
+ /**
+ * sets the substates
+ */
+ protected void setSubStates(String msg)
+ {
+ for (int k = 0; k < entry.SubEntryCount; k++)
+ {
+ entry.SubEntries[k].hasErrorMsg = true;
+ entry.SubEntries[k].ErrorMsg = msg;
+ if (entry.SubEntries[k].State.equals("UNKNOWN"))
+ {
+ entry.SubEntries[k].State = msg;
+ }
+ }
+
+ }
+
+ /**
+ * Checks if the <code>method</code> is optional in the service.
+ */
+ protected boolean isOptional(String _method)
+ {
+ for (int k = 0; k < entry.SubEntryCount; k++)
+ {
+ final String sName = entry.SubEntries[k].entryName;
+ if (sName.equals(_method))
+ {
+ final boolean bIsOptional = entry.SubEntries[k].isOptional;
+ return bIsOptional;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Checks if the <code>method</code> test has been already called.
+ */
+ protected boolean isCalled(String method)
+ {
+ return methCalled.contains(method);
+ }
+
+ /**
+ * Calling of the method indicates that the <code>method</code> test should
+ * be called. The method checks this and if it is not called, calls it.
+ * If the method is failed or skipped, it throws StatusException.
+ */
+ protected void requiredMethod(String method)
+ {
+ log.println("starting required method: " + method);
+ executeMethod(method);
+ Status mtStatus = tRes.getStatusFor(method);
+
+ if (mtStatus != null && (!mtStatus.isPassed() || mtStatus.isFailed()))
+ {
+ log.println("! Required method " + method + " failed");
+ throw new StatusException(mtStatus);
+ }
+ }
+
+ /**
+ * Checks if the <code>method</code> was called, and if not, call it.
+ * On contrary to requiredMethod(), he method doesn't check its status.
+ */
+ protected void executeMethod(String method)
+ {
+ if (!isCalled(method))
+ {
+ log.println("Execute: " + method);
+ callMethod(method);
+ log.println(method + ": " + tRes.getStatusFor(method));
+ log.println();
+ }
+ }
+
+ /**
+ * Just calls the <code>method</code> test.
+ */
+ protected void callMethod(String method)
+ {
+ methCalled.add(method);
+ invokeTestMethod(getMethodFor(method), method);
+ }
+
+ /**
+ * Invokes a test method of the subclass using reflection API. Handles
+ * the method results and sets its status.
+ *
+ * @param meth the subclass' method to invoke
+ * @param methName the name of the method
+ */
+ protected void invokeTestMethod(Method meth, String methName)
+ {
+ if (meth == null)
+ {
+ setStatus(methName, Status.skipped(false));
+ }
+ else
+ {
+ Status stat;
+
+ try
+ {
+ meth.invoke(this, new Object[0]);
+ return;
+ }
+ catch (InvocationTargetException itE)
+ {
+ Throwable t = itE.getTargetException();
+
+ if (t instanceof StatusException)
+ {
+ stat = ((StatusException) t).getStatus();
+ }
+ else
+ {
+ t.printStackTrace(log);
+ stat = Status.exception(t);
+ }
+ }
+ catch (IllegalAccessException iaE)
+ {
+ iaE.printStackTrace(log);
+ stat = Status.exception(iaE);
+ }
+ catch (IllegalArgumentException iaE)
+ {
+ iaE.printStackTrace(log);
+ stat = Status.exception(iaE);
+ }
+ catch (ClassCastException ccE)
+ {
+ ccE.printStackTrace(log);
+ stat = Status.exception(ccE);
+ }
+
+ setStatus(methName, stat);
+ }
+ }
+
+ /**
+ * Finds a testing method for the <code>method</code> of the interface.
+ *
+ * @return the testing method, if found, <tt>null</tt> otherwise
+ */
+ protected Method getMethodFor(String method)
+ {
+ String mName = "_" + method;
+
+ if (mName.endsWith("()"))
+ {
+ mName = mName.substring(0, mName.length() - 2);
+ }
+
+ final Class[] paramTypes = new Class[0];
+
+ try
+ {
+ return this.getClass().getDeclaredMethod(mName, paramTypes);
+ }
+ catch (NoSuchMethodException nsmE)
+ {
+ return null;
+ }
+ }
+
+ /**
+ * @return the name of the interface tested
+ */
+ public String getInterfaceName()
+ {
+ String clName = this.getClass().getName();
+ return clName.substring(clName.lastIndexOf('.') + 1);
+ }
+
+ /**
+ * Initializes <code>fieldName</code> of the subclass with
+ * <code>value</code>.
+ *
+ * @return Status describing the result of the operation.
+ */
+ protected Status setField(String fieldName, Object value)
+ {
+ Field objField;
+
+ try
+ {
+ objField = this.getClass().getField(fieldName);
+ }
+ catch (NoSuchFieldException nsfE)
+ {
+ return Status.exception(nsfE);
+ }
+
+ try
+ {
+ objField.set(this, value);
+ return Status.passed(true);
+ }
+ catch (IllegalArgumentException iaE)
+ {
+ return Status.exception(iaE);
+ }
+ catch (IllegalAccessException iaE)
+ {
+ return Status.exception(iaE);
+ }
+ }
+}
diff --git a/qadevOOo/runner/lib/MultiPropertyTest.java b/qadevOOo/runner/lib/MultiPropertyTest.java
new file mode 100644
index 000000000000..a02f93c04347
--- /dev/null
+++ b/qadevOOo/runner/lib/MultiPropertyTest.java
@@ -0,0 +1,608 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package lib;
+
+import com.sun.star.beans.Property;
+import com.sun.star.beans.PropertyAttribute;
+import com.sun.star.beans.PropertyVetoException;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.beans.XPropertySetInfo;
+import com.sun.star.beans.UnknownPropertyException;
+import com.sun.star.lang.XServiceInfo;
+import com.sun.star.lang.IllegalArgumentException;
+import com.sun.star.lang.WrappedTargetException;
+import com.sun.star.uno.UnoRuntime;
+
+import java.lang.reflect.Method;
+
+import util.ValueChanger;
+import util.ValueComparer;
+import util.utils;
+
+import com.sun.star.uno.Any;
+import com.sun.star.uno.AnyConverter;
+import com.sun.star.uno.Type;
+
+/**
+ * MultiPropertyTest extends the functionality of MultiMethodTest to support
+ * services testing. Since, in most cases, service tests has one method testing
+ * most of its properties, the MultiPropertyTest provides unified version of
+ * the method: testProperty().
+ *
+ * <p>The testProperty() is called, when the MultiMethodTest's testing method
+ * is not found in the subclass. So, by defining such methods for properties
+ * the standard testing behavioutr can be changed.
+ *
+ * <p>The testing behaviour also can be changed by overriding compare(),
+ * getNewVAlue() or toString(Object) methods, or by extending PropertyTester
+ * class.
+ *
+ * @see MultiMethodTest
+ * @see #testProperty(String)
+ * @see #testProperty(String, Propertytester)
+ * @see #getNewValue
+ * @see #compare
+ * @see #toString(Object)
+ */
+public class MultiPropertyTest extends MultiMethodTest
+{
+
+ /**
+ * Contains a XPropertySet interface of the tested object. Is initialized
+ * in MultiMethodTest code.
+ */
+ public XPropertySet oObj;
+ protected boolean optionalService = false;
+
+ /**
+ * Overrides super.before() to check the service is supported by the object.
+ */
+ protected void before()
+ {
+ XServiceInfo xInfo = (XServiceInfo) UnoRuntime.queryInterface(
+ XServiceInfo.class, oObj);
+
+ optionalService = entry.isOptional;
+
+ String theService = getTestedClassName();
+ if (xInfo != null && !xInfo.supportsService(theService))
+ {
+ log.println("Service " + theService + " not available");
+ if (optionalService)
+ {
+ log.println("This is OK since it is optional");
+ }
+ else
+ {
+ Status.failed(theService + " is not supported");
+ }
+ }
+ }
+
+ /**
+ * Overrides MultiMethodTest.invokeTestMethod(). If the test for the
+ * <code>meth</code> is not available (<code>meth</code> == <tt>null</tt>)
+ * calls testProperty method for the method. Otherwise calls
+ * super.invokeTestMethod().
+ *
+ * @see #MultiMethodTest.invokeTestMethod()
+ */
+ protected void invokeTestMethod(Method meth, String methName)
+ {
+ if (meth != null)
+ {
+ super.invokeTestMethod(meth, methName);
+ }
+ else
+ {
+ testProperty(methName);
+ }
+ }
+
+ /**
+ * PropertyTester class defines how to test a property and defined
+ * to allow subclasses of MultiPropertyTest to change the testing
+ * behaviour more flexible, since the behaviour can be customized for
+ * each property separately, by providing subclass of PropertyTester
+ * and passing it to testProperty(String, PropertyTester method).
+ */
+ public class PropertyTester
+ {
+
+ /**
+ * The method defines the whole process of testing propName
+ * property.
+ *
+ * <p>First, it checks if the property exists(it maybe optional).
+ * Then, a value to set the property with is calculated with
+ * getNewValue method. Normally, the new value is calculated
+ * based on old value, but subclasses can override the behaviour
+ * (for example, if old value is null) and specify their own value.
+ * Then the property is set with that new value and the result(
+ * it maybe an exception too, for example a PropertyVetoException)
+ * is checked with checkResult method.
+ *
+ * @param propName - the property to test.
+ * @result - adds the result of testing propName property to
+ * MultiMethodTest.tRes.
+ */
+ protected void testProperty(String propName)
+ {
+ XPropertySetInfo info = oObj.getPropertySetInfo();
+
+ if (info != null)
+ {
+ final boolean bHasProperty = info.hasPropertyByName(propName);
+ if (!bHasProperty)
+ {
+ if (isOptional(propName) || optionalService)
+ {
+ // skipping optional property test
+ log.println("Property '" + propName + "' is optional and not supported");
+ tRes.tested(propName, true);
+ return;
+ }
+ else
+ {
+ // cannot test the property
+ log.println("Tested XPropertySet does not contain'" + propName + "' property");
+ tRes.tested(propName, false);
+ return;
+ }
+ }
+ }
+
+ try
+ {
+ Object oldValue = oObj.getPropertyValue(propName);
+
+ if( (oldValue==null) || utils.isVoid(oldValue) )
+ {
+ // #i111560# method getNewValue() does not work with an empty oldValue
+ Property prop = info.getPropertyByName(propName);
+ if( (prop.Attributes & PropertyAttribute.MAYBEVOID) != 0 )
+ {
+ // todo: implement a new test independent from method getNewValue()
+ log.println("changing initially empty MAYBEVOID properties is not supported by the test framework so far - skip test of property: " + propName);
+ tRes.tested(propName, true);
+ return;
+ }
+ else
+ {
+ log.println( "property '"+propName+"' is not set but is not MAYBEVOID");
+ tRes.tested(propName, false);
+ return;
+ }
+ }
+
+ Object newValue;
+
+ // trying to create new value
+ try
+ {
+ newValue = getNewValue(propName, oldValue);
+ }
+ catch (java.lang.IllegalArgumentException e)
+ {
+ // skipping test since new value is not available
+ Status.failed("Cannot create new value for '" + propName + " : " + e.getMessage());
+ return;
+ }
+
+ // for an exception thrown during setting new value
+ // to pass it to checkResult method
+ Exception exception = null;
+
+ try
+ {
+ log.println("try to set:");
+ log.println("old = " + toString(oldValue));
+ log.println("new = " + toString(newValue));
+ oObj.setPropertyValue(propName, newValue);
+ }
+ catch (IllegalArgumentException e)
+ {
+ exception = e;
+ }
+ catch (PropertyVetoException e)
+ {
+ exception = e;
+ }
+ catch (WrappedTargetException e)
+ {
+ exception = e;
+ }
+ catch (UnknownPropertyException e)
+ {
+ exception = e;
+ }
+ catch (RuntimeException e)
+ {
+ exception = e;
+ }
+
+ // getting result value
+ Object resValue = oObj.getPropertyValue(propName);
+
+ // checking results
+ checkResult(propName, oldValue, newValue, resValue, exception);
+ }
+ catch (Exception e)
+ {
+ log.println("Exception occured while testing property '" + propName + "'");
+ e.printStackTrace(log);
+ tRes.tested(propName, false);
+ }
+ }
+
+ /**
+ * The method checks result of setting a new value to the
+ * property based o the following arguments:
+ * @propName - the property to test
+ * @oldValue - the old value of the property, before changing it.
+ * @newValue - the new value the property has been set with
+ * @resValue - the value of the property after having changed it
+ * @exception - if not null - the exception thrown by
+ * XPropertySet.setPropertyValue, else indicates
+ * normal method completion.
+ *
+ * <p>If the property is READ_ONLY, than either PropertyVetoException
+ * should be thrown or the value of property should not have changed
+ * (resValue is compared with oldValue with compare method).
+ *
+ * <p>If the property is not READ_ONLY, checks that the new value has
+ * been successfully set(resValue is compared with newValue with
+ * compare method).
+ *
+ * <p>If the exception is not null then(except the case of read-only
+ * property and PropertyVetoException above) it is rethrown to allow
+ * further catching it if needed.
+ *
+ * <p>Subclasses can override to change this behaviour.
+ */
+ protected void checkResult(String propName, Object oldValue,
+ Object newValue, Object resValue, Exception exception)
+ throws Exception
+ {
+ XPropertySetInfo info = oObj.getPropertySetInfo();
+ if (info == null)
+ {
+ log.println("Can't get XPropertySetInfo for property " + propName);
+ tRes.tested(propName, false);
+ return;
+ }
+ Property prop = info.getPropertyByName(propName);
+
+ short attr = prop.Attributes;
+ boolean readOnly = (prop.Attributes & PropertyAttribute.READONLY) != 0;
+ boolean maybeVoid = (prop.Attributes & PropertyAttribute.MAYBEVOID) != 0;
+ //check get-set methods
+ if (maybeVoid)
+ {
+ log.println("Property " + propName + " is void");
+ }
+ if (readOnly)
+ {
+ log.println("Property " + propName + " is readOnly");
+ }
+ if (util.utils.isVoid(oldValue) && !maybeVoid)
+ {
+ log.println(propName + " is void, but it's not MAYBEVOID");
+ tRes.tested(propName, false);
+ }
+ else if (oldValue == null)
+ {
+ log.println(propName + " has null value, and therefore can't be changed");
+ tRes.tested(propName, true);
+ }
+ else if (readOnly)
+ {
+ // check if exception was thrown
+ if (exception != null)
+ {
+ if (exception instanceof PropertyVetoException)
+ {
+ // the change of read only prohibited - OK
+ log.println("Property is ReadOnly and wasn't changed");
+ log.println("Property '" + propName + "' OK");
+ tRes.tested(propName, true);
+ }
+ else if (exception instanceof IllegalArgumentException)
+ {
+ // the change of read only prohibited - OK
+ log.println("Property is ReadOnly and wasn't changed");
+ log.println("Property '" + propName + "' OK");
+ tRes.tested(propName, true);
+ }
+ else if (exception instanceof UnknownPropertyException)
+ {
+ // the change of read only prohibited - OK
+ log.println("Property is ReadOnly and wasn't changed");
+ log.println("Property '" + propName + "' OK");
+ tRes.tested(propName, true);
+ }
+ else if (exception instanceof RuntimeException)
+ {
+ // the change of read only prohibited - OK
+ log.println("Property is ReadOnly and wasn't changed");
+ log.println("Property '" + propName + "' OK");
+ tRes.tested(propName, true);
+ }
+ else
+ {
+ throw exception;
+ }
+ }
+ else
+ {
+ // if no exception - check that value
+ // has not changed
+ if (!compare(resValue, oldValue))
+ {
+ log.println("Read only property '" + propName + "' has changed");
+ try
+ {
+ if (!util.utils.isVoid(oldValue) && oldValue instanceof Any)
+ {
+ oldValue = AnyConverter.toObject(new Type(((Any) oldValue).getClass()), oldValue);
+ }
+// log.println("old = " + toString(oldValue));
+// log.println("new = " + toString(newValue));
+ log.println("result = " + toString(resValue));
+ }
+ catch (com.sun.star.lang.IllegalArgumentException iae)
+ {
+ log.println("NOTIFY: this property needs further investigations.");
+ log.println("\t The type seems to be an Any with value of NULL.");
+ log.println("\t Maybe the property should get it's own test method.");
+ }
+
+ tRes.tested(propName, false);
+ }
+ else
+ {
+ log.println("Read only property '" + propName + "' hasn't changed");
+ log.println("Property '" + propName + "' OK");
+ tRes.tested(propName, true);
+ }
+ }
+ }
+ else
+ {
+ if (exception == null)
+ {
+ // if no exception thrown
+ // check that the new value is set
+ if ((!compare(resValue, newValue)) || (compare(resValue, oldValue)))
+ {
+ log.println("Value for '" + propName + "' hasn't changed as expected");
+ try
+ {
+ if (!util.utils.isVoid(oldValue) && oldValue instanceof Any)
+ {
+ oldValue = AnyConverter.toObject(new Type(((Any) oldValue).getClass()), oldValue);
+ }
+// log.println("old = " + toString(oldValue));
+// log.println("new = " + toString(newValue));
+ log.println("result = " + toString(resValue));
+ }
+ catch (com.sun.star.lang.IllegalArgumentException iae)
+ {
+ log.println("NOTIFY: this property needs further investigations.");
+ log.println("\t The type seems to be an Any with value of NULL.");
+ log.println("\t Maybe the property should get it's own test method.");
+ }
+ if (resValue != null)
+ {
+ if ((!compare(resValue, oldValue)) || (!resValue.equals(oldValue)))
+ {
+ log.println("But it has changed.");
+ tRes.tested(propName, true);
+ }
+ else
+ {
+ tRes.tested(propName, false);
+ }
+ }
+ else
+ {
+ tRes.tested(propName, false);
+ }
+ //tRes.tested(propName, false);
+ }
+ else
+ {
+ log.println("Property '" + propName + "' OK");
+ try
+ {
+ if (!util.utils.isVoid(oldValue) && oldValue instanceof Any)
+ {
+ oldValue = AnyConverter.toObject(new Type(((Any) oldValue).getClass()), oldValue);
+ }
+// log.println("old = " + toString(oldValue));
+// log.println("new = " + toString(newValue));
+ log.println("result = " + toString(resValue));
+ }
+ catch (com.sun.star.lang.IllegalArgumentException iae)
+ {
+ }
+ tRes.tested(propName, true);
+ }
+ }
+ else
+ {
+ throw exception;
+ }
+ }
+ }
+
+ /**
+ * The method produces new value of the property from the oldValue.
+ * It returns the result of ValueChanger.changePValue method.
+ * Subclasses can override the method to return their own value,
+ * when the changePValue beahviour is not enough, for example,
+ * when oldValue is null.
+ */
+ protected Object getNewValue(String propName, Object oldValue)
+ throws java.lang.IllegalArgumentException
+ {
+ return ValueChanger.changePValue(oldValue);
+ }
+
+ /**
+ * The method compares obj1 and obj2. It calls
+ * MultiPropertyTest.compare, but subclasses can override to change
+ * the behaviour, since normally compare calls Object.equals method
+ * which is not apropriate in some cases(e.g., structs with equals
+ * not overridden).
+ */
+ protected boolean compare(Object obj1, Object obj2)
+ {
+ return callCompare(obj1, obj2);
+ }
+
+ /**
+ * The method returns a String representation of the obj. It calls
+ * MultipropertyTest.toString(Object), but subclasses can override
+ * to change the behaviour.
+ */
+ protected String toString(Object obj)
+ {
+ return callToString(obj);
+ }
+ }
+
+ /**
+ * Extension for <code>PropertyTester</code> which switches two
+ * different values. <code>getNewValue()</code> method of this
+ * class returns one of these two values depending on the
+ * old value, so new value is not equal to old value.
+ */
+ public class PropertyValueSwitcher extends PropertyTester
+ {
+
+ Object val1 = null;
+ Object val2 = null;
+
+ /**
+ * Constructs a property tester with two different values
+ * specified as parameters.
+ *
+ * @param val1 Not <code>null</code> value for the property
+ * tested.
+ * @param val1 Not <code>null</code> value for the property
+ * tested which differs from the first value.
+ */
+ public PropertyValueSwitcher(Object val1, Object val2)
+ {
+ this.val1 = val1;
+ this.val2 = val2;
+ }
+
+ /**
+ * Overriden method of <code>PropertyTester</code> which
+ * retruns new value from two values specified.
+ *
+ * @return The second value if old value is equal to the first
+ * one, the first value otherwise.
+ */
+ protected Object getNewValue(String propName, Object old)
+ {
+ if (ValueComparer.equalValue(val1, old))
+ {
+ return val2;
+ }
+ else
+ {
+ return val1;
+ }
+ }
+ }
+
+ /**
+ * The method performs testing of propName property using propTester.
+ */
+ protected void testProperty(String propName, PropertyTester propTester)
+ {
+ propTester.testProperty(propName);
+ }
+
+ /**
+ * The method performs testing of propName property. It uses PropertyTester
+ * instance for testing.
+ */
+ protected void testProperty(String propName)
+ {
+ testProperty(propName, new PropertyTester());
+ }
+
+ /**
+ * Tests the property using <code>PropertyValueSwitcher</code>
+ * tester and two values for this property.
+ *
+ * @see #PropertyValueSwitcher
+ */
+ protected void testProperty(String propName, Object val1, Object val2)
+ {
+ testProperty(propName, new PropertyValueSwitcher(val1, val2));
+ }
+
+ /**
+ * The method just calls compare. This is a workaround to CodeWarrior's
+ * compiler bug.
+ */
+ private boolean callCompare(Object obj1, Object obj2)
+ {
+ return compare(obj1, obj2);
+ }
+
+ /**
+ * Compares two object. In the implementation calls obj1.equals(obj2).
+ */
+ protected boolean compare(Object obj1, Object obj2)
+ {
+ return ValueComparer.equalValue(obj1, obj2);
+ }
+
+ /**
+ * The method just calls toString. This is a workaround to
+ * CodeWarrior's compiler bug.
+ */
+ private String callToString(Object obj)
+ {
+ return toString(obj);
+ }
+
+ /**
+ * Gets string representation of the obj. In the implementation
+ * returns obj.toString().
+ */
+ protected String toString(Object obj)
+ {
+ return obj == null ? "null" : obj.toString();
+ }
+}
diff --git a/qadevOOo/runner/lib/Parameters.java b/qadevOOo/runner/lib/Parameters.java
new file mode 100644
index 000000000000..1c4a43c4fd3a
--- /dev/null
+++ b/qadevOOo/runner/lib/Parameters.java
@@ -0,0 +1,233 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package lib;
+
+import java.util.Iterator;
+import java.util.Hashtable;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import com.sun.star.beans.Property;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.beans.XPropertySetInfo;
+import com.sun.star.beans.XPropertyChangeListener;
+import com.sun.star.beans.XVetoableChangeListener;
+import com.sun.star.beans.UnknownPropertyException;
+import com.sun.star.lang.WrappedTargetException;
+import com.sun.star.uno.Type;
+
+/**
+ * Parameters is a container of String parameters.
+ * @deprecated
+ */
+
+public class Parameters implements XPropertySet {
+/* final protected Map parameters;
+ final Parameters defaults; */
+ final protected Map parameters;
+ final Parameters defaults;
+ Property[] props;
+
+ public Parameters(Map params) {
+ this (params, null);
+ }
+
+ public Parameters(Map params, Parameters defaultParams) {
+ parameters = params;
+ defaults = defaultParams;
+ checkParameters(parameters);
+
+ Set paramSet = new HashSet(parameters.keySet());
+
+ if (defaults != null) {
+ Set defSet = defaults.toMap().keySet();
+ paramSet.addAll(defSet);
+ }
+
+ props = new Property[paramSet.size()];
+
+ int num = 0;
+
+ for (Iterator i = paramSet.iterator(); i.hasNext(); num++) {
+ String name = (String)i.next();
+
+ props[num] = new Property(name, num, new Type(String.class), (short)0);
+ }
+ }
+
+
+ public String get(String paramName) {
+ Object res = parameters.get(paramName);
+
+ if (res != null && res instanceof String)
+ return (String)res;
+
+ if (defaults != null)
+ return defaults.get(paramName);
+
+ return null;
+ }
+
+ public Object getPropertyValue(String name) {
+ Object erg = parameters.get(name);
+ if (erg == null && defaults != null)
+ return defaults.getPropertyValue(name);
+ return erg;
+ }
+
+ public void setPropertyValue(String name, Object value) {
+ parameters.put(name, value);
+ int size = props.length;
+ Property[] addProps = new Property[size+1];
+ for (int i=0; i<size; i++)
+ {
+ addProps[i] = props[i];
+ }
+ addProps[size] = new Property(name, size, new Type(value.getClass()), (short)0);
+ props = addProps;
+ }
+
+ public void addVetoableChangeListener(String name, XVetoableChangeListener l) {
+ }
+
+ public void removeVetoableChangeListener(String name, XVetoableChangeListener l) {
+ }
+
+ public void addPropertyChangeListener(String name, XPropertyChangeListener l) {
+ }
+
+ public void removePropertyChangeListener(String name, XPropertyChangeListener l) {
+ }
+
+ public XPropertySetInfo getPropertySetInfo() {
+ return new XPropertySetInfo() {
+ public Property[] getProperties() {
+ return props;
+ }
+
+ public boolean hasPropertyByName(String name) {
+ for (int i = 0; i < props.length; i++) {
+ Property prop = props[i];
+
+ if (prop.Name.equals(name)) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ public Property getPropertyByName(String name) throws UnknownPropertyException {
+ for (int i = 0; i < props.length; i++) {
+ Property prop = props[i];
+
+ if (prop.Name.equals(name)) {
+ return prop;
+ }
+ }
+
+ throw new UnknownPropertyException(name);
+ }
+ };
+ }
+
+ public Map toMap() {
+ return new Hashtable(parameters) {
+ public Object get(Object obj) {
+ if (obj instanceof String) {
+ return Parameters.this.get((String) obj);
+ } else {
+ return null;
+ }
+ }
+ };
+ }
+
+ private static void checkParameters(Map params) {
+ for (Iterator i = params.keySet().iterator(); i.hasNext();) {
+ Object key = i.next();
+
+ if (!(key instanceof String)) {
+ throw new IllegalArgumentException(
+ "Wrong key " + key + ", it should be of String type");
+ }
+
+/* Object value = params.get(key);
+
+ if (!(value instanceof String)) {
+ throw new IllegalArgumentException(
+ "Wrong value " + value + ", it should be of String type");
+ } */
+ }
+ }
+
+ public static String getString(XPropertySet props, String name) {
+ try {
+ return (String)props.getPropertyValue(name);
+ } catch (UnknownPropertyException e) {
+ return null;
+ } catch (WrappedTargetException e) {
+ return null;
+ }
+ }
+
+ public static Object get(XPropertySet props, String name) {
+ try {
+ return props.getPropertyValue(name);
+ } catch (UnknownPropertyException e) {
+ return null;
+ } catch (WrappedTargetException e) {
+ return null;
+ }
+ }
+
+ public static Map toMap(XPropertySet props) {
+ Hashtable result = new Hashtable(10);
+
+ XPropertySetInfo setInfo = props.getPropertySetInfo();
+ Property[] properties = setInfo.getProperties();
+
+ for (int i = 0; i < properties.length; i++) {
+ String name = properties[i].Name;
+ Object value;
+
+ try {
+ value = props.getPropertyValue(name);
+ } catch (WrappedTargetException e) {
+ continue;
+ } catch (UnknownPropertyException e) {
+ continue;
+ }
+
+ result.put(name, value);
+ }
+
+ return result;
+ }
+}
diff --git a/qadevOOo/runner/lib/SimpleStatus.java b/qadevOOo/runner/lib/SimpleStatus.java
new file mode 100644
index 000000000000..2c2304b5088e
--- /dev/null
+++ b/qadevOOo/runner/lib/SimpleStatus.java
@@ -0,0 +1,149 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package lib;
+
+/**
+ * The class is a simple implementation of Status class. It implements simple
+ * Status behaviour: its state, reason and log are defined when creating
+ * the SimpleSTatus instance.
+ */
+class SimpleStatus {
+ /* Run states. */
+
+ /**
+ * The constatnt represents PASSED runtime state.
+ */
+ public final static int PASSED = 0;
+
+ /**
+ * The constant represents EXCEPTION runtime state.
+ */
+ public final static int EXCEPTION = 3;
+
+ /**
+ * The constant represents EXCLUDED runtime state.
+ */
+ public final static int EXCLUDED = 2;
+
+ /**
+ * The constant represents SKIPPED runtime state.
+ */
+ public final static int SKIPPED = 1;
+
+ /**
+ * This is a private indicator for a user defined runtime state
+ */
+ private final static int USER_DEFINED = 4;
+
+ /* Test states */
+
+ /**
+ * The constant represents FAILED state.
+ */
+ public final static boolean FAILED = false;
+
+ /**
+ * The constant represents OK state.
+ */
+ public final static boolean OK = true;
+
+ /**
+ * The field is holding state of the status.
+ */
+ protected final boolean state;
+
+ /**
+ * The field is holding reason of the status.
+ */
+ protected final int runState;
+
+ /**
+ * This is the run state: either SKIPPED, PASSED, etc.
+ * or user defined. Deriving classes can overwrite it for own run states.
+ */
+ protected String runStateString;
+
+ /**
+ * The constructor initialize state and reason field.
+ */
+ protected SimpleStatus( int runState, boolean state ) {
+ this.state = state;
+ this.runState = runState;
+ if ( runState == PASSED ) {
+ runStateString = "PASSED";
+ } else if ( runState == EXCLUDED ) {
+ runStateString = "EXCLUDED";
+ } else if ( runState == SKIPPED ) {
+ runStateString = "SKIPPED";
+ } else if ( runState == EXCEPTION ) {
+ runStateString = "EXCEPTION";
+ } else {
+ runStateString = "UNKNOWN";
+ }
+ }
+
+ /**
+ * The constructor initialize state and reson field.
+ */
+ protected SimpleStatus(String runStateString, boolean state) {
+ this.state = state;
+ this.runState = USER_DEFINED;
+ this.runStateString = runStateString;
+ }
+
+ /**
+ * getState implementation. Just returns the state field value.
+ */
+ public boolean getState() {
+ return state;
+ }
+
+ /**
+ * getRunState() implementation. Just returns th runState field value.
+ */
+ public int getRunState() {
+ return runState;
+ }
+
+ /**
+ * getReason implementation. Just returns the reason field value.
+ */
+ public String getRunStateString() {
+ return runStateString;
+ }
+
+ /**
+ * Get the ressult: passed or failed.
+ */
+ public String getStateString() {
+ if (state)
+ return "OK";
+ return "FAILED";
+
+ }
+} \ No newline at end of file
diff --git a/qadevOOo/runner/lib/Status.java b/qadevOOo/runner/lib/Status.java
new file mode 100644
index 000000000000..7cd65c380425
--- /dev/null
+++ b/qadevOOo/runner/lib/Status.java
@@ -0,0 +1,173 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package lib;
+
+/**
+ * Status represents a result of a testing activity performed. The result is
+ * described in two ways: state and runtime state. The state describes if the
+ * activity was successful (OK state) or not (FAILED state). The runtime state
+ * describes what happend during the activity: the test can be:
+ * - PASSED - the activity completed normally (although it can complete with
+ * FAILED state)
+ * - SKIPPED - the activity was not performed because of a reason (it also can
+ * has OK or FAILED state)
+ * - EXCEPTION - the activity was abnormally terminated because of an
+ * unexpected exception. It always has a FAILED state.
+ * - EXCLUDED - the activity is expected to fail. The state represents how
+ * the state really completed: OK or FAILED.
+ * - other variants are not formalized now and can be represented by
+ * Status.failed() method. They always have a FAILED state.
+ */
+public class Status extends SimpleStatus {
+
+ /**
+ * Construct a status: use runState and state
+ * @param runState: either PASSED, SKIPPED, etc.
+ * @param state: OK or FAILED.
+ */
+ public Status(int runState, boolean state ) {
+ super(runState, state);
+ }
+
+ /**
+ * Construct a status: use own message and state.
+ * @parame messaeg An own message for the status.
+ * @param state: OK or FAILED.
+ */
+ public Status(String message, boolean state) {
+ super( message, state );
+ }
+
+ /**
+ * This is a factory method for creating a Status representing normal
+ * actibity termination.
+ *
+ * @param state describes a test state (OK if state == true, FAILED
+ * otherwise).
+ */
+ public static Status passed( boolean state ) {
+ return new Status(PASSED, state );
+ }
+
+ /**
+ * This is a factory method for creating a Status representing an exception
+ * activity termination. The Status alway has FAILED state.
+ *
+ * @param t the exception with that the activity completed.
+ */
+ public static Status exception( Throwable t ) {
+ return new ExceptionStatus( t );
+ }
+
+ /**
+ * This is a factory method for creating a Status representing a skipped
+ * activity.
+ *
+ * @param state describes a test state (OK if state == true, FAILED
+ * otherwise).
+ */
+ public static Status skipped( boolean state ) {
+ return new Status( SKIPPED, state );
+ }
+
+ /**
+ * This is a factory method for creating a Status representing that the
+ * result of the activity was excluded. It alwas has FAILED state.
+ */
+ public static Status excluded() {
+ return new Status( EXCLUDED, false );
+ }
+
+ /**
+ * Creates a Status representing an activity failed for an arbitrary reason.
+ * It always has FAILED state.
+ *
+ * @param reason describes why the activity failed
+ */
+ public static Status failed(final String reason) {
+ return new Status(reason, FAILED);
+ }
+
+ /**
+ * The method returns a human-readable description of the status.
+ * The Status implementation of the method returns the status state
+ * description and appends to it it the reason, for example:
+ * "FAILED.The getLabel works wrong", "PASSED.OK".
+ */
+ public String toString() {
+ String str = getRunStateString() + "." + getStateString();;
+
+ return str;
+ }
+
+ /**
+ * Checks whether the status runstate is passed.
+ */
+ public boolean isPassed() {
+ return getRunState() == PASSED;
+ }
+
+ /**
+ * Checks whether the status runstate is skipped.
+ */
+ public boolean isSkipped() {
+ return getRunState() == SKIPPED;
+ }
+
+ /**
+ * Checks whether the status runstate is excluded.
+ */
+ public boolean isExcluded() {
+ return getRunState() == EXCLUDED;
+ }
+
+ /**
+ * Checks whether the status runstate is exception.
+ */
+ public boolean isException() {
+ return getRunState() == EXCEPTION;
+ }
+
+ /**
+ * Checks whether the status state is failed.
+ */
+ public boolean isFailed() {
+ return !getState();
+ }
+
+ /**
+ * Checks whether the status state is ok.
+ */
+ public boolean isOK() {
+ return getState();
+ }
+
+ public String getDescription () {
+ return getRunStateString();
+ }
+}
diff --git a/qadevOOo/runner/lib/StatusException.java b/qadevOOo/runner/lib/StatusException.java
new file mode 100644
index 000000000000..4768a9229c8f
--- /dev/null
+++ b/qadevOOo/runner/lib/StatusException.java
@@ -0,0 +1,81 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package lib;
+
+/**
+ * StatusException is used to pass a Status object from a test code which is
+ * terminated abnormaly. In many cases this is because of an exception thrown,
+ * but that can also be any other event that hinders the test execution.
+ */
+public class StatusException extends RuntimeException {
+ /**
+ * Contains an exception if the StatusException was created with
+ * StatusException(String, Throwable) constructor.
+ */
+ protected Throwable exceptionThrown;
+
+ /**
+ * The Status contained in the StatusException.
+ */
+ protected Status status;
+
+ /**
+ * Constructs a StatusException containing an exception Status.
+ *
+ * @param message the message of the StatusException
+ * @param t the exception of the exception Status
+ */
+ public StatusException( String message, Throwable t ) {
+ super( message );
+ exceptionThrown = t;
+ status = Status.exception( t );
+ }
+
+ /**
+ * Creates a StatusException containing a Status.
+ */
+ public StatusException( Status st ) {
+ super( st.getRunStateString() );
+ status = st;
+ }
+
+ /**
+ * @return an exception, if this represents an exception Status,
+ * <tt>false</tt> otherwise.
+ */
+ public Throwable getThrownException() {
+ return exceptionThrown;
+ }
+
+ /**
+ * @return a status contained in the StatusException.
+ */
+ public Status getStatus() {
+ return status;
+ }
+} \ No newline at end of file
diff --git a/qadevOOo/runner/lib/TestCase.java b/qadevOOo/runner/lib/TestCase.java
new file mode 100644
index 000000000000..6b8b960c3014
--- /dev/null
+++ b/qadevOOo/runner/lib/TestCase.java
@@ -0,0 +1,182 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package lib;
+
+import java.io.PrintWriter;
+
+import lib.TestParameters;
+/**
+ * <code>TestCase</code> represent a factory for <code>TestEnvironment</code>s
+ * creation and disposing for a given implementation object. The
+ * <code>TestEnvironment</code> contains an instance of the implementation
+ * object and all additional objects needed to perform tests on the object.
+ *
+ * <p>The <code>TestCase</code> provides four methods for its subclasses to
+ * define its functionality: <code>initialize()</code>, <code>cleanup()</code>,
+ * <code>createTestEnvironment()</code> and <code>disposeTestEnvironment()</code>.
+ * The first two are intended to initialize and cleanup common objects shared
+ * among all instances of <code>TestEnvironment</code> produced by the
+ * <code>TestCase</code>, and they are called at the beginning and at the end of
+ * the <code>TestCase</code> lifecycle accordingly.
+ *
+ * <p>The other two are intended to produce and dispose
+ * <code>TestEnvironment</code> instances. The
+ * <code>createTestEnvironment()</code> is called to create a
+ * <code>TestEnvironment</code> instance and the
+ * <code>disposeTestEnvironment()</code> is called when the instane is not used
+ * anymore.
+ *
+ * @see lib.TestEnvironment
+ */
+public abstract class TestCase {
+
+ /**
+ * Specifies the PrintWriter to log information.
+ */
+ public PrintWriter log;
+
+ //public static TestCase tCase;
+
+ /**
+ * Sets the log to write information during testing.
+ */
+ public void setLogWriter( PrintWriter log ) {
+ this.log = log;
+ }
+
+ /**
+ * Initializes the <code>TestCase</code>. Calls <code>initialize()</code>
+ * method.
+ *
+ * @param tParam test parameters.
+ */
+ public void initializeTestCase( TestParameters tParam ) {
+ initialize( tParam, log );
+ }
+
+ /**
+ * Called while the <code>TestCase</code> initialization. In the
+ * implementation does nothing. Subclasses can override to initialize
+ * objects shared among all <code>TestEnvironment</code>s.
+ *
+ * @param tParam test parameters
+ * @param log writer to log information while testing
+ *
+ * @see #initializeTestCase()
+ */
+ protected void initialize( TestParameters tParam, PrintWriter log ) {
+ }
+
+
+ /**
+ * Cleans up the <code>TestCase</code>. Calls <code>cleanup()</code>.
+ *
+ * @param tParam test parameters
+ */
+ public void cleanupTestCase( TestParameters tParam ) {
+ cleanup( tParam, log );
+ }
+
+ /**
+ * Called while the <code>TestCase</code> cleanup. In the implementation
+ * does nothing. Subclasses can override to cleanup objects shared among
+ * all <code>TestEnvironment</code>s.
+ *
+ * @param tParam test parameters
+ * @param log writer to log information while testing
+ *
+ * @see #cleanupTestCase
+ */
+ protected void cleanup( TestParameters tParam, PrintWriter log ) {
+ }
+
+ /**
+ * Creates a <code>TestEnvironment</code> containing an instance of the
+ * implementation object and related objects needed to perform test.
+ *
+ * @param tParam test parameters
+ *
+ * @return the created <code>TestEnvironment</code>
+ *
+ * @see #createTestEnvironment()
+ * @see lib.TestEnvironment
+ */
+ public synchronized TestEnvironment getTestEnvironment( TestParameters tParam ) {
+ TestEnvironment tEnv = null;
+ try {
+ tEnv = createTestEnvironment( tParam, log );
+ System.out.println("Environment created");
+ if (tEnv != null) {
+ tEnv.setTestCase(this);
+ }
+ } catch (Exception e) {
+ String message = e.getMessage();
+ if (message == null)
+ message = e.toString();
+ System.out.println("Exception while getting Environment "+message);
+ e.printStackTrace();
+ cleanup(tParam, log);
+ }
+ return tEnv;
+ }
+
+ /**
+ * Disposes the <code>TestEnvironment</code> when it is not needed anymore.
+ *
+ * @param tEnv the environment to dispose
+ * @param tParam test parameters
+ */
+ public synchronized void disposeTestEnvironment( TestEnvironment tEnv,
+ TestParameters tParam ) {
+ cleanup( tParam, log );
+ }
+
+ /**
+ * Called to create an instance of <code>TestEnvironment</code> with an
+ * object to test and related objects. Subclasses should implement this
+ * method to provide the implementation and related objects. The method is
+ * called from <code>getTestEnvironment()</code>.
+ *
+ * @param tParam test parameters
+ * @param log writer to log information while testing
+ *
+ * @see TestEnvironment
+ * @see #getTestEnvironment()
+ */
+ protected abstract TestEnvironment createTestEnvironment(
+ TestParameters tParam, PrintWriter log );
+
+ /**
+ * @return the name of the object
+ */
+ public String getObjectName() {
+ String clName = this.getClass().getName();
+ return clName.substring( clName.lastIndexOf('.') + 1 );
+ }
+
+}
diff --git a/qadevOOo/runner/lib/TestEnvironment.java b/qadevOOo/runner/lib/TestEnvironment.java
new file mode 100644
index 000000000000..9848a5b2b633
--- /dev/null
+++ b/qadevOOo/runner/lib/TestEnvironment.java
@@ -0,0 +1,153 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package lib;
+import com.sun.star.uno.XInterface;
+
+import java.util.Hashtable;
+
+
+/**
+ * The class contains an instance of a given implementation object and
+ * auxiliary objects associated with it and required for the object testing.
+ *
+ * @see TestCase
+ */
+
+public final class TestEnvironment {
+ /**
+ * Contains object relations - auxiliary objects associated with the
+ * tested object and required for testing.
+ */
+ private final Hashtable relations = new Hashtable(10);
+
+ /**
+ * An instance of the tested implementation object.
+ */
+ private final XInterface testObject;
+
+ /**
+ * Indicates that the testObject is in invalid state and should notbe
+ * used for testing anymore.
+ */
+ private boolean disposed = false;
+
+ /**
+ * A reference to TestCase which has created the test environment.
+ */
+ private TestCase tCase;
+
+ /**
+ * Creates an instance of test environment with testObject.
+ *
+ * @param testObject object to test
+ *
+ * @throws java.lang.IllegalArgumentException if the testObject is
+ * <tt>null</tt>.
+ */
+ public TestEnvironment( XInterface testObject ) {
+ if (testObject == null) {
+ throw new IllegalArgumentException(
+ "Couldn't create a test object");
+ }
+ this.testObject = testObject;
+ }
+
+ /**
+ * @return the object to test.
+ */
+ public XInterface getTestObject() {
+ return testObject;
+ }
+
+ /**
+ * Adds to the environment an auxiliary object required for testing.
+ *
+ * @param name a name to reference the auxiliary object
+ *
+ * @param relation the auxiliary object related to the tested one
+ */
+ public void addObjRelation( String name, Object relation) {
+ relations.put( name, relation );
+ }
+
+ /**
+ * Returns an auxiliary object referenced by tname.
+ *
+ * @param name a name of the object relation
+ *
+ * @return the auxiliary object(object relation)
+ */
+ public Object getObjRelation( String name ) {
+ return relations.get( name );
+ }
+
+ /**
+ * Checks if an auxiliary object has been registered with name
+ *
+ * @param name a name referencing an auxiliarx object
+ *
+ * @return <tt>true</tt> if the object has been associated, <tt>false</tt>
+ * otherwise.
+ */
+ public boolean hasObjRelation(String name) {
+ return (relations.get(name) != null) ;
+ }
+
+ /**
+ * Sets the <code>TestCase</code> that created the environment.
+ */
+ public void setTestCase( TestCase tCase) {
+ this.tCase = tCase;
+ }
+
+ /**
+ * @return the <code>TestCase</code> created the environment.
+ */
+ public TestCase getTestCase() {
+ return tCase;
+ }
+
+ /**
+ * Makes the environment invalid, i.e. it should not be used for
+ * testing anymore.
+ */
+ public void dispose() {
+ disposed = true;
+ }
+
+ /**
+ * Checks if the environment has been disposed.
+ *
+ * @return <tt>true</tt< if it has been disposed, <tt>false</tt> otherwise.
+ *
+ * @see #dispose()
+ */
+ public boolean isDisposed() {
+ return disposed;
+ }
+} \ No newline at end of file
diff --git a/qadevOOo/runner/lib/TestParameters.java b/qadevOOo/runner/lib/TestParameters.java
new file mode 100644
index 000000000000..9d1e171b95d9
--- /dev/null
+++ b/qadevOOo/runner/lib/TestParameters.java
@@ -0,0 +1,343 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package lib;
+
+import java.util.Hashtable;
+import util.PropertyName;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.uno.XComponentContext;
+
+//import com.sun.star.lang.XMultiServiceFactory;
+
+/**
+ * TestParameters describes a parameters (in a form of pairs: name, value) to
+ * be passed to tests and which may affect the test behaviour. That can be,
+ * for example, standard paths, connection strings, etc. The TestParameters
+ * also provides XMultiServiceFactory for the test (tests).
+ */
+public class TestParameters extends Hashtable {
+
+ /**
+ * The ConnectionString for Office Connection<br>
+ * default is 'socket,host=localhost,port=8100'
+ */
+
+ public String ConnectionString="socket,host=localhost,port=8100";
+
+ /**
+ * The AppProvider contains the Application Provider<br>
+ * to control the ServiceFactory.
+ */
+
+ public Object AppProvider=null;
+
+ /**
+ * The Process contains the Process handler<br>
+ * to control the Application.
+ */
+
+ public Object ProcessHandler=null;
+
+ /**
+ * The AppExecutionCmd contains the full qualified<br>
+ * command to an Application to be started.
+ */
+
+ public String AppExecutionCommand="";
+
+ /**
+ * If this parameter is <CODE>true</CODE> the <CODE>OfficeProvider</CODE> tries
+ * to get the URL to the binary of the office and to fill the
+ * <CODE>AppExecutionCommand</CODE> with usefull content if needet
+ */
+ public boolean AutoRestart = false;
+
+ /**
+ * Shoert wait time for the Office: default is 500 milliseconds
+ */
+ public int ShortWait = 500;
+
+
+ /**
+ * The OfficeProvider contains the full qualified
+ * class that provides a connection to StarOffice<br>
+ * default is helper.OfficeProvider
+ */
+
+ public String OfficeProvider = "helper.OfficeProvider";
+
+ /**
+ * The Testbase to be executed by the runner<br>
+ * default is 'java_fat'
+ */
+
+ public String TestBase="java_fat";
+
+ /**
+ * The ServiceFactory to create instances
+ */
+
+ public Object ServiceFactory;
+
+ /**
+ * The Path to the component description
+ */
+
+ public String DescriptionPath;
+
+ /**
+ * The Path to the test documents that are loaded during the test <br>
+ */
+
+ public String TestDocumentPath="unknown";
+
+ /**
+ * 'true' is a log should be written, 'false' elsewhere <br>
+ * these will be provided by the testcases<br>
+ * default is true
+ */
+
+ public boolean LoggingIsActive=true;
+
+ /**
+ * 'true' is a debug information should be written, 'false' elsewhere
+ * these will be provided by the framework.<br>
+ * Debug information will always be written on standard out.<br>
+ * default is true
+ */
+
+ public boolean DebugIsActive=false;
+
+ /*
+ * This parameter contains the testjob to be executed<br>
+ * by the framework
+ */
+
+ public Object TestJob;
+
+ /*
+ * This parameter contains the class used<br>
+ * for Logging
+ */
+
+ public String LogWriter="stats.SimpleLogWriter";
+
+ /*
+ * This parameter contains the class used<br>
+ * for Logging
+ */
+
+ public String OutProducer="stats.SimpleOutProducer";
+
+ /*
+ * This parameter contains the timeout used<br>
+ * by the watcher
+ */
+ public Integer TimeOut = new Integer(3000000);
+
+ /*
+ * This parameter contains the timeout used<br>
+ * by the complex tests
+ */
+ public Integer ThreadTimeOut = new Integer(3000000);
+
+ /*
+ * This parameter contains the time which the office could use to close for
+ * itself before its destroyed. Default is 15000 ms
+ */
+ public Integer OfficeCloseTimeOut = new Integer(15000);
+
+ /**
+ * Wraper around "get()" with some debug output
+ * @param key A key of this table.
+ * @return The value of this key.
+ * @see java.util.Hashtable
+ */
+ public Object get(Object key) {
+ Object val = super.get(key);
+ if (val == null && DebugIsActive) {
+ System.out.print("Have been asked for key \""+key.toString());
+ System.out.println("\" which is not part of params.");
+ }
+ return val;
+ }
+
+ /**
+ * Special get method for boolean values: for convenience.
+ * Will return 'false' if the value is not of "Boolean" type.
+ * @param key A key of this table.
+ * @return The value of this key, castet to a boolean type.
+ */
+ public boolean getBool(Object key) {
+ Object val = super.get(key);
+ if (val != null) {
+ if (val instanceof String) {
+ String sVal = (String)val;
+ if (sVal.equalsIgnoreCase("true") ||
+ sVal.equalsIgnoreCase("yes")) {
+ return true;
+ }
+ else if (sVal.equalsIgnoreCase("false") ||
+ sVal.equalsIgnoreCase("no")) {
+ return false;
+ }
+ }
+ if (val instanceof Boolean)
+ return ((Boolean)val).booleanValue();
+ }
+ return false;
+ }
+
+ /**
+ * Special get method for integer values: for convenience.
+ * Will return 0 if the value cannot be interpreted as Integer.
+ * @param key A key of this table.
+ * @return The value of this key, castet to an int type.
+ */
+ public int getInt(Object key) {
+ Object val = super.get(key);
+ if ( val != null ) {
+ if (val instanceof Integer) {
+ return ((Integer)val).intValue();
+ }
+ else {
+ try {
+ if ( val instanceof String ) {
+ Integer nr = new Integer((String)val);
+ if (nr.intValue() > 0) return nr.intValue();
+ }
+ } catch ( java.lang.NumberFormatException nfe) {}
+ }
+ }
+ return 0;
+ }
+
+
+ /**
+ * Wraper around "put()"
+ * @param key A key of this table.
+ * @param val The value of the key.
+ * @return The value of this key.
+ * @see java.util.Hashtable
+ */
+ public Object put(Object key, Object val) {
+ return super.put(key,val);
+ }
+
+ /**
+ * Constructor, defaults for Parameters are set.
+ */
+ public TestParameters() {
+ //fill the propertyset
+ String user = System.getProperty("user.name");
+ if ( user != null)
+ {
+ String PipeConnectionString = "pipe,name=" + user;
+ put(PropertyName.PIPE_CONNECTION_STRING,PipeConnectionString);
+ put(PropertyName.USE_PIPE_CONNECTION, Boolean.TRUE);
+ }
+ put(PropertyName.CONNECTION_STRING,ConnectionString);
+ put(PropertyName.TEST_BASE,TestBase);
+ put(PropertyName.TEST_DOCUMENT_PATH,TestDocumentPath);
+ put(PropertyName.LOGGING_IS_ACTIVE,LoggingIsActive?Boolean.TRUE:Boolean.FALSE);
+ put(PropertyName.DEBUG_IS_ACTIVE,DebugIsActive?Boolean.TRUE:Boolean.FALSE);
+ put(PropertyName.OUT_PRODUCER,OutProducer);
+ put(PropertyName.SHORT_WAIT,new Integer(ShortWait));
+ put(PropertyName.OFFICE_PROVIDER,OfficeProvider);
+ put(PropertyName.LOG_WRITER,LogWriter);
+ put(PropertyName.APP_EXECUTION_COMMAND,AppExecutionCommand);
+ put(PropertyName.TIME_OUT,TimeOut);
+ put(PropertyName.THREAD_TIME_OUT,ThreadTimeOut);
+ put(PropertyName.AUTO_RESTART,AutoRestart?Boolean.TRUE:Boolean.FALSE);
+ put(PropertyName.OFFICE_CLOSE_TIME_OUT, OfficeCloseTimeOut);
+
+ // get the operating system
+ put(PropertyName.OPERATING_SYSTEM, getSOCompatibleOSName());
+
+ //For compatibility Reasons
+ put("CNCSTR",ConnectionString);
+ put("DOCPTH",TestDocumentPath);
+ System.setProperty("DOCPTH",TestDocumentPath);
+ }
+
+ /**
+ * @return a XMultiServiceFactory to be used by a test (tests).
+ */
+ public Object getMSF() {
+ Object ret = null;
+ ret = get("ServiceFactory");
+ return ret;
+ }
+
+ public XComponentContext getComponentContext() {
+ Object context = get( "ComponentContext" );
+ if ( context == null )
+ {
+ XPropertySet factoryProps = (XPropertySet)com.sun.star.uno.UnoRuntime.queryInterface(
+ XPropertySet.class, getMSF() );
+ try
+ {
+ context = com.sun.star.uno.UnoRuntime.queryInterface(
+ XComponentContext.class, factoryProps.getPropertyValue( "DefaultContext" ) );
+ put( "ComponentContext", context );
+ }
+ catch( com.sun.star.beans.UnknownPropertyException e ) { }
+ catch( com.sun.star.lang.WrappedTargetException e ) { }
+ }
+ return (XComponentContext)context;
+ }
+
+ /**
+ * Convert the system dependent operating system name to a name according
+ * to OOo rules.
+ * @return A valid OS name, or "" if the name is not known.
+ */
+ String getSOCompatibleOSName() {
+ String osname = System.getProperty ("os.name").toLowerCase ();
+ String osarch = System.getProperty ("os.arch");
+ String operatingSystem = "";
+ if (osname.indexOf ("windows")>-1) {
+ operatingSystem = PropertyName.WNTMSCI;
+ } else if (osname.indexOf ("linux")>-1) {
+ operatingSystem = PropertyName.UNXLNGI;
+ } else if (osname.indexOf ("sunos")>-1) {
+ if (osarch.equals ("x86")) {
+ operatingSystem = PropertyName.UNXSOLI;
+ } else {
+ operatingSystem = PropertyName.UNXSOLS;
+ }
+ } else if (osname.indexOf ("mac")>-1) {
+ operatingSystem = PropertyName.UNXMACXI;
+ } else {
+ System.out.println("ERROR: not supported platform: " + osname);
+ System.exit(1);
+ }
+ return operatingSystem;
+ }
+
+}// finish class TestParamenters
diff --git a/qadevOOo/runner/lib/TestResult.java b/qadevOOo/runner/lib/TestResult.java
new file mode 100644
index 000000000000..b0c70954a6cc
--- /dev/null
+++ b/qadevOOo/runner/lib/TestResult.java
@@ -0,0 +1,106 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package lib;
+
+import java.util.Hashtable;
+
+/**
+ * The class supports interface tests development and Status calculation.
+ */
+public class TestResult {
+ /**
+ * Contains methods having been tested and their results.
+ */
+ protected Hashtable testedMethods = new Hashtable();
+
+ /**
+ * The method makes method tested with the result, i.e. it adds to its
+ * state OK (if result == true) or FAILED (if result == false) status
+ * and makes the state of the method completed. It's equal to
+ * tested(method, Status(result)) call.
+ *
+ * @param method reffers to the method whoch was tested
+ * @param result the result of testing the method
+ *
+ * @return the result value
+ *
+ * @throw java.lang.IllegalArgumentException if the method is not
+ * available in the interface.
+ *
+ * @see #tested(String, Status)
+ */
+ public boolean tested( String method, boolean result) {
+ System.out.println("Method "+method+" finished with state "+(result?"OK":"FAILED"));
+ return tested( method, Status.passed( result ) );
+ }
+
+ /**
+ * The method makes the method tested with the status, i.e. it adds the
+ * status to its state and makes it completed.
+ *
+ * @param method reffers to the method whoch was tested
+ * @param status describes the result of testing the method
+ * @return <tt>true</tt> if status is OK, <tt>false</tt> otherwise.
+ *
+ * @throw java.lang.IllegalArgumentException if the method is not
+ * available in the interface.
+ */
+ public boolean tested( String method, Status status ) {
+ testedMethods.put(method,status);
+ return true;
+ }
+
+ /**
+ * @return methods available in the interface tested.
+ */
+ public String[] getTestedMethods() {
+ return (String[])testedMethods.keySet().toArray(
+ new String[testedMethods.size()]);
+ }
+
+ /**
+ * @return <tt>true</tt> if the method belongs to the interface tested,
+ * <tt>false</tt> otherwise.
+ */
+ public boolean hasMethod( String method ) {
+ return testedMethods.containsKey( method );
+ }
+
+ /**
+ * @return status of testing the method, if it is available (was set by
+ * the tested or assert method), <tt>null</tt> otherwise.
+ *
+ * @see #tested(String, boolean)
+ * @see #tested(String, Status)
+ * @see #assert
+ */
+ public Status getStatusFor( String method ) {
+ return (Status)testedMethods.get( method );
+ }
+
+} \ No newline at end of file
diff --git a/qadevOOo/runner/lib/makefile.mk b/qadevOOo/runner/lib/makefile.mk
new file mode 100644
index 000000000000..4807416e1939
--- /dev/null
+++ b/qadevOOo/runner/lib/makefile.mk
@@ -0,0 +1,58 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..
+
+PRJNAME = OOoRunner
+PACKAGE = lib
+TARGET = runner_lib
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+# --- Files --------------------------------------------------------
+
+JARFILES = ridl.jar jurt.jar unoil.jar
+
+JAVAFILES = DynamicClassLoader.java \
+ SimpleStatus.java \
+ TestEnvironment.java \
+ ExceptionStatus.java \
+ Status.java \
+ MultiMethodTest.java \
+ StatusException.java \
+ TestParameters.java \
+ TestResult.java \
+ MultiPropertyTest.java \
+ TestCase.java
+
+JAVACLASSFILES= $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class)
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
diff --git a/qadevOOo/runner/makefile.mk b/qadevOOo/runner/makefile.mk
new file mode 100644
index 000000000000..c18d77f25b0e
--- /dev/null
+++ b/qadevOOo/runner/makefile.mk
@@ -0,0 +1,60 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+PRJ = ..
+PRJNAME = OOoRunner
+TARGET = $(PRJNAME)
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE: settings.mk
+
+SUBDIRS_TESTS = mod ifc complex
+SUBDIRS_RUNNER = util share stats lib complexlib helper basicrunner \
+ base org$/openoffice convwatch graphical
+
+JARCOMMANDS_TESTS = $(foreach,i,$(SUBDIRS_TESTS) -C $(CLASSDIR) $i)
+JARCOMMANDS_RUNNER = $(foreach,i,$(SUBDIRS_RUNNER) -C $(CLASSDIR) $i)
+
+# --- Targets ------------------------------------------------------
+.IF "$(SOLAR_JAVA)"=="TRUE" && "$(L10N_framework)"==""
+OWNJAR: ALLTAR
+
+
+.INCLUDE : target.mk
+
+# LLA: parameter v is only verbose, need too long!
+OWNJAR: LIGHT
+ jar cfm $(CLASSDIR)$/$(TARGET).jar manifest -C $(PRJ) objdsc $(JARCOMMANDS_TESTS) $(JARCOMMANDS_RUNNER)
+
+# LLA: parameter v is only verbose, need too long!
+LIGHT:
+ jar cfm $(CLASSDIR)$/$(TARGET)Light.jar manifest $(JARCOMMANDS_RUNNER)
+
+.ELSE
+all:
+ @echo "no java"
+.ENDIF
diff --git a/qadevOOo/runner/manifest b/qadevOOo/runner/manifest
new file mode 100644
index 000000000000..7b905b7b5a28
--- /dev/null
+++ b/qadevOOo/runner/manifest
@@ -0,0 +1,3 @@
+Class-Path: ridl.jar unoil.jar
+RegistrationClassName: org.openoffice.RunnerService
+
diff --git a/qadevOOo/runner/org/openoffice/Runner.java b/qadevOOo/runner/org/openoffice/Runner.java
new file mode 100644
index 000000000000..a3741774917e
--- /dev/null
+++ b/qadevOOo/runner/org/openoffice/Runner.java
@@ -0,0 +1,261 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package org.openoffice;
+
+import java.util.Enumeration;
+import java.util.Properties;
+import java.util.StringTokenizer;
+import lib.TestParameters;
+import util.DynamicClassLoader;
+import base.TestBase;
+import helper.ClParser;
+import helper.CfgParser;
+
+/**
+ * The main class, will call ClParser and CfgParser to <br>
+ * fill the TestParameters.<br>
+ * Will then call the appropriate Testbase to run the tests.
+ */
+public class Runner
+{
+
+ private static long m_nStartTime;
+
+ public static long getRunnerStartTime()
+ {
+ return m_nStartTime;
+ }
+ /*
+ simple helper functions to start/stop a timer, to know how long a process need in milliseconds
+ */
+
+ private static long getTime()
+ {
+ return System.currentTimeMillis();
+ }
+
+ private static void setStartTime(long _nStartTime)
+ {
+ m_nStartTime = _nStartTime;
+ }
+
+ /*
+ return the time, which is done until last startTime()
+ */
+ public static long meanTime(long _nCurrentTimer)
+ {
+ if (_nCurrentTimer == 0)
+ {
+ System.out.println("Forgotten to initialise a start timer?");
+ return 0;
+ }
+ long nMeanTime = getTime();
+ return nMeanTime - _nCurrentTimer;
+ }
+
+ private static String beautifyTime(long _nTime)
+ {
+ long sec = (_nTime / 1000) % 60;
+ long min = (_nTime / (60 * 1000)) % 60;
+ long hour = _nTime / (60 * 60 * 1000);
+ StringBuffer aTime = new StringBuffer();
+ aTime.append(helper.StringHelper.createValueString((int) hour, 2)).
+ append(':').
+ append(helper.StringHelper.createValueString((int) min, 2)).
+ append(':').
+ append(helper.StringHelper.createValueString((int) sec, 2));
+ return aTime.toString();
+ }
+
+ /**
+ Helper to check if there are problems with Cygwin Path variables.
+ */
+ private static boolean checkVariableForCygwin(String _sVariable)
+ {
+ if (_sVariable == null)
+ {
+ return false;
+ }
+ if (_sVariable.startsWith("/cygdrive"))
+ {
+ return true;
+ }
+ return false;
+ }
+
+ private static boolean checkPathVariable(String _sPath, String delim)
+ {
+ String sPath = System.getProperty(_sPath);
+ if (sPath != null)
+ {
+ StringTokenizer aTokenEnum = new StringTokenizer(sPath, delim);
+ while (aTokenEnum.hasMoreElements())
+ {
+ String sToken = (String) aTokenEnum.nextElement();
+ if (checkVariableForCygwin(sToken))
+ {
+ System.err.println("ERROR: OOoRunner detect cygwin path in '" + _sPath + "'");
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ private static void checkAllVariablesForCygwinPath(TestParameters _aParams)
+ {
+ // ----- check all System.getProperty(key) variables -----
+ String sOsName = System.getProperty("os.name");
+ if (!sOsName.toLowerCase().startsWith("windows"))
+ {
+ // we need to check only on windows
+ return;
+ }
+
+ Properties aProps = System.getProperties();
+ Enumeration aEnum = aProps.propertyNames();
+ // Enumeration aEnum = aProps.elements(); // these are only the values
+ boolean bEmergencyStop = false;
+
+ while (aEnum.hasMoreElements())
+ {
+ String sKey = (String) aEnum.nextElement();
+ String sValue = System.getProperty(sKey);
+
+ if (checkVariableForCygwin(sValue))
+ {
+ System.err.println("ERROR: OOoRunner detect cygwin path in '" + sKey + ":=" + sValue + "'");
+ bEmergencyStop = true;
+ }
+ }
+
+ // ----- check path variables separatly -----
+ String sDelim = System.getProperty("path.separator");
+ bEmergencyStop |= checkPathVariable("java.library.path", sDelim);
+ bEmergencyStop |= checkPathVariable("java.class.path", sDelim);
+ bEmergencyStop |= checkPathVariable("sun.boot.class.path", sDelim);
+
+ // ----- check all TestParameters -----
+ aEnum = _aParams.keys();
+ while (aEnum.hasMoreElements())
+ {
+ String sKey = (String) aEnum.nextElement();
+ if (_aParams.get(sKey) instanceof String)
+ {
+ String sValue = (String) _aParams.get(sKey);
+
+ if (checkVariableForCygwin(sValue))
+ {
+ System.err.println("ERROR: OOoRunner detect cygwin path in '" + sKey + ":=" + sValue + "'");
+ bEmergencyStop = true;
+ }
+ }
+ }
+
+ if (bEmergencyStop)
+ {
+ System.exit(-1);
+ }
+ }
+
+ public static boolean run(String... args)
+ {
+ System.out.println("OOoRunner Main() version from 20100323 (yyyymmdd)");
+
+ setStartTime(getTime());
+
+ DynamicClassLoader dcl = new DynamicClassLoader();
+
+ // get a class for test parameters
+ TestParameters param = new TestParameters();
+
+ ClParser cli = new ClParser();
+
+ //parse the commandline arguments if an ini-parameter is given
+ String iniFile = cli.getIniPath(args);
+
+ //initialize cfgParser with ini-path
+ CfgParser ini = new CfgParser(iniFile);
+
+ //parse ConfigFile
+ ini.getIniParameters(param);
+
+
+ //parse the commandline arguments if an runnerprops-parameter is given
+ String runnerIniFile = cli.getRunnerIniPath(args);
+
+ //initialize cfgParser with ini-path
+ CfgParser runnerIni = new CfgParser(runnerIniFile);
+
+ //parse ConfigFile
+ runnerIni.getIniParameters(param);
+
+ //parse the commandline arguments
+ // TODO: no right error message, if no parameter given!
+ cli.getCommandLineParameter(param, args);
+
+ Object tj = param.get("TestJob");
+
+ if (tj == null)
+ {
+ System.out.println("==========================================================================");
+ System.out.println("No TestJob given, please make sure that you ");
+ System.out.println("a.) called the OOoRunner with the paramter -o <job> or -sce <scenarioFile>");
+ System.out.println("or");
+ System.out.println("b.) have an entry called TestJob in your used properties file");
+ System.out.println("==========================================================================");
+ System.exit(-1);
+ }
+
+ System.out.println("TestJob: " + tj);
+ String sName = "base." + (String) param.get("TestBase");
+ TestBase toExecute = (TestBase) dcl.getInstance(sName);
+
+ checkAllVariablesForCygwinPath(param);
+
+ boolean worked = toExecute.executeTest(param);
+ long nTime = meanTime(getRunnerStartTime());
+ String sBeautifyTime = beautifyTime(nTime);
+
+ System.out.println("Job run took: " + nTime + "ms " + " [" + sBeautifyTime + "]");
+
+ if (!worked)
+ {
+ System.out.println("Job " + param.get("TestJob") + " failed");
+ }
+ else
+ {
+ System.out.println("Job " + param.get("TestJob") + " done");
+ }
+ return worked;
+ }
+
+ public static void main(String[] args)
+ {
+ System.exit(run(args) ? 0 : -1);
+ }
+}
diff --git a/qadevOOo/runner/org/openoffice/RunnerService.java b/qadevOOo/runner/org/openoffice/RunnerService.java
new file mode 100644
index 000000000000..cbe1787f2de1
--- /dev/null
+++ b/qadevOOo/runner/org/openoffice/RunnerService.java
@@ -0,0 +1,397 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package org.openoffice;
+
+import share.LogWriter;
+import stats.InternalLogWriter;
+import lib.TestParameters;
+import util.DynamicClassLoader;
+import base.TestBase;
+import helper.ClParser;
+import helper.CfgParser;
+import com.sun.star.beans.XPropertyAccess;
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.task.XJob;
+import com.sun.star.uno.XInterface;
+import com.sun.star.comp.loader.FactoryHelper;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.lang.XServiceInfo;
+import com.sun.star.lang.XSingleServiceFactory;
+import com.sun.star.lang.XTypeProvider;
+import com.sun.star.uno.Type;
+import com.sun.star.registry.XRegistryKey;
+import com.sun.star.beans.NamedValue;
+
+import java.util.Vector;
+
+/**
+ * The main class, will call ClParser and CfgParser to <br>
+ * fill the TestParameters.<br>
+ * Will then call the appropriate Testbase to run the tests.
+ */
+public class RunnerService implements XJob, XServiceInfo,
+ XTypeProvider, XPropertyAccess {
+
+ static public final String __serviceName = "org.openoffice.Runner";
+ static public final String __implName = "org.openoffice.RunnerService";
+ static private XMultiServiceFactory xMSF = null;
+
+ /**
+ * ct'tor
+ * Construct an own office provider for tests
+ */
+ public RunnerService(XMultiServiceFactory xMSF) {
+ }
+
+ public Object execute(NamedValue[] args) {
+ // construct valid arguments from the given stuff
+ int arg_length=args.length;
+ String[] arguments = new String[arg_length*2];
+ for ( int i=0; i< arg_length; i++ ) {
+ arguments[i*2] = args[i].Name;
+ Object o = args[i].Value;
+ arguments[i*2+1] = o.toString();
+ }
+
+ TestParameters param = new TestParameters();
+ DynamicClassLoader dcl = new DynamicClassLoader();
+
+
+ // take the standard log writer
+ String standardLogWriter = param.LogWriter;
+ String standardOutProducer = param.OutProducer;
+
+ ClParser cli = new ClParser();
+
+ //parse the arguments if an ini-parameter is given
+ String iniFile = cli.getIniPath(arguments);
+
+ //initialize cfgParser with ini-path
+ CfgParser ini = new CfgParser(iniFile);
+
+ //parse ConfigFile
+ ini.getIniParameters(param);
+
+
+ //parse the commandline arguments if an runnerprops-parameter is given
+ String runnerIniFile = cli.getRunnerIniPath(arguments);
+
+ //initialize cfgParser with ini-path
+ CfgParser runnerIni = new CfgParser(runnerIniFile);
+
+ //parse ConfigFile
+ runnerIni.getIniParameters(param);
+
+ //parse the commandline arguments
+ cli.getCommandLineParameter(param,arguments);
+
+ // now compare the standard log writer with the parameters:
+ // if we have a new one, use the new, else use the internal
+ // log writer
+ if (((String)param.get("LogWriter")).equals(standardLogWriter))
+ param.put("LogWriter", "stats.InternalLogWriter");
+ if (((String)param.get("OutProducer")).equals(standardOutProducer))
+ param.put("OutProducer", "stats.InternalLogWriter");
+ LogWriter log = (LogWriter) dcl.getInstance(
+ (String)param.get("LogWriter"));
+
+ param.put("ServiceFactory", xMSF);
+
+ param.ServiceFactory = xMSF; //(XMultiServiceFactory)
+ // appProvider.getManager(param);
+
+ log.println("TestJob: "+param.get("TestJob"));
+
+ TestBase toExecute = (TestBase)dcl.getInstance("base.java_fat_service");
+
+ boolean worked = toExecute.executeTest(param);
+ if (!worked)
+ log.println("Test did not execute correctly.");
+
+ String returnString = "";
+ if (log instanceof InternalLogWriter)
+ returnString = ((InternalLogWriter)log).getLog();
+ return returnString;
+ }
+
+ /**
+ * This function provides the service name
+ * @return the service name
+ */
+ public String getServiceName() {
+ return __serviceName;
+ }
+
+ /**
+ * Get all implemented types of this class.
+ * @return An array of implemented interface types.
+ * @see com.sun.star.lang.XTypeProvider
+ */
+ public Type[] getTypes() {
+ Type[] type = new Type[5];
+ type[0] = new Type(XInterface.class);
+ type[1] = new Type(XTypeProvider.class);
+ type[2] = new Type(XJob.class);
+ type[3] = new Type(XServiceInfo.class);
+ type[4] = new Type(XPropertyAccess.class);
+ return type;
+ }
+
+ /**
+ * Get the implementation id.
+ * @return An empty implementation id.
+ * @see com.sun.star.lang.XTypeProvider
+ */
+ public byte[] getImplementationId() {
+ return new byte[0];
+ }
+ /**
+ * Function for reading the implementation name.
+ *
+ * @return the implementation name
+ * @see com.sun.star.lang.XServiceInfo
+ */
+ public String getImplementationName() {
+ return __implName;
+ }
+
+ /**
+ * Does the implementation support this service?
+ *
+ * @param serviceName The name of the service in question
+ * @return true, if service is supported, false otherwise
+ * @see com.sun.star.lang.XServiceInfo
+ */
+ public boolean supportsService(String serviceName) {
+ if(serviceName.equals(__serviceName))
+ return true;
+ return false;
+ }
+
+ /**
+ * Function for reading all supported services
+ *
+ * @return An aaray with all supported service names
+ * @see com.sun.star.lang.XServiceInfo
+ */
+ public String[] getSupportedServiceNames() {
+ String[] supServiceNames = {__serviceName};
+ return supServiceNames;
+ }
+
+ /**
+ * Return all valid testcases from the object descriptions
+ * @return The valid testcases as property values
+ */
+ public PropertyValue[] getPropertyValues() {
+ PropertyValue[] pVal = null;
+ java.net.URL url = this.getClass().getResource("/objdsc");
+ if (url == null) {
+ pVal = new PropertyValue[1];
+ pVal[0] = new PropertyValue();
+ pVal[0].Name = "Error";
+ pVal[0].Value = "OOoRunner.jar file doesn't contain object " +
+ "descriptions: don't know what to test.";
+ return pVal;
+ }
+
+ Vector v = new Vector(600);
+ try {
+ // open connection to Jar
+ java.net.JarURLConnection con =
+ (java.net.JarURLConnection)url.openConnection();
+ // get Jar file from connection
+ java.util.jar.JarFile f = con.getJarFile();
+ // Enumerate over all entries
+ java.util.Enumeration aEnum = f.entries();
+
+ while (aEnum.hasMoreElements()) {
+ String entry = aEnum.nextElement().toString();
+ if (entry.endsWith(".csv")) {
+
+ String module = null;
+ String object = null;
+
+ int startIndex = entry.indexOf("objdsc/") + 7;
+ int endIndex = entry.lastIndexOf('/');
+/* int endIndex = entry.indexOf('.');
+ module = entry.substring(startIndex, endIndex);
+ startIndex = 0;
+ endIndex = module.lastIndexOf('/'); */
+ module = entry.substring(startIndex, endIndex);
+
+ // special cases
+ if (entry.indexOf("/file/") != -1 || entry.indexOf("/xmloff/") != -1) {
+ endIndex = entry.indexOf(".csv");
+ object = entry.substring(0, endIndex);
+ endIndex = object.lastIndexOf('.');
+ startIndex = object.indexOf('.');
+ while (startIndex != endIndex) {
+ object = object.substring(startIndex+1);
+ startIndex = object.indexOf('.');
+ endIndex = object.lastIndexOf('.');
+ }
+ }
+/* else if (entry.indexOf("/xmloff/") != -1) {
+ endIndex = entry.indexOf(".csv");
+ object = entry.substring(0, endIndex);
+ endIndex = entry.lastIndexOf('.');
+ while (object.indexOf('.') != endIndex) {
+ object = object.substring(object.indexOf('.')+1);
+ }
+ } */
+ else {
+ startIndex = 0;
+ endIndex = entry.indexOf(".csv");
+ object = entry.substring(startIndex, endIndex);
+ startIndex = object.lastIndexOf('.');
+ object = object.substring(startIndex+1);
+ }
+ v.add(module+"."+object);
+ }
+ }
+ }
+ catch(java.io.IOException e) {
+ e.printStackTrace();
+ }
+
+ int size = v.size();
+
+ String[] sTestCases = new String[size];
+ v.toArray(sTestCases);
+ java.util.Arrays.sort(sTestCases);
+
+ pVal = new PropertyValue[size];
+ for (int i=0; i<size; i++) {
+ pVal[i] = new PropertyValue();
+ pVal[i].Name = "TestCase"+i;
+ pVal[i].Value = sTestCases[i];
+ }
+ return pVal;
+ }
+
+
+ /**
+ *
+ * Gives a factory for creating the service.
+ * This method is called by the <code>JavaLoader</code>
+ * <p>
+ * @return returns a <code>XSingleServiceFactory</code> for creating the component
+ * @param implName the name of the implementation for which a service is desired
+ * @param multiFactory the service manager to be used if needed
+ * @param regKey the registryKey
+ * @see com.sun.star.comp.loader.JavaLoader
+ */
+ public static XSingleServiceFactory __getServiceFactory(String implName,
+ XMultiServiceFactory multiFactory, XRegistryKey regKey)
+ {
+ XSingleServiceFactory xSingleServiceFactory = null;
+
+ if (implName.equals(RunnerService.class.getName()))
+ xSingleServiceFactory = FactoryHelper.getServiceFactory(
+ RunnerService.class, __serviceName, multiFactory, regKey);
+ xMSF = multiFactory;
+ return xSingleServiceFactory;
+ }
+
+ /**
+ * Writes the service information into the given registry key.
+ * This method is called by the <code>JavaLoader</code>
+ * <p>
+ * @return returns true if the operation succeeded
+ * @param regKey the registryKey
+ * @see com.sun.star.comp.loader.JavaLoader
+ */
+ public static boolean __writeRegistryServiceInfo(XRegistryKey regKey) {
+ return FactoryHelper.writeRegistryServiceInfo(RunnerService.class.getName(),
+ __serviceName, regKey);
+ }
+
+ /**
+ * empty: not needed here.
+ */
+ public void setPropertyValues(PropertyValue[] propertyValue)
+ throws com.sun.star.beans.UnknownPropertyException,
+ com.sun.star.beans.PropertyVetoException,
+ com.sun.star.lang.IllegalArgumentException,
+ com.sun.star.lang.WrappedTargetException {
+ // empty implementation
+ }
+
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/qadevOOo/runner/org/openoffice/makefile.mk b/qadevOOo/runner/org/openoffice/makefile.mk
new file mode 100644
index 000000000000..e3ba3b4f6e22
--- /dev/null
+++ b/qadevOOo/runner/org/openoffice/makefile.mk
@@ -0,0 +1,46 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+
+PRJNAME = OOoRunner
+PACKAGE = org$/openoffice
+TARGET = runner_org_openoffice
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+# --- Files --------------------------------------------------------
+
+JARFILES = ridl.jar jurt.jar unoil.jar
+JAVAFILES = Runner.java RunnerService.java
+JAVACLASSFILES= $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class)
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
diff --git a/qadevOOo/runner/share/ComplexTest.java b/qadevOOo/runner/share/ComplexTest.java
new file mode 100644
index 000000000000..ea1ab3c55850
--- /dev/null
+++ b/qadevOOo/runner/share/ComplexTest.java
@@ -0,0 +1,39 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package share;
+
+/**
+ * Interface for complex tests.
+ */
+public interface ComplexTest {
+
+ public String[] getTestMethodNames();
+
+ public String getTestObjectName();
+
+}
+
diff --git a/qadevOOo/runner/share/CwsDataExchange.java b/qadevOOo/runner/share/CwsDataExchange.java
new file mode 100644
index 000000000000..8f6c31943ad4
--- /dev/null
+++ b/qadevOOo/runner/share/CwsDataExchange.java
@@ -0,0 +1,51 @@
+/*
+ * ************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ * ***********************************************************************
+ */
+
+package share;
+
+import java.util.ArrayList;
+
+/**
+ * Exchange information to the EIS database
+ *
+ */
+public interface CwsDataExchange {
+
+ /**
+ * Retunrs all module names which are added to the specified childworkspace
+ * @return a String array of all added modules
+ */
+ public ArrayList getModules();
+
+ /**
+ * Set the test status of cws related UnoAPI tests to the EIS dabase
+ * @param status the status of the UnoAPI test
+ */
+ public void setUnoApiCwsStatus(boolean status);
+}
diff --git a/qadevOOo/runner/share/DescEntry.java b/qadevOOo/runner/share/DescEntry.java
new file mode 100644
index 000000000000..6485cd840950
--- /dev/null
+++ b/qadevOOo/runner/share/DescEntry.java
@@ -0,0 +1,97 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+package share;
+
+/**
+ *
+ * Structure to describe the entries to be tested
+ *
+ */
+public class DescEntry {
+
+ /**
+ * Contains the name used inside the framework
+ */
+ public String entryName;
+ /**
+ * Contains the name that may be used by state writers
+ */
+ public String longName;
+ /**
+ * Contains information if this entry is Optional
+ */
+ public boolean isOptional;
+ /**
+ * Contains information if this entry should be tested
+ */
+ public boolean isToTest;
+ /**
+ * Contains the information about the number of SubEntries
+ */
+ public int SubEntryCount;
+ /**
+ * Contains the SubEntries
+ */
+ public DescEntry[] SubEntries;
+
+ /**
+ * Contains information about the Type of the entry<br>
+ * possible 'component', 'interface', 'service', 'method', 'property', 'unit'
+ */
+ public String EntryType;
+
+ /**
+ * Contains the ErrorMsg is something went wrong while gaining<br>
+ * the description
+ */
+ public String ErrorMsg;
+
+ /**
+ * Contains information if errors occured while gaining the Description
+ */
+ public boolean hasErrorMsg;
+
+ /**
+ * Contains the state for this entry
+ */
+ public String State = "UNKNOWN";
+
+ /**
+ * Contains the LogWriter to be used by the entry-test
+ */
+
+ public share.LogWriter Logger;
+
+ /**
+ * Contains an arbitrary set of parameters
+ */
+
+ public java.util.Hashtable UserDefinedParams = new java.util.Hashtable();
+
+}
diff --git a/qadevOOo/runner/share/DescGetter.java b/qadevOOo/runner/share/DescGetter.java
new file mode 100644
index 000000000000..b032dda1eec3
--- /dev/null
+++ b/qadevOOo/runner/share/DescGetter.java
@@ -0,0 +1,197 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package share;
+
+import java.io.BufferedReader;
+import java.io.FileReader;
+import java.util.ArrayList;
+import java.util.StringTokenizer;
+
+import java.util.Vector;
+
+/**
+ *
+ * Base Interface to get a description for a given TestJob
+ *
+ */
+public abstract class DescGetter
+{
+
+ public abstract DescEntry[] getDescriptionFor(String entry,
+ String DescPath,
+ boolean debug);
+
+ protected abstract DescEntry getDescriptionForSingleJob(String job,
+ String descPath,
+ boolean debug);
+
+ protected abstract String[] createScenario(String descPath, String job,
+ boolean debug);
+
+ protected DescEntry[] getScenario(String url, String descPath,
+ boolean debug)
+ {
+ Vector entryList = new Vector();
+ String line = "";
+ BufferedReader scenario = null;
+ DescEntry[] entries = null;
+
+ try
+ {
+ scenario = new BufferedReader(new FileReader(url));
+ }
+ catch (java.io.FileNotFoundException fnfe)
+ {
+ System.out.println("Couldn't find file " + url);
+
+ return entries;
+ }
+
+ while (line != null)
+ {
+ try
+ {
+ if (line.startsWith("-o"))
+ {
+ String job = line.substring(3, line.length()).trim();
+ DescEntry aEntry;
+ // special in case several Interfaces are given comma separated
+ if (job.indexOf(",") < 0)
+ {
+ aEntry = getDescriptionForSingleJob(job, descPath,
+ debug);
+ }
+ else
+ {
+ ArrayList subs = getSubInterfaces(job);
+ String partjob = job.substring(0, job.indexOf(",")).trim();
+ aEntry = getDescriptionForSingleJob(partjob, descPath,
+ debug);
+
+ if (aEntry != null)
+ {
+ for (int i = 0; i < aEntry.SubEntryCount; i++)
+ {
+ String subEntry = aEntry.SubEntries[i].longName;
+ int cpLength = aEntry.longName.length();
+ subEntry = subEntry.substring(cpLength + 2,
+ subEntry.length());
+
+ if (subs.contains(subEntry))
+ {
+ aEntry.SubEntries[i].isToTest = true;
+ }
+ }
+ }
+ }
+// DescEntry aEntry = getDescriptionForSingleJob(
+// line.substring(3).trim(), descPath,
+// debug);
+ if (aEntry != null)
+ {
+ entryList.add(aEntry);
+ }
+ }
+ else if (line.startsWith("-sce"))
+ {
+ DescEntry[] subs = getScenario(line.substring(5,
+ line.length()).trim(), descPath,
+ debug);
+
+ for (int i = 0; i < subs.length; i++)
+ {
+ entryList.add(subs[i]);
+ }
+ }
+ else if (line.startsWith("-p"))
+ {
+ String[] perModule = createScenario(descPath,
+ line.substring(3).trim(), debug);
+
+ for (int i = 0; i < perModule.length; i++)
+ {
+ DescEntry aEntry = getDescriptionForSingleJob(
+ perModule[i].substring(3).trim(),
+ descPath, debug);
+ if (aEntry != null)
+ {
+ entryList.add(aEntry);
+ }
+ }
+ }
+
+ line = scenario.readLine();
+ }
+ catch (java.io.IOException ioe)
+ {
+ if (debug)
+ {
+ System.out.println("Exception while reading scenario");
+ }
+ }
+ }
+
+ try
+ {
+ scenario.close();
+ }
+ catch (java.io.IOException ioe)
+ {
+ if (debug)
+ {
+ System.out.println("Exception while closeing scenario");
+ }
+ }
+
+ if (entryList.size() == 0)
+ {
+ return null;
+ }
+ entries = new DescEntry[entryList.size()];
+ entries = (DescEntry[]) entryList.toArray(entries);
+
+ return entries;
+ }
+
+ protected ArrayList getSubInterfaces(String job)
+ {
+ ArrayList namesList = new ArrayList();
+ StringTokenizer st = new StringTokenizer(job, ",");
+
+ for (int i = 0; st.hasMoreTokens(); i++)
+ {
+ String token = st.nextToken();
+
+ if (token.indexOf(".") < 0)
+ {
+ namesList.add(token);
+ }
+ }
+
+ return namesList;
+ }
+} \ No newline at end of file
diff --git a/qadevOOo/runner/share/LogWriter.java b/qadevOOo/runner/share/LogWriter.java
new file mode 100644
index 000000000000..67b8250f6f01
--- /dev/null
+++ b/qadevOOo/runner/share/LogWriter.java
@@ -0,0 +1,68 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package share;
+
+public interface LogWriter {
+
+ /**
+ * Method to print
+ */
+ public void println(String msg);
+
+ /**
+ * initialization
+ *
+ */
+
+ public boolean initialize(share.DescEntry entry, boolean active);
+
+ /**
+ * will mostly be used by outproducers to sum up
+ * the information, maybe write them to a db
+ */
+
+ public boolean summary(share.DescEntry entry);
+
+
+ /**
+ * Returns the <CODE>Watcher</CODE> which is associated with this logger
+ * @see share.Watcher
+ * @return the associated <CODE>Watcher</CODE>
+ */
+ public Object getWatcher();
+
+ /**
+ * Set a <CODE>Watcher</CODE> to the <CODE>LogWriter</CODE>
+ * This is usefull if a test starts a new office instance by itself. In this cases
+ * the <CODE>LogWritter</CODE> could retrigger the <CODE>Watcher</CODE>
+ * @see share.Watcher
+ * @param watcher the new <CODE>Watcher</CODE>
+ */
+ public void setWatcher(Object watcher);
+
+}
diff --git a/qadevOOo/runner/share/Watcher.java b/qadevOOo/runner/share/Watcher.java
new file mode 100644
index 000000000000..bf0c40d9dadf
--- /dev/null
+++ b/qadevOOo/runner/share/Watcher.java
@@ -0,0 +1,42 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package share;
+
+public interface Watcher {
+
+ /**
+ * pings the watcher to check for changes
+ */
+ public void ping();
+
+ /**
+ * returns the amount of pings
+ */
+ public int getPing();
+
+}
diff --git a/qadevOOo/runner/share/makefile.mk b/qadevOOo/runner/share/makefile.mk
new file mode 100644
index 000000000000..ff780b13c0a9
--- /dev/null
+++ b/qadevOOo/runner/share/makefile.mk
@@ -0,0 +1,52 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..
+
+PRJNAME = OOoRunner
+PACKAGE = share
+TARGET = runner_share
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+# --- Files --------------------------------------------------------
+
+JARFILES = ridl.jar jurt.jar unoil.jar
+
+JAVAFILES = DescEntry.java \
+ DescGetter.java \
+ LogWriter.java \
+ ComplexTest.java \
+ Watcher.java
+
+JAVACLASSFILES= $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class)
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
diff --git a/qadevOOo/runner/stats/ComplexDataBaseOutProducer.java b/qadevOOo/runner/stats/ComplexDataBaseOutProducer.java
new file mode 100644
index 000000000000..7237fcc98dd8
--- /dev/null
+++ b/qadevOOo/runner/stats/ComplexDataBaseOutProducer.java
@@ -0,0 +1,181 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package stats;
+
+import share.LogWriter;
+import java.text.DecimalFormat;
+import java.util.Hashtable;
+import java.util.Calendar;
+import java.util.GregorianCalendar;
+
+/**
+ *
+ *
+ */
+public class ComplexDataBaseOutProducer extends DataBaseOutProducer {
+
+ /** Creates a new instance of ComplexDataBaseOutProducer */
+ public ComplexDataBaseOutProducer(Hashtable param) {
+ super(param);
+ // do we have to write debug output?
+ Object o = param.get("DebugIsActive");
+ if (o != null) {
+ if (o instanceof String) {
+ String debug = (String)o;
+ m_bDebug = (debug.equalsIgnoreCase("yes") || debug.equalsIgnoreCase("true"));
+ }
+
+ }
+
+ String testBase = (String)mSqlInput.get("TestBase");
+ String apiVersion = (String)mSqlInput.get("Version");
+ String os = (String)mSqlInput.get("OperatingSystem");
+ if (testBase == null || apiVersion == null || os == null) {
+ System.err.println("The ComplexDataBaseOutProducer constructor needs this parameters to work correctly:");
+ System.err.println("TestBase - " + testBase);
+ System.err.println("Version - " + apiVersion);
+ System.err.println("OperatingSystem - " + os);
+ System.err.println("Add the missing parameter.");
+ }
+ int sep = testBase.indexOf('_');
+ String testLanguage = testBase.substring(0,sep);
+ testBase = testBase.substring(sep+1);
+
+ // 2do fallback?
+// if (os == null || os.equals(""))
+// os = System.getProperty("os.name");
+ String descriptionString = testLanguage+":"+ os +":"+testBase+":"+apiVersion;
+ if (apiVersion != null)
+ apiVersion = apiVersion.substring(0, 6);
+
+ if (mSqlInput.get("date") == null) {
+ // build date if it's not there
+ Calendar cal = new GregorianCalendar();
+ DecimalFormat dfmt = new DecimalFormat("00");
+ String year = Integer.toString(cal.get(GregorianCalendar.YEAR));
+ // month is starting with "0"
+ String month = dfmt.format(cal.get(GregorianCalendar.MONTH) + 1);
+ String day = dfmt.format(cal.get(GregorianCalendar.DATE));
+ String dateString = year + "-" + month + "-" + day;
+
+ mSqlInput.put("date", dateString);
+ }
+ mSqlInput.put("test_run_description", descriptionString);
+ mSqlInput.put("api_version_name", apiVersion);
+ setWriteableEntryTypes(new String[]{"unit", "method"});
+ }
+
+ /**
+ * Prepare the database.
+ * @parameter log A log writer
+ * @return True, if everything worked.
+ */
+ protected boolean prepareDataBase(LogWriter log) {
+ executeSQLCommand("SELECT id AS \"test_run.id\", api_version_id, description, date FROM test_run" +
+ " WHERE date = \"$date\" AND description = \"$test_run_description\";", true);
+ String id = (String)mSqlInput.get("test_run.id");
+ // create an entry for this test run
+ if (id == null) {
+ executeSQLCommand("SELECT id as api_version_id FROM api_version" +
+ " WHERE version = \"$api_version_name\";", true);
+ String api_version_id = (String)mSqlInput.get("api_version_id");
+ // create an entry for this API
+ if (api_version_id == null) {
+ executeSQLCommand("INSERT api_version (api_name, version)" +
+ " VALUES (\"soapi\", \"$api_version_name\")");
+ executeSQLCommand("SELECT id as api_version_id FROM api_version" +
+ " WHERE version = \"$api_version_name\";", true);
+ }
+ executeSQLCommand("INSERT test_run (api_version_id, description, date)" +
+ " VALUES ($api_version_id, \"$test_run_description\", \"$date\");");
+ executeSQLCommand("SELECT id AS \"test_run.id\", api_version_id, description, date FROM test_run" +
+ " WHERE date = \"$date\" AND description = \"$test_run_description\";", true);
+ }
+ return true;
+ }
+
+ /**
+ * Insert the result of the test of an entry into the database.
+ * @parameter log A log writer
+ * @return True, if everything worked.
+ */
+ protected boolean insertEntry(LogWriter log) {
+
+ if ( m_bDebug ) {
+ System.out.println("DEBUG - ComplexDataBaseOutProducer: entry.id has to be null: " + (mSqlInput.get("entry.id")==null));
+ System.out.println("DEBUG - ComplexDataBaseOutProducer: EntryLongName: " + mSqlInput.get("EntryLongName"));
+ }
+ executeSQLCommand("SELECT id as \"entry.id\", name as \"entry.name\" FROM entry WHERE name = \"$EntryLongName\";", true);
+
+ if (mSqlInput.get("entry.id") == null) {
+ if ( m_bDebug ) {
+ System.out.println("DEBUG - ComplexDataBaseOutProducer: No entry.id found, this is a new entry in the database.");
+ }
+ executeSQLCommand("INSERT entry (name, type)" +
+ " VALUES (\"$EntryLongName\", \"$EntryType\");");
+ executeSQLCommand("SELECT id as \"entry.id\", name as \"entry.name\" FROM entry WHERE name = \"$EntryLongName\";", true);
+ }
+
+
+ executeSQLCommand("SELECT id as \"api_entry.id\", api_version_id as \"api_entry.api_version_id\", entry_id as \"api_entry.entry_id\" FROM api_entry" +
+ " WHERE entry_id = $entry.id;", true);
+ if (mSqlInput.get("api_entry.id") == null) {
+ System.out.println("No api_entry.id found");
+ executeSQLCommand("INSERT api_entry (entry_id, api_version_id)"+
+ " VALUES ($entry.id, $api_version_id);");
+ executeSQLCommand("SELECT id as \"api_entry.id\", api_version_id as \"api_entry.api_version_id\", entry_id as \"api_entry.entry_id\" FROM api_entry" +
+ " WHERE entry_id = $entry.id;", true);
+ }
+
+
+ executeSQLCommand("SELECT status as \"test_state.status\" FROM test_state"+
+ " WHERE test_run_id = $test_run.id AND entry_id = $entry.id;", true);
+
+ String entryState = (String)mSqlInput.get("EntryState");
+ String status = (String)mSqlInput.get("test_state.status");
+
+ if (!entryState.equals("SKIPPED.FAILED")) { // occurs in case of misspellings: do not make an database entry.
+ if (status == null) {
+ executeSQLCommand("INSERT test_state (test_run_id, entry_id, status)"+
+ " VALUES ($test_run.id, $entry.id, \"$EntryState\");");
+ }
+ else {
+ executeSQLCommand("UPDATE test_state SET status = \"$EntryState\""+
+ " where test_run_id =$test_run.id AND entry_id = $entry.id;");
+ }
+ }
+ return true;
+ }
+
+ public Object getWatcher() {
+ return null;
+ }
+
+ public void setWatcher(Object watcher) {
+ }
+
+}
diff --git a/qadevOOo/runner/stats/DataBaseOutProducer.java b/qadevOOo/runner/stats/DataBaseOutProducer.java
new file mode 100644
index 000000000000..814135d553ca
--- /dev/null
+++ b/qadevOOo/runner/stats/DataBaseOutProducer.java
@@ -0,0 +1,207 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package stats;
+
+import share.LogWriter;
+import share.DescEntry;
+
+import java.util.Hashtable;
+
+/**
+ *
+ * @author sg128468
+ */
+public abstract class DataBaseOutProducer implements LogWriter {
+ protected Hashtable mSqlInput = null;
+ protected Hashtable mSqlOutput = null;
+ protected String[] mWriteableEntryTypes = null;
+ protected SQLExecution mSqlExec;
+ protected boolean m_bDebug = false;
+
+
+ /** Creates a new instance of DataBaseOutProducer
+ * @param param The Hashtable with test parameters
+ */
+ public DataBaseOutProducer(Hashtable param) {
+ mSqlInput = new Hashtable();
+ mSqlInput.putAll(param);
+
+ Object o = param.get("DebugIsActive");
+ String debug = null;
+ if (o instanceof String)
+ debug = (String)o;
+ else
+ debug = o.toString();
+ if (debug != null && (debug.equalsIgnoreCase("true") || debug.equalsIgnoreCase("yes"))) {
+ m_bDebug = true;
+ }
+ // set default for writeable entries: method
+ setWriteableEntryTypes(new String[]{"method"});
+ }
+
+ /** initialization
+ *
+ */
+ public boolean initialize(DescEntry entry, boolean active) {
+ if (entry.UserDefinedParams != null)
+ mSqlInput.putAll(entry.UserDefinedParams);
+
+ String jdbcClass = (String)mSqlInput.get("JDBC");
+ if (jdbcClass == null)
+ jdbcClass = "org.gjt.mm.mysql.Driver";
+ String dbURL = (String)mSqlInput.get("DataBaseURL");
+ String user = (String)mSqlInput.get("User");
+ String password = (String)mSqlInput.get("Password");
+ if (user == null)
+ user = (String)mSqlInput.get("OperatingSystem");
+ if (password == null)
+ password = user;
+
+ mSqlExec = new SQLExecution(jdbcClass, dbURL, user, password, m_bDebug);
+ mSqlExec.openConnection();
+ prepareDataBase(entry.Logger);
+ return true;
+ }
+
+ /**
+ *
+ *
+ */
+ public boolean summary(DescEntry entry) {
+ mSqlExec.openConnection();
+ findTypeInEntryTree(entry, entry.Logger);
+// checkDataBase(entry.Logger);
+ mSqlExec.closeConnection();
+ return true;
+ }
+
+ /**
+ * Step recursively through the entry tree: write all entries of the
+ * defined types to the database.
+ * @param entry The description entry that is take as root
+ * @param log The log writer
+ */
+ protected boolean findTypeInEntryTree(DescEntry entry, LogWriter log) {
+ boolean returnVal = true;
+ if (isWriteableEntryType(entry)) {
+ returnVal &= insertEntry(entry, log);
+ }
+
+ if (entry.SubEntryCount >0) {
+ for (int i=0; i<entry.SubEntryCount; i++) {
+ returnVal &= findTypeInEntryTree(entry.SubEntries[i], log);
+ }
+ }
+ // if we are not on method leaf, exit here
+ // insert one method result into database
+ return returnVal;
+ }
+
+ /**
+ * Insert this entrry to the database.
+ * @param entry The entry to write.
+ * @param log The log writer.
+ */
+ protected boolean insertEntry(DescEntry entry, LogWriter log) {
+ // copy the swlInput Hashtable, so it can be reset easily for the next run
+ Hashtable copySqlInput = new Hashtable();
+ copySqlInput.putAll(mSqlInput);
+ // put some stuff from entry in the Hashtable
+ mSqlInput.put("EntryLongName", entry.longName);
+ mSqlInput.put("EntryName", entry.entryName);
+ mSqlInput.put("EntryState", entry.State);
+ mSqlInput.put("EntryType", entry.EntryType);
+ boolean result = insertEntry(log);
+ // reset the Hashtable
+ mSqlInput = copySqlInput;
+ return result;
+
+ }
+
+ /**
+ * Set the writeable entry types: for example "method", "interface", etc.
+ * All these entries are written to the database.
+ * @param types A String array with all types that have to be written.
+ */
+ public void setWriteableEntryTypes(String[] types) {
+ mWriteableEntryTypes = types;
+ }
+
+ /**
+ * Is the entry of the writeable entry type?
+ * @param entry The entry that is checked
+ * @return True, if it is indeed a writeable entry.
+ */
+ protected boolean isWriteableEntryType(DescEntry entry) {
+ boolean result = false;
+ for (int i=0; i<mWriteableEntryTypes.length; i++) {
+ if (entry.EntryType.equals(mWriteableEntryTypes[i])) {
+ result = true;
+ break;
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Wrap the command of SQLExecution class for transparency.
+ */
+ protected boolean executeSQLCommand(String command, boolean mergeOutput) {
+ return mSqlExec.executeSQLCommand(command, mSqlInput, mSqlOutput, mergeOutput);
+ }
+
+ /**
+ * Wrap the command of SQLExecution class for transparency.
+ */
+ protected boolean executeSQLCommand(String command) {
+ return mSqlExec.executeSQLCommand(command, mSqlInput, mSqlOutput);
+ }
+
+ /**
+ * Method to print: empty here
+ */
+ public void println(String msg) {
+ }
+
+ /**
+ * Prepare the database: executed once at the beginning.
+ * Abstract method, so derived classes have to overwrite it.
+ */
+ protected abstract boolean prepareDataBase(LogWriter log);
+
+ /**
+ * Insert one entr into the database.
+ * Abstract method, so derived classes have to overwrite it.
+ */
+ protected abstract boolean insertEntry(LogWriter log);
+
+ /**
+ *
+ protected abstract boolean checkDataBase(LogWriter log);
+ */
+
+}
diff --git a/qadevOOo/runner/stats/FatDataBaseOutProducer.java b/qadevOOo/runner/stats/FatDataBaseOutProducer.java
new file mode 100644
index 000000000000..dce9c137810a
--- /dev/null
+++ b/qadevOOo/runner/stats/FatDataBaseOutProducer.java
@@ -0,0 +1,147 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package stats;
+
+import java.text.DecimalFormat;
+import share.LogWriter;
+import java.util.Hashtable;
+import java.util.Calendar;
+import java.util.GregorianCalendar;
+
+
+/**
+ *
+ */
+public class FatDataBaseOutProducer extends DataBaseOutProducer {
+
+
+ /** Creates a new instance of APIDataBaseOutProducer */
+ public FatDataBaseOutProducer(Hashtable param) {
+ super(param);
+ String testBase = (String)mSqlInput.get("TestBase");
+ int sep = testBase.indexOf('_');
+ String testLanguage = testBase.substring(0,sep);
+ testBase = testBase.substring(sep+1);
+ String apiVersion = (String)mSqlInput.get("Version");
+ String descriptionString = testLanguage+":"+(String)mSqlInput.get("OperatingSystem")+":"+testBase+":"+apiVersion;
+ apiVersion = apiVersion.substring(0, 6);
+ // build date
+ if (mSqlInput.get("Date") != null) {
+ mSqlInput.put("date", mSqlInput.get("Date"));
+ }
+ if (mSqlInput.get("date") == null) {
+ // build date if it's not there
+ Calendar cal = new GregorianCalendar();
+ DecimalFormat dfmt = new DecimalFormat("00");
+ String year = Integer.toString(cal.get(GregorianCalendar.YEAR));
+ // month is starting with "0"
+ String month = dfmt.format(cal.get(GregorianCalendar.MONTH) + 1);
+ String day = dfmt.format(cal.get(GregorianCalendar.DATE));
+ String dateString = year + "-" + month + "-" + day;
+
+ mSqlInput.put("date", dateString);
+ }
+
+ setWriteableEntryTypes(new String[]{"property", "method", "component", "interface", "service"});
+
+ mSqlInput.put("test_run.description", descriptionString);
+ mSqlInput.put("api_version_name", apiVersion);
+ }
+
+ protected boolean prepareDataBase(LogWriter log) {
+ executeSQLCommand("SHOW TABLES");
+
+ executeSQLCommand("SELECT id AS \"test_run.id\", api_version_id, description, date FROM test_run" +
+ " WHERE date = \"$date\" AND description = \"$test_run.description\";", true);
+ String id = (String)mSqlInput.get("test_run.id");
+ // create an entry for this test run
+ if (id == null) {
+ executeSQLCommand("SELECT id AS api_version_id FROM api_version" +
+ " WHERE version = \"$api_version_name\";", true);
+ String api_version_id = (String)mSqlInput.get("api_version_id");
+ // create an entry for this API
+ if (api_version_id == null) {
+ executeSQLCommand("INSERT api_version (api_name, version)" +
+ " VALUES (\"soapi\", \"$api_version_name\")");
+ executeSQLCommand("SELECT id AS api_version_id FROM api_version" +
+ " WHERE version = \"$api_version_name\";", true);
+ }
+ // complete entry for the test run
+ executeSQLCommand("INSERT test_run (api_version_id, description, date)" +
+ " VALUES ($api_version_id, \"$test_run.description\", \"$date\");");
+ executeSQLCommand("SELECT test_run.id AS \"test_run.id\", api_version_id, description, date FROM test_run" +
+ " WHERE date = \"$date\" AND description = \"$test_run.description\";", true);
+ }
+ return true;
+ }
+
+ // check the database afterwards
+ protected boolean checkDataBase(LogWriter log) {
+ return true;
+ }
+
+ protected boolean insertEntry(LogWriter log) {
+
+ executeSQLCommand("SELECT id AS \"entry.id\", name AS \"entry.name\" FROM entry WHERE name = \"$EntryLongName\";", true);
+ if (mSqlInput.get("entry.id") == null) {
+ executeSQLCommand("INSERT entry (name, type)" +
+ " VALUES (\"$EntryLongName\", \"$EntryType\");");
+ executeSQLCommand("SELECT id AS \"entry.id\", name AS \"entry.name\" FROM entry WHERE name = \"$EntryLongName\";", true);
+ }
+ executeSQLCommand("SELECT id AS \"api_entry.id\", api_version_id AS \"api_entry.api_version_id\", entry_id AS \"api_entry.entry_id\" FROM api_entry" +
+ " WHERE entry_id = $entry.id;", true);
+ if (mSqlInput.get("api_entry.id") == null) {
+ executeSQLCommand("INSERT api_entry (entry_id, api_version_id)"+
+ " VALUES ($entry.id, $api_version_id);");
+ executeSQLCommand("SELECT id AS \"api_entry.id\", api_version_id AS \"api_entry.api_version_id\", entry_id AS \"api_entry.entry_id\" FROM api_entry" +
+ " WHERE entry_id = $entry.id;", true);
+ }
+ executeSQLCommand("SELECT status AS \"test_state.status\" FROM test_state"+
+ " WHERE test_run_id = $test_run.id AND entry_id = $entry.id;", true);
+
+ String status = (String)mSqlInput.get("test_state.status");
+ if (status == null) {
+ executeSQLCommand("INSERT test_state (test_run_id, entry_id, status)"+
+ " VALUES ($test_run.id, $entry.id, \"$EntryState\");");
+ }
+ else {
+ if (!status.endsWith("OK")) {
+ executeSQLCommand("UPDATE test_state SET status = \"$EntryState\""+
+ " WHERE test_run_id = $test_run.id AND entry_id = $entry.id;");
+ }
+ }
+ return true;
+ }
+
+ public Object getWatcher() {
+ return null;
+ }
+
+ public void setWatcher(Object watcher) {
+ }
+
+}
diff --git a/qadevOOo/runner/stats/FileLogWriter.java b/qadevOOo/runner/stats/FileLogWriter.java
new file mode 100644
index 000000000000..cfa4ccc5a617
--- /dev/null
+++ b/qadevOOo/runner/stats/FileLogWriter.java
@@ -0,0 +1,141 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package stats;
+
+import java.io.FileWriter;
+import java.io.IOException;
+import share.LogWriter;
+
+import java.io.PrintWriter;
+import java.text.DecimalFormat;
+import java.util.Calendar;
+import java.util.GregorianCalendar;
+import java.util.HashMap;
+import java.util.Iterator;
+
+public class FileLogWriter extends PrintWriter implements LogWriter {
+
+
+ HashMap mFileWriters = null;
+ boolean logging = false;
+ share.DescEntry entry = null;
+ share.Watcher ow = null;
+
+ public FileLogWriter() {
+ super(System.out);
+ Calendar cal = new GregorianCalendar();
+ DecimalFormat dfmt = new DecimalFormat("00");
+ super.println("LOG> Log started " +
+ dfmt.format(cal.get(Calendar.DAY_OF_MONTH)) + "." +
+ dfmt.format(cal.get(Calendar.MONTH)) + "." +
+ dfmt.format(cal.get(Calendar.YEAR)) + " - " +
+ dfmt.format(cal.get(Calendar.HOUR_OF_DAY)) + ":" +
+ dfmt.format(cal.get(Calendar.MINUTE)) + ":" +
+ dfmt.format(cal.get(Calendar.SECOND)));
+ super.flush();
+ }
+
+ public boolean initialize(share.DescEntry entry, boolean logging) {
+ this.logging = logging;
+ this.entry = entry;
+ return true;
+ }
+
+
+ public void addFileLog(String filePath){
+ try{
+ if(mFileWriters == null)
+ mFileWriters = new HashMap();
+ mFileWriters.put(filePath, new FileWriter(filePath));
+ }catch(IOException e ){
+ e.printStackTrace(this);
+ }
+ }
+
+
+ public void removeFileLog(String filePath){
+ if(filePath != null)
+ mFileWriters.remove(filePath);
+ }
+
+
+ public void println(String msg) {
+
+ this.ow = (share.Watcher) entry.UserDefinedParams.get("Watcher");
+
+ if (ow != null) {
+ ow.ping();
+ }
+ if (logging) {
+
+ // logoutput to console
+ super.println("LOG> "+msg);
+ super.flush();
+
+ //logoutput to file
+ if(mFileWriters != null && mFileWriters.size() > 0){
+ try{
+ FileWriter fw = null;
+ Iterator iter = mFileWriters.values().iterator();
+ while(iter.hasNext()){
+ fw = (FileWriter) iter.next();
+ fw.write("LOG> " + msg + "\n");
+ fw.flush();
+ }
+ }catch(IOException e ){
+ e.printStackTrace(this);
+ }
+ }
+ }
+ }
+
+ public boolean summary(share.DescEntry entry) {
+ String header = "***** State for "+entry.longName+" ******";
+ System.out.println(header);
+ if (entry.hasErrorMsg) {
+ System.out.println(entry.ErrorMsg);
+ System.out.println("Whole "+entry.EntryType+": "+entry.State);
+ } else {
+ System.out.println("Whole "+entry.EntryType+": "+entry.State);
+ }
+ for (int i=0;i<header.length();i++) {
+ System.out.print("*");
+ }
+ System.out.println("");
+ return true;
+ }
+
+ public Object getWatcher() {
+ return this.ow;
+ }
+
+ public void setWatcher(Object watcher) {
+ entry.UserDefinedParams.put("Watcher", (share.Watcher) watcher);
+ }
+
+}
diff --git a/qadevOOo/runner/stats/InternalLogWriter.java b/qadevOOo/runner/stats/InternalLogWriter.java
new file mode 100644
index 000000000000..b3c71217fb64
--- /dev/null
+++ b/qadevOOo/runner/stats/InternalLogWriter.java
@@ -0,0 +1,124 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package stats;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+
+/**
+ * Write all logs into a java.io.PrintWriter, i.e. a StringBuffer.
+ * Log is gathered there.
+ */
+public class InternalLogWriter extends PrintWriter
+ implements share.LogWriter {
+ /** log active **/
+ boolean active;
+ /** write all output to a StringBuffer **/
+ static StringWriter writer = new StringWriter();
+
+ /**
+ * c'*tor
+ */
+ public InternalLogWriter() {
+ super(new PrintWriter(writer));
+ active = true;
+ }
+
+ /**
+ * Initialization.
+ * @param entry The description entry.
+ * @param active Logging is active.
+ * @return True, if initialize worked.
+ */
+ public boolean initialize(share.DescEntry entry, boolean active) {
+ this.active = active;
+ return true;
+ }
+
+ /**
+ * Method to print a line that is added to the StringBuffer.
+ * @param msg The message that is printed.
+ */
+ public void println(String msg) {
+ if (active)
+ super.println(msg);
+ }
+
+ /**
+ * Method to print to the StringBuffer.
+ * @param msg The message that is printed.
+ */
+ public void print(String msg) {
+ if (active)
+ super.print(msg);
+
+ }
+
+ /**
+ * Is used to sum up the information.
+ * The summary is also added to the StringBuffer.
+ * @param entry The description entry.
+ * @return True, if a summary could be created.
+ */
+ public boolean summary(share.DescEntry entry) {
+// linePrefix = "";
+ String header = "***** State for "+entry.longName+" ******";
+ println(header);
+ if (entry.hasErrorMsg) {
+ println(entry.ErrorMsg);
+ println("Whole "+entry.EntryType+": "+entry.State);
+ } else {
+ println("Whole "+entry.EntryType+": "+entry.State);
+ }
+ for (int i=0;i<header.length();i++) {
+ print("*");
+ }
+ println("");
+ return true;
+ }
+
+ /**
+ * Return all the written stuff.
+ * @return All that was written to the StringBuffer with the
+ * 'println()', 'print()' and 'summarize()' methods.
+ * The StringBuffer is emptied afterwards.
+ **/
+ public String getLog() {
+ String message = writer.getBuffer().toString();
+ writer = new StringWriter();
+ return message;
+ }
+
+ public Object getWatcher() {
+ return null;
+ }
+
+ public void setWatcher(Object watcher) {
+ }
+
+}
+
diff --git a/qadevOOo/runner/stats/OutProducerFactory.java b/qadevOOo/runner/stats/OutProducerFactory.java
new file mode 100644
index 000000000000..ca569631f409
--- /dev/null
+++ b/qadevOOo/runner/stats/OutProducerFactory.java
@@ -0,0 +1,137 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package stats;
+
+import share.LogWriter;
+import java.util.Hashtable;
+import util.DynamicClassLoader;
+
+/**
+ * A factory class for creating out producers.
+ */
+public class OutProducerFactory {
+
+ /**
+ * Create an out producer. The type that is created depends on the
+ * parameters given. These are:
+ * <ul>
+ * <li>DataBaseOut - If set to true, a database outproducer is created.
+ * <li>OutProducer - The value of this parameter names the class that is created.
+ * </ul>
+ * @param Parameters of the test.
+ * @return The created out producer.
+ */
+ public static LogWriter createOutProducer(Hashtable param) {
+ LogWriter dbOut = null;
+ boolean getDatabase = convertToBool(param.get("DataBaseOut"));
+ if (getDatabase) {
+ dbOut = createDataBaseOutProducer(param);
+ }
+ if (dbOut == null) {
+ DynamicClassLoader dcl = new DynamicClassLoader();
+ String outProducerName = (String)param.get("OutProducer");
+ if (outProducerName != null) {
+ try {
+ dbOut = (LogWriter)dcl.getInstance(outProducerName);
+ }
+ catch(IllegalArgumentException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ if (dbOut == null) {
+ dbOut = createSimpleOutProducer();
+ }
+ return dbOut;
+ }
+
+ /**
+ * Create a databbase out producer.
+ * @param The test parameters
+ * @return The database out producer, or null if it couldn't be created.
+ */
+ public static LogWriter createDataBaseOutProducer(Hashtable param) {
+ String dataProducerName = (String)param.get("DataBaseOutProducer");
+ if (dataProducerName == null) {
+ String testBaseName = (String)param.get("TestBase");
+ dataProducerName = testBaseName.substring(testBaseName.indexOf("_")+1);
+ dataProducerName = "stats." + makeFirstCharUpperCase(dataProducerName)
+ + "DataBaseOutProducer";
+ }
+ DynamicClassLoader dcl = new DynamicClassLoader();
+ LogWriter dbOut = null;
+ try {
+ dbOut = (LogWriter)dcl.getInstance(dataProducerName,
+ new Class[]{new Hashtable().getClass()}, new Object[]{param});
+ }
+ catch(IllegalArgumentException e) {
+ e.printStackTrace();
+ }
+ return dbOut;
+ }
+
+ /**
+ * As a fallback, create a simple out producer, if all else failed.
+ * @return A simple out producer, writing to the screen.
+ */
+ public static LogWriter createSimpleOutProducer() {
+ return new SimpleOutProducer();
+ }
+
+ private static boolean convertToBool(Object val) {
+ if(val != null) {
+ if ( val instanceof String ) {
+ String sVal = (String)val;
+ if ( sVal.equalsIgnoreCase("true") || sVal.equalsIgnoreCase("yes") ) {
+ return true;
+ }
+
+ }
+ else if (val instanceof Boolean) {
+ return ((Boolean)val).booleanValue();
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Make the first character to an upper case char.
+ * @param name The String to change
+ * @return The String with an upper case first char.
+ */
+ private static String makeFirstCharUpperCase(String name) {
+ return name.substring(0,1).toUpperCase() + name.substring(1);
+ }
+
+/* public static void main(String[] args) {
+ Hashtable p = new Hashtable();
+ p.put("DataBaseOut", "yes");
+ p.put("TestBase", "java_complex");
+ p.put("Version", "srx645gggg");
+ createDataBaseOutProducer(p);
+ } */
+}
diff --git a/qadevOOo/runner/stats/SQLExecution.java b/qadevOOo/runner/stats/SQLExecution.java
new file mode 100644
index 000000000000..c55da50327a6
--- /dev/null
+++ b/qadevOOo/runner/stats/SQLExecution.java
@@ -0,0 +1,337 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package stats;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.ResultSet;
+import java.sql.ResultSetMetaData;
+import java.sql.Statement;
+import java.util.Enumeration;
+import java.util.Hashtable;
+import java.util.StringTokenizer;
+import java.util.Vector;
+
+/**
+ *
+ */
+public class SQLExecution {
+
+ protected Connection mConnection = null;
+ protected Statement mStatement = null;
+ protected String mJdbcClass = null;
+ protected String mDbURL = null;
+ protected String mUser = null;
+ protected String mPassword = null;
+ protected boolean m_bConnectionOpen = false;
+ protected boolean m_bDebug = false;
+
+
+ /** Creates a new instance of SQLExecution
+ * @param jdbcClass The jdbc class for the connection.
+ * @param dbUrl The url of the database.
+ * @param user The user for connecting the database.
+ * @param password The password of throws user.
+ */
+ public SQLExecution(String jdbcClass, String dbUrl, String user, String password) {
+ mJdbcClass = jdbcClass;
+ mUser = user;
+ mPassword = password;
+ mDbURL = dbUrl;
+ }
+
+ /** Creates a new instance of SQLExecution with additional debug output.
+ * @param jdbcClass The jdbc class for the connection.
+ * @param dbUrl The url of the database.
+ * @param user The user for connecting the database.
+ * @param password The password of throws user.
+ * @param debug Write debug information, if true.
+ */
+ public SQLExecution(String jdbcClass, String dbUrl, String user, String password, boolean debug) {
+ mJdbcClass = jdbcClass;
+ mUser = user;
+ mPassword = password;
+ mDbURL = dbUrl;
+ m_bDebug = debug;
+ }
+
+ /**
+ * Open a connection to the DataBase
+ * @return True, if no error occured.
+ */
+ public boolean openConnection() {
+ if(m_bConnectionOpen) return true;
+ try {
+ Class.forName(mJdbcClass);
+ } catch (ClassNotFoundException e) {
+ System.err.println("Couldn't find jdbc driver : " + e.getMessage());
+ return false;
+ }
+
+ try {
+ // establish database connection
+ mConnection = DriverManager.getConnection(
+ mDbURL, mUser, mPassword);
+ mStatement = mConnection.createStatement();
+ }
+ catch(java.sql.SQLException e) {
+ System.err.println("Couldn't establish a connection: " + e.getMessage());
+ return false;
+ }
+ m_bConnectionOpen = true;
+ return true;
+ }
+
+ /**
+ * Close the connection to the DataBase
+ * @return True, if no error occured.
+ */
+ public boolean closeConnection() {
+ if (!m_bConnectionOpen) return true;
+ try {
+ // close database connection
+ mStatement.close();
+ mConnection.close();
+ }
+ catch(java.sql.SQLException e) {
+ System.err.println("Couldn't close the connection: " + e.getMessage());
+ return false;
+ }
+ m_bConnectionOpen = false;
+ return true;
+ }
+
+ /**
+ * Execute an sql command.
+ * @param command The command to execute.
+ * @param sqlInput Input values for the command.
+ * @param sqlOutput The results of the command are put in this Hashtable.
+ * @return True, if no error occured.
+ */
+ public boolean executeSQLCommand(String command, Hashtable sqlInput, Hashtable sqlOutput)
+ throws IllegalArgumentException {
+ return executeSQLCommand(command, sqlInput, sqlOutput, false);
+ }
+
+ /**
+ * Execute an sql command.
+ * @param command The command to execute.
+ * @param sqlInput Input values for the command.
+ * @param sqlOutput The results of the command are put in this Hashtable.
+ * @param mergeOutputIntoInput The output of the result is put into the
+ * sqlInput Hashtable.
+ * @return True, if no error occured.
+ */
+ public boolean executeSQLCommand(String command, Hashtable sqlInput, Hashtable sqlOutput, boolean mergeOutputIntoInput)
+ throws IllegalArgumentException {
+ if (sqlOutput == null) {
+ sqlOutput = new Hashtable();
+ // this has to be true, so the user of this method gets a return
+ mergeOutputIntoInput = true;
+ if (sqlInput == null) {
+ System.out.println("sqlInput and sqlOutput are null: cannot return the results of the sql command.");
+ return false;
+ }
+ }
+ Vector sqlCommand = new Vector();
+ sqlCommand.add("");
+ boolean update = false;
+ // synchronize all "$varname" occurences in the command string with
+ // values from input
+ StringTokenizer token = new StringTokenizer(command, " ");
+ while (token.hasMoreTokens()) {
+ String originalKey = token.nextToken();
+ // search for keys, beginning with "$"
+ int index = originalKey.indexOf('$');
+ if (index != -1) {
+ // found key
+ String pre = "";
+ pre = originalKey.substring(0,index);
+ // generate key: remove "$"
+ String key = originalKey.substring(index+1);
+ String post = "";
+ // remove any endings the key might have
+ while (key.endsWith(",") || key.endsWith("\'") ||
+ key.endsWith(";") || key.endsWith(")") ||
+ key.endsWith("\"")) {
+ post = key.substring(key.length()-1) + post;
+ key = key.substring(0, key.length()-1);
+ }
+ // look for key in the Hashtable
+ if (sqlInput.containsKey(key)) {
+ // is there a value for the key?
+ Object in = sqlInput.get(key);
+ if (in instanceof String[]) {
+ // value is a String[]
+ String[]vals = (String[])in;
+ if (vals.length != sqlCommand.size() && sqlCommand.size() > 1) {
+ // size of this array and previous array(s) does not match
+ throw new IllegalArgumentException("The key '" + key + "' in command \n'"
+ + command + "'\n has not the same value count as the keys before.");
+ }
+ // build up the commands
+ boolean addNewVals = (sqlCommand.size() == 1);
+ for (int i=0; i<vals.length; i++) {
+ String value = checkForQuotationMarks(vals[i]);
+ // add the values
+ if (addNewVals && i!=0) {
+ // all values until now were of type String, not String[], so now new values have to be added.
+ sqlCommand.add(i, (String)sqlCommand.get(0) + " " + pre + value + post);
+ }
+ else {
+ // we already have vals.length commands (or are at the first command), so just add.
+ sqlCommand.set(i, (String)sqlCommand.get(i) + " " + pre + value + post);
+ }
+ }
+ }
+ else {
+ // value is a String: no other possibility
+ String value = checkForQuotationMarks((String)sqlInput.get(key));
+ for (int i=0; i<sqlCommand.size(); i++) {
+ sqlCommand.set(i, (String)sqlCommand.get(i) + " " + pre + value + post);
+ }
+ }
+ }
+ else {
+ // no input value found
+ throw new IllegalArgumentException ("The key '" + key + "' in command \n'"
+ + command + "'\n does not exist in the input values.");
+ }
+ }
+ else {
+ // token is not a key, just add it
+ for (int i=0; i<sqlCommand.size(); i++)
+ sqlCommand.set(i, (String)sqlCommand.get(i) + " " + originalKey);
+ if (originalKey.equalsIgnoreCase("update") ||
+ originalKey.equalsIgnoreCase("delete") ||
+ originalKey.equalsIgnoreCase("insert")) {
+ update = true;
+ }
+
+ }
+ }
+ for (int i=0;i<sqlCommand.size(); i++) {
+ execute((String)sqlCommand.get(i), sqlOutput, update);
+ // merge output with input
+ if (!update && mergeOutputIntoInput) {
+ Enumeration keys = sqlOutput.keys();
+ while(keys.hasMoreElements()) {
+ String key = (String)keys.nextElement();
+ String[]val = (String[])sqlOutput.get(key);
+ if (val != null && val.length != 0) {
+ if (val.length == 1)
+ sqlInput.put(key, val[0]);
+ else
+ sqlInput.put(key, val);
+ }
+ }
+ }
+ }
+ if (!update && sqlOutput == null)
+ return false;
+ return true;
+ }
+
+ /**
+ * Execute any SQL command.
+ * @param command The command.
+ * @param update If true, it is a update/alter command instead of an select
+ * command
+ * @return A Hashtable with the result.
+ */
+ private void execute(String command, Hashtable output, boolean update) {
+ if (m_bDebug)
+ System.out.println("Debug - SQLExecution - execute Command: " + command);
+ try {
+ if (update) {
+ // make an update
+ mStatement.executeUpdate(command);
+ }
+ else {
+ // make a select: collect the result
+ ResultSet sqlResult = mStatement.executeQuery(command);
+ ResultSetMetaData sqlRSMeta = sqlResult.getMetaData();
+ int columnCount = sqlRSMeta.getColumnCount();
+ String[] columnNames = new String[columnCount];
+ int countRows = 0;
+ boolean goThroughRowsTheFirstTime = true;
+ for(int i=1; i<=columnCount; i++) {
+ columnNames[i-1] = sqlRSMeta.getColumnName(i);
+ // initialize output
+ Vector v = new Vector();
+
+ sqlResult.beforeFirst();
+ while (sqlResult.next()) {
+ String value = sqlResult.getString(i);
+ v.add(value);
+ // the first time: count rows
+ if (goThroughRowsTheFirstTime)
+ countRows++;
+ }
+ // rows are counted
+ if (goThroughRowsTheFirstTime)
+ goThroughRowsTheFirstTime = false;
+
+ // put result in output Hashtable
+ String[]s = new String[countRows];
+ s = (String[])v.toArray(s);
+ output.put(columnNames[i-1], s);
+ if (m_bDebug) {
+ if (i == 1) {
+ System.out.print("Debug - SQLExecution - Command returns: ");
+ System.out.print("row: " + columnNames[i-1] + " vals: ");
+ }
+ for (int j=0; j<s.length; j++)
+ System.out.print(s[j] + " ");
+ if (i == columnCount - 1)
+ System.out.println();
+ }
+ }
+ }
+ }
+ catch (java.sql.SQLException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Replace <"> with <''> in the value Strings, or the command will fail.
+ * @param checkString The String that is checked: a part of the command
+ * @return The String, cleared of all quotation marks.
+ */
+ private String checkForQuotationMarks(String checkString) {
+ String returnString = checkString;
+ int quotIndex = 0;
+ while ((quotIndex = returnString.indexOf('\"')) != -1) {
+ String firstHalf = returnString.substring(0, quotIndex);
+ String secondHalf = returnString.substring(quotIndex+1);
+ returnString = firstHalf + "\'\'" + secondHalf;
+ }
+ return returnString;
+ }
+
+}
diff --git a/qadevOOo/runner/stats/SimpleFileOutProducer.java b/qadevOOo/runner/stats/SimpleFileOutProducer.java
new file mode 100644
index 000000000000..e03cf374e187
--- /dev/null
+++ b/qadevOOo/runner/stats/SimpleFileOutProducer.java
@@ -0,0 +1,114 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package stats;
+
+import share.LogWriter;
+import java.io.File;
+import java.io.FileWriter;
+
+public class SimpleFileOutProducer implements LogWriter {
+
+
+ /** initialization, here a filename might be given
+ * or a dbUrL
+ */
+ public boolean initialize(share.DescEntry entry, boolean active) {
+ return true;
+ }
+
+ /** Method to print
+ */
+ public void println(String msg) {
+
+ }
+
+ /** will mostly be used by outproducers to sum up
+ * the information, maybe write them to a db
+ */
+ public boolean summary(share.DescEntry entry) {
+ try {
+ String outpath = (String) entry.UserDefinedParams.get("OutputPath");
+ if (outpath==null) {
+ System.out.println("## Parameter OutputPath isn't defined using default");
+ return summary_default(entry);
+ }
+ String FileName = entry.longName + ".out";
+ if (!entry.EntryType.equals("component")) {
+ FileName = entry.longName.substring(0,
+ entry.longName.indexOf(":")) + ".out";
+ }
+ util.utils.make_Directories("",outpath);
+ File outputFile = new File(outpath, FileName);
+ FileWriter out = new FileWriter(outputFile.toString(),true);
+ String ls = System.getProperty("line.separator");
+ String date = new java.util.Date().toString();
+ String header = "***** State for "+entry.longName+"( "+ date +" ) ******";
+ out.write(header+ls);
+ if (entry.hasErrorMsg) {
+ out.write(entry.ErrorMsg+ls);
+ out.write("Whole "+entry.EntryType+": "+entry.State+ls);
+ } else {
+ out.write("Whole "+entry.EntryType+": "+entry.State+ls);
+ }
+ String bottom="";
+ for (int i=0;i<header.length();i++) {
+ bottom += "*";
+ }
+ out.write(bottom+ls);
+ out.write(""+ls);
+ out.close();
+ } catch (java.io.IOException e) {
+
+ }
+ return true;
+ }
+
+ public boolean summary_default(share.DescEntry entry) {
+ String header = "***** State for "+entry.longName+" ******";
+ System.out.println(header);
+ if (entry.hasErrorMsg) {
+ System.out.println(entry.ErrorMsg);
+ System.out.println("Whole "+entry.EntryType+": "+entry.State);
+ } else {
+ System.out.println("Whole "+entry.EntryType+": "+entry.State);
+ }
+ for (int i=0;i<header.length();i++) {
+ System.out.print("*");
+ }
+ System.out.println("");
+ return true;
+ }
+
+ public Object getWatcher() {
+ return null;
+ }
+
+ public void setWatcher(Object watcher) {
+ }
+
+}
diff --git a/qadevOOo/runner/stats/SimpleLogWriter.java b/qadevOOo/runner/stats/SimpleLogWriter.java
new file mode 100644
index 000000000000..9bdfb30fe223
--- /dev/null
+++ b/qadevOOo/runner/stats/SimpleLogWriter.java
@@ -0,0 +1,111 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package stats;
+
+import share.LogWriter;
+
+import java.io.PrintWriter;
+import java.text.DecimalFormat;
+import java.util.Calendar;
+import java.util.GregorianCalendar;
+
+public class SimpleLogWriter extends PrintWriter implements LogWriter {
+
+ boolean m_bLogging = false;
+ share.DescEntry entry = null;
+ share.Watcher ow = null;
+
+ public SimpleLogWriter() {
+ super(System.out);
+ Calendar cal = new GregorianCalendar();
+ DecimalFormat dfmt = new DecimalFormat("00");
+ super.println("LOG> Log started " +
+ dfmt.format(cal.get(Calendar.DAY_OF_MONTH)) + "." +
+ dfmt.format(cal.get(Calendar.MONTH)) + "." +
+ dfmt.format(cal.get(Calendar.YEAR)) + " - " +
+ dfmt.format(cal.get(Calendar.HOUR_OF_DAY)) + ":" +
+ dfmt.format(cal.get(Calendar.MINUTE)) + ":" +
+ dfmt.format(cal.get(Calendar.SECOND)));
+ super.flush();
+ }
+
+ public boolean initialize(share.DescEntry _entry, boolean _bLogging) {
+ m_bLogging = _bLogging;
+ entry = _entry;
+
+ return true;
+ }
+
+ public void println(String msg) {
+ if ((ow == null) && (entry != null))
+ {
+ this.ow = (share.Watcher) entry.UserDefinedParams.get("Watcher");
+ if (this.ow != null)
+ {
+ this.ow.ping();
+ }
+ }
+ else
+ {
+ if (ow != null)
+ {
+ this.ow.ping();
+ }
+ else
+ {
+ // special case: ow == null && entry == null
+ System.out.println(msg);
+ }
+ }
+
+ if (m_bLogging) {
+ super.println("LOG> " + msg);
+ super.flush();
+ }
+ // else
+ // {
+ // super.println(" ++ " + msg);
+ // super.flush();
+ // }
+ }
+
+ public boolean summary(share.DescEntry entry) {
+ return true;
+ }
+
+ public Object getWatcher() {
+ return this.ow;
+ }
+
+ public void setWatcher(Object watcher)
+ {
+ if (watcher != null)
+ {
+ entry.UserDefinedParams.put("Watcher", (share.Watcher) watcher);
+ }
+ }
+}
diff --git a/qadevOOo/runner/stats/SimpleOutProducer.java b/qadevOOo/runner/stats/SimpleOutProducer.java
new file mode 100644
index 000000000000..4c91233e6f67
--- /dev/null
+++ b/qadevOOo/runner/stats/SimpleOutProducer.java
@@ -0,0 +1,77 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package stats;
+
+import share.LogWriter;
+/**
+ *
+ * @author sw93809
+ */
+public class SimpleOutProducer implements LogWriter {
+
+
+ /** initialization, here a filename might be given
+ * or a dbUrL
+ */
+ public boolean initialize(share.DescEntry entry, boolean active) {
+ return true;
+ }
+
+ /** Method to print
+ */
+ public void println(String msg) {
+
+ }
+
+ /** will mostly be used by outproducers to sum up
+ * the information, maybe write them to a db
+ */
+ public boolean summary(share.DescEntry entry) {
+ String header = "***** State for "+entry.longName+" ******";
+ System.out.println(header);
+ if (entry.hasErrorMsg) {
+ System.out.println(entry.ErrorMsg);
+ System.out.println("Whole "+entry.EntryType+": "+entry.State);
+ } else {
+ System.out.println("Whole "+entry.EntryType+": "+entry.State);
+ }
+ for (int i=0;i<header.length();i++) {
+ System.out.print("*");
+ }
+ System.out.println("");
+ return true;
+ }
+
+ public Object getWatcher() {
+ return null;
+ }
+
+ public void setWatcher(Object watcher) {
+ }
+
+}
diff --git a/qadevOOo/runner/stats/Summarizer.java b/qadevOOo/runner/stats/Summarizer.java
new file mode 100644
index 000000000000..b1fe5fe61dd3
--- /dev/null
+++ b/qadevOOo/runner/stats/Summarizer.java
@@ -0,0 +1,114 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package stats;
+
+import java.util.Vector;
+import share.DescEntry;
+
+/**
+ *
+ * this class summs up the results of the subentries of a given DescEntry<br>
+ * and fills the subentries in cases of SKIPPED states
+ */
+public class Summarizer
+{
+
+ /**
+ *
+ * gets the state for a SuperEntry according to its subentries
+ * @param entry
+ */
+ public void summarizeUp(DescEntry entry)
+ {
+ if ((entry.State != null) && !entry.State.equals("UNKNOWN"))
+ {
+ return;
+ }
+ int count = entry.SubEntryCount;
+ int knownIssues = 0;
+ Vector failures = new Vector();
+ Vector states = new Vector();
+ for (int i = 0; i < count; i++)
+ {
+ if (entry.SubEntries[i].State == null)
+ {
+ entry.SubEntries[i].State = "PASSED.FAILED";
+ }
+ if (entry.SubEntries[i].State.equals("known issue"))
+ {
+ entry.SubEntries[i].State = "PASSED.OK";
+ knownIssues++;
+ }
+ if (!entry.SubEntries[i].State.endsWith("OK"))
+ {
+ String sFailure = "[" + entry.SubEntries[i].longName + "]" + " is testcode: [" + entry.SubEntries[i].entryName + "]";
+ failures.add(sFailure);
+ states.add(entry.SubEntries[i].State);
+ }
+ }
+ if (failures.size() > 0)
+ {
+ String errMsg = "";
+ String state = "PASSED.FAILED";
+ for (int j = 0; j < failures.size(); j++)
+ {
+ if (states.elementAt(j).equals("not part of the job"))
+ {
+ state = "Not possible since not all Interfaces/Services have been checked";
+ }
+ else
+ {
+ errMsg +=
+ failures.elementAt(j) + " - " + states.elementAt(j) + "\r\n";
+ }
+ }
+ entry.hasErrorMsg = true;
+ entry.ErrorMsg = errMsg;
+ entry.State = state;
+ }
+ else if (entry.EntryType.equals("component") && knownIssues > 0)
+ {
+ entry.State = "PASSED(with known issues).OK";
+ }
+ else
+ {
+ entry.State = "PASSED.OK";
+ }
+ }
+
+ public static void summarizeDown(DescEntry entry, String state)
+ {
+ if ((entry.State == null) || entry.State.equals("UNKNOWN"))
+ {
+ entry.State = state;
+ }
+ for (int i = 0; i < entry.SubEntryCount; i++)
+ {
+ summarizeDown(entry.SubEntries[i], entry.State);
+ }
+ }
+}
diff --git a/qadevOOo/runner/stats/makefile.mk b/qadevOOo/runner/stats/makefile.mk
new file mode 100644
index 000000000000..af503a229038
--- /dev/null
+++ b/qadevOOo/runner/stats/makefile.mk
@@ -0,0 +1,59 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..
+
+PRJNAME = OOoRunner
+PACKAGE = stats
+TARGET = runner_stats
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+# --- Files --------------------------------------------------------
+
+JARFILES = ridl.jar jurt.jar unoil.jar
+
+JAVAFILES = \
+ DataBaseOutProducer.java \
+ ComplexDataBaseOutProducer.java \
+ FatDataBaseOutProducer.java \
+ FileLogWriter.java \
+ OutProducerFactory.java \
+ SQLExecution.java \
+ SimpleOutProducer.java \
+ SimpleFileOutProducer.java \
+ SimpleLogWriter.java \
+ Summarizer.java \
+ InternalLogWriter.java
+
+JAVACLASSFILES= $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class)
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
diff --git a/qadevOOo/runner/util/AccessibilityTools.java b/qadevOOo/runner/util/AccessibilityTools.java
new file mode 100644
index 000000000000..3fb964a2362b
--- /dev/null
+++ b/qadevOOo/runner/util/AccessibilityTools.java
@@ -0,0 +1,461 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package util;
+
+import com.sun.star.accessibility.XAccessible;
+import com.sun.star.accessibility.XAccessibleComponent;
+import com.sun.star.accessibility.XAccessibleContext;
+import com.sun.star.awt.XWindow;
+import com.sun.star.frame.XController;
+import com.sun.star.frame.XFrame;
+import com.sun.star.frame.XModel;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XInterface;
+
+import java.io.PrintWriter;
+
+
+public class AccessibilityTools {
+ public static XAccessibleContext SearchedContext = null;
+ public static XAccessible SearchedAccessible = null;
+ private static boolean debug = false;
+
+ public AccessibilityTools() {
+ //done = false;
+ SearchedContext = null;
+ }
+
+ public static XAccessible getAccessibleObject(XInterface xObject) {
+ return UnoRuntime.queryInterface(XAccessible.class, xObject);
+ }
+
+ public static XWindow getCurrentContainerWindow(XMultiServiceFactory msf,
+ XModel xModel) {
+ return getWindow(msf, xModel, true);
+ }
+
+ public static XWindow getCurrentWindow(XMultiServiceFactory msf,
+ XModel xModel) {
+ return getWindow(msf, xModel, false);
+ }
+
+ private static XWindow getWindow(XMultiServiceFactory msf, XModel xModel,
+ boolean containerWindow) {
+ XWindow xWindow = null;
+
+ try {
+ if (xModel == null) {
+ System.out.println("invalid model (==null)");
+ }
+
+ XController xController = xModel.getCurrentController();
+
+ if (xController == null) {
+ System.out.println("can't get controller from model");
+ }
+
+ XFrame xFrame = xController.getFrame();
+
+ if (xFrame == null) {
+ System.out.println("can't get frame from controller");
+ }
+
+ if (containerWindow)
+ xWindow = xFrame.getContainerWindow();
+ else
+ xWindow = xFrame.getComponentWindow();
+
+ if (xWindow == null) {
+ System.out.println("can't get window from frame");
+ }
+ } catch (Exception e) {
+ System.out.println("caught exception while getting current window" + e);
+ }
+
+ return xWindow;
+ }
+
+ public static XAccessibleContext getAccessibleObjectForRole(XAccessible xacc,
+ short role) {
+ SearchedContext = null;
+ SearchedAccessible = null;
+ getAccessibleObjectForRole_(xacc, role);
+
+ return SearchedContext;
+ }
+
+ public static XAccessibleContext getAccessibleObjectForRole(XAccessible xacc,
+ short role,
+ boolean ignoreShowing) {
+ SearchedContext = null;
+ SearchedAccessible = null;
+
+ if (ignoreShowing) {
+ getAccessibleObjectForRoleIgnoreShowing_(xacc, role);
+ } else {
+ getAccessibleObjectForRole_(xacc, role);
+ }
+
+ return SearchedContext;
+ }
+
+ public static void getAccessibleObjectForRoleIgnoreShowing_(XAccessible xacc,
+ short role) {
+ XAccessibleContext ac = xacc.getAccessibleContext();
+
+ if (ac.getAccessibleRole() == role) {
+ SearchedContext = ac;
+ SearchedAccessible = xacc;
+ } else {
+ int k = ac.getAccessibleChildCount();
+
+ if (ac.getAccessibleChildCount() > 100) {
+ k = 50;
+ }
+
+ for (int i = 0; i < k; i++) {
+ try {
+ getAccessibleObjectForRoleIgnoreShowing_(
+ ac.getAccessibleChild(i), role);
+
+ if (SearchedContext != null) {
+ return;
+ }
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
+ System.out.println("Couldn't get Child");
+ }
+ }
+ }
+ }
+
+ public static void getAccessibleObjectForRole_(XAccessible xacc,
+ short role) {
+ XAccessibleContext ac = xacc.getAccessibleContext();
+ boolean isShowing = ac.getAccessibleStateSet()
+ .contains(com.sun.star.accessibility.AccessibleStateType.SHOWING);
+
+ if ((ac.getAccessibleRole() == role) && isShowing) {
+ SearchedContext = ac;
+ SearchedAccessible = xacc;
+ } else {
+ int k = ac.getAccessibleChildCount();
+
+ if (ac.getAccessibleChildCount() > 100) {
+ k = 50;
+ }
+
+ for (int i = 0; i < k; i++) {
+ try {
+ getAccessibleObjectForRole_(ac.getAccessibleChild(i), role);
+
+ if (SearchedContext != null) {
+ return;
+ }
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
+ System.out.println("Couldn't get Child");
+ }
+ }
+ }
+ }
+
+ public static XAccessibleContext getAccessibleObjectForRole(XAccessible xacc,
+ short role,
+ String name) {
+ return getAccessibleObjectForRole(xacc, role, name, "");
+ }
+
+ public static XAccessibleContext getAccessibleObjectForRole(XAccessible xacc,
+ short role,
+ String name,
+ boolean ignoreShowing) {
+ if (ignoreShowing) {
+ return getAccessibleObjectForRoleIgnoreShowing(xacc, role, name,
+ "");
+ } else {
+ return getAccessibleObjectForRole(xacc, role, name, "");
+ }
+ }
+
+ public static XAccessibleContext getAccessibleObjectForRoleIgnoreShowing(XAccessible xacc,
+ short role,
+ String name,
+ String implName) {
+ XAccessibleContext ac = xacc.getAccessibleContext();
+ if ((ac.getAccessibleRole() == role) &&
+ (ac.getAccessibleName().indexOf(name) > -1) &&
+ (utils.getImplName(ac).indexOf(implName) > -1)) {
+ SearchedAccessible = xacc;
+
+ //System.out.println("FOUND the desired component -- "+ ac.getAccessibleName() +isShowing);
+ return ac;
+ } else {
+ int k = ac.getAccessibleChildCount();
+
+ if (ac.getAccessibleChildCount() > 100) {
+ k = 50;
+ }
+
+ for (int i = 0; i < k; i++) {
+ try {
+ XAccessibleContext ac1 = getAccessibleObjectForRoleIgnoreShowing(
+ ac.getAccessibleChild(i),
+ role, name, implName);
+
+ if (ac1 != null) {
+ return ac1;
+ }
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
+ System.out.println("Couldn't get Child");
+ }
+ }
+ }
+
+ return null;
+ }
+
+ public static XAccessibleContext getAccessibleObjectForRole(XAccessible xacc,
+ short role,
+ String name,
+ String implName) {
+ XAccessibleContext ac = xacc.getAccessibleContext();
+ boolean isShowing = ac.getAccessibleStateSet()
+ .contains(com.sun.star.accessibility.AccessibleStateType.SHOWING);
+
+ // hotfix for i91828:
+ // if role to serach is 0 then ignore the role.
+ if ( (role == 0 || ac.getAccessibleRole() == role) &&
+ (ac.getAccessibleName().indexOf(name) > -1) &&
+ (utils.getImplName(ac).indexOf(implName) > -1) &&
+ isShowing) {
+ SearchedAccessible = xacc;
+ //System.out.println("FOUND the desired component -- "+ ac.getAccessibleName() +isShowing);
+ return ac;
+ } else {
+ int k = ac.getAccessibleChildCount();
+
+ if (ac.getAccessibleChildCount() > 100) {
+ k = 50;
+ }
+
+ for (int i = 0; i < k; i++) {
+ try {
+ XAccessibleContext ac1 = getAccessibleObjectForRole(
+ ac.getAccessibleChild(i),
+ role, name, implName);
+
+ if (ac1 != null) {
+ return ac1;
+ }
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
+ System.out.println("Couldn't get Child");
+ }
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * This methods retunrs the <CODE>XAccessibleContext</CODE> of a named Sheet-Cell like "G5".<p>
+ * @param xSheetAcc The <CODE>XAccessibleContext</CODE> of a Sheet
+ * @param cellName The name of a cell like "A5"
+ * @return the <CODE>XAccessiblecontext</CODE> of the named cell
+ */
+ public static XAccessibleContext getSheetCell(XAccessibleContext xSheetAcc, String cellName){
+
+ int cellIndex = 0;
+ int column =0;
+ int charMem = 0;
+ for (int n=0; n<cellName.length(); n++){
+ String cha = cellName.substring(n,n+1);
+ System.out.println("char: " + cha + " ");
+
+ byte[] bytes = cha.getBytes();
+
+ if ((bytes[0] >= 'A') && (bytes[0] <= 'Z')){
+ charMem = bytes[0]-64;
+ column++;
+ if ( column == 2 ){
+ cellIndex += charMem * 26;
+ }
+ cellIndex= cellIndex+ (bytes[0]-65);
+ } else {
+ String sNumb = cellName.substring(n, cellName.length());
+ int iNumb = new Integer(0).valueOf(sNumb).intValue();
+ cellIndex += (iNumb-1) * 256;
+ System.out.println("numb:" + (iNumb-1) * 256);
+ }
+
+ }
+
+ //System.out.println("cellName: " + cellName + " cellIndex: " + cellIndex);
+
+ try {
+ XAccessibleContext ac = xSheetAcc.getAccessibleChild(cellIndex).getAccessibleContext();
+ System.out.println(ac.getAccessibleRole() + "," +
+ ac.getAccessibleName() + "(" +
+ ac.getAccessibleDescription() + "):" +
+ utils.getImplName(ac));
+
+ return ac;
+ } catch (com.sun.star.lang.IndexOutOfBoundsException ex) {
+ System.out.println("ERROR: could not get child at index " + cellIndex +"': " + ex.toString());
+ return null;
+ }
+ }
+
+ public static void printAccessibleTree(PrintWriter log, XAccessible xacc, boolean debugIsActive) {
+ debug = debugIsActive;
+ if (debug) printAccessibleTree(log, xacc, "");
+ }
+
+ public static void printAccessibleTree(PrintWriter log, XAccessible xacc) {
+ printAccessibleTree(log, xacc, "");
+ }
+
+ protected static void printAccessibleTree(PrintWriter log,
+ XAccessible xacc, String indent) {
+
+ XAccessibleContext ac = xacc.getAccessibleContext();
+
+ logging(log,indent + ac.getAccessibleRole() + "," +
+ ac.getAccessibleName() + "(" +
+ ac.getAccessibleDescription() + "):" +
+ utils.getImplName(ac));
+
+ XAccessibleComponent aComp = (XAccessibleComponent) UnoRuntime.queryInterface(
+ XAccessibleComponent.class, xacc);
+
+ if (aComp != null) {
+ String bounds = "(" + aComp.getBounds().X + "," +
+ aComp.getBounds().Y + ")" + " (" +
+ aComp.getBounds().Width + "," +
+ aComp.getBounds().Height + ")";
+ bounds = "The boundary Rectangle is " + bounds;
+ logging(log,indent + indent + bounds);
+ }
+
+ boolean isShowing = ac.getAccessibleStateSet()
+ .contains(com.sun.star.accessibility.AccessibleStateType.SHOWING);
+ logging(log,indent + indent + "StateType contains SHOWING: " +
+ isShowing);
+
+ int k = ac.getAccessibleChildCount();
+
+ if (ac.getAccessibleChildCount() > 100) {
+ k = 50;
+ }
+
+ for (int i = 0; i < k; i++) {
+ try {
+ printAccessibleTree(log, ac.getAccessibleChild(i),
+ indent + " ");
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
+ System.out.println("Couldn't get Child");
+ }
+ }
+
+ if (ac.getAccessibleChildCount() > 100) {
+ k = ac.getAccessibleChildCount();
+
+ int st = ac.getAccessibleChildCount() - 50;
+ logging(log,indent + " " + " ...... [skipped] ......");
+
+ for (int i = st; i < k; i++) {
+ try {
+ printAccessibleTree(log, ac.getAccessibleChild(i),
+ indent + " ");
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
+ System.out.println("Couldn't get Child");
+ }
+ }
+ }
+ }
+
+ public static String accessibleToString(Object AC) {
+ XAccessibleContext xAC = (XAccessibleContext) UnoRuntime.queryInterface(
+ XAccessibleContext.class, AC);
+
+ if (xAC != null) {
+ return "" + xAC.getAccessibleRole() + "," +
+ xAC.getAccessibleName() + "(" +
+ xAC.getAccessibleDescription() + "):";
+ }
+
+ XAccessible xA = (XAccessible) UnoRuntime.queryInterface(
+ XAccessible.class, AC);
+
+ if (xA == null) {
+ return "(Not supported)";
+ }
+
+ xAC = xA.getAccessibleContext();
+
+ return "" + xAC.getAccessibleRole() + "," + xAC.getAccessibleName() +
+ "(" + xAC.getAccessibleDescription() + ")";
+ }
+
+ public static boolean equals(XAccessible c1, XAccessible c2) {
+ if ((c1 == null) || (c2 == null)) {
+ return c1 == c2;
+ }
+
+ return AccessibilityTools.equals(c1.getAccessibleContext(),
+ c2.getAccessibleContext());
+ }
+
+ public static boolean equals(XAccessibleContext c1, XAccessibleContext c2) {
+ if ((c1 == null) || (c2 == null)) {
+ return c1 == c2;
+ }
+
+ if (c1.getAccessibleRole() != c2.getAccessibleRole()) {
+ return false;
+ }
+
+ if (!c1.getAccessibleName().equals(c2.getAccessibleName())) {
+ return false;
+ }
+
+ if (!c1.getAccessibleDescription()
+ .equals(c2.getAccessibleDescription())) {
+ return false;
+ }
+
+ if (c1.getAccessibleChildCount() != c2.getAccessibleChildCount()) {
+ return false;
+ }
+
+ return AccessibilityTools.equals(c1.getAccessibleParent(),
+ c2.getAccessibleParent());
+ }
+
+ private static void logging(PrintWriter log, String content){
+ if (debug) log.println(content);
+ }
+} \ No newline at end of file
diff --git a/qadevOOo/runner/util/BasicMacroTools.java b/qadevOOo/runner/util/BasicMacroTools.java
new file mode 100644
index 000000000000..0d64779137f7
--- /dev/null
+++ b/qadevOOo/runner/util/BasicMacroTools.java
@@ -0,0 +1,261 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package util;
+
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.container.XNameAccess;
+import com.sun.star.frame.XController;
+import com.sun.star.frame.XDispatch;
+import com.sun.star.frame.XDispatchProvider;
+import com.sun.star.frame.XFrame;
+import com.sun.star.frame.XModel;
+import com.sun.star.lang.XComponent;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.script.XLibraryContainer;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.util.*;
+import com.sun.star.util.URL;
+import com.sun.star.util.XURLTransformer;
+
+
+
+public class BasicMacroTools {
+ private final XDispatchProvider mDispProv;
+ private final XMultiServiceFactory mMSF;
+ private final XURLTransformer mParser;
+ private final XNameAccess mLCxNA; //LibraryContainer::XNameAccess
+ private final XLibraryContainer mLCxLC; //LibraryContainer::XLibraryContainer
+
+ /*
+ *While initializing the Basic Libraries will be appendend to the Document
+ */
+ public BasicMacroTools(XMultiServiceFactory msf, XModel xModel,
+ XComponent xDoc) throws java.lang.Exception {
+ try {
+ mMSF = msf;
+ mDispProv = makeDispatchProvider(mMSF, xModel);
+ mParser = makeParser(mMSF);
+
+ Object DocLibCont = null;
+
+ try {
+ XPropertySet xDocProps = (XPropertySet) UnoRuntime.queryInterface(
+ XPropertySet.class, xDoc);
+ DocLibCont = xDocProps.getPropertyValue("BasicLibraries");
+ } catch (com.sun.star.uno.Exception e) {
+ throw new Exception(
+ "Couldn't get BasicLibraries-Container from document: " + e.toString());
+ }
+
+ mLCxNA = (XNameAccess) UnoRuntime.queryInterface(XNameAccess.class,
+ DocLibCont);
+
+ mLCxLC = (XLibraryContainer) UnoRuntime.queryInterface(
+ XLibraryContainer.class, DocLibCont);
+
+ } catch (Exception e) {
+ throw new Exception("could not initialize BasicMacros " +
+ e.toString());
+ }
+ }
+
+ /*
+ * While initializing the Basic Libraries will be appendend to the Office
+ */
+ public BasicMacroTools(XMultiServiceFactory msf, XModel xModel)
+ throws java.lang.Exception {
+ try {
+ mMSF = msf;
+ mDispProv = makeDispatchProvider(mMSF, xModel);
+ mParser = makeParser(mMSF);
+
+ Object ASLC = null;
+
+ try {
+ ASLC = mMSF.createInstance(
+ "com.sun.star.script.ApplicationScriptLibraryContainer");
+ } catch (com.sun.star.uno.Exception e) {
+ throw new Exception(
+ "Couldn't create ApplicationScriptLibraryContainer" + e.toString());
+ }
+
+ mLCxNA = (XNameAccess) UnoRuntime.queryInterface(XNameAccess.class,
+ ASLC);
+
+ mLCxLC = (XLibraryContainer) UnoRuntime.queryInterface(
+ XLibraryContainer.class, ASLC);
+
+ } catch (Exception e) {
+ throw new Exception("could not initialize BasicMacros " +
+ e.toString());
+ }
+ }
+
+ private static XDispatchProvider makeDispatchProvider(XMultiServiceFactory mMSF,
+ XModel aModel)
+ throws java.lang.Exception {
+ XController xController = aModel.getCurrentController();
+ XFrame xFrame = xController.getFrame();
+
+ if (xFrame == null) {
+ throw new Exception("Could not create DispatchProvider");
+ }
+
+ return (XDispatchProvider) UnoRuntime.queryInterface(
+ XDispatchProvider.class, xFrame);
+ }
+
+ private static XURLTransformer makeParser(XMultiServiceFactory mMSF)
+ throws java.lang.Exception {
+ try {
+ return (com.sun.star.util.XURLTransformer) UnoRuntime.queryInterface(
+ XURLTransformer.class, mMSF.createInstance(
+ "com.sun.star.util.URLTransformer"));
+ } catch (Exception e) {
+ throw new Exception("could not create UTL-Transformer " +
+ e.toString());
+ }
+ }
+
+ public void loadLibrary(String LibraryName, String LibraryURL)
+ throws java.lang.Exception {
+ try {
+ appendLibrary(LibraryName, LibraryURL);
+ } catch (java.lang.Exception e) {
+ e.printStackTrace();
+ throw new Exception("ERROR: Could not append Library " +
+ LibraryName + e.toString());
+ }
+
+ try {
+ mLCxLC.loadLibrary(LibraryName);
+ } catch (com.sun.star.container.NoSuchElementException e) {
+ e.printStackTrace();
+ throw new Exception("ERROR: Could not load Library " +
+ LibraryName + e.toString());
+ } catch (com.sun.star.lang.WrappedTargetException e) {
+ e.printStackTrace();
+ throw new Exception("ERROR: Could not load Library " +
+ LibraryName + e.toString());
+ }
+ }
+
+ private void appendLibrary(String LibraryName, String LibraryURL)
+ throws java.lang.Exception {
+ try {
+ removeLibrary(LibraryName);
+ } catch (java.lang.Exception e) {
+ }
+
+ try {
+ mLCxLC.createLibraryLink(LibraryName, LibraryURL, false);
+ } catch (com.sun.star.container.ElementExistException e) {
+ e.printStackTrace();
+ throw new Exception("ERROR: Library " + LibraryName +
+ "already exist." + e.toString());
+ } catch (com.sun.star.uno.Exception e) {
+ e.printStackTrace();
+ throw new Exception("Could not link Basic library:" +
+ LibraryName + e.toString());
+ }
+ }
+
+ public void removeLibrary(String LibraryName) throws java.lang.Exception {
+ if (mLCxNA.hasByName(LibraryName)) {
+ try {
+ mLCxLC.removeLibrary(LibraryName);
+ } catch (com.sun.star.container.NoSuchElementException e) {
+ e.printStackTrace();
+ throw new Exception("Could not remove Basic library:" +
+ LibraryName + ": Library does not exist" + e.toString());
+ } catch (com.sun.star.lang.WrappedTargetException e) {
+ e.printStackTrace();
+ throw new Exception("Could not remove Basic library:" +
+ LibraryName + e.toString());
+ }
+ }
+ }
+
+ public void runMarco(String MacroName) throws java.lang.Exception {
+ URL[] aParseURL = new URL[1];
+ aParseURL[0] = new URL();
+ aParseURL[0].Complete = "macro://./" + MacroName; //Standard.Stock.GetSymbol('micro','')";
+ mParser.parseStrict(aParseURL);
+
+ URL aURL = aParseURL[0];
+ XDispatch xDispatcher = mDispProv.queryDispatch(aURL, "", 0);
+
+ if (xDispatcher != null) {
+ xDispatcher.dispatch(aURL, null);
+ } else {
+ throw new Exception("Could not run Macro " + MacroName);
+ }
+ }
+
+ /**
+ * Set the given <CODE>secureURL</CODE> as secure URL for marco execution.
+ * The macros of documents located in <CODE>secureURL</CODE> will be executed
+ * automatically.
+ * @param xMSF the XMultiServiceFactory
+ * @param secureURL the URL the documet is located
+ * @throws java.lang.Exception throws this exception on any error
+ */
+ public static void addSecureBasicMarcosURL(XMultiServiceFactory xMSF, String secureURL)
+ throws Exception {
+
+ secureURL = utils.getFullURL(secureURL);
+
+ // configure Office to allow to execute macos
+ PropertyValue[] ProvArgs = new PropertyValue [1];
+ PropertyValue Arg = new PropertyValue();
+ Arg.Name = "nodepath";
+ Arg.Value = "/org.openoffice.Office.Common/Security";
+ ProvArgs[0] = Arg;
+
+ Object oProvider = xMSF.createInstance("com.sun.star.configuration.ConfigurationProvider");
+
+
+ XMultiServiceFactory oProviderMSF = (XMultiServiceFactory)
+ UnoRuntime.queryInterface(XMultiServiceFactory.class, oProvider);
+
+ Object oSecure = oProviderMSF.createInstanceWithArguments(
+ "com.sun.star.configuration.ConfigurationUpdateAccess",
+ ProvArgs);
+
+ XPropertySet oSecureProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, oSecure);
+
+ Object oScripting = oSecureProps.getPropertyValue("Scripting");
+ XPropertySet oScriptingSettings = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, oScripting);
+
+ oScriptingSettings.setPropertyValue("SecureURL", new String[]{secureURL});
+ oScriptingSettings.setPropertyValue("OfficeBasic", new Integer(2));
+
+ XChangesBatch oSecureChange = (XChangesBatch) UnoRuntime.queryInterface(XChangesBatch.class, oSecure);
+ oSecureChange.commitChanges();
+ }
+}
diff --git a/qadevOOo/runner/util/BookmarkDsc.java b/qadevOOo/runner/util/BookmarkDsc.java
new file mode 100644
index 000000000000..5929192ac1df
--- /dev/null
+++ b/qadevOOo/runner/util/BookmarkDsc.java
@@ -0,0 +1,84 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package util;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.uno.XInterface;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.text.XTextContent;
+
+/**
+ * describes a Bookmark to be inserted in a container
+ */
+public class BookmarkDsc extends InstDescr {
+
+ final String service = "com.sun.star.text.Bookmark";
+ String ifcName = "com.sun.star.text.XTextContent";
+ private String name = null;
+
+
+ public BookmarkDsc() {
+ initBookmark();
+ }
+
+ public BookmarkDsc( String name ) {
+ this.name = name;
+ initBookmark();
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getIfcName() {
+ return ifcName;
+ }
+
+ public String getService() {
+ return service;
+ }
+
+ private void initBookmark() {
+ try {
+ ifcClass = Class.forName( ifcName );
+ }
+ catch( ClassNotFoundException cnfE ) {
+ }
+ }
+ public XInterface createInstance( XMultiServiceFactory docMSF ) {
+ Object ServiceObj = null;
+
+ try {
+ ServiceObj = docMSF.createInstance( service );
+ }
+ catch( com.sun.star.uno.Exception cssuE ){
+ }
+ XTextContent BM = (XTextContent)UnoRuntime.queryInterface( ifcClass,
+ ServiceObj );
+ return BM;
+ }
+} \ No newline at end of file
diff --git a/qadevOOo/runner/util/CalcTools.java b/qadevOOo/runner/util/CalcTools.java
new file mode 100644
index 000000000000..08a8b945839a
--- /dev/null
+++ b/qadevOOo/runner/util/CalcTools.java
@@ -0,0 +1,160 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************
+ */
+
+package util;
+
+import com.sun.star.container.XIndexAccess;
+import com.sun.star.lang.IllegalArgumentException;
+import com.sun.star.lang.IndexOutOfBoundsException;
+import com.sun.star.lang.WrappedTargetException;
+import com.sun.star.lang.XComponent;
+import com.sun.star.sheet.XCellRangeData;
+import com.sun.star.sheet.XSpreadsheet;
+import com.sun.star.sheet.XSpreadsheetDocument;
+import com.sun.star.sheet.XSpreadsheets;
+import com.sun.star.table.XCellRange;
+import com.sun.star.uno.AnyConverter;
+import com.sun.star.uno.Exception;
+import com.sun.star.uno.Type;
+import com.sun.star.uno.UnoRuntime;
+
+/**
+ * This class contains some usefull mathods to handle Calc documents
+ * and its sheets.
+ */
+public class CalcTools {
+
+ /**
+ * fills a range of a calc sheet with computed data of type
+ * <CODE>Double</CODE>.
+ * @param xSheetDoc the Clac documents wich should be filled
+ * @param sheetNumber the number of the sheet of <CODE>xSheetDoc</CODE>
+ * @param startCellX the cell number of the X start point (row) of the range to fill
+ * @param startCellY the cell number of the Y start point (column) of the range to fill
+ * @param rangeLengthX the size of the range expansion in X-direction
+ * @param rangeLengthY the size of the range expansion in Y-direction
+ * @throws java.lang.Exception on any error an <CODE>java.lang.Exception</CODE> was thrown
+ */
+ public static void fillCalcSheetWithContent(XComponent xSheetDoc, int sheetNumber,
+ int startCellX, int startCellY, int rangeLengthX, int rangeLengthY)
+ throws java.lang.Exception {
+ try{
+ XSpreadsheet xSheet = getSpreadSheetFromSheetDoc(xSheetDoc, sheetNumber);
+
+ fillCalcSheetWithContent(xSheet, startCellX, startCellY, rangeLengthX, rangeLengthY);
+
+ } catch (Exception e){
+ throw new Exception(
+ "Couldn't fill CalcSheet with content: " + e.toString());
+ }
+ }
+
+ /**
+ * fills a range of a calc sheet with computed data of type
+ * <CODE>Double</CODE>.
+ * @param xSheet the sheet to fill with content
+ * @param startCellX the cell number of the X start point (row) of the range to fill
+ * @param startCellY the cell number of the Y start point (column) of the range to fill
+ * @param rangeLengthX the size of the range expansion in X-direction
+ * @param rangeLengthY the size of the range expansion in Y-direction
+ * @throws java.lang.Exception on any error an <CODE>java.lang.Exception</CODE> was thrown
+ */
+ public static void fillCalcSheetWithContent(XSpreadsheet xSheet,
+ int startCellX, int startCellY, int rangeLengthX, int rangeLengthY)
+ throws java.lang.Exception {
+
+ try{
+ // create a range with content
+ Object[][] newData = new Object[rangeLengthY][rangeLengthX];
+ for (int i=0; i<rangeLengthY; i++) {
+ for (int j=0; j<rangeLengthX; j++) {
+ newData[i][j] = new Double(10*i +j);
+ }
+ }
+ XCellRange xRange = null;
+ try {
+ xRange = xSheet.getCellRangeByPosition(startCellX, startCellY,
+ startCellX+rangeLengthX-1, startCellY+rangeLengthY-1);
+ } catch ( IndexOutOfBoundsException e){
+ throw new Exception(
+ "Couldn't get CellRange from sheett: " + e.toString());
+ }
+
+ XCellRangeData xRangeData = (XCellRangeData) UnoRuntime.queryInterface(XCellRangeData.class, xRange);
+
+ xRangeData.setDataArray(newData);
+ } catch (Exception e){
+ throw new Exception(
+ "Couldn't fill CalcSheet with content: " + e.toString());
+ }
+ }
+
+ /**
+ *
+ * returns an <CODE>XSpreadsheet</CODE> from a Calc document.
+ * @param xSheetDoc the Calc docuent which containes the sheet
+ * @param sheetNumber the number of the sheet to return
+ * @throws java.lang.Exception on any error an <CODE>java.lang.Exception</CODE> was thrown
+ * @return calc sheet
+ * @see com.sun.star.sheet.XSpreadsheet
+ */
+ public static XSpreadsheet getSpreadSheetFromSheetDoc(XComponent xSheetDoc, int sheetNumber)
+ throws java.lang.Exception {
+
+ XSpreadsheet xSheet = null;
+
+ try{
+ XSpreadsheetDocument xSpreadsheetDoc = (XSpreadsheetDocument)
+ UnoRuntime.queryInterface(XSpreadsheetDocument.class, xSheetDoc);
+
+ XSpreadsheets xSpreadsheets = xSpreadsheetDoc.getSheets();
+
+ XIndexAccess xSheetsIndexArray = (XIndexAccess)
+ UnoRuntime.queryInterface(XIndexAccess.class, xSpreadsheets);
+
+ try{
+ xSheet = (XSpreadsheet) AnyConverter.toObject(
+ new Type(XSpreadsheet.class),xSheetsIndexArray.getByIndex(sheetNumber));
+
+ } catch (IllegalArgumentException e){
+ throw new Exception(
+ "Couldn't get sheet '" +sheetNumber + "' : " + e.toString());
+ } catch (IndexOutOfBoundsException e){
+ throw new Exception(
+ "Couldn't get sheet '" +sheetNumber + "' : " + e.toString());
+ } catch (WrappedTargetException e){
+ throw new Exception(
+ "Couldn't get sheet '" +sheetNumber + "' : " + e.toString());
+ }
+ } catch (Exception e){
+ throw new Exception(
+ "Couldn't get sheet '" +sheetNumber + "' : " + e.toString());
+ }
+ return xSheet;
+ }
+}
diff --git a/qadevOOo/runner/util/ControlDsc.java b/qadevOOo/runner/util/ControlDsc.java
new file mode 100644
index 000000000000..f2f1a82e63f4
--- /dev/null
+++ b/qadevOOo/runner/util/ControlDsc.java
@@ -0,0 +1,80 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package util;
+
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.uno.XInterface;
+import com.sun.star.uno.UnoRuntime;
+
+/**
+ * Describes a Control to be inserted in a container
+ */
+
+public class ControlDsc extends InstDescr {
+
+ private String name = null;
+ final String ifcName = "com.sun.star.form.XFormComponent";
+ String service = "com.sun.star.form.component.CommandButton";
+
+ public ControlDsc( String kind ) {
+ service="com.sun.star.form.component."+kind;
+ initControl();
+ }
+ public String getName() {
+ return name;
+ }
+
+ public String getIfcName() {
+ return ifcName;
+ }
+ public String getService() {
+ return service;
+ }
+
+ private void initControl() {
+ try {
+ ifcClass = Class.forName( ifcName );
+ }
+ catch( ClassNotFoundException cnfE ) {
+ }
+ }
+ public XInterface createInstance( XMultiServiceFactory docMSF ) {
+
+ Object SrvObj = null;
+ try {
+ SrvObj = docMSF.createInstance( service );
+ }
+ catch( com.sun.star.uno.Exception cssuE ){
+ }
+
+ XInterface Control = (XInterface)UnoRuntime.queryInterface(ifcClass, SrvObj );
+
+ return Control;
+
+ }
+}
diff --git a/qadevOOo/runner/util/DBTools.java b/qadevOOo/runner/util/DBTools.java
new file mode 100644
index 000000000000..440274d8fd9a
--- /dev/null
+++ b/qadevOOo/runner/util/DBTools.java
@@ -0,0 +1,824 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package util;
+
+import com.sun.star.uno.Exception;
+import java.io.PrintWriter ;
+
+// access the implementations via names
+import com.sun.star.uno.XInterface;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.uno.UnoRuntime;
+
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.sdbc.XConnection ;
+import com.sun.star.sdbc.XResultSet ;
+import com.sun.star.sdbc.XResultSetUpdate ;
+import com.sun.star.sdbc.XStatement ;
+import com.sun.star.sdbc.XRowUpdate ;
+import com.sun.star.util.Date ;
+import com.sun.star.uno.XNamingService ;
+import com.sun.star.task.XInteractionHandler ;
+import com.sun.star.sdb.XCompletedConnection ;
+import com.sun.star.container.XEnumeration ;
+import com.sun.star.container.XEnumerationAccess ;
+import com.sun.star.io.XInputStream ;
+import com.sun.star.io.XTextInputStream ;
+import com.sun.star.io.XDataInputStream ;
+import com.sun.star.container.XNameAccess ;
+import com.sun.star.frame.XStorable;
+import com.sun.star.sdb.XDocumentDataSource;
+import com.sun.star.sdbc.XCloseable ;
+import java.sql.Statement;
+import java.sql.Connection;
+import java.sql.DriverManager;
+
+/**
+* Provides useful methods for working with SOffice databases.
+* Database creation, data transfering, outputting infromation.
+*/
+public class DBTools {
+
+ private XMultiServiceFactory xMSF = null ;
+ private XNamingService dbContext = null ;
+ private PrintWriter m_log = null;
+
+ //JDBC driver
+ public final static String TST_JDBC_DRIVER = "org.gjt.mm.mysql.Driver";
+
+ // constants for TestDB table column indexes
+ public final static int TST_STRING = 1 ;
+ public final static int TST_INT = 2 ;
+ public final static int TST_DOUBLE = 5 ;
+ public final static int TST_DATE = 6 ;
+ public final static int TST_BOOLEAN = 10 ;
+ public final static int TST_CHARACTER_STREAM = 11 ;
+ public final static int TST_BINARY_STREAM = 12 ;
+
+ // constants for TestDB columns names
+ public final static String TST_STRING_F = "_TEXT" ;
+ public final static String TST_INT_F = "_INT" ;
+ public final static String TST_DOUBLE_F = "_DOUBLE" ;
+ public final static String TST_DATE_F = "_DATE" ;
+ public final static String TST_BOOLEAN_F = "_BOOL" ;
+ public final static String TST_CHARACTER_STREAM_F = "_MEMO1" ;
+ public final static String TST_BINARY_STREAM_F = "_MEMO2" ;
+
+ /**
+ * Values for filling test table.
+ */
+ public final static Object[][] TST_TABLE_VALUES = new Object[][] {
+ {"String1", new Integer(1), null, null, new Double(1.1),
+ new Date((short) 1,(short) 1, (short) 2001), null, null, null,
+ Boolean.TRUE, null, null},
+ {"String2", new Integer(2), null, null, new Double(1.2),
+ new Date((short) 2, (short) 1,(short) 2001), null, null, null,
+ Boolean.FALSE, null, null},
+ {null, null, null, null, null,
+ null, null, null, null,
+ null, null, null}
+ } ;
+
+ /**
+ * Array of lengths of streams for each row in of the
+ * <code>TST_TABLE_VALUES</code> constants.
+ */
+ public final static int[] TST_STREAM_LENGTHS = {0, 0, 0} ;
+
+ /**
+ * It's just a structure with some useful methods for representing
+ * <code>com.sun.star.sdb.DataSource</code> service. All this
+ * service's properties are stored in appropriate class fields.
+ * Class also allows to construct its instances using service
+ * information, and create new service instance upon class
+ * fields.
+ * @see com.sun.star.sdb.DataSource
+ */
+ public class DataSourceInfo {
+ /**
+ * Representation of <code>'Name'</code> property.
+ */
+ public String Name = null ;
+ /**
+ * Representation of <code>'URL'</code> property.
+ */
+ public String URL = null ;
+ /**
+ * Representation of <code>'Info'</code> property.
+ */
+ public PropertyValue[] Info = null ;
+ /**
+ * Representation of <code>'User'</code> property.
+ */
+ public String User = null ;
+ /**
+ * Representation of <code>'Password'</code> property.
+ */
+ public String Password = null ;
+ /**
+ * Representation of <code>'IsPasswordRequired'</code> property.
+ */
+ public Boolean IsPasswordRequired = null ;
+ /**
+ * Representation of <code>'SuppressVersionColumns'</code> property.
+ */
+ public Boolean SuppressVersionColumns = null ;
+ /**
+ * Representation of <code>'IsReadOnly'</code> property.
+ */
+ public Boolean IsReadOnly = null ;
+ /**
+ * Representation of <code>'TableFilter'</code> property.
+ */
+ public String[] TableFilter = null ;
+ /**
+ * Representation of <code>'TableTypeFilter'</code> property.
+ */
+ public String[] TableTypeFilter = null ;
+
+ /**
+ * Creates an empty instance.
+ */
+ public DataSourceInfo()
+ {
+ }
+
+ /**
+ * Creates an instance laying upon specified DataSource.
+ * @param dataSource All source properties are copied into
+ * class fields.
+ */
+ public DataSourceInfo(Object dataSource) {
+ XPropertySet xProps = (XPropertySet)
+ UnoRuntime.queryInterface(XPropertySet.class, dataSource) ;
+
+ try {
+ Name = (String)xProps.getPropertyValue("Name") ;
+ URL = (String)xProps.getPropertyValue("URL") ;
+ Info = (PropertyValue[])xProps.getPropertyValue("Info") ;
+ User = (String)xProps.getPropertyValue("User") ;
+ Password = (String)xProps.getPropertyValue("Password") ;
+ IsPasswordRequired = (Boolean)xProps.getPropertyValue("IsPasswordRequired") ;
+ SuppressVersionColumns = (Boolean)
+ xProps.getPropertyValue("SuppressVersionColumns") ;
+ IsReadOnly = (Boolean)xProps.getPropertyValue("IsReadOnly") ;
+ TableFilter = (String[])xProps.getPropertyValue("TableFilter") ;
+ TableTypeFilter = (String[])xProps.getPropertyValue("TableTypeFilter") ;
+ } catch (com.sun.star.beans.UnknownPropertyException e) {
+ System.err.println("util.DBTools.DataSourceInfo: Error retrieving property") ;
+ e.printStackTrace(System.err) ;
+ } catch (com.sun.star.lang.WrappedTargetException e) {
+ System.err.println("util.DBTools.DataSourceInfo: Error retrieving property") ;
+ e.printStackTrace(System.err) ;
+ }
+ }
+
+ /**
+ * Prints datasource info.
+ * @param out Stream to which information is printed.
+ */
+ public void printInfo(PrintWriter out) {
+ out.println("Name = '" + Name + "'") ;
+ out.println(" URL = '" + URL + "'") ;
+ out.print(" Info = ") ;
+ if (Info == null) out.println("null") ;
+ else {
+ out.print("{") ;
+ for (int i = 0; i < Info.length; i++) {
+ out.print(Info[i].Name + " = '" + Info[i].Value + "'") ;
+ if (i + 1 < Info.length) out.print("; ") ;
+ }
+ out.println("}") ;
+ }
+ out.println(" User = '" + User + "'") ;
+ out.println(" Password = '" + Password + "'") ;
+ out.println(" IsPasswordRequired = '" + IsPasswordRequired + "'") ;
+ out.println(" SuppressVersionColumns = '" + SuppressVersionColumns + "'") ;
+ out.println(" IsReadOnly = '" + IsReadOnly + "'") ;
+ out.print(" TableFilter = ") ;
+ if (TableFilter == null) out.println("null") ;
+ else {
+ out.print("{") ;
+ for (int i = 0; i < TableFilter.length; i++) {
+ out.print("'" + TableFilter[i] + "'") ;
+ if (i+1 < TableFilter.length) out.print("; ");
+ }
+ out.println("}") ;
+ }
+ out.print(" TableTypeFilter = ") ;
+ if (TableTypeFilter == null) out.println("null") ;
+ else {
+ out.print("{") ;
+ for (int i = 0; i < TableTypeFilter.length; i++) {
+ out.print("'" + TableTypeFilter[i] + "'") ;
+ if (i+1 < TableTypeFilter.length) out.print("; ");
+ }
+ out.println("}") ;
+ }
+ }
+
+ /**
+ * Creates new <code>com.sun.star.sdb.DataSource</code> service
+ * instance and copies all fields (which are not null) to
+ * appropriate service properties.
+ * @return <code>com.sun.star.sdb.DataSource</code> service.
+ */
+ public Object getDataSourceService() throws Exception
+ {
+ Object src = src = xMSF.createInstance("com.sun.star.sdb.DataSource") ;
+
+ XPropertySet props = (XPropertySet) UnoRuntime.queryInterface
+ (XPropertySet.class, src) ;
+
+ if (Name != null) props.setPropertyValue("Name", Name) ;
+ if (URL != null) props.setPropertyValue("URL", URL) ;
+ if (Info != null) props.setPropertyValue("Info", Info) ;
+ if (User != null) props.setPropertyValue("User", User) ;
+ if (Password != null) props.setPropertyValue("Password", Password) ;
+ if (IsPasswordRequired != null) props.setPropertyValue("IsPasswordRequired", IsPasswordRequired) ;
+ if (SuppressVersionColumns != null) props.setPropertyValue("SuppressVersionColumns", SuppressVersionColumns) ;
+ if (IsReadOnly != null) props.setPropertyValue("IsReadOnly", IsReadOnly) ;
+ if (TableFilter != null) props.setPropertyValue("TableFilter", TableFilter) ;
+ if (TableTypeFilter != null) props.setPropertyValue("TableTypeFilter", TableTypeFilter) ;
+
+ return src ;
+ }
+ }
+
+ /**
+ * Creates class instance.
+ * @param xMSF <code>XMultiServiceFactory</code>.
+ */
+ public DBTools(XMultiServiceFactory xMSF, PrintWriter _logger )
+ {
+ this.xMSF = xMSF ;
+ this.m_log = _logger;
+
+ try {
+ Object cont = xMSF.createInstance("com.sun.star.sdb.DatabaseContext") ;
+
+ dbContext = (XNamingService) UnoRuntime.queryInterface
+ (XNamingService.class, cont) ;
+
+ } catch (com.sun.star.uno.Exception e) {}
+ }
+
+ /**
+ * Returns new instance of <code>DataSourceInfo</code> class.
+ */
+ public DataSourceInfo newDataSourceInfo() { return new DataSourceInfo() ;}
+
+ /**
+ * Returns new instance of <code>DataSourceInfo</code> class.
+ */
+ public DataSourceInfo newDataSourceInfo(Object dataSource) {
+ return new DataSourceInfo(dataSource);
+ }
+
+ /**
+ * Registers the datasource on the specified name in
+ * <code>DatabaseContext</code> service.
+ * @param name Name which dataSource will have in global context.
+ * @param dataSource <code>DataSource</code> object which is to
+ * be registered.
+ */
+ public void registerDB(String name, Object dataSource)
+ throws com.sun.star.uno.Exception {
+
+ dbContext.registerObject(name, dataSource) ;
+ }
+
+
+ /**
+ * First tries to revoke the datasource with the specified
+ * name and then registers a new one.
+ * @param name Name which dataSource will have in global context.
+ * @param dataSource <code>DataSource</code> object which is to
+ * be registered.
+ */
+ public void reRegisterDB(String name, Object dataSource)
+ throws com.sun.star.uno.Exception {
+
+ try {
+ revokeDB(name) ;
+ } catch (com.sun.star.uno.Exception e) {}
+
+ XDocumentDataSource xDDS = (XDocumentDataSource)
+ UnoRuntime.queryInterface(XDocumentDataSource.class, dataSource);
+ XStorable store = (XStorable) UnoRuntime.queryInterface(XStorable.class,
+ xDDS.getDatabaseDocument());
+ String aFile = utils.getOfficeTemp(xMSF) + name + ".odb";
+ store.storeAsURL(aFile, new PropertyValue[] { });
+
+ registerDB(name, dataSource) ;
+ }
+
+ /**
+ * RESERVED. Not used.
+ */
+ public XConnection connectToTextDB(String contextName,
+ String dbDir, String fileExtension)
+ throws com.sun.star.uno.Exception {
+
+ try {
+ XInterface newSource = (XInterface) xMSF.createInstance
+ ("com.sun.star.sdb.DataSource") ;
+
+ XPropertySet xSrcProp = (XPropertySet)
+ UnoRuntime.queryInterface(XPropertySet.class, newSource);
+
+ xSrcProp.setPropertyValue("URL", "sdbc:text:" + dirToUrl(dbDir));
+
+ PropertyValue extParam = new PropertyValue() ;
+ extParam.Name = "EXT" ;
+ extParam.Value = fileExtension ;
+
+ xSrcProp.setPropertyValue("Info", new PropertyValue[] {extParam}) ;
+
+ dbContext.registerObject(contextName, newSource) ;
+
+ Object handler = xMSF.createInstance("com.sun.star.sdb.InteractionHandler");
+ XInteractionHandler xHandler = (XInteractionHandler)
+ UnoRuntime.queryInterface(XInteractionHandler.class, handler) ;
+
+ XCompletedConnection xSrcCon = (XCompletedConnection)
+ UnoRuntime.queryInterface(XCompletedConnection.class, newSource) ;
+
+ XConnection con = xSrcCon.connectWithCompletion(xHandler) ;
+
+ return con ;
+ } finally {
+ try {
+ dbContext.revokeObject(contextName) ;
+ } catch (Exception e) {}
+ }
+ }
+
+ /**
+ * Registers DBase database (directory with DBF files) in the
+ * global DB context, then connects to it.
+ * @param contextName Name under which DB will be registered.
+ * @param dbDir The directory with DBF tables.
+ * @return Connection to the DB.
+ */
+ public XConnection connectToDBase(String contextName,
+ String dbDir)
+ throws com.sun.star.uno.Exception {
+
+ try {
+ XInterface newSource = (XInterface) xMSF.createInstance
+ ("com.sun.star.sdb.DataSource") ;
+
+ XPropertySet xSrcProp = (XPropertySet)
+ UnoRuntime.queryInterface(XPropertySet.class, newSource);
+ xSrcProp.setPropertyValue("URL", "sdbc:dbase:" + dirToUrl(dbDir));
+
+ dbContext.registerObject(contextName, newSource) ;
+
+ XConnection con = connectToSource(newSource) ;
+
+ return con ;
+ } catch(com.sun.star.uno.Exception e) {
+ try {
+ dbContext.revokeObject(contextName) ;
+ } catch (Exception ex) {}
+
+ throw e ;
+ }
+ }
+
+ /**
+ * Performs connection to DataSource specified.
+ * @param dbSource <code>com.sun.star.sdb.DataSource</code> service
+ * specified data source which must be already registered in the
+ * <code>DatabaseContext</code> service.
+ * @param dbSource Data source to be connected to.
+ * @return Connection to the data source.
+ */
+ public XConnection connectToSource(Object dbSource)
+ throws com.sun.star.uno.Exception {
+
+ Object handler = xMSF.createInstance("com.sun.star.sdb.InteractionHandler");
+ XInteractionHandler xHandler = (XInteractionHandler)
+ UnoRuntime.queryInterface(XInteractionHandler.class, handler) ;
+
+ XCompletedConnection xSrcCon = (XCompletedConnection)
+ UnoRuntime.queryInterface(XCompletedConnection.class, dbSource) ;
+
+ return xSrcCon.connectWithCompletion(xHandler) ;
+ }
+
+ /**
+ * Registers Test data source in the <code>DatabaseContext</code> service.
+ * This source always has name <code>'APITestDatabase'</code> and it
+ * is registered in subdirectory <code>TestDB</code> of directory
+ * <code>docPath</code> which is supposed to be a directory with test
+ * documents, but can be any other (it must have subdirectory with DBF
+ * tables). If such data source doesn't exists or exists with
+ * different URL it is recreated and reregistered.
+ * @param docPath Path to database <code>TestDB</code> directory.
+ * @return <code>com.sun.star.sdb.DataSource</code> service
+ * implementation which represents TestDB.
+ */
+ public Object registerTestDB(String docPath)
+ throws com.sun.star.uno.Exception {
+
+ String testURL = null ;
+ if (docPath.endsWith("/") || docPath.endsWith("\\"))
+ testURL = dirToUrl(docPath + "TestDB") ;
+ else
+ testURL = dirToUrl(docPath + "/" + "TestDB") ;
+ testURL = "sdbc:dbase:" + testURL ;
+
+ String existURL = null ;
+
+ XNameAccess na = (XNameAccess) UnoRuntime.queryInterface
+ (XNameAccess.class, dbContext) ;
+
+ Object src = null ;
+ if (na.hasByName("APITestDatabase")) {
+ src = dbContext.getRegisteredObject("APITestDatabase") ;
+
+ XPropertySet srcPs = (XPropertySet) UnoRuntime.queryInterface
+ (XPropertySet.class, src) ;
+
+ existURL = (String) srcPs.getPropertyValue("URL") ;
+ }
+
+ if (src == null || !testURL.equals(existURL)) {
+ // test data source must be reregistered.
+ DataSourceInfo info = new DataSourceInfo() ;
+ info.URL = testURL ;
+ src = info.getDataSourceService() ;
+ reRegisterDB("APITestDatabase", src) ;
+ src = dbContext.getRegisteredObject("APITestDatabase") ;
+ }
+
+ return src ;
+ }
+
+ /**
+ * Connects to <code>DataSource</code> specially created for testing.
+ * This source always has name <code>'APITestDatabase'</code> and it
+ * is registered in subdirectory <code>TestDB</code> of directory
+ * <code>docPath</code> which is supposed to be a directory with test
+ * documents, but can be any other (it must have subdirectory with DBF
+ * tables). If such data source doesn't exists or exists with
+ * different URL it is recreated and reregistered. Finally connection
+ * performed.
+ * @param docPath Path to database <code>TestDB</code> directory.
+ * @return Connection to test database.
+ */
+ public XConnection connectToTestDB(String docPath)
+ throws com.sun.star.uno.Exception {
+
+ return connectToSource(registerTestDB(docPath)) ;
+ }
+
+ /**
+ * Empties the table in the specified source.
+ * @param con Connection to the DataSource where appropriate
+ * table exists.
+ * @param table The name of the table where all rows will be deleted.
+ * @return Number of rows deleted.
+ */
+
+ // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ // Currently doesn't work because of bugs 85509, 85510
+
+ public int deleteAllRows(XConnection con, String table)
+ throws com.sun.star.sdbc.SQLException {
+
+ XStatement stat = con.createStatement() ;
+
+ XResultSet set = stat.executeQuery("SELECT * FROM " + table) ;
+
+ XResultSetUpdate updt = (XResultSetUpdate) UnoRuntime.queryInterface
+ (XResultSetUpdate.class, set) ;
+
+ int count = 0 ;
+ set.last() ;
+ int rowNum = set.getRow() ;
+ set.first() ;
+
+ for (int i = 0; i < rowNum; i++) {
+ updt.deleteRow() ;
+ set.next() ;
+ count ++ ;
+ }
+
+ XCloseable xClose = (XCloseable) UnoRuntime.queryInterface
+ (XCloseable.class, set) ;
+ xClose.close() ;
+
+ return count ;
+ }
+
+ /**
+ * Inserts row into test table of the specified connection.
+ * Test table has some predefined format which includes as much
+ * field types as possible. For every column type constants
+ * {@link #TST_STRING TST_STRING}, {@link #TST_INT TST_INT}, etc.
+ * are declared for column index fast find.
+ * @param con Connection to data source where test table exists.
+ * @param table Test table name.
+ * @param values Values to be inserted into test table. Values of
+ * this array inserted into appropriate fields depending on their
+ * types. So <code>String</code> value of the array is inserted
+ * into the field of <code>CHARACTER</code> type, etc.
+ * @param streamLength Is optional. It is used only if in values
+ * list <code>XCharacterInputStream</code> or <code>XBinaryInputStream
+ * </code> types specified. In this case the parameter specifies
+ * the length of the stream for inserting.
+ */
+ public void addRowToTestTable(XConnection con, String table, Object[] values,
+ int streamLength)
+ throws com.sun.star.sdbc.SQLException {
+
+ XStatement stat = con.createStatement() ;
+
+ XResultSet set = stat.executeQuery("SELECT * FROM " + table) ;
+
+ XResultSetUpdate updt = (XResultSetUpdate) UnoRuntime.queryInterface
+ (XResultSetUpdate.class, set) ;
+
+ XRowUpdate rowUpdt = (XRowUpdate) UnoRuntime.queryInterface
+ (XRowUpdate.class, set) ;
+
+ updt.moveToInsertRow() ;
+
+ for (int i = 0; i < values.length; i++) {
+ if (values[i] instanceof String) {
+ rowUpdt.updateString(TST_STRING, (String) values[i]) ;
+ } else
+ if (values[i] instanceof Integer) {
+ rowUpdt.updateInt(TST_INT, ((Integer) values[i]).intValue()) ;
+ } else
+ if (values[i] instanceof Double) {
+ rowUpdt.updateDouble(TST_DOUBLE, ((Double) values[i]).doubleValue()) ;
+ } else
+ if (values[i] instanceof Date) {
+ rowUpdt.updateDate(TST_DATE, (Date) values[i]) ;
+ } else
+ if (values[i] instanceof Boolean) {
+ rowUpdt.updateBoolean(TST_BOOLEAN, ((Boolean) values[i]).booleanValue()) ;
+ } else
+ if (values[i] instanceof XTextInputStream) {
+ rowUpdt.updateCharacterStream(TST_CHARACTER_STREAM, (XInputStream) values[i],
+ streamLength) ;
+ } else
+ if (values[i] instanceof XDataInputStream) {
+ rowUpdt.updateBinaryStream(TST_BINARY_STREAM, (XInputStream) values[i],
+ streamLength) ;
+ }
+ }
+
+ updt.insertRow() ;
+
+ XCloseable xClose = (XCloseable) UnoRuntime.queryInterface
+ (XCloseable.class, set) ;
+ xClose.close() ;
+ }
+
+ /**
+ * Initializes test table specified of the connection specified.
+ * Deletes all record from table, and then inserts data from
+ * <code>TST_TABLE_VALUES</code> constant array. <p>
+ * Test table has some predefined format which includes as much
+ * field types as possible. For every column type constants
+ * {@link #TST_STRING TST_STRING}, {@link #TST_INT TST_INT}, etc.
+ * are declared for column index fast find.
+ * @param con Connection to data source where test table exists.
+ * @param table Test table name.
+ */
+ public void initializeTestTable(XConnection con, String table)
+ throws com.sun.star.sdbc.SQLException {
+
+ deleteAllRows(con, table) ;
+
+ for (int i = 0; i < TST_TABLE_VALUES.length; i++) {
+ addRowToTestTable(con, table, TST_TABLE_VALUES[i], TST_STREAM_LENGTHS[i]) ;
+ }
+ }
+
+ /**
+ * Prints full info about currently registered DataSource's.
+ */
+ public void printRegisteredDatabasesInfo(PrintWriter out) {
+ XEnumerationAccess dbContEA = (XEnumerationAccess)
+ UnoRuntime.queryInterface(XEnumerationAccess.class, dbContext) ;
+
+ XEnumeration xEnum = dbContEA.createEnumeration() ;
+
+ out.println("DatabaseContext registered DataSource's :") ;
+ while (xEnum.hasMoreElements()) {
+ try {
+ DataSourceInfo inf = new DataSourceInfo(xEnum.nextElement()) ;
+ inf.printInfo(out) ;
+ } catch (com.sun.star.container.NoSuchElementException e) {}
+ catch (com.sun.star.lang.WrappedTargetException e) {}
+ }
+ }
+
+ /**
+ * Convert system pathname to SOffice URL string
+ * (for example 'C:\Temp\DBDir\' -> 'file:///C|/Temp/DBDir/').
+ * (for example '\\server\Temp\DBDir\' -> 'file://server/Temp/DBDir/').
+ * Already converted string retured unchanged.
+ */
+ public static String dirToUrl(String dir) {
+ String retVal = null;
+ if (dir.startsWith("file:/")) retVal = dir;
+ else {
+ retVal = dir.replace(':', '|').replace('\\', '/');
+
+ if (dir.startsWith("\\\\")) {
+ retVal = "file:" + retVal;
+ }
+
+ else retVal = "file:///" + retVal ;
+ }
+ return retVal;
+ }
+
+ /**
+ * Revokes datasource from global DB context.
+ * @param name DataSource name to be revoked.
+ */
+ public void revokeDB(String name) throws com.sun.star.uno.Exception
+ {
+ dbContext.revokeObject(name) ;
+ }
+
+ /**
+ * Initializes test table specified of the connection specified
+ * using JDBC driver. Drops table with the name <code>tbl_name</code>,
+ * creates new table with this name and then inserts data from
+ * <code>TST_TABLE_VALUES</code> constant array. <p>
+ * Test table has some predefined format which includes as much
+ * field types as possible. For every column type constants
+ * {@link #TST_STRING TST_STRING}, {@link #TST_INT TST_INT}, etc.
+ * are declared for column index fast find.
+ * @param tbl_name Test table name.
+ */
+ public void initTestTableUsingJDBC(String tbl_name, DataSourceInfo dsi)
+ throws java.sql.SQLException,
+ ClassNotFoundException {
+ //register jdbc driver
+ if ( dsi.Info[0].Name.equals("JavaDriverClass") ) {
+ Class.forName((String)dsi.Info[0].Value);
+ } else {
+ Class.forName(TST_JDBC_DRIVER);
+ }
+
+ //getting connection
+ Connection connection = null;
+
+ connection = DriverManager.getConnection(
+ dsi.URL, dsi.User, dsi.Password);
+ Statement statement = connection.createStatement();
+
+ //drop table
+ dropMySQLTable(statement, tbl_name);
+
+ //create table
+ createMySQLTable(statement, tbl_name);
+
+ //insert some content
+ insertContentMySQLTable(statement, tbl_name);
+ }
+
+ /**
+ * Inserts data from <code>TST_TABLE_VALUES</code> constant array
+ * to test table <code>tbl_name</code>.
+ * @param statement object used for executing a static SQL
+ * statement and obtaining the results produced by it.
+ * @param tbl_name Test table name.
+ */
+ protected void insertContentMySQLTable(Statement statement, String tbl_name)
+ throws java.sql.SQLException {
+
+
+ for(int i = 0; i < DBTools.TST_TABLE_VALUES.length; i++) {
+ String query = "insert into " + tbl_name + " values (";
+ int j = 0;
+ while(j < DBTools.TST_TABLE_VALUES[i].length) {
+ if (j > 0) {
+ query += ", ";
+ }
+ Object value = DBTools.TST_TABLE_VALUES[i][j];
+ if (value instanceof String ||
+ value instanceof Date) {
+ query += "'";
+ }
+ if (value instanceof Date) {
+ Date date = (Date)value;
+ query += date.Year + "-" + date.Month +
+ "-" + date.Day;
+ } else if (value instanceof Boolean) {
+ query += (((Boolean)value).booleanValue())
+ ? "1" : "0";
+ } else {
+ query += value;
+ }
+
+ if (value instanceof String ||
+ value instanceof Date) {
+ query += "'";
+ }
+ j++;
+ }
+ query += ")";
+ statement.executeUpdate(query);
+ }
+ }
+
+ /**
+ * Creates test table specified.
+ * Test table has some predefined format which includes as much
+ * field types as possible. For every column type constants
+ * {@link #TST_STRING TST_STRING}, {@link #TST_INT TST_INT}, etc.
+ * are declared for column index fast find.
+ * @param statement object used for executing a static SQL
+ * statement and obtaining the results produced by it.
+ * @param table Test table name.
+ */
+ protected void createMySQLTable(Statement statement, String tbl_name)
+ throws java.sql.SQLException {
+
+ final String empty_col_name = "Column";
+ int c = 0;
+ String query = "create table " + tbl_name + " (";
+ for (int i = 0; i < TST_TABLE_VALUES[0].length; i++) {
+ if (i > 0) query += ",";
+
+ switch(i + 1) {
+ case TST_BINARY_STREAM:
+ query += TST_BINARY_STREAM_F + " BLOB";
+ break;
+ case TST_BOOLEAN:
+ query += TST_BOOLEAN_F + " TINYINT";
+ break;
+ case TST_CHARACTER_STREAM:
+ query += TST_CHARACTER_STREAM_F + " TEXT";
+ break;
+ case TST_DATE:
+ query += TST_DATE_F + " DATE";
+ break;
+ case TST_DOUBLE:
+ query += TST_DOUBLE_F + " DOUBLE";
+ break;
+ case TST_INT:
+ query += TST_INT_F + " INT";
+ break;
+ case TST_STRING:
+ query += TST_STRING_F + " TEXT";
+ break;
+ default: query += empty_col_name + (c++) + " INT";
+ if (c == 1) {
+ query += " NOT NULL AUTO_INCREMENT";
+ }
+ }
+ }
+ query += ", PRIMARY KEY (" + empty_col_name + "0)";
+ query += ")";
+ statement.execute(query);
+ }
+
+ /**
+ * Drops table.
+ * @param statement object used for executing a static SQL
+ * statement and obtaining the results produced by it.
+ * @param table Test table name.
+ */
+ protected void dropMySQLTable(Statement statement, String tbl_name)
+ throws java.sql.SQLException {
+ statement.executeUpdate("drop table if exists " + tbl_name);
+ }
+}
diff --git a/qadevOOo/runner/util/DefaultDsc.java b/qadevOOo/runner/util/DefaultDsc.java
new file mode 100644
index 000000000000..07a2cdd2c5cc
--- /dev/null
+++ b/qadevOOo/runner/util/DefaultDsc.java
@@ -0,0 +1,81 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package util;
+
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.uno.XInterface;
+import com.sun.star.uno.UnoRuntime;
+
+/**
+ * Defaultdescriptor:
+ * This descriptor is useful for instances in default values.
+ */
+public class DefaultDsc extends InstDescr {
+
+ private String name = null;
+ String ifcName = null;
+ String service = null;
+
+ public DefaultDsc( String Interface, String kind ) {
+ service = kind;
+ ifcName = Interface;
+ initDefault();
+ }
+ public String getName() {
+ return name;
+ }
+
+ public String getIfcName() {
+ return ifcName;
+ }
+ public String getService() {
+ return service;
+ }
+
+ private void initDefault() {
+ try {
+ ifcClass = Class.forName( ifcName );
+ }
+ catch( ClassNotFoundException cnfE ) {
+ }
+ }
+ public XInterface createInstance( XMultiServiceFactory docMSF ) {
+
+ Object SrvObj = null;
+ try {
+ SrvObj = docMSF.createInstance( service );
+ }
+ catch( com.sun.star.uno.Exception cssuE ){
+ }
+
+ XInterface Default = (XInterface)UnoRuntime.queryInterface(ifcClass, SrvObj );
+
+ return Default;
+
+ }
+}
diff --git a/qadevOOo/runner/util/DesktopTools.java b/qadevOOo/runner/util/DesktopTools.java
new file mode 100644
index 000000000000..3384a8b83423
--- /dev/null
+++ b/qadevOOo/runner/util/DesktopTools.java
@@ -0,0 +1,515 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package util;
+
+import com.sun.star.awt.Rectangle;
+import com.sun.star.awt.WindowDescriptor;
+import com.sun.star.awt.XToolkit;
+import com.sun.star.awt.XWindowPeer;
+import com.sun.star.awt.XTopWindow;
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.container.XEnumeration;
+import com.sun.star.container.XNameReplace;
+import com.sun.star.frame.XComponentLoader;
+import com.sun.star.frame.XDesktop;
+import com.sun.star.frame.XFrame;
+import com.sun.star.frame.XModel;
+import com.sun.star.lang.XComponent;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.lang.XServiceInfo;
+import com.sun.star.uno.UnoRuntime;
+
+// access the implementations via names
+import com.sun.star.uno.XInterface;
+import com.sun.star.util.XCloseable;
+import com.sun.star.util.XModifiable;
+import com.sun.star.view.XViewSettingsSupplier;
+import helper.ConfigHelper;
+import java.util.Vector;
+import lib.StatusException;
+
+/**
+ * contains helper methods for the Desktop
+ */
+public class DesktopTools
+{
+
+ /**
+ * Queries the XComponentLoader
+ *
+ * @param xMSF the MultiServiceFactory
+ * @return the gained XComponentLoader
+ */
+ public static XComponentLoader getCLoader(XMultiServiceFactory xMSF)
+ {
+ XDesktop oDesktop = (XDesktop) UnoRuntime.queryInterface(
+ XDesktop.class, createDesktop(xMSF));
+
+ XComponentLoader oCLoader = (XComponentLoader) UnoRuntime.queryInterface(
+ XComponentLoader.class, oDesktop);
+
+ return oCLoader;
+ } // finish getCLoader
+
+ /**
+ * Creates an Instance of the Desktop service
+ *
+ * @param xMSF the MultiServiceFactory
+ * @return the gained Object
+ */
+ public static Object createDesktop(XMultiServiceFactory xMSF)
+ {
+ Object oInterface;
+
+ try
+ {
+ oInterface = xMSF.createInstance("com.sun.star.comp.framework.Desktop");
+ }
+ catch (com.sun.star.uno.Exception e)
+ {
+ throw new IllegalArgumentException("Desktop Service not available");
+ }
+
+ return oInterface;
+ } //finish createDesktop
+
+ /**
+ * returns a XEnumeration containing all components containing on the desktop
+ * @param xMSF the XMultiServiceFactory
+ * @return XEnumeration of all components on the desktop
+ */
+ public static XEnumeration getAllComponents(XMultiServiceFactory xMSF)
+ {
+ XDesktop xDesktop = (XDesktop) UnoRuntime.queryInterface(
+ XDesktop.class, createDesktop(xMSF));
+ return xDesktop.getComponents().createEnumeration();
+ }
+
+ /**
+ * returns the current component on the desktop
+ * @param xMSF the XMultiServiceFactory
+ * @return XComponent of the current component on the desktop
+ */
+ public static XComponent getCurrentComponent(XMultiServiceFactory xMSF)
+ {
+ XDesktop xDesktop = (XDesktop) UnoRuntime.queryInterface(
+ XDesktop.class, createDesktop(xMSF));
+ return xDesktop.getCurrentComponent();
+ }
+
+ /**
+ * returns the current component on the desktop
+ * @param xMSF the XMultiServiceFactory
+ * @return XComponent of the current component on the desktop
+ */
+ public static XFrame getCurrentFrame(XMultiServiceFactory xMSF)
+ {
+ XDesktop xDesktop = (XDesktop) UnoRuntime.queryInterface(
+ XDesktop.class, createDesktop(xMSF));
+ return xDesktop.getCurrentFrame();
+ }
+
+ /**
+ * returns an object arrary of all open documents
+ * @param xMSF the MultiServiceFactory
+ * @return returns an Array of document kinds like ["swriter"]
+ */
+ /**
+ * returns an array of all open documents
+ * @param xMSF the XMultiSerivceFactory
+ * @return returns an array of all open documents
+ */
+ public static Object[] getAllOpenDocuments(XMultiServiceFactory xMSF)
+ {
+ Vector components = new Vector();
+ XDesktop xDesktop = (XDesktop) UnoRuntime.queryInterface(
+ XDesktop.class, createDesktop(xMSF));
+
+ XEnumeration allComp = getAllComponents(xMSF);
+
+ while (allComp.hasMoreElements())
+ {
+ try
+ {
+ XComponent xComponent = (XComponent) UnoRuntime.queryInterface(
+ XComponent.class, allComp.nextElement());
+
+ if (getDocumentType(xComponent) != null)
+ {
+ components.add(xComponent);
+ }
+
+ }
+ catch (com.sun.star.container.NoSuchElementException e)
+ {
+ }
+ catch (com.sun.star.lang.WrappedTargetException e)
+ {
+ }
+ }
+ return components.toArray();
+ }
+
+ /**
+ * Returns the document type for the given XComponent of an document
+ * @param xComponent the document to query for its type
+ * @return possible:
+ * <ul>
+ * <li>swriter</li>
+ * <li>scalc</li>
+ * <li>sdraw</li>
+ * <li>smath</li>
+ * </ul>
+ * or <CODE>null</CODE>
+ */
+ public static String getDocumentType(XComponent xComponent)
+ {
+ XServiceInfo sInfo = (XServiceInfo) UnoRuntime.queryInterface(
+ XServiceInfo.class, xComponent);
+
+ if (sInfo == null)
+ {
+ return "";
+ }
+ else if (sInfo.supportsService("com.sun.star.sheet.SpreadsheetDocument"))
+ {
+ return "scalc";
+ }
+ else if (sInfo.supportsService("com.sun.star.text.TextDocument"))
+ {
+ return "swriter";
+ }
+ else if (sInfo.supportsService("com.sun.star.drawing.DrawingDocument"))
+ {
+ return "sdraw";
+ }
+ else if (sInfo.supportsService("com.sun.star.presentation.PresentationDocument"))
+ {
+ return "simpress";
+ }
+ else if (sInfo.supportsService("com.sun.star.formula.FormulaProperties"))
+ {
+ return "smath";
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ /**
+ * Opens a new document of a given kind
+ * with arguments
+ * @return the XComponent Interface of the document
+ * @param kind the kind of document to load.<br>
+ * possible:
+ * <ul>
+ * <li>swriter</li>
+ * <li>scalc</li>
+ * <li>sdaw</li>
+ * <li>smath</li>
+ * </ul>
+ * @param Args arguments which passed to the document to load
+ * @param xMSF the MultiServiceFactory
+ */
+ public static XComponent openNewDoc(XMultiServiceFactory xMSF, String kind,
+ PropertyValue[] Args)
+ {
+ XComponent oDoc = null;
+
+ try
+ {
+ oDoc = getCLoader(xMSF).loadComponentFromURL("private:factory/" + kind,
+ "_blank", 0, Args);
+ }
+ catch (com.sun.star.uno.Exception e)
+ {
+ throw new IllegalArgumentException("Document could not be opened");
+ }
+
+ return oDoc;
+ } //finish openNewDoc
+
+ /**
+ * loads a document of from a given url
+ * with arguments
+ * @return the XComponent Interface of the document
+ * @param url the URL of the document to load.
+ * @param Args arguments which passed to the document to load
+ * @param xMSF the MultiServiceFactory
+ */
+ public static XComponent loadDoc(XMultiServiceFactory xMSF, String url,
+ PropertyValue[] Args)
+ {
+ XComponent oDoc = null;
+ if (Args == null)
+ {
+ Args = new PropertyValue[0];
+ }
+ try
+ {
+ oDoc = getCLoader(xMSF).loadComponentFromURL(url, "_blank", 0, Args);
+ }
+ catch (com.sun.star.uno.Exception e)
+ {
+ throw new IllegalArgumentException("Document could not be loaded");
+ }
+
+ bringWindowToFront(oDoc);
+ return oDoc;
+ } //finish openNewDoc
+
+ /**
+ * closes a given document
+ * @param DocumentToClose the document to close
+ */
+ public static void closeDoc(XInterface DocumentToClose)
+ {
+ if (DocumentToClose == null)
+ {
+ return;
+ }
+
+ String kd = System.getProperty("KeepDocument");
+ if (kd != null)
+ {
+ System.out.println("The property 'KeepDocument' is set and so the document won't be disposed");
+ return;
+ }
+ XModifiable modified = (XModifiable) UnoRuntime.queryInterface(XModifiable.class, DocumentToClose);
+ XCloseable closer = (XCloseable) UnoRuntime.queryInterface(XCloseable.class, DocumentToClose);
+
+ try
+ {
+ if (modified != null)
+ {
+ modified.setModified(false);
+ }
+ closer.close(true);
+ }
+ catch (com.sun.star.util.CloseVetoException e)
+ {
+ // e.printStackTrace();
+ System.out.println("Couldn't close document");
+ }
+ catch (com.sun.star.lang.DisposedException e)
+ {
+ // e.printStackTrace();
+ System.out.println("Couldn't close document");
+ }
+ catch (java.lang.NullPointerException e)
+ {
+ // e.printStackTrace();
+ System.out.println("Couldn't close document");
+ }
+ catch (com.sun.star.beans.PropertyVetoException e)
+ {
+ // e.printStackTrace();
+ System.out.println("Couldn't close document");
+ }
+ }
+
+ /**
+ * Creates a floating XWindow with the size of X=500 Y=100 width=400 height=600
+ * @param xMSF the MultiServiceFactory
+ * @throws lib.StatusException if it is not possible to create a floating window a lib.StatusException was thrown
+ * @return a floating XWindow
+ */
+ public static XWindowPeer createFloatingWindow(XMultiServiceFactory xMSF)
+ throws StatusException
+ {
+ return createFloatingWindow(xMSF, 500, 100, 400, 600);
+ }
+
+ /**
+ * Creates a floating XWindow on the given position and size.
+ * @return a floating XWindow
+ * @param X the X-Postion of the floating XWindow
+ * @param Y the Y-Postion of the floating XWindow
+ * @param width the width of the floating XWindow
+ * @param height the height of the floating XWindow
+ * @param xMSF the MultiServiceFactory
+ * @throws lib.StatusException if it is not possible to create a floating window a lib.StatusException was thrown
+ */
+ public static XWindowPeer createFloatingWindow(XMultiServiceFactory xMSF, int X, int Y, int width, int height)
+ throws StatusException
+ {
+
+ XInterface oObj = null;
+
+ try
+ {
+ oObj = (XInterface) xMSF.createInstance("com.sun.star.awt.Toolkit");
+ }
+ catch (com.sun.star.uno.Exception e)
+ {
+ throw new StatusException("Couldn't get toolkit", e);
+ }
+
+ XToolkit tk = (XToolkit) UnoRuntime.queryInterface(
+ XToolkit.class, oObj);
+
+ WindowDescriptor descriptor = new com.sun.star.awt.WindowDescriptor();
+
+ descriptor.Type = com.sun.star.awt.WindowClass.TOP;
+ descriptor.WindowServiceName = "modelessdialog";
+ descriptor.ParentIndex = -1;
+
+ Rectangle bounds = new com.sun.star.awt.Rectangle();
+ bounds.X = X;
+ bounds.Y = Y;
+ bounds.Width = width;
+ bounds.Height = height;
+
+ descriptor.Bounds = bounds;
+ descriptor.WindowAttributes = (com.sun.star.awt.WindowAttribute.BORDER +
+ com.sun.star.awt.WindowAttribute.MOVEABLE +
+ com.sun.star.awt.WindowAttribute.SIZEABLE +
+ com.sun.star.awt.WindowAttribute.CLOSEABLE +
+ com.sun.star.awt.VclWindowPeerAttribute.CLIPCHILDREN);
+
+ XWindowPeer xWindow = null;
+
+ try
+ {
+ xWindow = tk.createWindow(descriptor);
+ }
+ catch (com.sun.star.lang.IllegalArgumentException e)
+ {
+ throw new StatusException("Could not create window", e);
+ }
+
+ return xWindow;
+
+ }
+
+ /**
+ * zoom to have a view over the hole page
+ * @param xDoc the document to zoom
+ */
+ public static void zoomToEntirePage(XInterface xDoc)
+ {
+ try
+ {
+ XModel xMod = (XModel) UnoRuntime.queryInterface(XModel.class, xDoc);
+ XInterface oCont = xMod.getCurrentController();
+ XViewSettingsSupplier oVSSupp = (XViewSettingsSupplier) UnoRuntime.queryInterface(XViewSettingsSupplier.class, oCont);
+
+ XInterface oViewSettings = oVSSupp.getViewSettings();
+ XPropertySet oViewProp = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, oViewSettings);
+ oViewProp.setPropertyValue("ZoomType",
+ new Short(com.sun.star.view.DocumentZoomType.ENTIRE_PAGE));
+
+ utils.shortWait(5000);
+ }
+ catch (Exception e)
+ {
+ System.out.println("Could not zoom to entire page: " + e.toString());
+ }
+
+ }
+
+ /**
+ * This function docks the Stylist onto the right side of the window.</p>
+ * Note:<P>
+ * Since the svt.viewoptions cache the view configuration at start up
+ * the chage of the docking will be effective at a restart.
+ * @param xMSF the XMultiServiceFactory
+ */
+ public static void dockStylist(XMultiServiceFactory xMSF)
+ {
+ // prepare Window-Settings
+ try
+ {
+ ConfigHelper aConfig = new ConfigHelper(xMSF,
+ "org.openoffice.Office.Views", false);
+
+ // Is node "5539" (slot-id for navigator) available? If not, insert it
+ XNameReplace x5539 = aConfig.getOrInsertGroup("Windows", "5539");
+
+ aConfig.updateGroupProperty(
+ "Windows", "5539", "WindowState", "952,180,244,349;1;0,0,0,0;");
+
+ aConfig.insertOrUpdateExtensibleGroupProperty(
+ "Windows", "5539", "UserData", "Data", "V2,V,0,AL:(5,16,0/0/244/349,244;610)");
+
+ // Is node "SplitWindow2" available? If not, instert it.
+ aConfig.getOrInsertGroup("Windows", "SplitWindow2");
+
+ aConfig.insertOrUpdateExtensibleGroupProperty(
+ "Windows", "SplitWindow2", "UserData", "UserItem", "V1,2,1,0,5539");
+
+ aConfig.flush();
+ aConfig = null;
+
+ }
+ catch (com.sun.star.uno.Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Due to typo deprecated
+ * @param xModel
+ * @deprecated
+ */
+ @Deprecated
+ public static void bringWindowToFromt(XModel xModel)
+ {
+ bringWindowToFront(xModel);
+ }
+
+ /**
+ * This function brings a document to the front.<P>
+ * NOTE: it is not possible to change the window order of your Window-Manager!!
+ * Only the order of Office documents are changeable.
+ * @param xModel the XModel of the document to bring to top
+ */
+ public static void bringWindowToFront(XModel xModel)
+ {
+ // System.out.println("DEBUG: bring to front xModel");
+
+ XTopWindow xTopWindow =
+ (XTopWindow) UnoRuntime.queryInterface(
+ XTopWindow.class,
+ xModel.getCurrentController().getFrame().getContainerWindow());
+
+ xTopWindow.toFront();
+ }
+
+ public static void bringWindowToFront(XComponent xComponent)
+ {
+ // System.out.println("DEBUG: bring to front xComponent");
+ XModel xModel = (XModel) UnoRuntime.queryInterface(XModel.class, xComponent);
+ if (xModel != null)
+ {
+ bringWindowToFront(xModel);
+ }
+ }
+}
diff --git a/qadevOOo/runner/util/DrawTools.java b/qadevOOo/runner/util/DrawTools.java
new file mode 100644
index 000000000000..d5f862cb49a7
--- /dev/null
+++ b/qadevOOo/runner/util/DrawTools.java
@@ -0,0 +1,162 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package util;
+
+// access the implementations via names
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.uno.UnoRuntime;
+
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.lang.XComponent;
+import com.sun.star.drawing.XDrawPages;
+import com.sun.star.drawing.XDrawPagesSupplier;
+import com.sun.star.drawing.XDrawPage;
+import com.sun.star.drawing.XShapes;
+import com.sun.star.drawing.XShape;
+
+
+import util.DesktopTools;
+import util.InstCreator;
+import util.ShapeDsc;
+
+import com.sun.star.uno.AnyConverter;
+import com.sun.star.uno.Type;
+
+/**
+ * contains helper methods for draw documents
+ */
+
+
+public class DrawTools {
+
+ /**
+ * Opens a new draw document
+ * with arguments
+ * @param xMSF the MultiServiceFactory
+ * @return the XComponent Interface of the document
+ */
+
+ public static XComponent createDrawDoc( XMultiServiceFactory xMSF ) {
+ PropertyValue[] Args = new PropertyValue [0];
+ XComponent DrawDoc = DesktopTools.openNewDoc( xMSF, "sdraw", Args );
+ return DrawDoc;
+ } // finish createDrawDoc
+
+ /**
+ * gets the XDrawPages container of a draw document
+ *
+ * @param aDoc the draw document
+ * @return the XDrawpages container of the document
+ */
+
+ public static XDrawPages getDrawPages ( XComponent aDoc ) {
+ XDrawPages oDPn = null;
+ try {
+ XDrawPagesSupplier oDPS = (XDrawPagesSupplier)
+ UnoRuntime.queryInterface(XDrawPagesSupplier.class,aDoc);
+
+ oDPn = oDPS.getDrawPages();
+ } catch ( Exception e ) {
+ throw new IllegalArgumentException( "Couldn't get drawpages" );
+ }
+ return oDPn;
+ } // finish getDrawPages
+
+ /**
+ * gets the specified XDrawPage of a draw document
+ *
+ * @param aDoc the draw document
+ * @param nr the index of the DrawPage
+ * @return the XDrawpage with index nr of the document
+ */
+
+ public static XDrawPage getDrawPage ( XComponent aDoc, int nr ) {
+ XDrawPage oDP = null;
+ try {
+ oDP = (XDrawPage) AnyConverter.toObject(
+ new Type(XDrawPage.class),getDrawPages( aDoc ).getByIndex( nr ));
+ } catch ( Exception e ) {
+ throw new IllegalArgumentException( "Couldn't get drawpage" );
+ }
+ return oDP;
+ }
+
+ /**
+ * gets the XShapes container of a draw page
+ *
+ * @param oDP the draw page
+ * @return the XDrawShape container of the drawpage
+ */
+
+ public static XShapes getShapes ( XDrawPage oDP ) {
+ return (XShapes) UnoRuntime.queryInterface(XShapes.class,oDP);
+ }
+
+ /**
+ * creates a XShape
+ *
+ * @param oDoc the document
+ * @param height the height of the shape
+ * @param width the width of the shape
+ * @param x the x-position of the shape
+ * @param y the y-position of the shape
+ * @param kind the kind of the shape ('Ellipse', 'Line' or 'Rectangle')
+ * @return the created XShape
+ */
+
+ public XShape createShape( XComponent oDoc, int height, int width, int x,
+ int y, String kind ) {
+ //possible values for kind are 'Ellipse', 'Line' and 'Rectangle'
+
+ ShapeDsc sDsc = new ShapeDsc( height, width, x, y, kind );
+ InstCreator instCreate = new InstCreator( oDoc, sDsc );
+ XShape oShape = (XShape)instCreate.getInstance();
+
+ return oShape;
+ }
+
+ /**
+ * creates a XShape and adds it to the documents
+ * first drawpage
+ * @param oDoc the document
+ * @param height the height of the shape
+ * @param width the width of the shape
+ * @param x the x-position of the shape
+ * @param y the y-position of the shape
+ * @param kind the kind of the shape ('Ellipse', 'Line' or 'Rectangle')
+ * @return the created XShape
+ */
+
+ public void addShape( XComponent oDoc, int height, int width, int x,
+ int y, String kind ) {
+
+ getShapes(getDrawPage(oDoc,0)).add(createShape( oDoc, height, width, x,
+ y, kind ) );
+ }
+
+}
diff --git a/qadevOOo/runner/util/DynamicClassLoader.java b/qadevOOo/runner/util/DynamicClassLoader.java
new file mode 100644
index 000000000000..659593e69346
--- /dev/null
+++ b/qadevOOo/runner/util/DynamicClassLoader.java
@@ -0,0 +1,123 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package util;
+
+import java.lang.reflect.Constructor;
+
+public class DynamicClassLoader {
+
+ /**
+ * This method returns a class created by its name
+ * created by call to <code>Class.forName()</code>.<p>
+ * This method must be overloaded if another loading
+ * policy is required for Component and Interface
+ * testing classes.
+ * @param className The name of the class to create.
+ * @return The created class.
+ */
+ public static Class forName(String className)
+ throws ClassNotFoundException {
+
+ return Class.forName(className) ;
+ }
+
+ /**
+ * Get an instance of a class. The empty constructor is used.
+ * @param className The class to instantiate.
+ * @return The instance of the class.
+ */
+ public Object getInstance(String className)
+ throws IllegalArgumentException {
+ try {
+ Class cls = DynamicClassLoader.forName(className);
+ return cls.newInstance();
+ } catch ( ClassNotFoundException e ) {
+ throw new IllegalArgumentException("Couldn't find " + className
+ + " " + e);
+ } catch ( IllegalAccessException e ) {
+ throw new IllegalArgumentException("Couldn't access " + className
+ + " " + e);
+ } catch ( InstantiationException e ) {
+ throw new IllegalArgumentException("Couldn't instantiate " +
+ className + " " + e);
+ }
+ }
+
+ /**
+ * Get an instance of a class. The constructor matching to the
+ * arguments is used and the arguments are given to this constructor.
+ * @param className The class to instantiate.
+ * @param ctorArgs Arguments for the constructor.
+ * @return The instance of the class.
+ */
+ public Object getInstance(String className, Object[] ctorArgs)
+ throws IllegalArgumentException {
+ Class[] ctorType = new Class[ctorArgs.length];
+ for(int i=0; i<ctorType.length; i++) {
+ ctorType[i] = ctorArgs[i].getClass();
+ }
+ return getInstance(className, ctorType, ctorArgs);
+
+ }
+
+ /**
+ * Get an instance of a class. The constructor matching to the
+ * given calss types is used and the instance is created using the arguments
+ * for the constructor.
+ * @param className The class to instantiate.
+ * @param ctorClassTypes The class types matching to the constructor.
+ * @param ctorArgs Arguments for the constructor.
+ * @return The instance of the class.
+ */
+ public Object getInstance(String className, Class[]ctorClassTypes, Object[] ctorArgs)
+ throws IllegalArgumentException {
+ try {
+ Class cls = DynamicClassLoader.forName(className);
+ Constructor ctor = cls.getConstructor(ctorClassTypes);
+ System.out.println("ctor: " + ctor.getName() + " " + ctor.getModifiers());
+
+ return ctor.newInstance(ctorArgs);
+ } catch ( ClassNotFoundException e ) {
+ throw new IllegalArgumentException("Couldn't find " + className
+ + " " + e);
+ } catch ( IllegalAccessException e ) {
+ throw new IllegalArgumentException("Couldn't access " + className
+ + " " + e);
+ } catch ( NoSuchMethodException e ) {
+ throw new IllegalArgumentException("Couldn't find constructor for " + className
+ + " " + e);
+ } catch ( java.lang.reflect.InvocationTargetException e ) {
+ e.printStackTrace();
+ throw new IllegalArgumentException("Couldn't invoke " +
+ className + " " + e);
+ } catch ( InstantiationException e ) {
+ throw new IllegalArgumentException("Couldn't instantiate " +
+ className + " " + e);
+ }
+ }
+}
diff --git a/qadevOOo/runner/util/FootnoteDsc.java b/qadevOOo/runner/util/FootnoteDsc.java
new file mode 100644
index 000000000000..ce7b62d4003b
--- /dev/null
+++ b/qadevOOo/runner/util/FootnoteDsc.java
@@ -0,0 +1,84 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package util;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.uno.XInterface;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.text.XTextContent;
+
+/**
+ * describes a Footnote to be inserted in a container
+ */
+public class FootnoteDsc extends InstDescr {
+
+ final String service = "com.sun.star.text.Footnote";
+ String ifcName = "com.sun.star.text.XTextContent";
+ private String name = null;
+
+
+ public FootnoteDsc() {
+ initFootnote();
+ }
+
+ public FootnoteDsc( String name ) {
+ this.name = name;
+ initFootnote();
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getIfcName() {
+ return ifcName;
+ }
+
+ public String getService() {
+ return service;
+ }
+
+ private void initFootnote() {
+ try {
+ ifcClass = Class.forName( ifcName );
+ }
+ catch( ClassNotFoundException cnfE ) {
+ }
+ }
+ public XInterface createInstance( XMultiServiceFactory docMSF ) {
+ Object ServiceObj = null;
+
+ try {
+ ServiceObj = docMSF.createInstance( service );
+ }
+ catch( com.sun.star.uno.Exception cssuE ){
+ }
+ XTextContent FN = (XTextContent)UnoRuntime.queryInterface( ifcClass,
+ ServiceObj );
+ return FN;
+ }
+} \ No newline at end of file
diff --git a/qadevOOo/runner/util/FormTools.java b/qadevOOo/runner/util/FormTools.java
new file mode 100644
index 000000000000..46515043f677
--- /dev/null
+++ b/qadevOOo/runner/util/FormTools.java
@@ -0,0 +1,349 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package util;
+
+// access the implementations via names
+import com.sun.star.uno.XInterface;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.lang.XComponent;
+import com.sun.star.drawing.XControlShape;
+import com.sun.star.drawing.XDrawPage;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.awt.Size;
+import com.sun.star.awt.Point;
+import com.sun.star.awt.XControlModel;
+import com.sun.star.container.XNameContainer;
+import com.sun.star.container.XIndexContainer;
+import com.sun.star.form.XFormsSupplier;
+import com.sun.star.form.XForm;
+import com.sun.star.form.XLoadable;
+import com.sun.star.text.XTextDocument;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.uno.AnyConverter;
+import com.sun.star.uno.Type;
+
+/**
+ * contains helper methods forms
+ */
+
+public class FormTools {
+
+
+ /**
+ * creates a XControlShape
+ *
+ * @param oDoc the document
+ * @param height the height of the shape
+ * @param width the width of the shape
+ * @param x the x-position of the shape
+ * @param y the y-position of the shape
+ * @param kind the kind of the shape
+ * @return the created XControlShape
+ */
+ public static XControlShape createControlShape( XComponent oDoc, int height,
+ int width, int x, int y, String kind ) {
+
+ Size size = new Size();
+ Point position = new Point();
+ XControlShape oCShape = null;
+ XControlModel aControl = null;
+
+ //get MSF
+ XMultiServiceFactory oDocMSF = (XMultiServiceFactory)
+ UnoRuntime.queryInterface( XMultiServiceFactory.class, oDoc );
+
+ try{
+ Object oInt = oDocMSF.createInstance("com.sun.star.drawing.ControlShape");
+ Object aCon = oDocMSF.createInstance("com.sun.star.form.component."+kind);
+ XPropertySet model_props = (XPropertySet)
+ UnoRuntime.queryInterface(XPropertySet.class,aCon);
+ model_props.setPropertyValue("DefaultControl","com.sun.star.form.control."+kind);
+ aControl = (XControlModel) UnoRuntime.queryInterface( XControlModel.class, aCon );
+ oCShape = (XControlShape) UnoRuntime.queryInterface( XControlShape.class, oInt );
+ size.Height = height;
+ size.Width = width;
+ position.X = x;
+ position.Y = y;
+ oCShape.setSize(size);
+ oCShape.setPosition(position);
+ } catch ( com.sun.star.uno.Exception e ) {
+ // Some exception occures.FAILED
+ System.out.println( "Couldn't create instance "+ e );
+ }
+
+ oCShape.setControl(aControl);
+
+ return oCShape;
+ } // finish createControlShape
+
+ public static XControlShape createUnoControlShape( XComponent oDoc, int height,
+ int width, int x, int y, String kind, String defControl ) {
+
+ Size size = new Size();
+ Point position = new Point();
+ XControlShape oCShape = null;
+ XControlModel aControl = null;
+
+ //get MSF
+ XMultiServiceFactory oDocMSF = (XMultiServiceFactory) UnoRuntime.queryInterface( XMultiServiceFactory.class, oDoc );
+
+ try{
+ Object oInt = oDocMSF.createInstance("com.sun.star.drawing.ControlShape");
+ Object aCon = oDocMSF.createInstance("com.sun.star.form.component."+kind);
+ XPropertySet model_props = (XPropertySet)
+ UnoRuntime.queryInterface(XPropertySet.class,aCon);
+ model_props.setPropertyValue("DefaultControl","com.sun.star.awt."+defControl);
+ aControl = (XControlModel) UnoRuntime.queryInterface( XControlModel.class, aCon );
+ oCShape = (XControlShape) UnoRuntime.queryInterface( XControlShape.class, oInt );
+ size.Height = height;
+ size.Width = width;
+ position.X = x;
+ position.Y = y;
+ oCShape.setSize(size);
+ oCShape.setPosition(position);
+
+
+ } catch ( com.sun.star.uno.Exception e ) {
+ // Some exception occures.FAILED
+ System.out.println( "Couldn't create instance "+ e );
+ }
+
+ oCShape.setControl(aControl);
+
+ return oCShape;
+ } // finish createControlShape
+
+ public static XControlShape createControlShapeWithDefaultControl( XComponent oDoc, int height,
+ int width, int x, int y, String kind ) {
+
+ Size size = new Size();
+ Point position = new Point();
+ XControlShape oCShape = null;
+ XControlModel aControl = null;
+
+ //get MSF
+ XMultiServiceFactory oDocMSF = (XMultiServiceFactory) UnoRuntime.queryInterface( XMultiServiceFactory.class, oDoc );
+
+ try{
+ Object oInt = oDocMSF.createInstance("com.sun.star.drawing.ControlShape");
+ Object aCon = oDocMSF.createInstance("com.sun.star.form.component."+kind);
+
+ aControl = (XControlModel) UnoRuntime.queryInterface( XControlModel.class, aCon );
+ oCShape = (XControlShape) UnoRuntime.queryInterface( XControlShape.class, oInt );
+ size.Height = height;
+ size.Width = width;
+ position.X = x;
+ position.Y = y;
+ oCShape.setSize(size);
+ oCShape.setPosition(position);
+
+
+ } catch ( com.sun.star.uno.Exception e ) {
+ // Some exception occures.FAILED
+ System.out.println( "Couldn't create instance "+ e );
+ }
+
+ oCShape.setControl(aControl);
+
+ return oCShape;
+ } // finish createControlShape
+
+ public static XInterface createControl( XComponent oDoc, String kind ) {
+
+ XInterface oControl = null;
+
+ XMultiServiceFactory oDocMSF = (XMultiServiceFactory)
+ UnoRuntime.queryInterface( XMultiServiceFactory.class, oDoc );
+
+ try{
+ oControl = (XInterface) oDocMSF.createInstance(
+ "com.sun.star.form.component."+kind);
+ } catch ( Exception e ) {
+ // Some exception occures.FAILED
+ System.out.println( "Couldn't create instance "+ kind + ": "+ e );
+ }
+ return oControl;
+ } // finish createControl
+
+ public static XNameContainer getForms ( XDrawPage oDP )
+ {
+ XFormsSupplier oFS = (XFormsSupplier) UnoRuntime.queryInterface(
+ XFormsSupplier.class,oDP);
+ return oFS.getForms();
+ } //finish getForms
+
+ public static XIndexContainer getIndexedForms ( XDrawPage oDP )
+ {
+ XFormsSupplier oFS = (XFormsSupplier) UnoRuntime.queryInterface(
+ XFormsSupplier.class,oDP);
+ return (XIndexContainer)UnoRuntime.queryInterface( XIndexContainer.class,
+ oFS.getForms() );
+ } //finish getIndexedForms
+
+ public static void insertForm ( XComponent aDoc, XNameContainer Forms,
+ String aName ) {
+ try {
+ XInterface oControl = createControl(aDoc, "Form");
+ XForm oForm = (XForm) UnoRuntime.queryInterface(XForm.class, oControl);
+ Forms.insertByName(aName,oForm);
+ } catch ( Exception e ) {
+ throw new IllegalArgumentException( "Couldn't insert Form" );
+ }
+ }
+
+ public static XControlShape insertControlShape( XComponent oDoc, int height,
+ int width, int x, int y, String kind ) {
+
+ XControlShape aShape = createControlShape(oDoc,height,width,x,y,kind);
+ XDrawPage oDP = DrawTools.getDrawPage(oDoc,0);
+ DrawTools.getShapes(oDP).add(aShape);
+ return aShape;
+ }
+
+ public static XLoadable bindForm( XTextDocument aDoc ) {
+ XLoadable formLoader = null;
+
+ try {
+ Object aForm = FormTools.getIndexedForms(WriterTools.getDrawPage(aDoc)).getByIndex(0);
+ XForm the_form = null;
+ try {
+ the_form = (XForm) AnyConverter.toObject(new Type(XForm.class), aForm);
+ } catch (com.sun.star.lang.IllegalArgumentException iae) {
+ System.out.println("### Couldn't convert Any");
+ }
+ XPropertySet formProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, the_form);
+ formProps.setPropertyValue("DataSourceName","Bibliography");
+ formProps.setPropertyValue("Command","biblio");
+ formProps.setPropertyValue("CommandType",new Integer(com.sun.star.sdb.CommandType.TABLE));
+ formLoader = (XLoadable) UnoRuntime.queryInterface(XLoadable.class, the_form);
+ }
+ catch (Exception ex) {
+ System.out.println("Exception: "+ex);
+ ex.printStackTrace(System.out);
+ }
+
+ return formLoader;
+ }
+
+ /**
+ * Binds <code>'Standard'</code> form of <code>aDoc</code> Writer document
+ * to the <code>tableName</code> table of <code>sourceName</code>
+ * Data Source.
+ * @param aDoc Writer document where DB controls are added.
+ * @param sourceName The name of DataSource in the <code>DatabaseContext</code>.
+ * @param tableName The name of the table to which controls are bound.
+ * @return <code>com.sun.star.form.component.DatabaseForm</code> service
+ * implementation which is the bound form inside the document.
+ */
+ public static XLoadable bindForm( XTextDocument aDoc, String sourceName, String tableName )
+ throws com.sun.star.uno.Exception {
+
+ XForm the_form = (XForm) AnyConverter.toObject(new Type(XForm.class),
+ FormTools.getIndexedForms(WriterTools.getDrawPage(aDoc)).getByIndex(0));
+ XPropertySet formProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, the_form);
+ formProps.setPropertyValue("DataSourceName",sourceName);
+ formProps.setPropertyValue("Command",tableName);
+ formProps.setPropertyValue("CommandType",new Integer(com.sun.star.sdb.CommandType.TABLE));
+
+ return (XLoadable) UnoRuntime.queryInterface(XLoadable.class, the_form);
+ }
+
+ public static XLoadable bindForm( XTextDocument aDoc, String formName ) {
+ XLoadable formLoader = null;
+
+ try {
+ XForm the_form = (XForm) FormTools.getForms(WriterTools.getDrawPage(aDoc)).getByName(formName);
+ XPropertySet formProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, the_form);
+ formProps.setPropertyValue("DataSourceName","Bibliography");
+ formProps.setPropertyValue("Command","biblio");
+ formProps.setPropertyValue("CommandType",new Integer(com.sun.star.sdb.CommandType.TABLE));
+ formLoader = (XLoadable) UnoRuntime.queryInterface(XLoadable.class, the_form);
+ }
+ catch (Exception ex) {
+ System.out.println("Exception: "+ex);
+ ex.printStackTrace(System.out);
+ }
+
+ return formLoader;
+ }
+
+ /**
+ * Binds the form with the name specified of <code>aDoc</code> Writer document
+ * to the <code>tableName</code> table of <code>sourceName</code>
+ * Data Source.
+ * @param aDoc Writer document where DB controls are added.
+ * @param formName The name of the form to be bound.
+ * @param sourceName The name of DataSource in the <code>DatabaseContext</code>.
+ * @param tableName The name of the table to which controls are bound.
+ * @return <code>com.sun.star.form.component.DatabaseForm</code> service
+ * implementation which is the bound form inside the document.
+ */
+ public static XLoadable bindForm( XTextDocument aDoc, String formName, String sourceName,
+ String tableName) throws com.sun.star.uno.Exception {
+
+ XForm the_form = (XForm) AnyConverter.toObject(new Type(XForm.class),
+ FormTools.getForms(WriterTools.getDrawPage(aDoc)).getByName(formName));
+ XPropertySet formProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, the_form);
+ formProps.setPropertyValue("DataSourceName",sourceName);
+ formProps.setPropertyValue("Command",tableName);
+ formProps.setPropertyValue("CommandType",new Integer(com.sun.star.sdb.CommandType.TABLE));
+
+ return (XLoadable) UnoRuntime.queryInterface(XLoadable.class, the_form);
+ }
+
+ public static void switchDesignOf(XMultiServiceFactory xMSF, XTextDocument aDoc) {
+ try {
+ com.sun.star.frame.XController aController = aDoc.getCurrentController();
+ com.sun.star.frame.XFrame aFrame = aController.getFrame();
+ com.sun.star.frame.XDispatchProvider aDispProv = (com.sun.star.frame.XDispatchProvider)
+ UnoRuntime.queryInterface(com.sun.star.frame.XDispatchProvider.class,aFrame);
+ com.sun.star.util.URL aURL = new com.sun.star.util.URL();
+ aURL.Complete = ".uno:SwitchControlDesignMode";
+
+ Object instance = xMSF.createInstance("com.sun.star.util.URLTransformer");
+ com.sun.star.util.XURLTransformer atrans =
+ (com.sun.star.util.XURLTransformer)UnoRuntime.queryInterface(
+ com.sun.star.util.XURLTransformer.class,instance);
+ com.sun.star.util.URL[] aURLA = new com.sun.star.util.URL[1];
+ aURLA[0] = aURL;
+ atrans.parseStrict(aURLA);
+ aURL = aURLA[0];
+
+ com.sun.star.frame.XDispatch aDisp = (com.sun.star.frame.XDispatch)aDispProv.queryDispatch(aURL, "",
+ com.sun.star.frame.FrameSearchFlag.SELF |
+ com.sun.star.frame.FrameSearchFlag.CHILDREN);
+
+ com.sun.star.beans.PropertyValue[] noArgs = new com.sun.star.beans.PropertyValue[0];
+ aDisp.dispatch(aURL, noArgs);
+ } catch (Exception e) {
+ System.out.println("******* Mist");
+ e.printStackTrace();
+ }
+ }
+
+}
diff --git a/qadevOOo/runner/util/FrameDsc.java b/qadevOOo/runner/util/FrameDsc.java
new file mode 100644
index 000000000000..4bfb64e8459c
--- /dev/null
+++ b/qadevOOo/runner/util/FrameDsc.java
@@ -0,0 +1,126 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package util;
+
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.uno.XInterface;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.text.XTextFrame;
+import com.sun.star.drawing.XShape;
+import com.sun.star.awt.Size;
+import com.sun.star.beans.XPropertySet;
+/**
+ * the class FrameDsc
+ */
+public class FrameDsc extends InstDescr {
+
+ private Size size = null;
+ private int height = 2000;
+ private int width = 2000;
+ private String name = null;
+ private int autoheigth = 0;
+ private int anchorType = 0;// bound at paragraph
+
+ final String ifcName = "com.sun.star.text.XTextFrame";
+ final String service = "com.sun.star.text.TextFrame";
+
+ public FrameDsc() {
+ initFrame();
+ }
+
+ public FrameDsc( int nHeight, int nWidth ) {
+ height = nHeight;
+ width = nWidth;
+ initFrame();
+ }
+
+ public FrameDsc( String FrameName, int nHeight, int nWidth ) {
+ name = FrameName;
+ height = nHeight;
+ width = nWidth;
+ initFrame();
+ }
+ public String getName() {
+ return name;
+ }
+ public String getIfcName() {
+ return ifcName;
+ }
+ public String getService() {
+ return service;
+ }
+
+ private void initFrame() {
+ try {
+ ifcClass = Class.forName( ifcName );
+ }
+ catch( ClassNotFoundException cnfE ) {
+ }
+ }
+ public XInterface createInstance( XMultiServiceFactory docMSF ) {
+ Object SrvObj = null;
+
+ size = new Size();
+ size.Height = height;
+ size.Width = width;
+
+ try {
+ SrvObj = docMSF.createInstance( service );
+ }
+ catch( com.sun.star.uno.Exception cssuE ){
+ }
+ XShape shape = (XShape)UnoRuntime.queryInterface( XShape.class, SrvObj );
+ try {
+ shape.setSize(size);
+ }
+ catch( com.sun.star.beans.PropertyVetoException pvE ){
+ }
+
+ XTextFrame TF = (XTextFrame)UnoRuntime.queryInterface( ifcClass, SrvObj );
+
+ XPropertySet oPropSet = (XPropertySet)
+ UnoRuntime.queryInterface( XPropertySet.class, SrvObj );
+
+
+ try {
+ oPropSet.setPropertyValue("AnchorType", new Integer(2));
+ }
+ catch( com.sun.star.beans.UnknownPropertyException upE ){
+ }
+ catch( com.sun.star.beans.PropertyVetoException pvE ){
+ }
+ catch( com.sun.star.lang.IllegalArgumentException iaE ){
+ }
+ catch( com.sun.star.lang.WrappedTargetException wtE ){
+ }
+
+
+
+ return TF;
+ }
+}
diff --git a/qadevOOo/runner/util/InstCreator.java b/qadevOOo/runner/util/InstCreator.java
new file mode 100644
index 000000000000..b76066d7e95e
--- /dev/null
+++ b/qadevOOo/runner/util/InstCreator.java
@@ -0,0 +1,122 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package util;
+
+import util.XInstCreator;
+
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XInterface;
+import com.sun.star.text.XTextTablesSupplier;
+import com.sun.star.text.XTextFramesSupplier;
+import com.sun.star.text.XTextSectionsSupplier;
+import com.sun.star.text.XFootnotesSupplier;
+import com.sun.star.text.XBookmarksSupplier;
+import com.sun.star.container.XNameAccess;
+import com.sun.star.container.XIndexAccess;
+
+
+public class InstCreator implements XInstCreator {
+ XInterface xParent;
+ XMultiServiceFactory xMSF;
+ XInterface xInstance;
+ XIndexAccess xIA;
+ InstDescr iDsc;
+
+ public InstCreator( XInterface xParent, InstDescr iDsc ) {
+ this.xParent = xParent;
+ this.iDsc = iDsc;
+
+ xMSF = (XMultiServiceFactory)UnoRuntime.queryInterface(
+ XMultiServiceFactory.class, xParent );
+
+ xInstance = createInstance();
+ xIA = createCollection();
+ }
+ public XInterface getInstance() {
+ return xInstance;
+ }
+
+ public XInterface createInstance() {
+ XInterface xIfc = null;
+ Object xObj = null;
+
+ xIfc = iDsc.createInstance( xMSF );
+
+ return xIfc;
+ }
+
+ public XIndexAccess getCollection() {
+ return xIA;
+ }
+
+ private XIndexAccess createCollection() {
+ XNameAccess oNA = null;
+
+ if ( iDsc instanceof TableDsc ) {
+ XTextTablesSupplier oTTS = (XTextTablesSupplier)
+ UnoRuntime.queryInterface(
+ XTextTablesSupplier.class, xParent );
+
+ oNA = oTTS.getTextTables();
+ }
+ if ( iDsc instanceof FrameDsc ) {
+ XTextFramesSupplier oTTS = (XTextFramesSupplier)
+ UnoRuntime.queryInterface(
+ XTextFramesSupplier.class, xParent );
+
+ oNA = oTTS.getTextFrames();
+ }
+ if ( iDsc instanceof BookmarkDsc ) {
+ XBookmarksSupplier oTTS = (XBookmarksSupplier)
+ UnoRuntime.queryInterface(
+ XBookmarksSupplier.class, xParent );
+
+ oNA = oTTS.getBookmarks();
+ }
+
+ if ( iDsc instanceof FootnoteDsc ) {
+ XFootnotesSupplier oTTS = (XFootnotesSupplier)
+ UnoRuntime.queryInterface(
+ XFootnotesSupplier.class, xParent );
+
+ return( oTTS.getFootnotes() );
+ }
+
+ if ( iDsc instanceof TextSectionDsc ) {
+ XTextSectionsSupplier oTSS = (XTextSectionsSupplier)
+ UnoRuntime.queryInterface(
+ XTextSectionsSupplier.class, xParent );
+
+ oNA = oTSS.getTextSections();
+ }
+
+ return (XIndexAccess)UnoRuntime.queryInterface(
+ XIndexAccess.class, oNA);
+ }
+} \ No newline at end of file
diff --git a/qadevOOo/runner/util/InstDescr.java b/qadevOOo/runner/util/InstDescr.java
new file mode 100644
index 000000000000..e8343bc866e3
--- /dev/null
+++ b/qadevOOo/runner/util/InstDescr.java
@@ -0,0 +1,53 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package util;
+
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.uno.XInterface;
+/**
+ * the class InstDescr
+ */
+abstract public class InstDescr {
+
+ protected Class ifcClass = null;
+
+ protected abstract String getIfcName();
+ protected abstract String getName();
+
+ /**
+ * the method getIfcClass
+ */
+ public Class getIfcClass() {
+ return ifcClass;
+ }
+ /**
+ * the method getService
+ */
+ protected abstract String getService();
+ protected abstract XInterface createInstance( XMultiServiceFactory docMSF );
+} \ No newline at end of file
diff --git a/qadevOOo/runner/util/ParagraphDsc.java b/qadevOOo/runner/util/ParagraphDsc.java
new file mode 100644
index 000000000000..acaa630baad5
--- /dev/null
+++ b/qadevOOo/runner/util/ParagraphDsc.java
@@ -0,0 +1,85 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package util;
+
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.uno.XInterface;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.text.XTextContent;
+
+/**
+ * the class ParagraphDsc
+ */
+public class ParagraphDsc extends InstDescr {
+
+ final String service = "com.sun.star.text.Paragraph";
+ String ifcName = "com.sun.star.text.XTextContent";
+ private String name = null;
+
+
+ public ParagraphDsc() {
+ initParagraph();
+ }
+
+ public ParagraphDsc( String name ) {
+ this.name = name;
+ initParagraph();
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getIfcName() {
+ return ifcName;
+ }
+
+ public String getService() {
+ return service;
+ }
+
+ private void initParagraph() {
+ try {
+ ifcClass = Class.forName( ifcName );
+ }
+ catch( ClassNotFoundException cnfE ) {
+ }
+ }
+ public XInterface createInstance( XMultiServiceFactory docMSF ) {
+ Object ServiceObj = null;
+
+ try {
+ ServiceObj = docMSF.createInstance( service );
+ }
+ catch( com.sun.star.uno.Exception cssuE ){
+ }
+ XTextContent PG = (XTextContent)UnoRuntime.queryInterface( ifcClass,
+ ServiceObj );
+ return PG;
+ }
+} \ No newline at end of file
diff --git a/qadevOOo/runner/util/PropertyName.java b/qadevOOo/runner/util/PropertyName.java
new file mode 100644
index 000000000000..075fa4d9704e
--- /dev/null
+++ b/qadevOOo/runner/util/PropertyName.java
@@ -0,0 +1,169 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package util;
+
+/**
+ * This interfaces describes some key names which are used in <CODE>lib.TestParameters</CODE>.
+ */
+
+public interface PropertyName {
+ /**
+ * parameter name: "AppExecutionCommand"
+ */
+ final public static String APP_EXECUTION_COMMAND = "AppExecutionCommand";
+ /**
+ * parameter name: "AppKillCommand"
+ */
+ final public static String APP_KILL_COMMAND = "AppKillCommand";
+ /**
+ * parameter name: "ConnectionString"
+ */
+ final public static String CONNECTION_STRING = "ConnectionString";
+ final public static String PIPE_CONNECTION_STRING = "PipeConnectionString";
+ final public static String USE_PIPE_CONNECTION = "UsePipeConnection";
+
+ /**
+ * parameter name: "TestBase"
+ */
+ final public static String TEST_BASE = "TestBase";
+ /**
+ * parameter name: "TestDocumentPath"
+ */
+ final public static String TEST_DOCUMENT_PATH = "TestDocumentPath";
+ /**
+ * parameter name: "LoggingIsActive"
+ */
+ final public static String LOGGING_IS_ACTIVE = "LoggingIsActive";
+ /**
+ * parameter name: "DebugIsActive"
+ */
+ final public static String DEBUG_IS_ACTIVE = "DebugIsActive";
+ /**
+ * parameter name: "OutProduceer"
+ */
+ final public static String OUT_PRODUCER = "OutProducer";
+ /**
+ * parameter name: "ShortWait"
+ */
+ final public static String SHORT_WAIT= "ShortWait";
+ /**
+ * internal only, no parameter
+ */
+ final public static String OFFICE_PROVIDER = "OfficeProvider";
+ /**
+ * internal only, no parameter
+ */
+ final public static String OFFICE_WATCHER = "Watcher";
+ /**
+ * internal only, no parameter
+ */
+ final public static String LOG_WRITER = "LogWriter";
+ /**
+ * parameter name: "TimeOut"<p>
+ * time out given in milli seconds
+ */
+ final public static String TIME_OUT = "TimeOut";
+ /**
+ * parameter name: "ThreadTimeOut"
+ */
+ final public static String THREAD_TIME_OUT = "ThreadTimeOut";
+ /**
+ * parameter name: "OfficeCloseTimeOut"
+ */
+ final public static String OFFICE_CLOSE_TIME_OUT = "OfficeCloseTimeOut";
+ /**
+ * parameter name: "OperatingSystem"
+ */
+ final public static String OPERATING_SYSTEM = "OperatingSystem";
+ /**
+ * parameter name: "AutoRestart"
+ */
+ final public static String AUTO_RESTART = "AutoRestart";
+ /**
+ * parameter name: "NewOfficeInstance"
+ */
+ final public static String NEW_OFFICE_INSTANCE = "NewOfficeInstance";
+ /**
+ * parameter name: "KeepDocument"
+ */
+ final public static String KEEP_DOCUMENT = "KeepDocument";
+ /**
+ * parameter name: "SRC_ROOT"<p>
+ * path to the source root of OpenOffice.org
+ */
+ final public static String SRC_ROOT = "SRC_ROOT";
+ /**
+ * parameter name: "Version"<p>
+ * the name of the version to test
+ */
+ final public static String VERSION = "Version";
+
+ /**
+ * parameter name "Shell"<p>
+ * Path to a shell.
+ * This shell is used to run some commands outside of Java
+ * example: /bin/tcsh c:\\myShell\\myShell.exe
+ */
+ final public static String SHELL = "Shell";
+ /**
+ * parameter name "Cygwin"<p>
+ * If Cygwin is set to TRUE it indicates if the runner runs in a Cygwin
+ * environment
+ */
+ final public static String CYGWIN = "Cygwin";
+ /**
+ * parameter name: "NoCwsAttach"<p>
+ * If this paraeter is set to "true" , a status of CWS-UnoAPI-Tests was not attached to EIS<p>
+ * @see tests.complex.unoapi.CheckModuleAPI
+ */
+ final public static String NO_CWS_ATTACH = "NoCwsAttach";
+ /**
+ * internal only, no parameter
+ */
+ final public static String WNTMSCI = "wntmsci";
+ /**
+ * internal only, no parameter
+ */
+ final public static String UNXLNGI = "unxlngi";
+ /**
+ * internal only, no parameter
+ */
+ final public static String UNXSOLS = "unxsols";
+ /**
+ * internal only, no parameter
+ */
+ final public static String UNXSOLI = "unxsoli";
+ /**
+ * internal only, no parameter
+ */
+ final public static String UNXMACXI = "unxmacxi";
+
+ /**
+ * can be used to dont backup the user layer, faster office start/stop but less secure default is to backup the user layer
+ */
+ final public static String DONT_BACKUP_USERLAYER = "DontBackupUserLayer";
+}
diff --git a/qadevOOo/runner/util/ReferenceMarkDsc.java b/qadevOOo/runner/util/ReferenceMarkDsc.java
new file mode 100644
index 000000000000..948fab207a13
--- /dev/null
+++ b/qadevOOo/runner/util/ReferenceMarkDsc.java
@@ -0,0 +1,84 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package util;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.uno.XInterface;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.text.XTextContent;
+
+/**
+ * the class ReferenceMarkDsc
+ */
+public class ReferenceMarkDsc extends InstDescr {
+
+ final String service = "com.sun.star.text.ReferenceMark";
+ String ifcName = "com.sun.star.text.XTextContent";
+ private String name = null;
+
+
+ public ReferenceMarkDsc() {
+ initReferenceMark();
+ }
+
+ public ReferenceMarkDsc( String name ) {
+ this.name = name;
+ initReferenceMark();
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getIfcName() {
+ return ifcName;
+ }
+
+ public String getService() {
+ return service;
+ }
+
+ private void initReferenceMark() {
+ try {
+ ifcClass = Class.forName( ifcName );
+ }
+ catch( ClassNotFoundException cnfE ) {
+ }
+ }
+ public XInterface createInstance( XMultiServiceFactory docMSF ) {
+ Object ServiceObj = null;
+
+ try {
+ ServiceObj = docMSF.createInstance( service );
+ }
+ catch( com.sun.star.uno.Exception cssuE ){
+ }
+ XTextContent RM = (XTextContent)UnoRuntime.queryInterface( ifcClass,
+ ServiceObj );
+ return RM;
+ }
+} \ No newline at end of file
diff --git a/qadevOOo/runner/util/RegistryTools.java b/qadevOOo/runner/util/RegistryTools.java
new file mode 100644
index 000000000000..199eb1c01451
--- /dev/null
+++ b/qadevOOo/runner/util/RegistryTools.java
@@ -0,0 +1,370 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package util;
+
+// access the implementations via names
+import com.sun.star.uno.UnoRuntime;
+import java.io.PrintWriter ;
+
+import com.sun.star.registry.XRegistryKey ;
+import com.sun.star.registry.XSimpleRegistry ;
+import com.sun.star.registry.RegistryKeyType ;
+import com.sun.star.registry.RegistryValueType ;
+import com.sun.star.registry.InvalidRegistryException ;
+import com.sun.star.lang.XMultiServiceFactory ;
+import com.sun.star.uno.Exception;
+
+public class RegistryTools {
+
+ /**
+ * Creates 'com.sun.star.registry.SimpleRegistry'
+ * service.
+ * @param xMSF Multiservice factory.
+ * @return Service created.
+ */
+ public static XSimpleRegistry createRegistryService
+ (XMultiServiceFactory xMSF) throws com.sun.star.uno.Exception {
+
+ Object oInterface = xMSF.createInstance
+ ("com.sun.star.registry.SimpleRegistry");
+ return (XSimpleRegistry) UnoRuntime.queryInterface (
+ XSimpleRegistry.class, oInterface) ;
+ }
+
+ /**
+ * Opens registry file for reading/writing. If file doesn't
+ * exist a new one created.
+ * @param file Registry file name.
+ * @param xMSF Multiservice factory.
+ * @return Opened registry.
+ */
+ public static XSimpleRegistry openRegistry
+ (String file, XMultiServiceFactory xMSF)
+ throws com.sun.star.uno.Exception {
+
+ XSimpleRegistry reg = createRegistryService(xMSF) ;
+
+ reg.open(file, false, true) ;
+
+ return reg ;
+ }
+
+ /**
+ * Compares two registry keys, their names, value
+ * types and values.
+ * return <code>true</code> if key names, value types
+ * and values are equal, else returns <code>false</code>.
+ */
+ public static boolean compareKeys
+ (XRegistryKey key1, XRegistryKey key2) {
+
+ if (key1 == null || key2 == null ||
+ !key1.isValid() || !key2.isValid())
+
+ return false ;
+
+ String keyName1 = getShortKeyName(key1.getKeyName()) ;
+ String keyName2 = getShortKeyName(key2.getKeyName()) ;
+
+ if (!keyName1.equals(keyName2)) return false ;
+
+ try {
+ if (key1.getValueType() != key2.getValueType()) return false ;
+ } catch (InvalidRegistryException e) {
+ return false ;
+ }
+
+ RegistryValueType type ;
+ try {
+ type = key1.getValueType() ;
+
+ if (type.equals(RegistryValueType.ASCII)) {
+ if (!key1.getAsciiValue().equals(key2.getAsciiValue()))
+ return false ;
+ } else
+ if (type.equals(RegistryValueType.STRING)) {
+ if (!key1.getStringValue().equals(key2.getStringValue()))
+ return false ;
+ } else
+ if (type.equals(RegistryValueType.LONG)) {
+ if (key1.getLongValue() != key2.getLongValue())
+ return false ;
+ } else
+ if (type.equals(RegistryValueType.BINARY)) {
+ byte[] bin1 = key1.getBinaryValue() ;
+ byte[] bin2 = key2.getBinaryValue() ;
+ if (bin1.length != bin2.length)
+ return false ;
+ for (int i = 0; i < bin1.length; i++)
+ if (bin1[i] != bin2[i]) return false ;
+ } else
+ if (type.equals(RegistryValueType.ASCIILIST)) {
+ String[] list1 = key1.getAsciiListValue() ;
+ String[] list2 = key2.getAsciiListValue() ;
+ if (list1.length != list2.length)
+ return false ;
+ for (int i = 0; i < list1.length; i++)
+ if (!list1[i].equals(list2[i])) return false ;
+ } else
+ if (type.equals(RegistryValueType.STRINGLIST)) {
+ String[] list1 = key1.getStringListValue() ;
+ String[] list2 = key2.getStringListValue() ;
+ if (list1.length != list2.length)
+ return false ;
+ for (int i = 0; i < list1.length; i++)
+ if (!list1[i].equals(list2[i])) return false ;
+ } else
+ if (type.equals(RegistryValueType.LONGLIST)) {
+ int[] list1 = key1.getLongListValue() ;
+ int[] list2 = key2.getLongListValue() ;
+ if (list1.length != list2.length)
+ return false ;
+ for (int i = 0; i < list1.length; i++)
+ if (list1[i] != list2[i]) return false ;
+ }
+ } catch (Exception e) {
+ return false ;
+ }
+
+ return true ;
+ }
+
+ /**
+ * Gets name of the key relative to its parent.
+ * For example if full name of key is '/key1/subkey'
+ * short key name is 'subkey'
+ * @param keyName Full key name.
+ * @return Short key name.
+ */
+ public static String getShortKeyName(String keyName) {
+ if (keyName == null) return null ;
+ int idx = keyName.lastIndexOf("/") ;
+ if (idx < 0) return keyName ;
+ else return keyName.substring(idx + 1) ;
+ }
+
+ /**
+ * Compare all child keys.
+ * @param compareRoot If <code>true</code> method also
+ * compare root keys, if <code>false</code> it begins recursive
+ * comparing from children of root keys.
+ * @return <code>true</code> if keys and their sub keys are equal.
+ */
+ protected static boolean compareKeyTrees
+ (XRegistryKey tree1, XRegistryKey tree2, boolean compareRoot) {
+
+ if (compareRoot && !compareKeys(tree1, tree2)) return false ;
+
+ try {
+ String[] keyNames1 = tree1.getKeyNames() ;
+ String[] keyNames2 = tree2.getKeyNames() ;
+
+ if (keyNames1 == null && keyNames2 == null) return true ;
+
+ if (keyNames1 == null || keyNames2 == null ||
+ keyNames2.length != keyNames1.length)
+ return false ;
+
+ for (int i = 0; i < keyNames1.length; i++) {
+
+ String keyName = getShortKeyName(keyNames1[i]) ;
+ XRegistryKey key2 = tree2.openKey(keyName) ;
+
+ if (key2 == null)
+ // key with the same name doesn't exist in the second tree
+ return false ;
+
+ if (!tree1.getKeyType(keyName).equals(
+ tree2.getKeyType(keyName)))
+ return false ;
+
+ if (tree1.getKeyType(keyName).equals(
+ RegistryKeyType.LINK)) {
+
+ if (!getShortKeyName(tree1.getLinkTarget(keyName)).equals(
+ getShortKeyName(tree2.getLinkTarget(keyName))))
+
+ return false ;
+ } else {
+
+ if (compareKeyTrees(tree1.openKey(keyName),
+ tree2.openKey(keyName), true) == false) return false ;
+ }
+ }
+ } catch (InvalidRegistryException e) {
+ return false ;
+ }
+
+ return true ;
+ }
+
+ /**
+ * Compare keys specified and all their child keys.
+ * @return <code>true</code> if keys and their sub keys are equal.
+ */
+ public static boolean compareKeyTrees
+ (XRegistryKey tree1, XRegistryKey tree2) {
+
+ return compareKeyTrees(tree1, tree2, false) ;
+ }
+
+ /**
+ * Prints to a specified output about all keys and subkeys information
+ * (key name, type, value, link target, attributes) recursively.
+ * @param reg Registry for which information is needed.
+ * @param out Output stream.
+ */
+ public static void printRegistryInfo(XSimpleRegistry reg, PrintWriter out) {
+ try {
+ printRegistryInfo(reg.getRootKey(), out) ;
+ } catch (com.sun.star.registry.InvalidRegistryException e) {
+ out.println("!!! Can't open root registry key for info printing") ;
+ }
+ }
+
+ /**
+ * Prints to a specified output about all keys and subkeys information
+ * (key name, type, value, link target, attributes) recursively.
+ * @param root Key for which subkeys (and further) information is required.
+ * @param out Output stream.
+ */
+ public static void printRegistryInfo(XRegistryKey root, PrintWriter out) {
+ if (root == null) {
+ out.println("/(null)") ;
+ return ;
+ }
+
+ out.println("/") ;
+ try {
+ printTreeInfo(root, out, " ") ;
+ } catch (com.sun.star.registry.InvalidRegistryException e) {
+ out.println("Exception accessing registry :") ;
+ e.printStackTrace(out) ;
+ }
+ }
+
+ private static void printTreeInfo(XRegistryKey key,
+ PrintWriter out, String margin)
+ throws com.sun.star.registry.InvalidRegistryException {
+
+ String[] subKeys = key.getKeyNames() ;
+
+ if (subKeys == null || subKeys.length == 0) return ;
+
+ for (int i = 0; i < subKeys.length; i++) {
+ printKeyInfo(key, subKeys[i], out, margin) ;
+ XRegistryKey subKey = key.openKey
+ (getShortKeyName(subKeys[i])) ;
+ printTreeInfo(subKey, out, margin + " ") ;
+ subKey.closeKey() ;
+ }
+ }
+
+ private static void printKeyInfo(XRegistryKey parentKey,
+ String keyName, PrintWriter out, String margin)
+ throws com.sun.star.registry.InvalidRegistryException {
+
+ out.print(margin) ;
+ keyName = getShortKeyName(keyName) ;
+ XRegistryKey key = parentKey.openKey(keyName) ;
+ if (key != null)
+ out.print("/" + getShortKeyName(key.getKeyName()) + " ") ;
+ else {
+ out.println("(null)") ;
+ return ;
+ }
+
+ if (!key.isValid()) {
+ out.println("(not valid)") ;
+ return ;
+ }
+
+ if (key.isReadOnly()) {
+ out.print("(read only) ") ;
+ }
+
+ if (parentKey.getKeyType(keyName) == RegistryKeyType.LINK) {
+ out.println("(link to " + parentKey.getLinkTarget(keyName) + ")") ;
+ return ;
+ }
+
+ RegistryValueType type ;
+ try {
+ type = key.getValueType() ;
+
+ if (type.equals(RegistryValueType.ASCII)) {
+ out.println("[ASCII] = '" + key.getAsciiValue() + "'") ;
+ } else
+ if (type.equals(RegistryValueType.STRING)) {
+ out.println("[STRING] = '" + key.getStringValue() + "'") ;
+ } else
+ if (type.equals(RegistryValueType.LONG)) {
+ out.println("[LONG] = " + key.getLongValue()) ;
+ } else
+ if (type.equals(RegistryValueType.BINARY)) {
+ out.print("[BINARY] = {") ;
+ byte[] bin = key.getBinaryValue() ;
+ for (int i = 0; i < bin.length; i++)
+ out.print("" + bin[i] + ",") ;
+ out.println("}") ;
+ } else
+ if (type.equals(RegistryValueType.ASCIILIST)) {
+ out.print("[ASCIILIST] = {") ;
+ String[] list = key.getAsciiListValue() ;
+ for (int i = 0; i < list.length; i++)
+ out.print("'" + list[i] + "',") ;
+ out.println("}") ;
+ } else
+ if (type.equals(RegistryValueType.STRINGLIST)) {
+ out.print("[STRINGLIST] = {") ;
+ String[] list = key.getStringListValue() ;
+ for (int i = 0; i < list.length; i++)
+ out.print("'" + list[i] + "',") ;
+ out.println("}") ;
+ } else
+ if (type.equals(RegistryValueType.LONGLIST)) {
+ out.print("[LONGLIST] = {") ;
+ int[] list = key.getLongListValue() ;
+ for (int i = 0; i < list.length; i++)
+ out.print("" + list[i] + ",") ;
+ out.println("}") ;
+ } else {
+ out.println("") ;
+ }
+ } catch (com.sun.star.uno.Exception e) {
+ out.println("Exception occured : ") ;
+ e.printStackTrace(out) ;
+ } finally {
+ key.closeKey() ;
+ }
+ }
+
+
+// public static void compareKeyTrees
+
+}
diff --git a/qadevOOo/runner/util/SOfficeFactory.java b/qadevOOo/runner/util/SOfficeFactory.java
new file mode 100644
index 000000000000..80493fdee058
--- /dev/null
+++ b/qadevOOo/runner/util/SOfficeFactory.java
@@ -0,0 +1,629 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package util;
+
+import java.util.Hashtable;
+// access the implementations via names
+import com.sun.star.uno.XInterface;
+import com.sun.star.lang.XMultiServiceFactory;
+
+import com.sun.star.uno.UnoRuntime;
+// staroffice interfaces to provide desktop and componentloader
+// and components i.e. spreadsheets, writerdocs etc.
+import com.sun.star.frame.XDesktop;
+import com.sun.star.frame.XComponentLoader;
+import com.sun.star.lang.XComponent;
+import com.sun.star.lang.XServiceInfo;
+
+// name - value pair
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.beans.PropertyState;
+
+// additional classes required for testcase
+import com.sun.star.sheet.*;
+import com.sun.star.text.*;
+import com.sun.star.container.*;
+import com.sun.star.chart.*;
+import com.sun.star.drawing.*;
+import com.sun.star.awt.*;
+
+public class SOfficeFactory {
+
+ private static Hashtable lookup = new Hashtable(10);
+ protected XComponentLoader oCLoader;
+
+ private SOfficeFactory(XMultiServiceFactory xMSF) {
+ // get XInterface of Desktop service
+ Object oInterface;
+ try {
+ oInterface = xMSF.createInstance("com.sun.star.frame.Desktop");
+ } catch (com.sun.star.uno.Exception e) {
+ throw new IllegalArgumentException(
+ "Desktop Service not available");
+ }
+
+ // query the desktop interface and then it's componentloader
+ XDesktop oDesktop = (XDesktop) UnoRuntime.queryInterface(
+ XDesktop.class, oInterface);
+
+ oCLoader = (XComponentLoader) UnoRuntime.queryInterface(
+ XComponentLoader.class, oDesktop);
+ }
+
+ public static SOfficeFactory getFactory(XMultiServiceFactory xMSF) {
+
+ SOfficeFactory soFactory = (SOfficeFactory) lookup.get(new Integer(xMSF.hashCode()).toString());
+
+ if (soFactory == null) {
+ soFactory = new SOfficeFactory(xMSF);
+ lookup.put(new Integer(xMSF.hashCode()).toString(), soFactory);
+ }
+
+ return soFactory;
+ }
+
+ // *********************************************************
+ // Document creation. The documents needed are created here.
+ // *********************************************************
+ /**
+ * method which opens a new TextDocument
+ *
+ * @see XTextDocument
+ */
+ public XTextDocument createTextDoc(String frameName)
+ throws com.sun.star.uno.Exception {
+
+ XComponent oDoc = openDoc("swriter", frameName);
+
+ if (oDoc != null) {
+ DesktopTools.bringWindowToFront(oDoc);
+ return (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, oDoc);
+ } else {
+ return null;
+ }
+
+ } // finished createTextDoc
+
+ /**
+ * method which opens a new TextDocument
+ *
+ * @see XTextDocument
+ */
+ public XTextDocument createTextDoc(String frameName, PropertyValue[] mediaDescriptor)
+ throws com.sun.star.uno.Exception {
+
+ XComponent oDoc = openDoc("swriter", frameName, mediaDescriptor);
+
+ if (oDoc != null) {
+ DesktopTools.bringWindowToFront(oDoc);
+ return (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, oDoc);
+ } else {
+ return null;
+ }
+ } // finished createTextDoc
+
+ /**
+ * method which opens a new SpreadsheetDocument
+ *
+ * @see XSpreadsheetDocument
+ */
+ public XSpreadsheetDocument createCalcDoc(String frameName)
+ throws com.sun.star.uno.Exception {
+
+ XComponent oDoc = openDoc("scalc", frameName);
+
+ if (oDoc != null) {
+ DesktopTools.bringWindowToFront(oDoc);
+ return (XSpreadsheetDocument) UnoRuntime.queryInterface(XSpreadsheetDocument.class, oDoc);
+ } else {
+ return null;
+ }
+ } // finished createCalcDoc
+
+ /**
+ * method which opens a new SpreadsheetDocument
+ *
+ * @see XSpreadsheetDocument
+ */
+ public XSpreadsheetDocument createCalcDoc(String frameName, PropertyValue[] mediaDescriptor)
+ throws com.sun.star.uno.Exception {
+
+ XComponent oDoc = openDoc("scalc", frameName, mediaDescriptor);
+
+ if (oDoc != null) {
+ DesktopTools.bringWindowToFront(oDoc);
+ return (XSpreadsheetDocument) UnoRuntime.queryInterface(XSpreadsheetDocument.class, oDoc);
+ } else {
+ return null;
+ }
+ } // finished createCalcDoc
+
+ /**
+ * method which opens a new DrawDocument
+ */
+ public XComponent createDrawDoc(String frameName)
+ throws com.sun.star.uno.Exception {
+
+ return openDoc("sdraw", frameName);
+ } // finished createDrawDoc
+
+ /**
+ * method which opens a new ImpressDocument
+ */
+ /**
+ * method which opens a new DrawDocument
+ */
+ public XComponent createDrawDoc(String frameName, PropertyValue[] mediaDescriptor)
+ throws com.sun.star.uno.Exception {
+
+ return openDoc("sdraw", frameName, mediaDescriptor);
+ } // finished createDrawDoc
+
+ /**
+ * method which opens a new ImpressDocument
+ */
+ public XComponent createImpressDoc(String frameName)
+ throws com.sun.star.uno.Exception {
+
+ return openDoc("simpress", frameName);
+ } // finished createImpressDoc
+
+ /**
+ * method which opens a new ImpressDocument
+ */
+ public XComponent createImpressDoc(String frameName, PropertyValue[] mediaDescriptor)
+ throws com.sun.star.uno.Exception {
+
+ return openDoc("simpress", frameName, mediaDescriptor);
+ } // finished createImpressDoc
+
+ /**
+ * method which opens a new MathDocument
+ */
+ public XComponent createMathDoc(String frameName)
+ throws com.sun.star.uno.Exception {
+
+ return openDoc("smath", frameName);
+ } // finished createMathDoc
+
+ /**
+ * method which opens a new MathDocument
+ */
+ public XComponent createMathDoc(String frameName, PropertyValue[] mediaDescriptor)
+ throws com.sun.star.uno.Exception {
+
+ return openDoc("smath", frameName, mediaDescriptor);
+ } // finished createMathDoc
+
+ /**
+ * method which opens a new ChartDocument
+ *
+ * @see XChartDocument
+ */
+ public XChartDocument createChartDoc(String frameName)
+ throws com.sun.star.uno.Exception {
+
+// XComponent oDoc = loadDocument(
+// util.utils.getFullTestURL("emptyChart.sds"));
+
+ XComponent oDoc = loadDocument("private:factory/schart");
+
+ if (oDoc != null) {
+ DesktopTools.bringWindowToFront(oDoc);
+ return (XChartDocument) UnoRuntime.queryInterface(XChartDocument.class, oDoc);
+ } else {
+ return null;
+ }
+
+ } // finished createChartDoc
+
+ /**
+ * creates a simple TextTable defaultet to 2 rows and 2 columns
+ */
+ public static XTextTable createTextTable(XTextDocument xTextDoc)
+ throws com.sun.star.uno.Exception {
+
+ TableDsc tDsc = new TableDsc();
+ InstCreator instCreate = new InstCreator(xTextDoc, tDsc);
+
+ XTextTable oTable = (XTextTable) instCreate.getInstance();
+ return oTable;
+ }
+
+ /**
+ * creates a TextTable with a specified count of rows and columns
+ */
+ public static XTextTable createTextTable(XTextDocument xTextDoc,
+ int rows, int columns)
+ throws com.sun.star.uno.Exception {
+
+ TableDsc tDsc = new TableDsc(rows, columns);
+ InstCreator instCreate = new InstCreator(xTextDoc, tDsc);
+
+ XTextTable oTable = (XTextTable) instCreate.getInstance();
+ return oTable;
+ }
+
+ /**
+ * creates a simple TextFrame
+ * ... to be continued
+ */
+ public static XTextFrame createTextFrame(XTextDocument xTextDoc)
+ throws com.sun.star.uno.Exception {
+
+ FrameDsc tDsc = new FrameDsc();
+ InstCreator instCreate = new InstCreator(xTextDoc, tDsc);
+
+ XTextFrame oFrame = (XTextFrame) instCreate.getInstance();
+ return oFrame;
+ }
+
+ /**
+ * creates a simple TextFrame
+ * ... to be continued
+ */
+ public static XTextFrame createTextFrame(XTextDocument xTextDoc,
+ int height, int width) {
+
+ FrameDsc tDsc = new FrameDsc(height, width);
+ InstCreator instCreate = new InstCreator(xTextDoc, tDsc);
+
+ XTextFrame oFrame = (XTextFrame) instCreate.getInstance();
+ return oFrame;
+ }
+
+ public static void insertString(XTextDocument xTextDoc, String cString)
+ throws com.sun.star.uno.Exception {
+ XText xText = xTextDoc.getText();
+ XText oText = (XText) UnoRuntime.queryInterface(
+ XText.class, xText);
+
+ XTextCursor oCursor = oText.createTextCursor();
+ oText.insertString(oCursor, cString, false);
+ }
+
+ public static void insertTextContent(XTextDocument xTextDoc,
+ XTextContent xCont)
+ throws com.sun.star.lang.IllegalArgumentException {
+ XText xText = xTextDoc.getText();
+ XText oText = (XText) UnoRuntime.queryInterface(
+ XText.class, xText);
+
+ XTextCursor oCursor = oText.createTextCursor();
+ oText.insertTextContent(oCursor, xCont, false);
+ }
+
+ public static com.sun.star.table.XCell getFirstTableCell(
+ XTextContent oTable) {
+
+ String CellNames[] = ((XTextTable) oTable).getCellNames();
+
+ com.sun.star.table.XCell oCell = ((XTextTable) oTable).getCellByName(
+ CellNames[0]);
+ return oCell;
+
+ }
+
+ /**
+ * the method createBookmark
+ */
+ public static XTextContent createBookmark(XTextDocument xTextDoc)
+ throws com.sun.star.uno.Exception {
+
+ BookmarkDsc tDsc = new BookmarkDsc();
+ InstCreator instCreate = new InstCreator(xTextDoc, tDsc);
+
+ XTextContent oBookmark = (XTextContent) instCreate.getInstance();
+ return oBookmark;
+
+ } /// finish createBookmark
+
+ /**
+ * the method createReferenceMark
+ */
+ public static XTextContent createReferenceMark(XTextDocument xTextDoc)
+ throws com.sun.star.uno.Exception {
+
+ ReferenceMarkDsc tDsc = new ReferenceMarkDsc();
+ InstCreator instCreate = new InstCreator(xTextDoc, tDsc);
+
+ XTextContent oReferenceMark = (XTextContent) instCreate.getInstance();
+ return oReferenceMark;
+
+ } /// finish createReferenceMark
+
+ /**
+ * the method createFootnote
+ */
+ public static XTextContent createFootnote(XTextDocument xTextDoc)
+ throws com.sun.star.uno.Exception {
+
+ FootnoteDsc tDsc = new FootnoteDsc();
+ InstCreator instCreate = new InstCreator(xTextDoc, tDsc);
+
+ XTextContent oFootnote = (XTextContent) instCreate.getInstance();
+ return oFootnote;
+
+ } /// finish createFootnote
+
+ /**
+ * the method create Index
+ */
+ public static XTextContent createIndex(XTextDocument xTextDoc, String kind)
+ throws com.sun.star.uno.Exception {
+
+ XMultiServiceFactory oDocMSF = (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class,
+ xTextDoc);
+
+ Object oInt = oDocMSF.createInstance(kind);
+
+ XTextContent xTC = (XTextContent) UnoRuntime.queryInterface(XDocumentIndex.class, oInt);
+
+ return xTC;
+
+ }
+
+ public static XSpreadsheet createSpreadsheet(XSpreadsheetDocument oDoc)
+ throws com.sun.star.uno.Exception {
+
+ XMultiServiceFactory oDocMSF = (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, oDoc);
+
+ Object oInt = oDocMSF.createInstance(
+ "com.sun.star.sheet.Spreadsheet");
+
+ XSpreadsheet oSpreadsheet = (XSpreadsheet) UnoRuntime.queryInterface(XSpreadsheet.class, oInt);
+
+ return oSpreadsheet;
+ }
+
+ public static XIndexAccess getTableCollection(XTextDocument oDoc) {
+
+ XTextTablesSupplier oTTS = (XTextTablesSupplier) UnoRuntime.queryInterface(XTextTablesSupplier.class, oDoc);
+
+ XNameAccess oNA = oTTS.getTextTables();
+ XIndexAccess oIA = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, oNA);
+
+ return oIA;
+ }
+
+ public static String getUniqueName(XInterface oInterface, String prefix) {
+ XNameAccess oNameAccess = (XNameAccess) UnoRuntime.queryInterface(XNameAccess.class, oInterface);
+ if (oNameAccess == null) {
+ return null;
+ }
+ int i;
+ for (i = 0; oNameAccess.hasByName(prefix + i); i++) {
+ }
+ ;
+ return prefix + i;
+ }
+
+ public XShape createShape(XComponent oDoc, int height, int width, int x, int y, String kind) {
+ //possible values for kind are 'Ellipse', 'Line' and 'Rectangle'
+
+ ShapeDsc sDsc = new ShapeDsc(height, width, x, y, kind);
+ InstCreator instCreate = new InstCreator(oDoc, sDsc);
+
+ XShape oShape = (XShape) instCreate.getInstance();
+
+ return oShape;
+
+ }
+
+ /**
+ * creates a Diagram wich specified in kind(String)
+ */
+ public XDiagram createDiagram(XComponent oDoc, String kind) {
+ XInterface oInterface = null;
+ XDiagram oDiagram = null;
+
+ //get LineDiagram
+ XMultiServiceFactory oDocMSF = (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, oDoc);
+
+ try {
+ oInterface = (XInterface) oDocMSF.createInstance("com.sun.star.chart." + kind);
+ oDiagram = (XDiagram) UnoRuntime.queryInterface(XDiagram.class, oInterface);
+ } catch (Exception e) {
+ // Some exception occures.FAILED
+ System.out.println("Couldn't create " + kind + "-Diagram " + e);
+ }
+ return oDiagram;
+ }
+
+ /*
+ // create a Control-Instance which specified in kind(String)
+ */
+ public XInterface createControl(XComponent oDoc, String kind) {
+
+ XInterface oControl = null;
+
+ XMultiServiceFactory oDocMSF = (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, oDoc);
+
+ try {
+ oControl = (XInterface) oDocMSF.createInstance("com.sun.star.form.component." + kind);
+ } catch (Exception e) {
+ // Some exception occures.FAILED
+ System.out.println("Couldn't create instance " + kind + ": " + e);
+ }
+ return oControl;
+ }
+
+ /*
+ // create an Instance which is specified in kind(String)
+ */
+ public Object createInstance(XComponent oDoc, String kind) {
+
+ Object oInstance = null;
+
+ XMultiServiceFactory oDocMSF = (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, oDoc);
+
+ try {
+ oInstance = (Object) oDocMSF.createInstance(kind);
+ } catch (Exception e) {
+ // Some exception occures.FAILED
+ System.out.println("Couldn't create instance " + kind + ": " + e);
+ }
+ return oInstance;
+ }
+
+ public XControlShape createControlShape(XComponent oDoc, int height, int width, int x, int y, String kind) {
+
+ Size size = new Size();
+ Point position = new Point();
+ XControlShape oCShape = null;
+ XControlModel aControl = null;
+
+ //get MSF
+ XMultiServiceFactory oDocMSF = (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, oDoc);
+
+ try {
+ Object oInt = oDocMSF.createInstance("com.sun.star.drawing.ControlShape");
+ Object aCon = oDocMSF.createInstance("com.sun.star.form.component." + kind);
+ aControl = (XControlModel) UnoRuntime.queryInterface(XControlModel.class, aCon);
+ oCShape = (XControlShape) UnoRuntime.queryInterface(XControlShape.class, oInt);
+ size.Height = height;
+ size.Width = width;
+ position.X = x;
+ position.Y = y;
+ oCShape.setSize(size);
+ oCShape.setPosition(position);
+
+
+ } catch (Exception e) {
+ // Some exception occures.FAILED
+ System.out.println("Couldn't create instance " + e);
+ }
+
+ try {
+ oCShape.setControl(aControl);
+ } catch (Exception e) {
+ // Some exception occures.FAILED
+ System.out.println("Couldn't get Control " + e);
+ }
+
+
+ return oCShape;
+
+ }
+
+ public XComponent loadDocument(String fileName)
+ throws com.sun.star.lang.IllegalArgumentException,
+ com.sun.star.io.IOException,
+ com.sun.star.uno.Exception {
+
+ // that noargs thing for load attributes
+ PropertyValue[] szEmptyArgs = new PropertyValue[0];
+ String frameName = "_blank";
+
+ XComponent oDoc = oCLoader.loadComponentFromURL(
+ fileName, frameName, 0, szEmptyArgs);
+
+ if (oDoc == null) {
+ return null;
+ }
+ DesktopTools.bringWindowToFront(oDoc);
+ return oDoc;
+ }
+
+ public XComponent loadDocument(String fileName, PropertyValue[] Args)
+ throws com.sun.star.lang.IllegalArgumentException,
+ com.sun.star.io.IOException,
+ com.sun.star.uno.Exception {
+
+ // that noargs thing for load attributes
+ String frameName = "_blank";
+
+ XComponent oDoc = oCLoader.loadComponentFromURL(
+ fileName, frameName, 0, Args);
+
+ if (oDoc == null) {
+ return null;
+ }
+ DesktopTools.bringWindowToFront(oDoc);
+
+ return oDoc;
+ }
+
+ public XComponent openDoc(String kind, String frameName)
+ throws com.sun.star.lang.IllegalArgumentException,
+ com.sun.star.io.IOException,
+ com.sun.star.uno.Exception {
+
+ // that noargs thing for load attributes
+ PropertyValue[] Args = null;
+ if (kind.equals("simpress")) {
+ Args = new PropertyValue[1];
+ PropertyValue Arg = new PropertyValue();
+ Arg.Name = "OpenFlags";
+ Arg.Value = "S";
+ Arg.Handle = -1;
+ Arg.State = PropertyState.DEFAULT_VALUE;
+ Args[0] = Arg;
+ } else {
+ Args = new PropertyValue[0];
+ }
+
+ if (frameName == null) {
+ frameName = "_blank";
+ }
+ // load a blank a doc
+ XComponent oDoc = oCLoader.loadComponentFromURL("private:factory/" + kind, frameName, 40, Args);
+ DesktopTools.bringWindowToFront(oDoc);
+
+ return oDoc;
+
+ } // finished openDoc
+
+ public XComponent openDoc(String kind, String frameName, PropertyValue[] mediaDescriptor)
+ throws com.sun.star.lang.IllegalArgumentException,
+ com.sun.star.io.IOException,
+ com.sun.star.uno.Exception {
+
+ if (frameName == null) {
+ frameName = "_blank";
+ }
+ // load a blank a doc
+ XComponent oDoc = oCLoader.loadComponentFromURL(
+ "private:factory/" + kind, frameName, 40, mediaDescriptor);
+ DesktopTools.bringWindowToFront(oDoc);
+
+ return oDoc;
+
+ } // finished openDoc
+
+ // query for XServiceInfo
+ public Object queryXServiceInfo(Object oObj) {
+ if (oObj != null) {
+ XServiceInfo oInfo = (XServiceInfo) UnoRuntime.queryInterface(
+ XServiceInfo.class, oObj);
+ System.out.println("!!!! XServiceInfo n.a. !!!! ");
+ } else {
+ System.out.println("Object is empty!!!! ");
+ }
+ return null;
+ } // finish queryXServiceInfo
+} \ No newline at end of file
diff --git a/qadevOOo/runner/util/ShapeDsc.java b/qadevOOo/runner/util/ShapeDsc.java
new file mode 100644
index 000000000000..df9364a7d9a2
--- /dev/null
+++ b/qadevOOo/runner/util/ShapeDsc.java
@@ -0,0 +1,101 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package util;
+
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.uno.XInterface;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.drawing.*;
+import com.sun.star.awt.*;
+/**
+ * the class TableDsc
+ */
+public class ShapeDsc extends InstDescr {
+
+ private int x = 0;
+ private int y = 0;
+ private int height = 0;
+ private int width = 0;
+ private String name = null;
+ final String ifcName = "com.sun.star.drawing.XShape";
+ String service = "com.sun.star.drawing.RectangleShape";
+
+ public ShapeDsc( int nheight, int nwidth, int nx, int ny, String kind ) {
+ x=nx;
+ y=ny;
+ height=nheight;
+ width=nwidth;
+ service="com.sun.star.drawing."+kind+"Shape";
+ initShape();
+ }
+ public String getName() {
+ return name;
+ }
+
+ public String getIfcName() {
+ return ifcName;
+ }
+ public String getService() {
+ return service;
+ }
+
+ private void initShape() {
+ try {
+ ifcClass = Class.forName( ifcName );
+ }
+ catch( ClassNotFoundException cnfE ) {
+ }
+ }
+ public XInterface createInstance( XMultiServiceFactory docMSF ) {
+
+
+ Object SrvObj = null;
+ try {
+ SrvObj = docMSF.createInstance( service );
+ }
+ catch( com.sun.star.uno.Exception cssuE ){
+ }
+
+ XShape Sh = (XShape)UnoRuntime.queryInterface(ifcClass, SrvObj );
+ Size size = new Size();
+ Point position = new Point();
+ size.Height = height;
+ size.Width = width;
+ position.X = x;
+ position.Y = y;
+ try {
+ Sh.setSize(size);
+ Sh.setPosition(position);
+ }
+ catch ( com.sun.star.beans.PropertyVetoException e) {
+ }
+
+ return Sh;
+
+ }
+} \ No newline at end of file
diff --git a/qadevOOo/runner/util/StyleFamilyDsc.java b/qadevOOo/runner/util/StyleFamilyDsc.java
new file mode 100644
index 000000000000..eed3835bfab4
--- /dev/null
+++ b/qadevOOo/runner/util/StyleFamilyDsc.java
@@ -0,0 +1,80 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package util;
+
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.uno.XInterface;
+import com.sun.star.uno.UnoRuntime;
+
+/**
+ * the class StyleFamilyDsc
+ */
+public class StyleFamilyDsc extends InstDescr {
+
+ private String name = null;
+ final String ifcName = "com.sun.star.style.XStyle";
+ String service = "com.sun.star.style.CharacterStyle";
+
+ public StyleFamilyDsc( String kind ) {
+ service = "com.sun.star.style." + kind;
+ initStyleFamily();
+ }
+ public String getName() {
+ return name;
+ }
+
+ public String getIfcName() {
+ return ifcName;
+ }
+ public String getService() {
+ return service;
+ }
+
+ private void initStyleFamily() {
+ try {
+ ifcClass = Class.forName( ifcName );
+ }
+ catch( ClassNotFoundException cnfE ) {
+ }
+ }
+ public XInterface createInstance( XMultiServiceFactory docMSF ) {
+
+
+ Object SrvObj = null;
+ try {
+ SrvObj = docMSF.createInstance( service );
+ }
+ catch( com.sun.star.uno.Exception cssuE ){
+ }
+
+ XInterface StyleFamily = (XInterface)UnoRuntime.queryInterface(ifcClass, SrvObj );
+
+ return StyleFamily;
+
+ }
+}
diff --git a/qadevOOo/runner/util/SysUtils.java b/qadevOOo/runner/util/SysUtils.java
new file mode 100644
index 000000000000..110b7ea549d7
--- /dev/null
+++ b/qadevOOo/runner/util/SysUtils.java
@@ -0,0 +1,153 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package util;
+
+import java.io.File;
+import java.io.FileFilter;
+import java.util.ArrayList;
+
+import com.sun.star.frame.XDesktop;
+import com.sun.star.frame.XFrame;
+import com.sun.star.lang.XComponent;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.datatransfer.clipboard.*;
+import com.sun.star.datatransfer.*;
+
+public class SysUtils {
+
+ public static String getJavaPath() {
+ String cp = (String) System.getProperty("java.class.path");
+ String jh = (String) System.getProperty("java.home");
+ String fs = (String) System.getProperty("file.separator");
+ jh = jh + fs + "bin" + fs;
+ jh = jh + "java -classpath "+cp;
+ return jh;
+ }
+
+ static ArrayList files = new ArrayList();
+
+ public static Object[] traverse( String afileDirectory ) {
+
+ File fileDirectory = new File(afileDirectory);
+ // Testing, if the file is a directory, and if so, it throws an exception
+ if ( !fileDirectory.isDirectory() ) {
+ throw new IllegalArgumentException(
+ "not a directory: " + fileDirectory.getName()
+ );
+ }
+
+ // Getting all files and directories in the current directory
+ File[] entries = fileDirectory.listFiles(
+ new FileFilter() {
+ public boolean accept( File pathname ) {
+ return true;
+ }
+ }
+ );
+
+ // Iterating for each file and directory
+ for ( int i = 0; i < entries.length; ++i ) {
+ // Testing, if the entry in the list is a directory
+ if ( entries[ i ].isDirectory() ) {
+ // Recursive call for the new directory
+ traverse( entries[ i ].getAbsolutePath() );
+ } else {
+ // adding file to List
+ try {
+ // Composing the URL by replacing all backslashs
+ String stringUrl = "file:///"
+ + entries[ i ].getAbsolutePath().replace( '\\', '/' );
+ files.add(stringUrl);
+ }
+ catch( Exception exception ) {
+ exception.printStackTrace();
+ }
+
+ }
+ }
+ return files.toArray();
+ }
+
+ public static XComponent getActiveComponent(XMultiServiceFactory msf) {
+ XComponent ac = null;
+ try {
+ Object desk = msf.createInstance("com.sun.star.frame.Desktop");
+ XDesktop xDesk = (XDesktop) UnoRuntime.queryInterface(XDesktop.class,desk);
+ ac = xDesk.getCurrentComponent();
+ } catch (com.sun.star.uno.Exception e) {
+ System.out.println("Couldn't get active Component");
+ }
+ return ac;
+ }
+
+ public static XFrame getActiveFrame(XMultiServiceFactory msf) {
+ try {
+ Object desk = msf.createInstance("com.sun.star.frame.Desktop");
+ XDesktop xDesk = (XDesktop) UnoRuntime.queryInterface(XDesktop.class,desk);
+ return xDesk.getCurrentFrame();
+ } catch (com.sun.star.uno.Exception e) {
+ System.out.println("Couldn't get active Component");
+ }
+
+ return null;
+ }
+
+ /**
+ * Tries to obtain text data from cliboard if such one exists.
+ * The method iterates through all 'text/plain' supported data
+ * flavors and returns the first non-null String value.
+ *
+ * @param msf MultiserviceFactory
+ * @return First found string clipboard contents or null if no
+ * text contents were found.
+ * @throws com.sun.star.uno.Exception if system clipboard is not accessible.
+ */
+ public static String getSysClipboardText(XMultiServiceFactory msf)
+ throws com.sun.star.uno.Exception {
+
+ XClipboard xCB = (XClipboard) UnoRuntime.queryInterface
+ (XClipboard.class, msf.createInstance
+ ("com.sun.star.datatransfer.clipboard.SystemClipboard"));
+
+ XTransferable xTrans = xCB.getContents();
+
+ DataFlavor[] dfs = xTrans.getTransferDataFlavors();
+
+ for (int i = 0; i < dfs.length; i++) {
+ if (dfs[i].MimeType.startsWith("text/plain")) {
+ Object data = xTrans.getTransferData(dfs[i]);
+ if (data != null && data instanceof String) {
+ return (String) data;
+ }
+ }
+ }
+
+ return null;
+ }
+}
diff --git a/qadevOOo/runner/util/TableDsc.java b/qadevOOo/runner/util/TableDsc.java
new file mode 100644
index 000000000000..d933bc0cb041
--- /dev/null
+++ b/qadevOOo/runner/util/TableDsc.java
@@ -0,0 +1,96 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package util;
+
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.uno.XInterface;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.text.XTextTable;
+/**
+ * the class TableDsc
+ */
+public class TableDsc extends InstDescr {
+
+ private int rows = 0;
+ private int columns = 0;
+ private String name = null;
+ final String ifcName = "com.sun.star.text.XTextTable";
+ final String service = "com.sun.star.text.TextTable";
+
+ public TableDsc() {
+ initTable();
+ }
+
+ public TableDsc( int nRows, int nColumns ) {
+ rows = nRows;
+ columns = nColumns;
+ initTable();
+ }
+
+ public TableDsc( String TableName, int nRows, int nColumns ) {
+ name = TableName;
+ rows = nRows;
+ columns = nColumns;
+ initTable();
+ }
+ public String getName() {
+ return name;
+ }
+ public String getIfcName() {
+ return ifcName;
+ }
+ public String getService() {
+ return service;
+ }
+
+ private void initTable() {
+ try {
+ ifcClass = Class.forName( ifcName );
+ }
+ catch( ClassNotFoundException cnfE ) {
+ }
+ }
+ public XInterface createInstance( XMultiServiceFactory docMSF ) {
+ Object SrvObj = null;
+ try {
+ SrvObj = docMSF.createInstance( service );
+ }
+ catch( com.sun.star.uno.Exception cssuE ){
+ }
+
+ XTextTable TT = (XTextTable)UnoRuntime.queryInterface(
+ ifcClass, SrvObj );
+
+ if ( rows > 0 && columns > 0 ) {
+ TT.initialize( rows, columns );
+ }
+
+ return TT;
+
+ }
+}
diff --git a/qadevOOo/runner/util/TextSectionDsc.java b/qadevOOo/runner/util/TextSectionDsc.java
new file mode 100644
index 000000000000..3afcbbce5dd5
--- /dev/null
+++ b/qadevOOo/runner/util/TextSectionDsc.java
@@ -0,0 +1,84 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package util;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.uno.XInterface;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.text.XTextContent;
+
+/**
+ * the class TextSectionDsc
+ */
+public class TextSectionDsc extends InstDescr {
+
+ final String service = "com.sun.star.text.TextSection";
+ String ifcName = "com.sun.star.text.XTextContent";
+ private String name = null;
+
+
+ public TextSectionDsc() {
+ initTextSection();
+ }
+
+ public TextSectionDsc( String name ) {
+ this.name = name;
+ initTextSection();
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getIfcName() {
+ return ifcName;
+ }
+
+ public String getService() {
+ return service;
+ }
+
+ private void initTextSection() {
+ try {
+ ifcClass = Class.forName( ifcName );
+ }
+ catch( ClassNotFoundException cnfE ) {
+ }
+ }
+ public XInterface createInstance( XMultiServiceFactory docMSF ) {
+ Object ServiceObj = null;
+
+ try {
+ ServiceObj = docMSF.createInstance( service );
+ }
+ catch( com.sun.star.uno.Exception cssuE ){
+ }
+ XTextContent PG = (XTextContent)UnoRuntime.queryInterface( ifcClass,
+ ServiceObj );
+ return PG;
+ }
+} \ No newline at end of file
diff --git a/qadevOOo/runner/util/UITools.java b/qadevOOo/runner/util/UITools.java
new file mode 100644
index 000000000000..c9562949632f
--- /dev/null
+++ b/qadevOOo/runner/util/UITools.java
@@ -0,0 +1,814 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package util;
+
+import com.sun.star.awt.Point;
+import com.sun.star.awt.XTopWindow;
+import com.sun.star.awt.XWindow;
+import com.sun.star.text.XTextDocument;
+import com.sun.star.uno.UnoRuntime;
+
+import com.sun.star.frame.XModel;
+import com.sun.star.uno.XInterface;
+import com.sun.star.accessibility.XAccessible;
+import com.sun.star.accessibility.XAccessibleAction;
+import com.sun.star.accessibility.AccessibleRole;
+import com.sun.star.accessibility.XAccessibleComponent;
+import com.sun.star.awt.XExtendedToolkit;
+import com.sun.star.accessibility.XAccessibleContext;
+import com.sun.star.accessibility.XAccessibleEditableText;
+import com.sun.star.accessibility.XAccessibleSelection;
+import com.sun.star.accessibility.XAccessibleText;
+import com.sun.star.accessibility.XAccessibleValue;
+import com.sun.star.lang.XMultiServiceFactory;
+import java.awt.Robot;
+import java.awt.event.InputEvent;
+import java.io.PrintWriter;
+import java.util.Vector;
+import util.AccessibilityTools;
+
+
+/**
+ * This class supports some functions to handle easily accessible objects
+ */
+public class UITools {
+
+ private static final AccessibilityTools mAT = new AccessibilityTools();
+ private final XAccessible mXRoot;
+ private final XMultiServiceFactory mMSF;
+
+ public UITools(XMultiServiceFactory msf, XModel xModel)
+ {
+ mMSF = msf;
+ mXRoot = makeRoot(mMSF, xModel);
+ }
+
+ public UITools(XMultiServiceFactory msf, XTextDocument xTextDoc)
+ {
+ mMSF = msf;
+ XModel xModel = (XModel) UnoRuntime.queryInterface(XModel.class, xTextDoc);
+ mXRoot = makeRoot(mMSF, xModel);
+ }
+
+ public UITools(XMultiServiceFactory msf, XWindow xWindow)
+ {
+ mMSF = msf;
+ mXRoot = makeRoot(xWindow);
+ }
+
+ private static XAccessible makeRoot(XMultiServiceFactory msf, XModel aModel)
+ {
+ XWindow xWindow = mAT.getCurrentWindow(msf, aModel);
+ return mAT.getAccessibleObject(xWindow);
+ }
+
+
+ private static String getString(XInterface xInt)
+ {
+ XAccessibleText oText = (XAccessibleText)
+ UnoRuntime.queryInterface(XAccessibleText.class, xInt);
+ return oText.getText();
+ }
+
+ private static void setString(XInterface xInt, String cText)
+ {
+ XAccessibleEditableText oText = (XAccessibleEditableText)
+ UnoRuntime.queryInterface(XAccessibleEditableText.class, xInt);
+
+ oText.setText(cText);
+ }
+
+ private static Object getValue(XInterface xInt)
+ {
+ XAccessibleValue oValue = (XAccessibleValue)
+ UnoRuntime.queryInterface(XAccessibleValue.class, xInt);
+ return oValue.getCurrentValue();
+ }
+
+ private static XAccessible makeRoot(XWindow xWindow)
+ {
+ return mAT.getAccessibleObject(xWindow);
+ }
+
+ /**
+ * get the root element of the accessible tree
+ * @return the root element
+ */
+ public XAccessible getRoot()
+ {
+ return mXRoot;
+ }
+
+ /**
+ * Helper mathod: set a text into AccessibleEdit field
+ * @param textfiledName is the name of the text field
+ * @param stringToSet is the string to set
+ * @throws java.lang.Exception if something fail
+ */
+ public void setTextEditFiledText(String textfiledName, String stringToSet)
+ throws java.lang.Exception
+ {
+ XInterface oTextField = mAT.getAccessibleObjectForRole(mXRoot,
+ AccessibleRole.TEXT, textfiledName);
+ setString(oTextField, stringToSet);
+ }
+
+ /**
+ * returns the button by the given name
+ * @param buttonName is name name of the button to get
+ * @return a XAccessibleContext of the button
+ * @throws java.lang.Exception if something fail
+ */
+ public XAccessibleContext getButton(String buttonName) throws java.lang.Exception
+ {
+ return mAT.getAccessibleObjectForRole
+ (mXRoot, AccessibleRole.PUSH_BUTTON, buttonName);
+ }
+
+ /**
+ * Helper method: gets button via accessibility and 'click' it</code>
+ * @param buttonName is name name of the button to click
+ * @throws java.lang.Exception if something fail
+ */
+
+ public void clickButton(String buttonName) throws java.lang.Exception
+ {
+
+ XAccessibleContext oButton =mAT.getAccessibleObjectForRole
+ (mXRoot, AccessibleRole.PUSH_BUTTON, buttonName);
+ if (oButton == null){
+ throw new Exception("Could not get button '" + buttonName + "'");
+ }
+ XAccessibleAction oAction = (XAccessibleAction)
+ UnoRuntime.queryInterface(XAccessibleAction.class, oButton);
+
+ // "click" the button
+ try{
+ oAction.doAccessibleAction(0);
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
+ throw new Exception("Could not do accessible action with '" +
+ buttonName + "'" + e.toString());
+ }
+ }
+
+
+
+ /**
+ * Helper method: gets button via accessibility and 'click' it
+ * @param buttonName The name of the button in the accessibility tree
+ * @param toBePressed desired state of the toggle button
+ *
+ * @return true if the state of the button could be changed in the desired manner
+ */
+ private boolean clickToggleButton(String buttonName, boolean toBePressed)
+ {
+ XAccessibleContext oButton =mAT.getAccessibleObjectForRole
+ (mXRoot, AccessibleRole.TOGGLE_BUTTON, buttonName);
+
+ if (oButton != null){
+ boolean isChecked = oButton.getAccessibleStateSet().contains(com.sun.star.accessibility.AccessibleStateType.CHECKED);
+ if((isChecked && !toBePressed) || (!isChecked && toBePressed)){
+ XAccessibleAction oAction = (XAccessibleAction)
+ UnoRuntime.queryInterface(XAccessibleAction.class, oButton);
+ try{
+ // "click" the button
+ oAction.doAccessibleAction(0);
+ return true;
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
+ System.out.println("Could not do accessible action with '"
+ + buttonName + "'" + e.toString());
+ return false;
+ }
+ }else
+ //no need to press togglebar, do nothing
+ return true;
+ } else{
+ System.out.println("Could not get button '" + buttonName + "'");
+ return false;
+ }
+ }
+
+ /**
+ * Deactivates toggle button via Accessibility
+ * @param buttonName The name of the button in the Accessibility tree
+ *
+ * @return true if the button could be set to deactivated
+ */
+ public boolean deactivateToggleButton(String buttonName){
+ return clickToggleButton(buttonName, false);
+ }
+
+ /**
+ * Activates toggle button via Accessibility
+ * @param buttonName The name of the button in the Accessibility tree
+ *
+ * @return true if the button could be set to activated
+ */
+ public boolean activateToggleButton(String buttonName){
+ return clickToggleButton(buttonName, true);
+ }
+
+ /**
+ * returns the value of named radio button
+ * @param buttonName the name of the button to get the value of
+ * @throws java.lang.Exception if something fail
+ * @return Integer
+ */
+ public Integer getRadioButtonValue(String buttonName)
+ throws java.lang.Exception
+ {
+ try {
+ XInterface xRB =mAT.getAccessibleObjectForRole(mXRoot,
+ AccessibleRole.RADIO_BUTTON, buttonName);
+
+ return (Integer) getValue(xRB);
+ } catch (Exception e) {
+ throw new Exception("Could not get value from RadioButton '"
+ + buttonName + "' : " + e.toString());
+ }
+ }
+
+ /**
+ * returns the named graphic
+ * @param GraphicName the name of the graphic
+ * @return XInterface
+ * @throws java.lang.Exception if something fail
+ */
+ public XInterface getGraphic(String GraphicName) throws java.lang.Exception
+ {
+ return mAT.getAccessibleObjectForRole(mXRoot, AccessibleRole.GRAPHIC,
+ GraphicName);
+ }
+
+
+ /**
+ * set a named radio button the a given value
+ * @param buttonName the name of the button to set
+ * @param iValue the value to set
+ * @throws java.lang.Exception if something fail
+ */
+ public void setRadioButtonValue(String buttonName, int iValue)
+ throws java.lang.Exception
+ {
+ try {
+ XInterface xRB =mAT.getAccessibleObjectForRole(mXRoot, AccessibleRole.RADIO_BUTTON, buttonName);
+ if(xRB == null)
+ System.out.println("AccessibleObjectForRole couldn't be found for " + buttonName);
+ XAccessibleValue oValue = (XAccessibleValue)
+ UnoRuntime.queryInterface(XAccessibleValue.class, xRB);
+ if(oValue == null)
+ System.out.println("XAccessibleValue couldn't be queried for " + buttonName);
+ oValue.setCurrentValue(new Integer(iValue));
+ } catch (Exception e) {
+ e.printStackTrace();
+
+ throw new Exception("Could not set value to RadioButton '"
+ + buttonName + "' : " + e.toString());
+ }
+
+ }
+
+ /**
+ * select an item in nanmed listbox
+ * @param ListBoxName the name of the listbox
+ * @param nChildIndex the index of the item to set
+ * @throws java.lang.Exception if something fail
+ */
+ public void selectListboxItem(String ListBoxName, int nChildIndex)
+ throws java.lang.Exception
+ {
+ try {
+ XAccessibleContext xListBox = null;
+
+ xListBox =mAT.getAccessibleObjectForRole(mXRoot,
+ AccessibleRole.COMBO_BOX, ListBoxName);
+ if (xListBox == null){
+ xListBox =mAT.getAccessibleObjectForRole(mXRoot,
+ AccessibleRole.PANEL, ListBoxName);
+ }
+ XAccessible xListBoxAccess = (XAccessible)
+ UnoRuntime.queryInterface(XAccessible.class, xListBox);
+
+ // if a List is not pulled to be open all entries are not visiblle, therefore the
+ // boolean argument
+ XAccessibleContext xList =mAT.getAccessibleObjectForRole(
+ xListBoxAccess, AccessibleRole.LIST, true);
+ XAccessibleSelection xListSelect = (XAccessibleSelection)
+ UnoRuntime.queryInterface(XAccessibleSelection.class, xList);
+
+ xListSelect.selectAccessibleChild(nChildIndex);
+
+ } catch (Exception e) {
+ throw new Exception("Could not select item '" +nChildIndex+
+ "' in listbox '" + ListBoxName + "' : " + e.toString());
+ }
+ }
+
+ /**
+ * This method returns all entries as XInterface of a list box
+ * @param ListBoxName the name of the listbox
+ * @return Object[] containing XInterface
+ * @throws java.lang.Exception if something fail
+ */
+
+ public Object[] getListBoxObjects(String ListBoxName)
+ throws java.lang.Exception
+ {
+ Vector Items = new Vector();
+ try {
+ XAccessibleContext xListBox = null;
+ XAccessibleContext xList = null;
+
+ xListBox =mAT.getAccessibleObjectForRole(mXRoot,
+ AccessibleRole.COMBO_BOX, ListBoxName);
+ if (xListBox == null){
+ xListBox =mAT.getAccessibleObjectForRole(mXRoot,
+ AccessibleRole.PANEL, ListBoxName);
+ }
+
+ if (xListBox == null){
+ // get the list of TreeListBox
+ xList =mAT.getAccessibleObjectForRole(mXRoot,
+ AccessibleRole.TREE, ListBoxName);
+
+ // all other list boxes have a children of kind of LIST
+ } else {
+
+ XAccessible xListBoxAccess = (XAccessible)
+ UnoRuntime.queryInterface(XAccessible.class, xListBox);
+ // if a List is not pulled to be open all entries are not visiblle, therefore the
+ // boolean argument
+ xList =mAT.getAccessibleObjectForRole(
+ xListBoxAccess, AccessibleRole.LIST, true);
+ }
+
+ for (int i=0;i<xList.getAccessibleChildCount();i++) {
+ try {
+ XAccessible xChild = xList.getAccessibleChild(i);
+ XAccessibleContext xChildCont =
+ xChild.getAccessibleContext();
+ XInterface xChildInterface = (XInterface)
+ UnoRuntime.queryInterface(XInterface.class, xChildCont);
+ Items.add(xChildInterface);
+
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
+ throw new Exception("Could not get child form list of '"
+ + ListBoxName + "' : " + e.toString());
+ }
+ }
+
+ } catch (Exception e) {
+ throw new Exception("Could not get list of items from '"
+ + ListBoxName + "' : " + e.toString());
+ }
+ Object[]ret = new XInterface[Items.size()];
+ for (int i=0;i<Items.size();i++){
+ ret[i] = Items.get(i);
+ }
+ return ret;
+ }
+
+ /**
+ * Helper method: returns the entry manes of a List-Box
+ * @param ListBoxName the name of the listbox
+ * @return the listbox entry names
+ * @throws java.lang.Exception if something fail
+ */
+
+ public String[] getListBoxItems(String ListBoxName)
+ throws java.lang.Exception
+ {
+ Vector Items = new Vector();
+ try {
+ XAccessibleContext xListBox = null;
+ XAccessibleContext xList = null;
+
+ xListBox =mAT.getAccessibleObjectForRole(mXRoot,
+ AccessibleRole.COMBO_BOX, ListBoxName);
+ if (xListBox == null){
+ xListBox =mAT.getAccessibleObjectForRole(mXRoot,
+ AccessibleRole.PANEL, ListBoxName);
+ }
+
+ if (xListBox == null){
+ // get the list of TreeListBox
+ xList =mAT.getAccessibleObjectForRole(mXRoot,
+ AccessibleRole.TREE, ListBoxName);
+
+ // all other list boxes have a children of kind of LIST
+ } else {
+
+ XAccessible xListBoxAccess = (XAccessible)
+ UnoRuntime.queryInterface(XAccessible.class, xListBox);
+ // if a List is not pulled to be open all entries are not visiblle, therefore the
+ // boolean argument
+ xList =mAT.getAccessibleObjectForRole(
+ xListBoxAccess, AccessibleRole.LIST, true);
+ }
+
+ for (int i=0;i<xList.getAccessibleChildCount();i++) {
+ try {
+ XAccessible xChild = xList.getAccessibleChild(i);
+ XAccessibleContext xChildCont =
+ xChild.getAccessibleContext();
+ XInterface xChildInterface = (XInterface)
+ UnoRuntime.queryInterface(XInterface.class, xChildCont);
+ Items.add(getString(xChildInterface));
+
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
+ throw new Exception("Could not get child form list of '"
+ + ListBoxName + "' : " + e.toString());
+ }
+ }
+
+ } catch (Exception e) {
+ throw new Exception("Could not get list of items from '"
+ + ListBoxName + "' : " + e.toString());
+ }
+ String[]ret = new String[Items.size()];
+ return (String[])Items.toArray(ret);
+ }
+ /**
+ * set to a named nureric filed a given value
+ * @param NumericFieldName the name of the nureic field
+ * @param cValue the value to set
+ * @throws java.lang.Exception if something fail
+ */
+ public void setNumericFieldValue(String NumericFieldName, String cValue)
+ throws java.lang.Exception
+ {
+ try{
+ XInterface xNumericField =mAT.getAccessibleObjectForRole(
+ mXRoot, AccessibleRole.TEXT, NumericFieldName);
+ //util.dbg.printInterfaces(xNumericField);
+ XAccessibleEditableText oValue = (XAccessibleEditableText)
+ UnoRuntime.queryInterface(
+ XAccessibleEditableText.class, xNumericField);
+
+ setString(xNumericField, cValue);
+ } catch (Exception e) {
+ throw new Exception("Could not set value '" + cValue +
+ "' into NumericField '" + NumericFieldName + "' : " + e.toString());
+ }
+ }
+
+ /**
+ * returns the value of a numeric field
+ * @param NumericFieldName the name of the numreic field
+ * @throws java.lang.Exception if something fail
+ * @return the value of the named numeric filed
+ */
+ public String getNumericFieldValue(String NumericFieldName)
+ throws java.lang.Exception
+ {
+ try{
+ XInterface xNumericField =mAT.getAccessibleObjectForRole(
+ mXRoot, AccessibleRole.TEXT, NumericFieldName);
+ return (String) getString(xNumericField);
+
+ } catch (Exception e) {
+ throw new Exception("Could get value from NumericField '"
+ + NumericFieldName + "' : " + e.toString());
+ }
+ }
+
+ private String removeCharactersFromCurrencyString(String stringVal)
+ throws java.lang.Exception
+ {
+ try{
+ int beginIndex = 0;
+ int endIndex = 0;
+ boolean startFound = false;
+ // find the first numeric character in stringVal
+ for(int i = 0; i < stringVal.length(); i++){
+ int numVal = Character.getNumericValue(stringVal.charAt(i));
+ // if ascii is a numeric value
+ if (numVal != -1){
+ beginIndex = i;
+ break;
+ }
+ }
+ // find the last numeric character in stringVal
+ for(int i = stringVal.length()-1; i > 0; i--){
+ int numVal = Character.getNumericValue(stringVal.charAt(i));
+ if (numVal != -1){
+ endIndex = i+1;
+ break;
+ }
+ }
+ String currencyVal = stringVal.substring(beginIndex, endIndex);
+
+ currencyVal = currencyVal.substring(0, currencyVal.length()-3) +
+ "#" + currencyVal.substring(currencyVal.length()-2);
+
+ currencyVal = utils.replaceAll13(currencyVal, ",", "");
+ currencyVal = utils.replaceAll13(currencyVal, "\\.", "");
+ currencyVal = utils.replaceAll13(currencyVal, "#", ".");
+
+ return currencyVal;
+ } catch (Exception e) {
+ throw new Exception("Could get remove characters from currency string '"
+ + stringVal + "' : " + e.toString());
+ }
+
+ }
+
+ /**
+ * returns the numeric value of a numeric filed. This is needed ie. for
+ * fileds include the moneytary unit.
+ * @param NumericFieldName the name of the numeric filed
+ * @return the value of the numeric filed
+ * @throws java.lang.Exception if something fail
+ */
+ public Double getNumericFieldNumericValue(String NumericFieldName)
+ throws java.lang.Exception
+ {
+ try{
+ Double retValue = null;
+ String sValue = getNumericFieldValue(NumericFieldName);
+ String sAmount = removeCharactersFromCurrencyString(sValue);
+ retValue = retValue.valueOf(sAmount);
+
+ return retValue;
+
+ } catch (Exception e) {
+ throw new Exception("Could get numeric value from NumericField '"
+ + NumericFieldName + "' : " + e.toString());
+ }
+ }
+
+
+ /**
+ * returns the content of a TextBox
+ * @param TextFieldName the name of the textbox
+ * @return the value of the text box
+ * @throws java.lang.Exception if something fail
+ */
+ public String getTextBoxText(String TextFieldName)
+ throws java.lang.Exception
+ {
+ String TextFieldText = null;
+ try{
+ XAccessibleContext xTextField =mAT.getAccessibleObjectForRole(mXRoot,
+ AccessibleRole.SCROLL_PANE, TextFieldName);
+ XAccessible xTextFieldAccess = (XAccessible)
+ UnoRuntime.queryInterface(XAccessible.class, xTextField);
+ XAccessibleContext xFrame =mAT.getAccessibleObjectForRole(
+ xTextFieldAccess, AccessibleRole.TEXT_FRAME);
+ for (int i=0;i<xFrame.getAccessibleChildCount();i++) {
+ try {
+ XAccessible xChild = xFrame.getAccessibleChild(i);
+ XAccessibleContext xChildCont =
+ xChild.getAccessibleContext();
+ XInterface xChildInterface = (XInterface)
+ UnoRuntime.queryInterface(XInterface.class, xChildCont);
+ TextFieldText += (getString(xChildInterface));
+
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
+ throw new Exception("Could not get child fom TextFrame of '"
+ + TextFieldName + "' : " + e.toString());
+ }
+ }
+ return TextFieldText;
+ } catch (Exception e) {
+ throw new Exception("Could not get content fom Textbox '"
+ + TextFieldName + "' : " + e.toString());
+ }
+ }
+
+ /**
+ * set a value to a named check box
+ * @param CheckBoxName the name of the check box
+ * @param Value the value to set
+ *<ul>
+ * <li>0: not checked </li>
+ * <li>1: checked </li>
+ * <li>2: don't know </li>
+ *</ul>
+ * @throws java.lang.Exception if something fail
+ */
+ public void setCheckBoxValue(String CheckBoxName, Integer Value)
+ throws java.lang.Exception
+ {
+ try {
+ XInterface xCheckBox =mAT.getAccessibleObjectForRole(mXRoot,
+ AccessibleRole.CHECK_BOX, CheckBoxName);
+ XAccessibleValue xCheckBoxValue = (XAccessibleValue)
+ UnoRuntime.queryInterface(XAccessibleValue.class, xCheckBox);
+ xCheckBoxValue.setCurrentValue(Value);
+
+ } catch (Exception e) {
+ throw new Exception("Could not set value to CheckBox '"
+ + CheckBoxName + "' : " + e.toString());
+ }
+ }
+
+ /**
+ * returns the value of the named check box
+ * @param CheckBoxName the name of the check box
+ * @return the value of the check box
+ * @throws java.lang.Exception if something fail
+ */
+ public Integer getCheckBoxValue(String CheckBoxName)
+ throws java.lang.Exception
+ {
+ try {
+ XInterface xCheckBox =mAT.getAccessibleObjectForRole(mXRoot,
+ AccessibleRole.CHECK_BOX, CheckBoxName);
+ XAccessibleValue xCheckBoxValue = (XAccessibleValue)
+ UnoRuntime.queryInterface(XAccessibleValue.class, xCheckBox);
+
+ return (Integer) xCheckBoxValue.getCurrentValue();
+ } catch (Exception e) {
+ throw new Exception("Could not set value to CheckBox '"
+ + CheckBoxName + "' : " + e.toString());
+ }
+ }
+
+ /**
+ * returns the message of a Basic-MessageBox
+ * @return the message of a Basic-MessageBox
+ * @throws java.lang.Exception if something fail
+ */
+ public String getMsgBoxText()
+ throws java.lang.Exception
+ {
+ String cMessage = null;
+ try{
+ XAccessibleContext xMessage =mAT.getAccessibleObjectForRole(mXRoot,
+ AccessibleRole.LABEL);
+
+ XInterface xMessageInterface = (XInterface)
+ UnoRuntime.queryInterface(XInterface.class, xMessage);
+ cMessage += (getString(xMessageInterface));
+
+
+ return cMessage;
+ } catch (Exception e) {
+ throw new Exception("Could not get message from Basic-MessageBox: " + e.toString());
+ }
+ }
+
+ /**
+ * fetch the window which is equal to the given <CODE>WindowName</CODE>
+ * @return the named window
+ * @throws java.lang.Exception if something fail
+ */
+ public XWindow getTopWindow(String WindowName, boolean debug) throws java.lang.Exception
+ {
+ XInterface xToolKit = null;
+ try {
+ xToolKit = (XInterface) mMSF.createInstance("com.sun.star.awt.Toolkit") ;
+ } catch (com.sun.star.uno.Exception e) {
+ throw new Exception("Could not toolkit: " + e.toString());
+ }
+ XExtendedToolkit tk = (XExtendedToolkit)
+ UnoRuntime.queryInterface(XExtendedToolkit.class, xToolKit);
+
+ int count = tk.getTopWindowCount();
+
+ XTopWindow retWindow = null;
+
+ if (debug) System.out.println("getTopWindow ->");
+
+ for (int i=0; i < count ; i++){
+ XTopWindow xTopWindow = tk.getTopWindow(i);
+ XAccessible xAcc = mAT.getAccessibleObject(xTopWindow);
+ String accName = xAcc.getAccessibleContext().getAccessibleName();
+
+ if (debug){
+ System.out.println("AccessibleName: " + accName);
+ }
+
+ if (WindowName.equals(accName)){
+ if (debug) System.out.println("-> found window with name '" + WindowName + "'");
+ retWindow = xTopWindow;
+ }
+ }
+
+
+ if (debug) {
+ if (retWindow == null) System.out.println("could not found window with name '" + WindowName + "'");
+ System.out.println("<- getTopWindow ");
+ }
+ return (XWindow) UnoRuntime.queryInterface(XWindow.class, retWindow);
+ }
+
+ public void clickMiddleOfAccessibleObject(short role, String name){
+
+ XAccessibleContext xAcc =mAT.getAccessibleObjectForRole(mXRoot, role, name);
+ XAccessibleComponent aComp = (XAccessibleComponent) UnoRuntime.queryInterface(
+ XAccessibleComponent.class, xAcc);
+
+ System.out.println(xAcc.getAccessibleRole() + "," +
+ xAcc.getAccessibleName() + "(" +
+ xAcc.getAccessibleDescription() + "):" +
+ utils.getImplName(xAcc));
+
+ if (aComp != null) {
+ Point location = aComp.getLocationOnScreen();
+ String bounds = "(" + aComp.getBounds().X + "," +
+ aComp.getBounds().Y + ")" + " (" +
+ aComp.getBounds().Width + "," +
+ aComp.getBounds().Height + ")";
+ System.out.println("The boundary Rectangle is " + bounds);
+ try {
+ Robot rob = new Robot();
+ int x = aComp.getLocationOnScreen().X + (aComp.getBounds().Width / 2);
+ int y = aComp.getLocationOnScreen().Y + (aComp.getBounds().Height / 2);
+ System.out.println("try to click mouse button on x/y " + x + "/" + y);
+ rob.mouseMove(x, y);
+ rob.mousePress(InputEvent.BUTTON1_MASK);
+ rob.mouseRelease(InputEvent.BUTTON1_MASK);
+ } catch (java.awt.AWTException e) {
+ System.out.println("couldn't press mouse button");
+ }
+
+ }
+ }
+
+ public void doubleClickMiddleOfAccessibleObject(short role, String name) {
+ XAccessibleContext xAcc =mAT.getAccessibleObjectForRole(mXRoot, role, name);
+ XAccessibleComponent aComp = (XAccessibleComponent) UnoRuntime.queryInterface(
+ XAccessibleComponent.class, xAcc);
+
+ System.out.println(xAcc.getAccessibleRole() + "," +
+ xAcc.getAccessibleName() + "(" +
+ xAcc.getAccessibleDescription() + "):" +
+ utils.getImplName(xAcc));
+
+ if (aComp != null) {
+ Point location = aComp.getLocationOnScreen();
+ String bounds = "(" + aComp.getBounds().X + "," +
+ aComp.getBounds().Y + ")" + " (" +
+ aComp.getBounds().Width + "," +
+ aComp.getBounds().Height + ")";
+ System.out.println("The boundary Rectangle is " + bounds);
+ try {
+ Robot rob = new Robot();
+ int x = aComp.getLocationOnScreen().X + (aComp.getBounds().Width / 2);
+ int y = aComp.getLocationOnScreen().Y + (aComp.getBounds().Height / 2);
+ System.out.println("try to double click mouse button on x/y " + x + "/" + y);
+ rob.mouseMove(x, y);
+ rob.mousePress(InputEvent.BUTTON1_MASK);
+ rob.mouseRelease(InputEvent.BUTTON1_MASK);
+ utils.shortWait(100);
+ rob.mousePress(InputEvent.BUTTON1_MASK);
+ rob.mouseRelease(InputEvent.BUTTON1_MASK);
+ } catch (java.awt.AWTException e) {
+ System.out.println("couldn't press mouse button");
+ }
+
+ }
+ }
+
+ /**
+ * <B>DEPRECATED</B>
+ * Since <CODE>AccessibilityTools</CODE> handle parameter <CODE>debugIsActive</CODE>
+ * this function does not work anymore.
+ * @deprecated Since <CODE>AccessibilityTools</CODE> handle parameter <CODE>debugIsActive</CODE>
+ * this function does not work anymore.
+ * @param log logWriter
+ */
+ public void printAccessibleTree(PrintWriter log)
+ {
+ mAT.printAccessibleTree(log, mXRoot);
+ }
+
+
+ /**
+ * Prints the accessible tree to the <CODE>logWriter</CODE> only if <CODE>debugIsActive</CODE>
+ * is set to <CODE>true</CODE>
+ * @param log logWriter
+ * @param debugIsActive prints only if this parameter is set to TRUE
+ */
+ public void printAccessibleTree(PrintWriter log, boolean debugIsActive) {
+ mAT.printAccessibleTree(log, mXRoot, debugIsActive);
+ }
+
+}
diff --git a/qadevOOo/runner/util/ValueChanger.java b/qadevOOo/runner/util/ValueChanger.java
new file mode 100644
index 000000000000..d63202d54e33
--- /dev/null
+++ b/qadevOOo/runner/util/ValueChanger.java
@@ -0,0 +1,994 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package util;
+
+import com.sun.star.awt.Point;
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.drawing.PolygonFlags;
+//import util.BitmapLoader;
+import com.sun.star.uno.Enum ;
+import java.lang.reflect.Field ;
+import java.lang.reflect.Method ;
+import java.lang.reflect.Modifier ;
+import java.lang.reflect.Array ;
+import com.sun.star.uno.Any;
+import com.sun.star.uno.AnyConverter;
+
+
+public class ValueChanger {
+
+
+ // Method to change a Value, thought for properties
+ public static Object changePValue( Object oldValue ) {
+
+ Object newValue = null;
+
+ if (oldValue instanceof com.sun.star.uno.Any) {
+ try {
+ oldValue = AnyConverter.toObject(((Any) oldValue).getType(),oldValue);
+ } catch (com.sun.star.lang.IllegalArgumentException iae) {
+ }
+ }
+
+ if (oldValue == null)
+ return null;
+
+ if (oldValue instanceof Boolean) {
+ boolean oldbool = ((Boolean) oldValue).booleanValue();
+ newValue = new Boolean(!oldbool);
+ } else
+
+ if (oldValue instanceof Integer) {
+ int oldint = ((Integer) oldValue).intValue();
+ newValue = new Integer(oldint+5);
+ } else
+
+ if (oldValue instanceof Long) {
+ long oldlong = ((Long) oldValue).longValue();
+ newValue = new Long(oldlong + 15);
+ } else
+
+ if (oldValue instanceof Short) {
+ short oldshort = ((Short) oldValue).shortValue();
+ newValue = new Short((short) (oldshort + 1));
+ } else
+
+ if (oldValue instanceof Byte) {
+ byte oldbyte = ((Byte) oldValue).byteValue();
+ newValue = new Byte((byte) (oldbyte + 1));
+ } else
+
+ if (oldValue instanceof Float) {
+ float oldfloat = ((Float) oldValue).floatValue();
+ newValue = new Float((float) (oldfloat + 16.7));
+ } else
+
+ if (oldValue instanceof Double) {
+ double olddouble = ((Double) oldValue).doubleValue();
+ newValue = new Double(olddouble + 17.8);
+ } else
+
+ if (oldValue instanceof String) {
+ String oldString = (String) oldValue;
+ newValue = oldString + "New";
+ } else
+
+
+ if (oldValue instanceof com.sun.star.chart.ChartAxisArrangeOrderType) {
+ Object AO1 = com.sun.star.chart.ChartAxisArrangeOrderType.AUTO;
+ Object AO2= com.sun.star.chart.ChartAxisArrangeOrderType.SIDE_BY_SIDE;
+ Object AO3= com.sun.star.chart.ChartAxisArrangeOrderType.STAGGER_EVEN;
+ Object AO4= com.sun.star.chart.ChartAxisArrangeOrderType.STAGGER_ODD;
+
+ if (oldValue.equals(AO1)) newValue = AO2;
+ if (oldValue.equals(AO2)) newValue = AO3;
+ if (oldValue.equals(AO3)) newValue = AO4;
+ if (oldValue.equals(AO4)) newValue = AO1;
+ } else
+
+ if (oldValue instanceof com.sun.star.view.PaperOrientation) {
+ Object OR1 = com.sun.star.view.PaperOrientation.LANDSCAPE;
+ Object OR2 = com.sun.star.view.PaperOrientation.PORTRAIT;
+
+ if (oldValue.equals(OR1)) newValue = OR2;
+ else newValue = OR1;
+ } else
+
+ if (oldValue instanceof com.sun.star.lang.Locale) {
+ Object Loc1 = new com.sun.star.lang.Locale("en","US","");
+ Object Loc2 = new com.sun.star.lang.Locale("de","DE","");
+
+ if (oldValue.equals(Loc1)) newValue = Loc2;
+ else newValue = Loc1;
+ } else
+
+ if (oldValue instanceof com.sun.star.style.ParagraphAdjust) {
+ Object PA1 = com.sun.star.style.ParagraphAdjust.LEFT;
+ Object PA2 = com.sun.star.style.ParagraphAdjust.CENTER;
+
+ if (oldValue.equals(PA1)) newValue = PA2;
+ else newValue = PA1;
+ } else
+
+ if (oldValue instanceof com.sun.star.style.LineSpacing) {
+ com.sun.star.style.LineSpacing LS = new com.sun.star.style.LineSpacing();
+ com.sun.star.style.LineSpacing LSold = (com.sun.star.style.LineSpacing) oldValue;
+ LS.Height = (short) ((LSold.Height)+1);
+ LS.Mode = (short) ((LSold.Mode)+1);
+ newValue = LS;
+ } else
+
+ if (oldValue instanceof com.sun.star.drawing.Direction3D) {
+ com.sun.star.drawing.Direction3D D3D = new com.sun.star.drawing.Direction3D();
+ com.sun.star.drawing.Direction3D D3Dold = (com.sun.star.drawing.Direction3D) oldValue;
+ D3D.DirectionX = D3Dold.DirectionX + .5;
+ D3D.DirectionY = D3Dold.DirectionY + .5;
+ D3D.DirectionZ = D3Dold.DirectionZ + .5;
+ newValue = D3D;
+ } else
+
+ if (oldValue instanceof com.sun.star.style.GraphicLocation) {
+ Object GL1 = com.sun.star.style.GraphicLocation.AREA;
+ Object GL2 = com.sun.star.style.GraphicLocation.LEFT_BOTTOM;
+
+ if (oldValue.equals(GL1)) newValue = GL2;
+ else newValue = GL1;
+ } else
+
+ if (oldValue instanceof com.sun.star.style.TabStop) {
+ com.sun.star.style.TabStop TS = new com.sun.star.style.TabStop();
+ com.sun.star.style.TabStop TSold = (com.sun.star.style.TabStop) oldValue;
+ com.sun.star.style.TabAlign TA1 = com.sun.star.style.TabAlign.CENTER;
+ com.sun.star.style.TabAlign TA2 = com.sun.star.style.TabAlign.RIGHT;
+
+ if ((TSold.Alignment).equals(TA1)) TS.Alignment = TA2;
+ else TS.Alignment = TA1;
+
+ TS.Position = ((TSold.Position)+1);
+
+ newValue = TS;
+ } else
+
+ if (oldValue instanceof com.sun.star.style.DropCapFormat) {
+ com.sun.star.style.DropCapFormat DCF = new com.sun.star.style.DropCapFormat();
+ com.sun.star.style.DropCapFormat DCFold = (com.sun.star.style.DropCapFormat) oldValue;
+ DCF.Count = (byte) ((DCFold.Count)+1);
+ DCF.Distance = (short) ((DCFold.Distance)+1);
+ DCF.Lines = (byte) ((DCFold.Lines)+1);
+ newValue = DCF;
+ } else
+
+ if (oldValue instanceof com.sun.star.text.TextContentAnchorType) {
+ com.sun.star.text.TextContentAnchorType TCAT1 = com.sun.star.text.TextContentAnchorType.AS_CHARACTER;
+ com.sun.star.text.TextContentAnchorType TCAT2 = com.sun.star.text.TextContentAnchorType.AT_CHARACTER;
+ com.sun.star.text.TextContentAnchorType TCAT3 = com.sun.star.text.TextContentAnchorType.AT_FRAME;
+ com.sun.star.text.TextContentAnchorType TCAT4 = com.sun.star.text.TextContentAnchorType.AT_PAGE;
+ com.sun.star.text.TextContentAnchorType TCAT5 = com.sun.star.text.TextContentAnchorType.AT_PARAGRAPH;
+ if (oldValue.equals(TCAT1)) newValue = TCAT2;
+ if (oldValue.equals(TCAT2)) newValue = TCAT3;
+ if (oldValue.equals(TCAT3)) newValue = TCAT4;
+ if (oldValue.equals(TCAT4)) newValue = TCAT5;
+ if (oldValue.equals(TCAT5)) newValue = TCAT1;
+ } else
+
+ if (oldValue instanceof com.sun.star.text.WrapTextMode) {
+ com.sun.star.text.WrapTextMode WTM1 = com.sun.star.text.WrapTextMode.DYNAMIC;
+ com.sun.star.text.WrapTextMode WTM2 = com.sun.star.text.WrapTextMode.LEFT;
+ com.sun.star.text.WrapTextMode WTM3 = com.sun.star.text.WrapTextMode.NONE;
+ com.sun.star.text.WrapTextMode WTM4 = com.sun.star.text.WrapTextMode.PARALLEL;
+ com.sun.star.text.WrapTextMode WTM5 = com.sun.star.text.WrapTextMode.RIGHT;
+ com.sun.star.text.WrapTextMode WTM6 = com.sun.star.text.WrapTextMode.THROUGHT;
+ if (oldValue.equals(WTM1)) newValue = WTM2;
+ if (oldValue.equals(WTM2)) newValue = WTM3;
+ if (oldValue.equals(WTM3)) newValue = WTM4;
+ if (oldValue.equals(WTM4)) newValue = WTM5;
+ if (oldValue.equals(WTM5)) newValue = WTM6;
+ if (oldValue.equals(WTM6)) newValue = WTM1;
+ } else
+
+ if (oldValue instanceof com.sun.star.awt.Size) {
+ com.sun.star.awt.Size oldSize = (com.sun.star.awt.Size) oldValue;
+ com.sun.star.awt.Size newSize = new com.sun.star.awt.Size();
+ newSize.Height = oldSize.Height +1;
+ newSize.Width = oldSize.Width +1;
+ newValue = newSize;
+ } else
+
+ if (oldValue instanceof com.sun.star.awt.Rectangle) {
+ com.sun.star.awt.Rectangle oldRectangle = (com.sun.star.awt.Rectangle) oldValue;
+ com.sun.star.awt.Rectangle newRectangle = new com.sun.star.awt.Rectangle();
+ newRectangle.Height =oldRectangle.Height +1;
+ newRectangle.Width = oldRectangle.Width +1;
+ newRectangle.X =oldRectangle.Y +1;
+ newRectangle.Y = oldRectangle.X +1;
+ newValue = newRectangle;
+ } else
+
+ if (oldValue instanceof com.sun.star.awt.Point) {
+ com.sun.star.awt.Point oldPoint = (com.sun.star.awt.Point) oldValue;
+ com.sun.star.awt.Point newPoint = new com.sun.star.awt.Point();
+ newPoint.X = oldPoint.X +1;
+ newPoint.Y = oldPoint.Y +1;
+ newValue = newPoint;
+ } else
+
+ if (oldValue instanceof com.sun.star.table.ShadowFormat) {
+ com.sun.star.table.ShadowFormat SF = new com.sun.star.table.ShadowFormat();
+ com.sun.star.table.ShadowFormat SFold = (com.sun.star.table.ShadowFormat) oldValue;
+ SF.IsTransparent = (! SFold.IsTransparent);
+ SF.ShadowWidth = (short) ((SFold.ShadowWidth)+1);
+ newValue = SF;
+ } else
+
+ if (oldValue instanceof com.sun.star.awt.FontSlant) {
+ com.sun.star.awt.FontSlant FS1 = com.sun.star.awt.FontSlant.DONTKNOW;
+ com.sun.star.awt.FontSlant FS2 = com.sun.star.awt.FontSlant.ITALIC;
+ com.sun.star.awt.FontSlant FS3 = com.sun.star.awt.FontSlant.NONE;
+ com.sun.star.awt.FontSlant FS4 = com.sun.star.awt.FontSlant.OBLIQUE;
+ com.sun.star.awt.FontSlant FS5 = com.sun.star.awt.FontSlant.REVERSE_ITALIC;
+ com.sun.star.awt.FontSlant FS6 = com.sun.star.awt.FontSlant.REVERSE_OBLIQUE;
+ if (oldValue.equals(FS1)) newValue = FS2;
+ if (oldValue.equals(FS2)) newValue = FS3;
+ if (oldValue.equals(FS3)) newValue = FS4;
+ if (oldValue.equals(FS4)) newValue = FS5;
+ if (oldValue.equals(FS5)) newValue = FS6;
+ if (oldValue.equals(FS6)) newValue = FS1;
+ } else
+
+ if (oldValue instanceof com.sun.star.table.CellHoriJustify) {
+ com.sun.star.table.CellHoriJustify CHJ1 = com.sun.star.table.CellHoriJustify.BLOCK;
+ com.sun.star.table.CellHoriJustify CHJ2 = com.sun.star.table.CellHoriJustify.CENTER;
+ com.sun.star.table.CellHoriJustify CHJ3 = com.sun.star.table.CellHoriJustify.LEFT;
+ com.sun.star.table.CellHoriJustify CHJ4 = com.sun.star.table.CellHoriJustify.REPEAT;
+ com.sun.star.table.CellHoriJustify CHJ5 = com.sun.star.table.CellHoriJustify.RIGHT;
+ com.sun.star.table.CellHoriJustify CHJ6 = com.sun.star.table.CellHoriJustify.STANDARD;
+ if (oldValue.equals(CHJ1)) newValue = CHJ2;
+ if (oldValue.equals(CHJ2)) newValue = CHJ3;
+ if (oldValue.equals(CHJ3)) newValue = CHJ4;
+ if (oldValue.equals(CHJ4)) newValue = CHJ5;
+ if (oldValue.equals(CHJ5)) newValue = CHJ6;
+ if (oldValue.equals(CHJ6)) newValue = CHJ1;
+ } else
+
+ if (oldValue instanceof com.sun.star.table.CellVertJustify) {
+ com.sun.star.table.CellVertJustify CVJ1 = com.sun.star.table.CellVertJustify.BOTTOM;
+ com.sun.star.table.CellVertJustify CVJ2 = com.sun.star.table.CellVertJustify.CENTER;
+ com.sun.star.table.CellVertJustify CVJ3 = com.sun.star.table.CellVertJustify.STANDARD;
+ com.sun.star.table.CellVertJustify CVJ4 = com.sun.star.table.CellVertJustify.TOP;
+ if (oldValue.equals(CVJ1)) newValue = CVJ2;
+ if (oldValue.equals(CVJ2)) newValue = CVJ3;
+ if (oldValue.equals(CVJ3)) newValue = CVJ4;
+ if (oldValue.equals(CVJ4)) newValue = CVJ1;
+ } else
+
+ if (oldValue instanceof com.sun.star.table.CellOrientation) {
+ com.sun.star.table.CellOrientation CO1 = com.sun.star.table.CellOrientation.BOTTOMTOP;
+ com.sun.star.table.CellOrientation CO2 = com.sun.star.table.CellOrientation.STACKED;
+ com.sun.star.table.CellOrientation CO3 = com.sun.star.table.CellOrientation.STANDARD;
+ com.sun.star.table.CellOrientation CO4 = com.sun.star.table.CellOrientation.TOPBOTTOM;
+ if (oldValue.equals(CO1)) newValue = CO2;
+ if (oldValue.equals(CO2)) newValue = CO3;
+ if (oldValue.equals(CO3)) newValue = CO4;
+ if (oldValue.equals(CO4)) newValue = CO1;
+ } else
+
+ if (oldValue instanceof com.sun.star.util.CellProtection) {
+ com.sun.star.util.CellProtection CP = new com.sun.star.util.CellProtection();
+ com.sun.star.util.CellProtection CPold = (com.sun.star.util.CellProtection) oldValue;
+ CP.IsFormulaHidden = (! CPold.IsFormulaHidden);
+ CP.IsHidden = (! CPold.IsHidden);
+ CP.IsLocked = (! CPold.IsLocked);
+ CP.IsPrintHidden = (! CPold.IsPrintHidden);
+ newValue = CP;
+ } else
+
+ if (oldValue instanceof com.sun.star.table.TableBorder) {
+ com.sun.star.table.TableBorder TBold = (com.sun.star.table.TableBorder) oldValue;
+ com.sun.star.table.TableBorder TB = new com.sun.star.table.TableBorder();
+ TB.IsBottomLineValid = (! TBold.IsBottomLineValid);
+ TB.IsDistanceValid = (! TBold.IsDistanceValid);
+ TB.IsRightLineValid = (! TBold.IsRightLineValid);
+ TB.IsTopLineValid = (! TBold.IsTopLineValid);
+ newValue = TB;
+ } else
+/*
+ if (oldValue instanceof com.sun.star.awt.XBitmap) {
+ newValue = new BitmapLoader();
+ }
+*/
+ if (oldValue instanceof com.sun.star.drawing.FillStyle) {
+ com.sun.star.drawing.FillStyle FS1 = com.sun.star.drawing.FillStyle.NONE;
+ com.sun.star.drawing.FillStyle FS2 = com.sun.star.drawing.FillStyle.SOLID;
+ com.sun.star.drawing.FillStyle FS3 = com.sun.star.drawing.FillStyle.GRADIENT;
+ com.sun.star.drawing.FillStyle FS4 = com.sun.star.drawing.FillStyle.HATCH;
+ com.sun.star.drawing.FillStyle FS5 = com.sun.star.drawing.FillStyle.BITMAP;
+ if (oldValue.equals(FS1)) newValue = FS2;
+ if (oldValue.equals(FS2)) newValue = FS3;
+ if (oldValue.equals(FS3)) newValue = FS4;
+ if (oldValue.equals(FS4)) newValue = FS5;
+ if (oldValue.equals(FS5)) newValue = FS1;
+ } else
+
+ if (oldValue instanceof com.sun.star.awt.Gradient){
+ com.sun.star.awt.Gradient _newValue = (com.sun.star.awt.Gradient)oldValue;
+ _newValue.Angle += 10;
+ _newValue.Border += 1;
+ _newValue.EndColor += 1000;
+ _newValue.EndIntensity -= 10;
+ _newValue.StartColor += 500;
+ _newValue.StartIntensity += 10;
+ _newValue.StepCount += 50;
+ _newValue.Style = com.sun.star.awt.GradientStyle.RADIAL;
+ _newValue.XOffset += 10;
+ _newValue.YOffset += 10;
+ newValue = _newValue;
+ } else
+
+ if (oldValue instanceof com.sun.star.text.GraphicCrop){
+ com.sun.star.text.GraphicCrop _newValue = (com.sun.star.text.GraphicCrop)oldValue;
+ _newValue.Bottom += 10;
+ _newValue.Left += 10;
+ _newValue.Right += 10;
+ _newValue.Top += 10;
+ newValue = _newValue;
+ } else
+
+ if (oldValue instanceof com.sun.star.drawing.BitmapMode){
+ com.sun.star.drawing.BitmapMode bm1 = com.sun.star.drawing.BitmapMode.NO_REPEAT;
+ com.sun.star.drawing.BitmapMode bm2 = com.sun.star.drawing.BitmapMode.REPEAT;
+ com.sun.star.drawing.BitmapMode bm3 = com.sun.star.drawing.BitmapMode.STRETCH;
+ if (oldValue.equals(bm1)) newValue = bm2;
+ if (oldValue.equals(bm2)) newValue = bm3;
+ if (oldValue.equals(bm3)) newValue = bm3;
+ } else
+
+ if (oldValue instanceof com.sun.star.drawing.TextAdjust){
+ com.sun.star.drawing.TextAdjust TA1 = com.sun.star.drawing.TextAdjust.BLOCK;
+ com.sun.star.drawing.TextAdjust TA2 = com.sun.star.drawing.TextAdjust.CENTER;
+ com.sun.star.drawing.TextAdjust TA3 = com.sun.star.drawing.TextAdjust.LEFT;
+ com.sun.star.drawing.TextAdjust TA4 = com.sun.star.drawing.TextAdjust.RIGHT;
+ com.sun.star.drawing.TextAdjust TA5 = com.sun.star.drawing.TextAdjust.STRETCH;
+ if (oldValue.equals(TA1)) newValue = TA2;
+ if (oldValue.equals(TA2)) newValue = TA3;
+ if (oldValue.equals(TA3)) newValue = TA4;
+ if (oldValue.equals(TA4)) newValue = TA5;
+ if (oldValue.equals(TA5)) newValue = TA1;
+ } else
+ if (oldValue instanceof com.sun.star.drawing.TextFitToSizeType){
+ com.sun.star.drawing.TextFitToSizeType TF1 = com.sun.star.drawing.TextFitToSizeType.ALLLINES;
+ com.sun.star.drawing.TextFitToSizeType TF2 = com.sun.star.drawing.TextFitToSizeType.NONE;
+ com.sun.star.drawing.TextFitToSizeType TF3 = com.sun.star.drawing.TextFitToSizeType.PROPORTIONAL;
+ com.sun.star.drawing.TextFitToSizeType TF4 = com.sun.star.drawing.TextFitToSizeType.RESIZEATTR;
+ if (oldValue.equals(TF1)) newValue = TF2;
+ if (oldValue.equals(TF2)) newValue = TF3;
+ if (oldValue.equals(TF3)) newValue = TF4;
+ if (oldValue.equals(TF4)) newValue = TF1;
+ } else
+ if (oldValue instanceof com.sun.star.drawing.TextAnimationKind){
+ com.sun.star.drawing.TextAnimationKind AK1 = com.sun.star.drawing.TextAnimationKind.NONE;
+ com.sun.star.drawing.TextAnimationKind AK2 = com.sun.star.drawing.TextAnimationKind.SLIDE;
+ com.sun.star.drawing.TextAnimationKind AK3 = com.sun.star.drawing.TextAnimationKind.SCROLL;
+ com.sun.star.drawing.TextAnimationKind AK4 = com.sun.star.drawing.TextAnimationKind.BLINK;
+ com.sun.star.drawing.TextAnimationKind AK5 = com.sun.star.drawing.TextAnimationKind.ALTERNATE;
+
+ if (oldValue.equals(AK1)) newValue = AK2;
+ if (oldValue.equals(AK2)) newValue = AK3;
+ if (oldValue.equals(AK3)) newValue = AK4;
+ if (oldValue.equals(AK4)) newValue = AK5;
+ if (oldValue.equals(AK5)) newValue = AK1;
+ } else
+ if (oldValue instanceof com.sun.star.drawing.TextAnimationDirection){
+ com.sun.star.drawing.TextAnimationDirection AD1 = com.sun.star.drawing.TextAnimationDirection.LEFT;
+ com.sun.star.drawing.TextAnimationDirection AD2 = com.sun.star.drawing.TextAnimationDirection.RIGHT;
+ com.sun.star.drawing.TextAnimationDirection AD3 = com.sun.star.drawing.TextAnimationDirection.DOWN;
+ com.sun.star.drawing.TextAnimationDirection AD4 = com.sun.star.drawing.TextAnimationDirection.UP;
+ if (oldValue.equals(AD1)) newValue = AD2;
+ if (oldValue.equals(AD2)) newValue = AD3;
+ if (oldValue.equals(AD3)) newValue = AD4;
+ if (oldValue.equals(AD4)) newValue = AD1;
+ } else
+ if (oldValue instanceof com.sun.star.drawing.LineStyle){
+ com.sun.star.drawing.LineStyle LS1 = com.sun.star.drawing.LineStyle.NONE;
+ com.sun.star.drawing.LineStyle LS2 = com.sun.star.drawing.LineStyle.DASH;
+ com.sun.star.drawing.LineStyle LS3 = com.sun.star.drawing.LineStyle.SOLID;
+ if (oldValue.equals(LS1)) newValue = LS2;
+ if (oldValue.equals(LS2)) newValue = LS3;
+ if (oldValue.equals(LS3)) newValue = LS1;
+ } else
+ if (oldValue instanceof com.sun.star.drawing.LineJoint){
+ com.sun.star.drawing.LineJoint LJ1 = com.sun.star.drawing.LineJoint.BEVEL;
+ com.sun.star.drawing.LineJoint LJ2 = com.sun.star.drawing.LineJoint.MIDDLE;
+ com.sun.star.drawing.LineJoint LJ3 = com.sun.star.drawing.LineJoint.MITER;
+ com.sun.star.drawing.LineJoint LJ4 = com.sun.star.drawing.LineJoint.NONE;
+ com.sun.star.drawing.LineJoint LJ5 = com.sun.star.drawing.LineJoint.ROUND;
+ if (oldValue.equals(LJ1)) newValue = LJ2;
+ if (oldValue.equals(LJ2)) newValue = LJ3;
+ if (oldValue.equals(LJ3)) newValue = LJ4;
+ if (oldValue.equals(LJ4)) newValue = LJ5;
+ if (oldValue.equals(LJ5)) newValue = LJ1;
+ } else
+ if (oldValue instanceof com.sun.star.drawing.LineDash){
+ com.sun.star.drawing.LineDash _newValue = (com.sun.star.drawing.LineDash)oldValue;
+ _newValue.Dashes += 1;
+ _newValue.DashLen += 10;
+ _newValue.Distance += 20;
+ _newValue.DotLen += 10;
+ _newValue.Dots += 10;
+ _newValue.Style = com.sun.star.drawing.DashStyle.RECT;
+ newValue = _newValue;
+ } else
+ if (oldValue instanceof com.sun.star.drawing.Hatch){
+ com.sun.star.drawing.Hatch _newValue = (com.sun.star.drawing.Hatch) oldValue;
+ _newValue.Angle += 10;
+ _newValue.Color += 1000;
+ _newValue.Distance += 10;
+ _newValue.Style = com.sun.star.drawing.HatchStyle.DOUBLE;
+ } else
+ if (oldValue instanceof com.sun.star.drawing.RectanglePoint){
+ com.sun.star.drawing.RectanglePoint RP1 = com.sun.star.drawing.RectanglePoint.LEFT_BOTTOM;
+ com.sun.star.drawing.RectanglePoint RP2 = com.sun.star.drawing.RectanglePoint.LEFT_MIDDLE;
+ com.sun.star.drawing.RectanglePoint RP3 = com.sun.star.drawing.RectanglePoint.LEFT_TOP;
+ com.sun.star.drawing.RectanglePoint RP4 = com.sun.star.drawing.RectanglePoint.MIDDLE_BOTTOM;
+ com.sun.star.drawing.RectanglePoint RP5 = com.sun.star.drawing.RectanglePoint.MIDDLE_MIDDLE;
+ com.sun.star.drawing.RectanglePoint RP6 = com.sun.star.drawing.RectanglePoint.MIDDLE_TOP;
+ com.sun.star.drawing.RectanglePoint RP7 = com.sun.star.drawing.RectanglePoint.RIGHT_BOTTOM;
+ com.sun.star.drawing.RectanglePoint RP8 = com.sun.star.drawing.RectanglePoint.RIGHT_MIDDLE;
+ com.sun.star.drawing.RectanglePoint RP9 = com.sun.star.drawing.RectanglePoint.RIGHT_TOP;
+
+ if (oldValue.equals(RP1)) newValue = RP2;
+ if (oldValue.equals(RP2)) newValue = RP3;
+ if (oldValue.equals(RP3)) newValue = RP4;
+ if (oldValue.equals(RP4)) newValue = RP5;
+ if (oldValue.equals(RP5)) newValue = RP6;
+ if (oldValue.equals(RP6)) newValue = RP7;
+ if (oldValue.equals(RP7)) newValue = RP8;
+ if (oldValue.equals(RP8)) newValue = RP9;
+ if (oldValue.equals(RP9)) newValue = RP1;
+
+ } else
+ if (oldValue instanceof com.sun.star.chart.ChartErrorCategory){
+ com.sun.star.chart.ChartErrorCategory CC1 = com.sun.star.chart.ChartErrorCategory.CONSTANT_VALUE;
+ com.sun.star.chart.ChartErrorCategory CC2 = com.sun.star.chart.ChartErrorCategory.ERROR_MARGIN;
+ com.sun.star.chart.ChartErrorCategory CC3 = com.sun.star.chart.ChartErrorCategory.NONE;
+ com.sun.star.chart.ChartErrorCategory CC4 = com.sun.star.chart.ChartErrorCategory.PERCENT;
+ com.sun.star.chart.ChartErrorCategory CC5 = com.sun.star.chart.ChartErrorCategory.STANDARD_DEVIATION;
+ com.sun.star.chart.ChartErrorCategory CC6 = com.sun.star.chart.ChartErrorCategory.VARIANCE;
+ if (oldValue.equals(CC1)) newValue = CC2;
+ if (oldValue.equals(CC2)) newValue = CC3;
+ if (oldValue.equals(CC3)) newValue = CC4;
+ if (oldValue.equals(CC4)) newValue = CC5;
+ if (oldValue.equals(CC5)) newValue = CC6;
+ if (oldValue.equals(CC6)) newValue = CC1;
+ } else
+ if (oldValue instanceof com.sun.star.chart.ChartErrorIndicatorType){
+ com.sun.star.chart.ChartErrorIndicatorType IT1 = com.sun.star.chart.ChartErrorIndicatorType.LOWER;
+ com.sun.star.chart.ChartErrorIndicatorType IT2 = com.sun.star.chart.ChartErrorIndicatorType.NONE;
+ com.sun.star.chart.ChartErrorIndicatorType IT3 = com.sun.star.chart.ChartErrorIndicatorType.TOP_AND_BOTTOM;
+ com.sun.star.chart.ChartErrorIndicatorType IT4 = com.sun.star.chart.ChartErrorIndicatorType.UPPER;
+ if (oldValue.equals(IT1)) newValue = IT2;
+ if (oldValue.equals(IT2)) newValue = IT3;
+ if (oldValue.equals(IT3)) newValue = IT4;
+ if (oldValue.equals(IT4)) newValue = IT1;
+ } else
+ if (oldValue instanceof com.sun.star.chart.ChartRegressionCurveType){
+ com.sun.star.chart.ChartRegressionCurveType CT1 = com.sun.star.chart.ChartRegressionCurveType.EXPONENTIAL;
+ com.sun.star.chart.ChartRegressionCurveType CT2 = com.sun.star.chart.ChartRegressionCurveType.LINEAR;
+ com.sun.star.chart.ChartRegressionCurveType CT3 = com.sun.star.chart.ChartRegressionCurveType.LOGARITHM;
+ com.sun.star.chart.ChartRegressionCurveType CT4 = com.sun.star.chart.ChartRegressionCurveType.NONE;
+ com.sun.star.chart.ChartRegressionCurveType CT5 = com.sun.star.chart.ChartRegressionCurveType.POLYNOMIAL;
+ com.sun.star.chart.ChartRegressionCurveType CT6 = com.sun.star.chart.ChartRegressionCurveType.POWER;
+ if (oldValue.equals(CT1)) newValue = CT2;
+ if (oldValue.equals(CT2)) newValue = CT3;
+ if (oldValue.equals(CT3)) newValue = CT4;
+ if (oldValue.equals(CT4)) newValue = CT5;
+ if (oldValue.equals(CT5)) newValue = CT6;
+ if (oldValue.equals(CT6)) newValue = CT1;
+
+ } else
+ if (oldValue instanceof com.sun.star.chart.ChartDataRowSource){
+ com.sun.star.chart.ChartDataRowSource RS1 = com.sun.star.chart.ChartDataRowSource.COLUMNS;
+ com.sun.star.chart.ChartDataRowSource RS2 = com.sun.star.chart.ChartDataRowSource.ROWS;
+ if (oldValue.equals(RS1)) newValue = RS2;
+ if (oldValue.equals(RS2)) newValue = RS1;
+ } else
+ if (oldValue instanceof com.sun.star.awt.FontDescriptor){
+ com.sun.star.awt.FontDescriptor _newValue = (com.sun.star.awt.FontDescriptor)oldValue;
+ _newValue.CharacterWidth += 5;
+ _newValue.CharSet = com.sun.star.awt.CharSet.ANSI;
+ _newValue.Family = com.sun.star.awt.FontFamily.DECORATIVE;
+ _newValue.Height += 2;
+ _newValue.Kerning = !_newValue.Kerning;
+ _newValue.Name = "Courier";
+ _newValue.Orientation += 45;
+ _newValue.Pitch = com.sun.star.awt.FontPitch.VARIABLE;
+ _newValue.Slant = com.sun.star.awt.FontSlant.REVERSE_ITALIC;
+ _newValue.Strikeout = com.sun.star.awt.FontStrikeout.X;
+ _newValue.StyleName = "Bold";
+ _newValue.Type = com.sun.star.awt.FontType.SCALABLE;
+ _newValue.Underline = com.sun.star.awt.FontUnderline.BOLDDASHDOTDOT;
+ _newValue.Weight += 5;
+ _newValue.Width += 6;
+ _newValue.WordLineMode = !_newValue.WordLineMode;
+
+ newValue = _newValue;
+ } else
+ if (oldValue instanceof com.sun.star.form.NavigationBarMode){
+ com.sun.star.form.NavigationBarMode BM1 = com.sun.star.form.NavigationBarMode.CURRENT;
+ com.sun.star.form.NavigationBarMode BM2 = com.sun.star.form.NavigationBarMode.NONE;
+ com.sun.star.form.NavigationBarMode BM3 = com.sun.star.form.NavigationBarMode.PARENT;
+ if (oldValue.equals(BM1)) newValue = BM2;
+ if (oldValue.equals(BM2)) newValue = BM3;
+ if (oldValue.equals(BM3)) newValue = BM1;
+ } else
+ if (oldValue instanceof com.sun.star.form.FormSubmitEncoding){
+ com.sun.star.form.FormSubmitEncoding SE1 = com.sun.star.form.FormSubmitEncoding.MULTIPART;
+ com.sun.star.form.FormSubmitEncoding SE2 = com.sun.star.form.FormSubmitEncoding.TEXT;
+ com.sun.star.form.FormSubmitEncoding SE3 = com.sun.star.form.FormSubmitEncoding.URL;
+ if (oldValue.equals(SE1)) newValue = SE2;
+ if (oldValue.equals(SE2)) newValue = SE3;
+ if (oldValue.equals(SE3)) newValue = SE1;
+ } else
+ if (oldValue instanceof com.sun.star.form.FormSubmitMethod){
+ com.sun.star.form.FormSubmitMethod FM1 = com.sun.star.form.FormSubmitMethod.GET;
+ com.sun.star.form.FormSubmitMethod FM2 = com.sun.star.form.FormSubmitMethod.POST;
+ if (oldValue.equals(FM1)) newValue = FM2;
+ if (oldValue.equals(FM2)) newValue = FM1;
+ } else
+
+ if (oldValue instanceof com.sun.star.text.SectionFileLink){
+ com.sun.star.text.SectionFileLink _newValue =
+ new com.sun.star.text.SectionFileLink();
+
+ _newValue.FileURL = util.utils.getFullTestURL("SwXTextSection.sdw");
+ newValue=_newValue;
+ } else
+
+ if (oldValue instanceof com.sun.star.table.BorderLine){
+ com.sun.star.table.BorderLine _newValue = (com.sun.star.table.BorderLine)oldValue;
+ _newValue.Color += 2;
+ _newValue.InnerLineWidth += 2;
+ _newValue.LineDistance += 2;
+ _newValue.OuterLineWidth += 3;
+ newValue=_newValue;
+ } else
+
+ if (oldValue instanceof com.sun.star.text.XTextColumns){
+ com.sun.star.text.XTextColumns _newValue = (com.sun.star.text.XTextColumns)oldValue;
+ _newValue.setColumnCount((short)1);
+ newValue=_newValue;
+ } else
+
+ if (oldValue instanceof com.sun.star.form.FormButtonType){
+ com.sun.star.form.FormButtonType BT1 = com.sun.star.form.FormButtonType.PUSH;
+ com.sun.star.form.FormButtonType BT2 = com.sun.star.form.FormButtonType.RESET;
+ com.sun.star.form.FormButtonType BT3 = com.sun.star.form.FormButtonType.SUBMIT;
+ com.sun.star.form.FormButtonType BT4 = com.sun.star.form.FormButtonType.URL;
+
+ if (oldValue.equals(BT1)) newValue = BT2;
+ if (oldValue.equals(BT2)) newValue = BT3;
+ if (oldValue.equals(BT3)) newValue = BT4;
+ if (oldValue.equals(BT4)) newValue = BT1;
+
+ } else
+ if (oldValue instanceof com.sun.star.form.ListSourceType){
+ com.sun.star.form.ListSourceType ST1 = com.sun.star.form.ListSourceType.QUERY;
+ com.sun.star.form.ListSourceType ST2 = com.sun.star.form.ListSourceType.SQL;
+ com.sun.star.form.ListSourceType ST3 = com.sun.star.form.ListSourceType.SQLPASSTHROUGH;
+ com.sun.star.form.ListSourceType ST4 = com.sun.star.form.ListSourceType.TABLE;
+ com.sun.star.form.ListSourceType ST5 = com.sun.star.form.ListSourceType.TABLEFIELDS;
+ com.sun.star.form.ListSourceType ST6 = com.sun.star.form.ListSourceType.VALUELIST;
+ if (oldValue.equals(ST1)) newValue = ST2;
+ if (oldValue.equals(ST2)) newValue = ST3;
+ if (oldValue.equals(ST3)) newValue = ST4;
+ if (oldValue.equals(ST4)) newValue = ST5;
+ if (oldValue.equals(ST5)) newValue = ST6;
+ if (oldValue.equals(ST6)) newValue = ST1;
+ } else
+ if (oldValue instanceof com.sun.star.table.BorderLine){
+ com.sun.star.table.BorderLine _newValue = (com.sun.star.table.BorderLine)oldValue;
+ _newValue.Color += 1000;
+ _newValue.InnerLineWidth += 2;
+ _newValue.LineDistance +=3;
+ _newValue.OuterLineWidth += 3;
+ newValue = _newValue;
+ } else
+ if (oldValue instanceof com.sun.star.sheet.DataPilotFieldOrientation) {
+ com.sun.star.sheet.DataPilotFieldOrientation FO1 = com.sun.star.sheet.DataPilotFieldOrientation.PAGE;
+ com.sun.star.sheet.DataPilotFieldOrientation FO2 = com.sun.star.sheet.DataPilotFieldOrientation.COLUMN;
+ com.sun.star.sheet.DataPilotFieldOrientation FO3 = com.sun.star.sheet.DataPilotFieldOrientation.DATA;
+ com.sun.star.sheet.DataPilotFieldOrientation FO4 = com.sun.star.sheet.DataPilotFieldOrientation.HIDDEN;
+ com.sun.star.sheet.DataPilotFieldOrientation FO5 = com.sun.star.sheet.DataPilotFieldOrientation.ROW;
+ if (oldValue.equals(FO1)) newValue = FO2;
+ if (oldValue.equals(FO2)) newValue = FO3;
+ if (oldValue.equals(FO3)) newValue = FO4;
+ if (oldValue.equals(FO4)) newValue = FO5;
+ if (oldValue.equals(FO5)) newValue = FO1;
+ } else
+ if (oldValue instanceof com.sun.star.sheet.GeneralFunction) {
+ com.sun.star.sheet.GeneralFunction GF1 = com.sun.star.sheet.GeneralFunction.NONE;
+ com.sun.star.sheet.GeneralFunction GF2 = com.sun.star.sheet.GeneralFunction.AVERAGE;
+ com.sun.star.sheet.GeneralFunction GF3 = com.sun.star.sheet.GeneralFunction.COUNT;
+ com.sun.star.sheet.GeneralFunction GF4 = com.sun.star.sheet.GeneralFunction.COUNTNUMS;
+ com.sun.star.sheet.GeneralFunction GF5 = com.sun.star.sheet.GeneralFunction.MAX;
+ com.sun.star.sheet.GeneralFunction GF6 = com.sun.star.sheet.GeneralFunction.MIN;
+ com.sun.star.sheet.GeneralFunction GF7 = com.sun.star.sheet.GeneralFunction.AUTO;
+ com.sun.star.sheet.GeneralFunction GF8 = com.sun.star.sheet.GeneralFunction.PRODUCT;
+ com.sun.star.sheet.GeneralFunction GF9 = com.sun.star.sheet.GeneralFunction.STDEV;
+ com.sun.star.sheet.GeneralFunction GF10 = com.sun.star.sheet.GeneralFunction.STDEVP;
+ com.sun.star.sheet.GeneralFunction GF11 = com.sun.star.sheet.GeneralFunction.SUM;
+ com.sun.star.sheet.GeneralFunction GF12 = com.sun.star.sheet.GeneralFunction.VAR;
+ com.sun.star.sheet.GeneralFunction GF13 = com.sun.star.sheet.GeneralFunction.VARP;
+
+ if (oldValue.equals(GF1)) newValue = GF2;
+ if (oldValue.equals(GF2)) newValue = GF3;
+ if (oldValue.equals(GF3)) newValue = GF4;
+ if (oldValue.equals(GF4)) newValue = GF5;
+ if (oldValue.equals(GF5)) newValue = GF6;
+ if (oldValue.equals(GF6)) newValue = GF7;
+ if (oldValue.equals(GF7)) newValue = GF8;
+ if (oldValue.equals(GF8)) newValue = GF9;
+ if (oldValue.equals(GF9)) newValue = GF10;
+ if (oldValue.equals(GF10)) newValue = GF11;
+ if (oldValue.equals(GF11)) newValue = GF12;
+ if (oldValue.equals(GF12)) newValue = GF13;
+ if (oldValue.equals(GF13)) newValue = GF1;
+ } else
+
+ if (oldValue instanceof com.sun.star.table.CellAddress){
+ com.sun.star.table.CellAddress _newValue = (com.sun.star.table.CellAddress)oldValue;
+ _newValue.Column += 1;
+ _newValue.Row += 1;
+ newValue = _newValue;
+ } else
+
+ if (oldValue instanceof com.sun.star.table.TableOrientation){
+ com.sun.star.table.TableOrientation TO1 = com.sun.star.table.TableOrientation.COLUMNS;
+ com.sun.star.table.TableOrientation TO2 = com.sun.star.table.TableOrientation.ROWS;
+ if (oldValue.equals(TO1)) newValue = TO2; else newValue = TO1;
+ } else
+
+ if (oldValue instanceof com.sun.star.sheet.DataImportMode){
+ com.sun.star.sheet.DataImportMode DIM1 = com.sun.star.sheet.DataImportMode.NONE;
+ com.sun.star.sheet.DataImportMode DIM2 = com.sun.star.sheet.DataImportMode.QUERY;
+ com.sun.star.sheet.DataImportMode DIM3 = com.sun.star.sheet.DataImportMode.SQL;
+ com.sun.star.sheet.DataImportMode DIM4 = com.sun.star.sheet.DataImportMode.TABLE;
+
+ if (oldValue.equals(DIM1)) newValue = DIM2;
+ if (oldValue.equals(DIM2)) newValue = DIM3;
+ if (oldValue.equals(DIM3)) newValue = DIM4;
+ if (oldValue.equals(DIM4)) newValue = DIM1;
+
+ } else
+
+// if (oldValue instanceof com.sun.star.text.TableColumnSeparator[]){
+// com.sun.star.text.TableColumnSeparator[] _newValue = (com.sun.star.text.TableColumnSeparator[]) oldValue;
+// com.sun.star.text.TableColumnSeparator sep = new com.sun.star.text.TableColumnSeparator();
+// sep.IsVisible = ! _newValue[0].IsVisible;
+// _newValue[0] = sep;
+// newValue = _newValue;
+// } else
+
+ if (oldValue instanceof com.sun.star.style.BreakType){
+ com.sun.star.style.BreakType BT1 = com.sun.star.style.BreakType.COLUMN_AFTER;
+ com.sun.star.style.BreakType BT2 = com.sun.star.style.BreakType.COLUMN_BEFORE;
+ com.sun.star.style.BreakType BT3 = com.sun.star.style.BreakType.COLUMN_BOTH;
+ com.sun.star.style.BreakType BT4 = com.sun.star.style.BreakType.PAGE_AFTER;
+ com.sun.star.style.BreakType BT5 = com.sun.star.style.BreakType.PAGE_BEFORE;
+ com.sun.star.style.BreakType BT6 = com.sun.star.style.BreakType.PAGE_BOTH;
+ com.sun.star.style.BreakType BT7 = com.sun.star.style.BreakType.NONE;
+ if (oldValue.equals(BT1)) newValue = BT2;
+ if (oldValue.equals(BT2)) newValue = BT3;
+ if (oldValue.equals(BT3)) newValue = BT4;
+ if (oldValue.equals(BT4)) newValue = BT5;
+ if (oldValue.equals(BT6)) newValue = BT6;
+ if (oldValue.equals(BT6)) newValue = BT7;
+ if (oldValue.equals(BT7)) newValue = BT1;
+ } else
+ if (oldValue instanceof PropertyValue){
+ PropertyValue newVal = new PropertyValue();
+ newVal.Name = ((PropertyValue)oldValue).Name;
+ newVal.Value = changePValue(((PropertyValue)oldValue).Value);
+ newValue = newVal;
+ } else
+ if (oldValue instanceof com.sun.star.sheet.ValidationAlertStyle){
+ com.sun.star.sheet.ValidationAlertStyle VAS1 = com.sun.star.sheet.ValidationAlertStyle.INFO;
+ com.sun.star.sheet.ValidationAlertStyle VAS2 = com.sun.star.sheet.ValidationAlertStyle.MACRO;
+ com.sun.star.sheet.ValidationAlertStyle VAS3 = com.sun.star.sheet.ValidationAlertStyle.STOP;
+ com.sun.star.sheet.ValidationAlertStyle VAS4 = com.sun.star.sheet.ValidationAlertStyle.WARNING;
+
+ if (oldValue.equals(VAS1)) newValue = VAS2;
+ if (oldValue.equals(VAS2)) newValue = VAS3;
+ if (oldValue.equals(VAS3)) newValue = VAS4;
+ if (oldValue.equals(VAS4)) newValue = VAS1;
+
+ } else
+ if (oldValue instanceof com.sun.star.sheet.ValidationType){
+ com.sun.star.sheet.ValidationType VT1 = com.sun.star.sheet.ValidationType.ANY;
+ com.sun.star.sheet.ValidationType VT2 = com.sun.star.sheet.ValidationType.CUSTOM;
+ com.sun.star.sheet.ValidationType VT3 = com.sun.star.sheet.ValidationType.DATE;
+ com.sun.star.sheet.ValidationType VT4 = com.sun.star.sheet.ValidationType.DECIMAL;
+ com.sun.star.sheet.ValidationType VT5 = com.sun.star.sheet.ValidationType.LIST;
+ com.sun.star.sheet.ValidationType VT6 = com.sun.star.sheet.ValidationType.TEXT_LEN;
+ com.sun.star.sheet.ValidationType VT7 = com.sun.star.sheet.ValidationType.TIME;
+ com.sun.star.sheet.ValidationType VT8 = com.sun.star.sheet.ValidationType.WHOLE;
+
+ if (oldValue.equals(VT1)) newValue = VT2;
+ if (oldValue.equals(VT2)) newValue = VT3;
+ if (oldValue.equals(VT3)) newValue = VT4;
+ if (oldValue.equals(VT4)) newValue = VT5;
+ if (oldValue.equals(VT5)) newValue = VT6;
+ if (oldValue.equals(VT6)) newValue = VT7;
+ if (oldValue.equals(VT7)) newValue = VT8;
+ if (oldValue.equals(VT8)) newValue = VT1;
+
+ } else
+ if (oldValue instanceof com.sun.star.text.WritingMode){
+ if (oldValue.equals(com.sun.star.text.WritingMode.LR_TB)) {
+ newValue = com.sun.star.text.WritingMode.TB_RL;
+ } else {
+ newValue = com.sun.star.text.WritingMode.LR_TB;
+ }
+ } else
+ if (oldValue instanceof com.sun.star.uno.Enum) {
+ // universal changer for Enumerations
+ try {
+ Class enumClass = oldValue.getClass() ;
+ Field[] flds = enumClass.getFields() ;
+
+ newValue = null ;
+
+ for (int i = 0; i < flds.length; i++) {
+ if (Enum.class.equals(flds[i].getType().getSuperclass())) {
+
+ Enum value = (Enum) flds[i].get(null) ;
+ if (newValue == null && !value.equals(oldValue)) {
+ newValue = value ;
+ break ;
+ }
+ }
+ }
+ } catch (Exception e) {
+ System.err.println("Exception occured while changing Enumeration value:") ;
+ e.printStackTrace(System.err) ;
+ }
+ if (newValue == null) newValue = oldValue ;
+
+ } else
+ if (oldValue instanceof com.sun.star.style.TabStop[]){
+ com.sun.star.style.TabStop[] _newValue = (com.sun.star.style.TabStop[]) oldValue;
+ if (_newValue.length == 0) {
+ _newValue = new com.sun.star.style.TabStop[1];
+ }
+ com.sun.star.style.TabStop sep = new com.sun.star.style.TabStop();
+ sep.Position += 1;
+ _newValue[0] = sep;
+ newValue = _newValue;
+ } else
+ if (oldValue instanceof short[]){
+ short[] oldArr = (short[])oldValue;
+ int len = oldArr.length;
+ short[] newArr = new short[len + 1];
+ for (int i = 0; i < len; i++) {
+ newArr[i] = (short)(oldArr[i] + 1);
+ }
+ newArr[len] = 5;
+ newValue = newArr;
+ } else
+ if (oldValue instanceof String[]){
+ String[] oldArr = (String[])oldValue;
+ int len = oldArr.length;
+ String[] newArr = new String[len + 1];
+ for (int i = 0; i < len; i++) {
+ newArr[i] = "_" + oldArr[i];
+ }
+ newArr[len] = "_dummy";
+ newValue = newArr;
+ } else
+ if (oldValue instanceof PropertyValue){
+ PropertyValue newVal = new PropertyValue();
+ newVal.Name = ((PropertyValue)oldValue).Name;
+ newVal.Value = changePValue(((PropertyValue)oldValue).Value);
+ newValue = newVal;
+ } else
+ if (oldValue instanceof com.sun.star.util.DateTime) {
+ com.sun.star.util.DateTime oldDT = (com.sun.star.util.DateTime) oldValue;
+ com.sun.star.util.DateTime newDT = new com.sun.star.util.DateTime();
+ newDT.Day = (short) (oldDT.Day+(short) 1);
+ newDT.Hours = (short) (oldDT.Hours+(short) 1);
+ newValue = newDT;
+ } else
+ if (oldValue instanceof com.sun.star.text.TableColumnSeparator) {
+ com.sun.star.text.TableColumnSeparator oldTCS = (com.sun.star.text.TableColumnSeparator) oldValue;
+ com.sun.star.text.TableColumnSeparator newTCS = new com.sun.star.text.TableColumnSeparator();
+ newTCS.IsVisible = !(oldTCS.IsVisible);
+ newTCS.Position = (short) (oldTCS.Position+(short) 1);
+ newValue = newTCS;
+ } else
+ if (oldValue instanceof com.sun.star.drawing.HomogenMatrix3) {
+ com.sun.star.drawing.HomogenMatrix3 oldHM = (com.sun.star.drawing.HomogenMatrix3) oldValue;
+ com.sun.star.drawing.HomogenMatrix3 newHM = new com.sun.star.drawing.HomogenMatrix3();
+ newHM.Line1.Column1 = oldHM.Line1.Column1+1;
+ newHM.Line2.Column2 = oldHM.Line2.Column2+1;
+ newHM.Line3.Column3 = oldHM.Line3.Column3+1;
+ newValue = newHM;
+ } else
+
+ if (oldValue instanceof com.sun.star.drawing.PolyPolygonBezierCoords) {
+ com.sun.star.drawing.PolyPolygonBezierCoords oldPPC = (com.sun.star.drawing.PolyPolygonBezierCoords) oldValue;
+ com.sun.star.drawing.PolyPolygonBezierCoords newPPC = new com.sun.star.drawing.PolyPolygonBezierCoords();
+ newPPC.Coordinates = oldPPC.Coordinates;
+ newPPC.Flags = oldPPC.Flags;
+ PolygonFlags[][] fArray = new PolygonFlags[1][1];
+ PolygonFlags[] flags = new PolygonFlags[1];
+ flags[0] = PolygonFlags.NORMAL;
+ fArray[0] = flags;
+ Point[][] pArray = new Point[1][1];
+ Point[] points = new Point[1];
+ Point aPoint = new Point();
+ aPoint.X = 1;
+ aPoint.Y = 2;
+ points[0] = aPoint;
+ pArray[0] = points;
+ if ( oldPPC.Coordinates.length == 0 ) {
+ newPPC.Coordinates = pArray;
+ newPPC.Flags = fArray;
+ } else {
+ if ( oldPPC.Coordinates[0].length == 0 ) {
+ newPPC.Coordinates = pArray;
+ newPPC.Flags = fArray;
+ } else {
+ newPPC.Coordinates[0][0].X = oldPPC.Coordinates[0][0].X +1;
+ newPPC.Coordinates[0][0].Y = oldPPC.Coordinates[0][0].Y +1;
+ }
+ }
+ newValue = newPPC;
+ } else
+ if (oldValue.getClass().isArray()) {
+ // changer for arrays : changes all elements
+ Class arrType = oldValue.getClass().getComponentType() ;
+ newValue = Array.newInstance(arrType, Array.getLength(oldValue)) ;
+ for (int i = 0; i < Array.getLength(newValue); i++) {
+ if (!arrType.isPrimitive()) {
+ Object elem = changePValue(Array.get(oldValue, i)) ;
+ Array.set(newValue, i, elem);
+ } else {
+ if (Boolean.TYPE.equals(arrType)) {
+ Array.setBoolean(newValue, i, !Array.getBoolean(oldValue, i));
+ } else
+ if (Byte.TYPE.equals(arrType)) {
+ Array.setByte(newValue, i,
+ (byte) (Array.getByte(oldValue, i) + 1));
+ } else
+ if (Character.TYPE.equals(arrType)) {
+ Array.setChar(newValue, i,
+ (char) (Array.getChar(oldValue, i) + 1));
+ } else
+ if (Double.TYPE.equals(arrType)) {
+ Array.setDouble(newValue, i, Array.getDouble(oldValue, i) + 1);
+ } else
+ if (Float.TYPE.equals(arrType)) {
+ Array.setFloat(newValue, i, Array.getFloat(oldValue, i) + 1);
+ } else
+ if (Integer.TYPE.equals(arrType)) {
+ Array.setInt(newValue, i, Array.getInt(oldValue, i) + 1);
+ } else
+ if (Long.TYPE.equals(arrType)) {
+ Array.setLong(newValue, i, Array.getLong(oldValue, i) + 1);
+ } else
+ if (Short.TYPE.equals(arrType)) {
+ Array.setShort(newValue, i,
+ (short) (Array.getShort(oldValue, i) + 1));
+ }
+ }
+ }
+ } else
+ if (isStructure(oldValue)) {
+ // universal changer for structures
+ Class clazz = oldValue.getClass() ;
+ try {
+ newValue = clazz.newInstance() ;
+ Field[] fields = clazz.getFields();
+ for (int i = 0; i < fields.length; i++) {
+ if ((fields[i].getModifiers() & Modifier.PUBLIC) != 0) {
+ Class fType = fields[i].getType() ;
+ Field field = fields[i] ;
+ if (!fType.isPrimitive()) {
+ field.set(newValue, changePValue(field.get(oldValue)));
+ } else {
+ if (Boolean.TYPE.equals(fType)) {
+ field.setBoolean(newValue, !field.getBoolean(oldValue));
+ } else
+ if (Byte.TYPE.equals(fType)) {
+ field.setByte(newValue, (byte) (field.getByte(oldValue) + 1));
+ } else
+ if (Character.TYPE.equals(fType)) {
+ field.setChar(newValue, (char) (field.getChar(oldValue) + 1));
+ } else
+ if (Double.TYPE.equals(fType)) {
+ field.setDouble(newValue, field.getDouble(oldValue) + 1);
+ } else
+ if (Float.TYPE.equals(fType)) {
+ field.setFloat(newValue, field.getFloat(oldValue) + 1);
+ } else
+ if (Integer.TYPE.equals(fType)) {
+ field.setInt(newValue, field.getInt(oldValue) + 1);
+ } else
+ if (Long.TYPE.equals(fType)) {
+ field.setLong(newValue, field.getLong(oldValue) + 1);
+ } else
+ if (Short.TYPE.equals(fType)) {
+ field.setShort(newValue, (short) (field.getShort(oldValue) + 1));
+ }
+ }
+ }
+ }
+ } catch (IllegalAccessException e) {
+ e.printStackTrace() ;
+ } catch (InstantiationException e) {
+ e.printStackTrace() ;
+ }
+
+ } else
+ {
+ System.out.println("ValueChanger don't know type " + oldValue.getClass());
+ }
+
+ return newValue;
+
+ } // end of Change PValue
+
+ /**
+ * Checks if the passed value is the API structure.
+ * The value assumed to be a structure if there are no public
+ * methods, and all public fields are not static or final.
+ *
+ * @param val the value to be checked.
+ * @return <code>true</code> if the value is acssumed to be a
+ * structure.
+ */
+ private static boolean isStructure(Object val) {
+ boolean result = true ;
+
+ Class clazz = val.getClass() ;
+
+ Method[] meth = clazz.getDeclaredMethods() ;
+ for (int i = 0; i < meth.length; i++) {
+ result &= (meth[i].getModifiers() & Modifier.PUBLIC) == 0 ;
+ }
+
+ Field[] fields = clazz.getDeclaredFields() ;
+ for (int i = 0; i < fields.length; i++) {
+ int mod = fields[i].getModifiers() ;
+ // If the field is PUBLIC it must not be STATIC or FINAL
+ result &= ((mod & Modifier.PUBLIC) == 0) ||
+ (((mod & Modifier.STATIC) == 0) && ((mod & Modifier.FINAL) == 0)) ;
+ }
+
+ return result ;
+ }
+}
diff --git a/qadevOOo/runner/util/ValueComparer.java b/qadevOOo/runner/util/ValueComparer.java
new file mode 100644
index 000000000000..dd9749119a8f
--- /dev/null
+++ b/qadevOOo/runner/util/ValueComparer.java
@@ -0,0 +1,266 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package util;
+
+import com.sun.star.beans.PropertyValue;
+import java.lang.reflect.Array;
+import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
+import com.sun.star.uno.Type;
+import com.sun.star.uno.Enum;
+import com.sun.star.uno.XInterface;
+import com.sun.star.uno.Any;
+import com.sun.star.uno.AnyConverter;
+import java.util.HashMap;
+
+
+public class ValueComparer {
+
+ // Method to change a Value, thought for properties
+ public static boolean equalValue( Object first, Object second ) {
+
+ if (first instanceof com.sun.star.uno.Any) {
+ try {
+ first = AnyConverter.toObject(((Any) first).getType(),first);
+ } catch (com.sun.star.lang.IllegalArgumentException iae) {
+ }
+ }
+ if (second instanceof com.sun.star.uno.Any) {
+ try {
+ second = AnyConverter.toObject(((Any) second).getType(),second);
+ } catch (com.sun.star.lang.IllegalArgumentException iae) {
+ }
+ }
+ boolean eq = false;
+ try {
+ if ( (first==null) || (second == null) ) {
+ eq = (first == second);
+ }
+ else {
+ if ( util.utils.isVoid(first) && util.utils.isVoid(second) ) {
+ eq=true;
+ } else if ( util.utils.isVoid(first) || util.utils.isVoid(second) ) {
+ eq = (first == second);
+ } else {
+ eq = compareObjects(first, second);
+ }
+ }
+ }
+ catch (Exception e) {
+ System.out.println("Exception occured while comparing Objects");
+ e.printStackTrace();
+ }
+ return eq;
+ } // end of equalValue
+
+ static boolean compareArrayOfPropertyValue(PropertyValue[] pv1, PropertyValue[] pv2){
+ if ( pv1.length != pv2.length) {
+ return false;
+ }
+ HashMap hm1 = new HashMap();
+ boolean result = true;
+ int i = 0;
+
+ for (i = 0; i < pv1.length; i++){
+ hm1.put(pv1[i].Name, pv1[i].Value);
+ }
+
+ i = 0;
+ while (i < pv2.length && result) {
+ result &= equalValue(hm1.get(pv2[i].Name),pv2[i].Value);
+ i++;
+ }
+ return result;
+ }
+
+ static boolean compareArrays(Object op1, Object op2) throws Exception {
+
+ if (op1 instanceof PropertyValue[] && op2 instanceof PropertyValue[]) {
+ return compareArrayOfPropertyValue((PropertyValue[])op1,(PropertyValue[])op2);
+ }
+ boolean result = true;
+ if((op1.getClass().getComponentType() == op2.getClass().getComponentType())
+ && (Array.getLength(op1) == Array.getLength(op2)))
+ {
+ Class zClass = op1.getClass().getComponentType();
+
+ for(int i = 0; i < Array.getLength(op1); ++ i)
+ result = result & compareObjects(Array.get(op1, i), Array.get(op2, i));
+ } else {
+ result = false ;
+ }
+
+ return result;
+ }
+
+ static boolean compareInterfaces(XInterface op1, XInterface op2) {
+ return op1 == op2;
+ }
+
+ static boolean compareUntil(Class zClass, Class untilClass, Object op1, Object op2) throws Exception {
+ boolean result = true;
+
+ // write inherited members first
+ Class superClass = zClass.getSuperclass();
+ if(superClass != null && superClass != untilClass)
+ result = result & compareUntil(superClass, untilClass, op1, op2);
+
+ Field fields[] = zClass.getDeclaredFields();
+
+ for(int i = 0; i < fields.length && result; ++ i) {
+ if((fields[i].getModifiers() & (Modifier.STATIC | Modifier.TRANSIENT)) == 0) { // neither static nor transient ?
+ Object obj1 = fields[i].get(op1);
+ Object obj2 = fields[i].get(op2);
+ if (obj1 instanceof com.sun.star.uno.Any) {
+ try {
+ if (utils.isVoid(obj1)) {
+ obj1 = null;
+ } else {
+ obj1 = AnyConverter.toObject(((Any) obj1).getType(),obj1);
+ }
+ } catch (com.sun.star.lang.IllegalArgumentException iae) {
+ }
+ }
+ if (obj2 instanceof com.sun.star.uno.Any) {
+ try {
+ if (utils.isVoid(obj2)) {
+ obj2 = null;
+ } else {
+ obj2 = AnyConverter.toObject(((Any) obj2).getType(),obj2);
+ }
+ } catch (com.sun.star.lang.IllegalArgumentException iae) {
+ }
+ }
+
+ result = result & compareObjects(obj1, obj2);
+
+ }
+ }
+
+ return result;
+ }
+
+ static boolean compareStructs(Object op1, Object op2) throws Exception {
+ boolean result = true;
+
+ if(op1.getClass() != op2.getClass())
+ result = false;
+ else {
+ result = compareUntil(op1.getClass(), Object.class, op1, op2);
+ }
+
+ return result;
+ }
+
+ static boolean compareThrowable(Throwable op1, Throwable op2) throws Exception {
+ boolean result = true;
+
+ if(op1.getClass() != op2.getClass())
+ result = false;
+ else {
+ result = compareUntil(op1.getClass(), Throwable.class, op1, op2);
+
+ result = result & op1.getMessage().equals(op2.getMessage());
+ }
+
+ return result;
+ }
+
+ static boolean compareEnums(Enum en1, Enum en2) {
+ return en1.getValue() == en2.getValue();
+ }
+
+ static boolean compareObjects(Object op1, Object op2) throws Exception {
+ boolean result = false;
+
+ if(op1 == op2)
+ result = true;
+
+ if ( (op1==null) || (op2 == null) ) {
+ result = (op1 == op2);
+ }
+
+ else if(op1.getClass().isPrimitive() && op2.getClass().isPrimitive())
+ result = op1.equals(op2);
+
+ else if(op1.getClass() == Byte.class && op2.getClass() == Byte.class)
+ result = op1.equals(op2);
+
+ else if(op1.getClass() == Type.class && op2.getClass() == Type.class)
+ result = op1.equals(op2);
+
+ else if(op1.getClass() == Boolean.class && op2.getClass() == Boolean.class)
+ result = op1.equals(op2);
+
+ else if(op1.getClass() == Short.class && op2.getClass() == Short.class)
+ result = op1.equals(op2);
+
+ else if(Throwable.class.isAssignableFrom(op1.getClass()) && Throwable.class.isAssignableFrom(op2.getClass()))
+ result = compareThrowable((Throwable)op1, (Throwable)op2);
+
+ else if(op1.getClass() == Integer.class && op2.getClass() == Integer.class)
+ result = op1.equals(op2);
+
+ else if(op1.getClass() == Character.class && op2.getClass() == Character.class)
+ result = op1.equals(op2);
+
+ else if(op1.getClass() == Long.class && op2.getClass() == Long.class)
+ result = op1.equals(op2);
+
+ else if(op1.getClass() == Void.class && op2.getClass() == Void.class)
+ result = op1.equals(op2);
+
+ else if(op1.getClass() == Float.class && op2.getClass() == Float.class)
+ result = op1.equals(op2);
+
+ else if(op1.getClass() == Double.class && op2.getClass() == Double.class)
+ result = op1.equals(op2);
+
+ else if(op1.getClass().isArray() && op2.getClass().isArray())
+ result = compareArrays(op1, op2);
+
+ else if(op1.getClass() == Void.class || op2.getClass() == void.class) // write nothing ?
+ result = true;
+
+ else if(XInterface.class.isAssignableFrom(op1.getClass()) && XInterface.class.isAssignableFrom(op2.getClass()))
+ compareInterfaces((XInterface)op1, (XInterface)op2);
+
+ else if(Enum.class.isAssignableFrom(op1.getClass()) && Enum.class.isAssignableFrom(op2.getClass()))
+ compareEnums((Enum)op1, (Enum)op2);
+
+ else if(op1.getClass() == String.class && op2.getClass() == String.class) // is it a String ?
+ result = ((String)op1).equals((String)op2);
+
+ else // otherwise it must be a struct
+ result = compareStructs(op1, op2);
+
+ return result;
+ }
+
+
+}
diff --git a/qadevOOo/runner/util/WaitUnreachable.java b/qadevOOo/runner/util/WaitUnreachable.java
new file mode 100644
index 000000000000..f756c9fae648
--- /dev/null
+++ b/qadevOOo/runner/util/WaitUnreachable.java
@@ -0,0 +1,127 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package util;
+
+import java.lang.ref.PhantomReference;
+import java.lang.ref.ReferenceQueue;
+
+/**
+ * Wait until an object has become unreachable.
+ *
+ * <p>Instances of this class will typically be used as either:</p>
+ * <pre>
+ * SomeType o = new SomeType(...);
+ * ... // use "o"
+ * WaitUnreachable u = new WaitUnreachable(o);
+ * o = null;
+ * u.waitUnreachable();
+ * </pre>
+ * <p>or:</p>
+ * <pre>
+ * WaitUnreachable u = new WaitUnreachable(new SomeType(...));
+ * ... // use "(SomeType) u.get()"
+ * u.waitUnreachable();
+ * </pre>
+ */
+public final class WaitUnreachable {
+ /**
+ * Creates a new waiter.
+ *
+ * @param obj the object on which to wait
+ */
+ public WaitUnreachable(Object obj) {
+ this.obj = obj;
+ queue = new ReferenceQueue();
+ ref = new PhantomReference(obj, queue);
+ }
+
+ /**
+ * Gets the object on which to wait.
+ *
+ * @return the object on which to wait, or <code>null</code> if
+ * <code>waitUnreachable</code> has already been called
+ */
+ public synchronized Object get() {
+ return obj;
+ }
+
+ /**
+ * Starts waiting for the object to become unreachable.
+ *
+ * <p>This blocks the current thread until the object has become
+ * unreachable.</p>
+ *
+ * <p>Actually, this method waits until the JVM has <em>detected</em> that
+ * the object has become unreachable. This is not deterministic, but this
+ * methods makes a best effort to cause the JVM to eventually detect the
+ * situation. With a typical JVM, this should suffice.</p>
+ */
+ public void waitUnreachable() {
+ synchronized (this) {
+ obj = null;
+ }
+ System.out.println("waiting for gc");
+ while (queue.poll() == null) {
+ System.gc();
+ System.runFinalization();
+ byte[] dummy = new byte[1024];
+ }
+ }
+
+ /**
+ * Ensures that an object will be finalized as soon as possible.
+ *
+ * <p>This does not block the current thread. Instead, a new thread is
+ * spawned that busy waits for the given object to become unreachable.</p>
+ *
+ * <p>This method cannot guarantee that the given object is eventually
+ * finalized, but it makes a best effort. With a typical JVM, this should
+ * suffice.</p>
+ *
+ * @param obj the object of which to ensure finalization
+ */
+ public static void ensureFinalization(final Object obj) {
+ final class WaitThread extends Thread {
+ public WaitThread(Object obj) {
+ super("ensureFinalization");
+ unreachable = new WaitUnreachable(obj);
+ }
+
+ public void run() {
+ unreachable.waitUnreachable();
+ }
+
+ private final WaitUnreachable unreachable;
+ };
+ new WaitThread(obj).start();
+ }
+
+ private Object obj;
+ private final ReferenceQueue queue;
+ private final PhantomReference ref;
+}
diff --git a/qadevOOo/runner/util/WriterTools.java b/qadevOOo/runner/util/WriterTools.java
new file mode 100644
index 000000000000..33b5d4f61aab
--- /dev/null
+++ b/qadevOOo/runner/util/WriterTools.java
@@ -0,0 +1,121 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package util;
+
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.container.XNamed;
+import com.sun.star.drawing.XDrawPage;
+import com.sun.star.drawing.XDrawPageSupplier;
+import com.sun.star.lang.XComponent;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.text.XText;
+import com.sun.star.text.XTextContent;
+import com.sun.star.text.XTextCursor;
+import com.sun.star.text.XTextDocument;
+import com.sun.star.uno.UnoRuntime;
+
+// access the implementations via names
+import com.sun.star.uno.XInterface;
+
+import util.DesktopTools;
+
+
+public class WriterTools {
+ public static XTextDocument createTextDoc(XMultiServiceFactory xMSF) {
+ PropertyValue[] Args = new PropertyValue[0];
+ XComponent comp = DesktopTools.openNewDoc(xMSF, "swriter", Args);
+ XTextDocument WriterDoc = (XTextDocument) UnoRuntime.queryInterface(
+ XTextDocument.class, comp);
+
+ return WriterDoc;
+ } // finish createTextDoc
+
+ public static XTextDocument loadTextDoc(XMultiServiceFactory xMSF,
+ String url) {
+ PropertyValue[] Args = new PropertyValue[0];
+ XTextDocument WriterDoc = loadTextDoc(xMSF, url, Args);
+
+ return WriterDoc;
+ } // finish createTextDoc
+
+ public static XTextDocument loadTextDoc(XMultiServiceFactory xMSF,
+ String url, PropertyValue[] Args) {
+ XComponent comp = DesktopTools.loadDoc(xMSF, url, Args);
+ XTextDocument WriterDoc = (XTextDocument) UnoRuntime.queryInterface(
+ XTextDocument.class, comp);
+
+ return WriterDoc;
+ } // finish createTextDoc
+
+ public static XDrawPage getDrawPage(XTextDocument aDoc) {
+ XDrawPage oDP = null;
+
+ try {
+ XDrawPageSupplier oDPS = (XDrawPageSupplier) UnoRuntime.queryInterface(
+ XDrawPageSupplier.class, aDoc);
+ oDP = (XDrawPage) oDPS.getDrawPage();
+ } catch (Exception e) {
+ throw new IllegalArgumentException("Couldn't get drawpage");
+ }
+
+ return oDP;
+ }
+
+ public static void insertTextGraphic(XTextDocument aDoc,
+ XMultiServiceFactory xMSF, int hpos,
+ int vpos, int width, int height,
+ String pic, String name) {
+ try {
+ Object oGObject = (XInterface) xMSF.createInstance(
+ "com.sun.star.text.GraphicObject");
+
+ XText the_text = aDoc.getText();
+ XTextCursor the_cursor = the_text.createTextCursor();
+ XTextContent the_content = (XTextContent) UnoRuntime.queryInterface(
+ XTextContent.class, oGObject);
+ the_text.insertTextContent(the_cursor, the_content, true);
+
+ XPropertySet oProps = (XPropertySet) UnoRuntime.queryInterface(
+ XPropertySet.class, oGObject);
+
+ String fullURL = util.utils.getFullTestURL(pic);
+ oProps.setPropertyValue("GraphicURL", fullURL);
+ oProps.setPropertyValue("HoriOrientPosition", new Integer(hpos));
+ oProps.setPropertyValue("VertOrientPosition", new Integer(vpos));
+ oProps.setPropertyValue("Width", new Integer(width));
+ oProps.setPropertyValue("Height", new Integer(height));
+
+ XNamed the_name = (XNamed) UnoRuntime.queryInterface(XNamed.class,
+ oGObject);
+ the_name.setName(name);
+ } catch (Exception ex) {
+ System.out.println("Exception while insertin TextGraphic");
+ ex.printStackTrace();
+ }
+ }
+} \ No newline at end of file
diff --git a/qadevOOo/runner/util/XInstCreator.java b/qadevOOo/runner/util/XInstCreator.java
new file mode 100644
index 000000000000..2f6ec3ecf272
--- /dev/null
+++ b/qadevOOo/runner/util/XInstCreator.java
@@ -0,0 +1,38 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package util;
+
+import com.sun.star.uno.XInterface;
+import com.sun.star.container.XIndexAccess;
+
+public interface XInstCreator {
+
+ XInterface getInstance();
+ XInterface createInstance();
+ XIndexAccess getCollection();
+}
diff --git a/qadevOOo/runner/util/XLayerHandlerImpl.java b/qadevOOo/runner/util/XLayerHandlerImpl.java
new file mode 100644
index 000000000000..e3a0ae3a1b23
--- /dev/null
+++ b/qadevOOo/runner/util/XLayerHandlerImpl.java
@@ -0,0 +1,119 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package util;
+
+public class XLayerHandlerImpl
+ implements com.sun.star.configuration.backend.XLayerHandler {
+ protected String calls = "";
+ protected String ls = System.getProperty("line.separator");
+
+ public void addOrReplaceNode(String str, short param)
+ throws com.sun.star.configuration.backend.MalformedDataException,
+ com.sun.star.lang.WrappedTargetException {
+ calls += ("addOrReplace(" + str + "," + param + ");" + ls);
+ }
+
+ public void addOrReplaceNodeFromTemplate(String str,
+ com.sun.star.configuration.backend.TemplateIdentifier templateIdentifier,
+ short param)
+ throws com.sun.star.configuration.backend.MalformedDataException,
+ com.sun.star.lang.WrappedTargetException {
+ calls += ("addOrReplaceNodeFromTemplate(" + str + "," + templateIdentifier + ");" + ls);
+ }
+
+ public void addProperty(String str, short param,
+ com.sun.star.uno.Type type)
+ throws com.sun.star.configuration.backend.MalformedDataException,
+ com.sun.star.lang.WrappedTargetException {
+ calls += ("addProperty(" + str + "," + param + "," + type + ");" + ls);
+ }
+
+ public void addPropertyWithValue(String str, short param, Object obj)
+ throws com.sun.star.configuration.backend.MalformedDataException,
+ com.sun.star.lang.WrappedTargetException {
+ calls += ("addPropertyWithValue(" + str + "," + param + "," + obj + ");" + ls);
+ }
+
+ public void dropNode(String str)
+ throws com.sun.star.configuration.backend.MalformedDataException,
+ com.sun.star.lang.WrappedTargetException {
+ calls += ("dropNode(" + str + ");" + ls);
+ }
+
+ public void endLayer()
+ throws com.sun.star.configuration.backend.MalformedDataException,
+ com.sun.star.lang.WrappedTargetException {
+ calls += ("endLayer();" + ls);
+ }
+
+ public void endNode()
+ throws com.sun.star.configuration.backend.MalformedDataException,
+ com.sun.star.lang.WrappedTargetException {
+ calls += ("endNode();" + ls);
+ }
+
+ public void endProperty()
+ throws com.sun.star.configuration.backend.MalformedDataException,
+ com.sun.star.lang.WrappedTargetException {
+ calls += ("endProperty();" + ls);
+ }
+
+ public void overrideNode(String str, short param, boolean param2)
+ throws com.sun.star.configuration.backend.MalformedDataException,
+ com.sun.star.lang.WrappedTargetException {
+ calls += ("overrideNode(" + str + "," + param + "," + param2 + ");" + ls);
+ }
+
+ public void overrideProperty(String str, short param,
+ com.sun.star.uno.Type type, boolean param3)
+ throws com.sun.star.configuration.backend.MalformedDataException,
+ com.sun.star.lang.WrappedTargetException {
+ calls += ("overrideProperty(" + str + "," + param + "," + type + "," + param3 + ");" + ls);
+ }
+
+ public void setPropertyValue(Object obj)
+ throws com.sun.star.configuration.backend.MalformedDataException,
+ com.sun.star.lang.WrappedTargetException {
+ calls += ("setPropertyValue(" + obj + ");" + ls);
+ }
+
+ public void setPropertyValueForLocale(Object obj, String str)
+ throws com.sun.star.configuration.backend.MalformedDataException,
+ com.sun.star.lang.WrappedTargetException {
+ calls += ("setPropertyValueForLocale(" + obj + "," + str + ");" + ls);
+ }
+
+ public void startLayer()
+ throws com.sun.star.configuration.backend.MalformedDataException,
+ com.sun.star.lang.WrappedTargetException {
+ calls = "startLayer();" + ls;
+ }
+
+ public String getCalls() {
+ return calls;
+ }
+} \ No newline at end of file
diff --git a/qadevOOo/runner/util/XLayerImpl.java b/qadevOOo/runner/util/XLayerImpl.java
new file mode 100644
index 000000000000..72dc2a2fa6aa
--- /dev/null
+++ b/qadevOOo/runner/util/XLayerImpl.java
@@ -0,0 +1,45 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package util;
+
+public class XLayerImpl implements com.sun.star.configuration.backend.XLayer {
+
+ protected boolean wasCalled = false;
+
+ public XLayerImpl() {
+ }
+
+ public void readData(com.sun.star.configuration.backend.XLayerHandler xLayerHandler) throws com.sun.star.lang.NullPointerException, com.sun.star.lang.WrappedTargetException, com.sun.star.configuration.backend.MalformedDataException {
+ wasCalled = true;
+ }
+
+ public boolean hasBeenCalled() {
+ return wasCalled;
+ }
+
+}
diff --git a/qadevOOo/runner/util/XMLTools.java b/qadevOOo/runner/util/XMLTools.java
new file mode 100644
index 000000000000..a744afe0a3f8
--- /dev/null
+++ b/qadevOOo/runner/util/XMLTools.java
@@ -0,0 +1,939 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package util;
+
+import java.io.PrintWriter ;
+import java.util.Vector ;
+import java.util.Hashtable ;
+import java.util.Enumeration ;
+import java.util.HashSet ;
+
+// access the implementations via names
+import com.sun.star.uno.XInterface;
+import com.sun.star.io.XOutputStream;
+import com.sun.star.io.XInputStream;
+import com.sun.star.io.XActiveDataSource;
+import com.sun.star.ucb.XSimpleFileAccess;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.xml.sax.XDocumentHandler;
+import com.sun.star.uno.Any;
+import com.sun.star.uno.Type;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.xml.sax.XLocator;
+import com.sun.star.xml.sax.XAttributeList;
+import com.sun.star.xml.sax.XParser ;
+import com.sun.star.xml.sax.InputSource ;
+import com.sun.star.lang.XComponent;
+import com.sun.star.document.XExporter;
+import com.sun.star.document.XImporter;
+import com.sun.star.document.XFilter;
+
+
+public class XMLTools {
+
+ /**
+ * The implementation of <code>com.sun.star.xml.sax.XAttributeList</code>
+ * where attributes and their values can be added.
+ */
+ public static class AttributeList implements XAttributeList {
+ private static class Attribute {
+ public String Name ;
+ public String Type ;
+ public String Value ;
+ }
+ private Hashtable attrByName = new Hashtable() ;
+ private Vector attributes = new Vector() ;
+ private PrintWriter log = null ;
+
+ /**
+ * Creates a class instance.
+ */
+ public AttributeList() {}
+
+ /**
+ * Constructs a list which will report to <code>log</code>
+ * specified about each <code>XDocumentHandler</code> method
+ * call.
+ */
+ public AttributeList(PrintWriter log) {
+ this.log = log ;
+ }
+
+ public AttributeList(XAttributeList list) {
+ if (list == null) return ;
+ for (short i = 0; i < list.getLength(); i++) {
+ add(list.getNameByIndex(i), list.getTypeByIndex(i),
+ list.getValueByIndex(i)) ;
+ }
+ }
+
+ /**
+ * Adds an attribute with type and value specified.
+ * @param name The attribute name.
+ * @param type Value type (usually 'CDATA' used).
+ * @param value Attribute value.
+ */
+ public void add(String name, String type, String value) {
+ Attribute attr = new Attribute() ;
+ attr.Name = name ;
+ attr.Type = type ;
+ attr.Value = value ;
+ attributes.add(attr) ;
+ attrByName.put(attr.Name, attr) ;
+ }
+
+ /**
+ * Adds an attribute with value specified. As a type of
+ * value 'CDATA' string specified.
+ * @param name The attribute name.
+ * @param value Attribute value.
+ */
+ public void add(String name, String value) {
+ add(name, "CDATA", value) ;
+ }
+
+ /**
+ * Clears all attributes added before.
+ */
+ public void clear() {
+ attrByName.clear() ;
+ attributes.clear() ;
+ }
+
+ /***************************************
+ * XAttributeList methods
+ ****************************************/
+
+ public short getLength() {
+ if (log != null)
+ log.println("getLength() called -> " + attributes.size()) ;
+ return (short) attributes.size() ;
+ }
+
+ public String getNameByIndex(short idx) {
+ String name = ((Attribute) attributes.get(idx)).Name ;
+ if (log != null)
+ log.println("getNameByIndex(" + idx + ") called -> '" +
+ name + "'") ;
+ return name ;
+ }
+
+ public String getTypeByIndex(short idx) {
+ String type = ((Attribute) attributes.get(idx)).Type ;
+ if (log != null)
+ log.println("getTypeByIndex(" + idx + ") called -> '" +
+ type + "'") ;
+ return type;
+ }
+
+ public String getTypeByName(String name) {
+ String type = ((Attribute) attrByName.get(name)).Type ;
+ if (log != null)
+ log.println("getTypeByName('" + name + "') called -> '" +
+ type + "'") ;
+ return type;
+ }
+ public String getValueByIndex(short idx) {
+ String value = ((Attribute) attributes.get(idx)).Value ;
+ if (log != null)
+ log.println("getValueByIndex(" + idx + ") called -> '" +
+ value + "'") ;
+ return value;
+ }
+
+ public String getValueByName(String name) {
+ String value = ((Attribute) attrByName.get(name)).Value ;
+ if (log != null)
+ log.println("getValueByName('" + name + "') called -> '" +
+ value + "'") ;
+ return value;
+ }
+ }
+
+ /**
+ * This class writes all XML data handled into a stream specified
+ * in the constructor.
+ */
+ public static class XMLWriter implements XDocumentHandler {
+ private PrintWriter _log = null ;
+ private String align = "" ;
+
+ /**
+ * Creates a SAX handler which writes all XML data
+ * handled into a <code>log</code> stream specified.
+ */
+ public XMLWriter(PrintWriter log) {
+ _log = log ;
+ }
+
+ /**
+ * Creates a SAX handler which does nothing.
+ */
+ public XMLWriter() {
+ }
+
+ public void processingInstruction(String appl, String data) {
+ if (_log == null) return ;
+ _log.println(align + "<?" + appl + " " + data + "?>") ;
+ }
+ public void startDocument() {
+ if (_log == null) return ;
+ _log.println("START DOCUMENT:") ;
+ }
+ public void endDocument() {
+ if (_log == null) return ;
+ _log.println("END DOCUMENT:") ;
+ }
+ public void setDocumentLocator(XLocator loc) {
+ if (_log == null) return ;
+ _log.println("DOCUMENT LOCATOR: ('" + loc.getPublicId() +
+ "','" + loc.getSystemId() + "')") ;
+ }
+ public void startElement(String name, XAttributeList attr) {
+ if (_log == null) return ;
+ _log.print(align + "<" + name + " ") ;
+ if (attr != null) {
+ short attrLen = attr.getLength() ;
+ for (short i = 0; i < attrLen; i++) {
+ if (i != 0) _log.print(align + " ") ;
+ _log.print(attr.getNameByIndex(i) + "[" +
+ attr.getTypeByIndex(i) + "]=\"" +
+ attr.getValueByIndex(i) + "\"") ;
+ if (i+1 != attrLen) {
+ _log.println() ;
+ }
+ }
+ }
+ _log.println(">") ;
+
+ align += " " ;
+ }
+
+ public void endElement(String name) {
+ if (_log == null) return ;
+ align = align.substring(3) ;
+ _log.println(align + "</" + name + ">") ;
+ }
+
+ public void characters(String chars) {
+ if (_log == null) return ;
+ _log.println(align + chars) ;
+ }
+ public void ignorableWhitespace(String sp) {
+ if (_log == null) return ;
+ _log.println(sp) ;
+ }
+ }
+
+ /**
+ * Checks if the XML structure is well formed (i.e. all tags opened must be
+ * closed and all tags opened inside a tag must be closed
+ * inside the same tag). It also checks parameters passed.
+ * If any collisions found appropriate error message is
+ * output into a stream specified. No XML data output, i.e.
+ * no output will be performed if no errors occur.<p>
+ * After document is completed there is a way to cehck
+ * if the XML data and structure was valid.
+ */
+ public static class XMLWellFormChecker extends XMLWriter {
+ protected boolean docStarted = false ;
+ protected boolean docEnded = false ;
+ protected Vector tagStack = new Vector() ;
+ protected boolean wellFormed = true ;
+ protected boolean noOtherErrors = true ;
+ protected PrintWriter log = null ;
+ protected boolean printXMLData = false ;
+
+ public XMLWellFormChecker(PrintWriter log) {
+ super() ;
+ this.log = log ;
+ }
+
+ public XMLWellFormChecker(PrintWriter log_, boolean printXMLData) {
+ super(printXMLData ? log_ : null) ;
+ this.printXMLData = printXMLData ;
+ this.log = log_ ;
+ }
+
+ /**
+ * Reset all values. This is important e.g. for test of XFilter
+ * interface, where 'filter()' method istbstarted twice.
+ */
+ public void reset() {
+ docStarted = false ;
+ docEnded = false ;
+ tagStack = new Vector() ;
+ wellFormed = true ;
+ noOtherErrors = true ;
+ PrintWriter log = null ;
+ printXMLData = false ;
+ }
+
+ public void startDocument() {
+ super.startDocument();
+
+ if (docStarted) {
+ printError("Document is started twice.") ;
+ wellFormed = false ;
+ }
+
+ docStarted = true ;
+ }
+ public void endDocument() {
+ super.endDocument();
+ if (!docStarted) {
+ wellFormed = false ;
+ printError("Document ended but not started.") ;
+ }
+ docEnded = true ;
+ }
+ public void startElement(String name, XAttributeList attr) {
+ super.startElement(name, attr);
+ if (attr == null) {
+ printError("attribute list passed as parameter to startElement()"+
+ " method has null value for tag <" + name + ">") ;
+ noOtherErrors = false ;
+ }
+ tagStack.add(0, name) ;
+ }
+ public void endElement(String name) {
+ super.endElement(name);
+ if (wellFormed) {
+ if (tagStack.size() == 0) {
+ wellFormed = false ;
+ printError("No tags to close (bad closing tag </" + name + ">)") ;
+ } else {
+ String startTag = (String) tagStack.elementAt(0) ;
+ tagStack.remove(0) ;
+ if (!startTag.equals(name)) {
+ wellFormed = false ;
+ printError("Bad closing tag: </" + name +
+ ">; tag expected: </" + startTag + ">");
+ }
+ }
+ }
+ }
+
+ /**
+ * Checks if there were no errors during document handling.
+ * I.e. startDocument() and endDocument() must be called,
+ * XML must be well formed, paramters must be valid.
+ */
+ public boolean isWellFormed() {
+ if (!docEnded) {
+ printError("Document was not ended.") ;
+ wellFormed = false ;
+ }
+
+ return wellFormed && noOtherErrors ;
+ }
+
+ /**
+ * Prints error message and all tags where error occured inside.
+ * Also prints "Tag trace" in case if the full XML data isn't
+ * printed.
+ */
+ public void printError(String msg) {
+ log.println("!!! Error: " + msg) ;
+ if (printXMLData) return ;
+ log.println(" Tag trace :") ;
+ for (int i = 0; i < tagStack.size(); i++) {
+ String tag = (String) tagStack.elementAt(i) ;
+ log.println(" <" + tag + ">") ;
+ }
+ }
+ }
+
+ /**
+ * Beside structure of XML this class also can check existence
+ * of tags, inner tags, and character data. After document
+ * completion there is a way to check if required tags and
+ * character data was found. If there any error occurs an
+ * appropriate message is output.
+ */
+ public static class XMLTagsChecker extends XMLWellFormChecker {
+ protected Hashtable tags = new Hashtable() ;
+ protected Hashtable chars = new Hashtable() ;
+ protected boolean allOK = true ;
+
+ public XMLTagsChecker(PrintWriter log) {
+ super(log) ;
+ }
+
+ /**
+ * Adds a tag name which must be contained in the XML data.
+ */
+ public void addTag(String tag) {
+ tags.put(tag, "") ;
+ }
+ /**
+ * Adds a tag name which must be contained in the XML data and
+ * must be inside the tag with name <code>outerTag</code>.
+ */
+ public void addTagEnclosed(String tag, String outerTag) {
+ tags.put(tag, outerTag) ;
+ }
+ /**
+ * Adds a character data which must be contained in the XML data.
+ */
+ public void addCharacters(String ch) {
+ chars.put(ch, "") ;
+ }
+ /**
+ * Adds a character data which must be contained in the XML data and
+ * must be inside the tag with name <code>outerTag</code>.
+ */
+ public void addCharactersEnclosed(String ch, String outerTag) {
+ chars.put(ch, outerTag) ;
+ }
+
+ public void startElement(String name, XAttributeList attrs) {
+ super.startElement(name, attrs) ;
+ if (tags.containsKey(name)) {
+ String outerTag = (String) tags.get(name);
+ if (!outerTag.equals("")) {
+ boolean isInTag = false ;
+ for (int i = 0; i < tagStack.size(); i++) {
+ if (outerTag.equals((String) tagStack.elementAt(i))) {
+ isInTag = true ;
+ break ;
+ }
+ }
+ if (!isInTag) {
+ printError("Required tag <" + name + "> found, but is not enclosed in tag <" +
+ outerTag + ">") ;
+ allOK = false ;
+ }
+ }
+ tags.remove(name) ;
+ }
+ }
+
+ public void characters(String ch) {
+ super.characters(ch) ;
+
+ if (chars.containsKey(ch)) {
+ String outerTag = (String) chars.get(ch);
+ if (!outerTag.equals("")) {
+ boolean isInTag = false ;
+ for (int i = 0; i < tagStack.size(); i++) {
+ if (outerTag.equals((String) tagStack.elementAt(i))) {
+ isInTag = true ;
+ break ;
+ }
+ }
+ if (!isInTag) {
+ printError("Required characters '" + ch + "' found, but are not enclosed in tag <" +
+ outerTag + ">") ;
+ allOK = false ;
+ }
+ }
+ chars.remove(ch) ;
+ }
+ }
+
+ /**
+ * Checks if the XML data was valid and well formed and if
+ * all necessary tags and character data was found.
+ */
+ public boolean checkTags() {
+ allOK &= isWellFormed() ;
+
+ Enumeration badTags = tags.keys() ;
+ Enumeration badChars = chars.keys() ;
+
+ if (badTags.hasMoreElements()) {
+ allOK = false ;
+ log.println("Required tags were not found in export :") ;
+ while(badTags.hasMoreElements()) {
+ log.println(" <" + ((String) badTags.nextElement()) + ">") ;
+ }
+ }
+ if (badChars.hasMoreElements()) {
+ allOK = false ;
+ log.println("Required characters were not found in export :") ;
+ while(badChars.hasMoreElements()) {
+ log.println(" <" + ((String) badChars.nextElement()) + ">") ;
+ }
+ }
+ reset();
+ return allOK ;
+ }
+ }
+
+ /**
+ * Represents an XML tag which must be found in XML data written.
+ * This tag can contain only its name or tag name and attribute
+ * name, or attribute value additionally.
+ */
+ public static class Tag {
+ private String name = null;
+ private String[][] attrList = new String[0][3] ;
+
+ /**
+ * Creates tag which has only a name. Attributes don't make sense.
+ * @param tagName The name of the tag.
+ */
+ public Tag(String tagName) {
+ name = tagName ;
+ }
+
+ /**
+ * Creates a tag with the name specified, which must have an
+ * attribute with name specified. The value of this attribute
+ * doesn't make sense.
+ * @param tagName The name of the tag.
+ * @param attrName The name of attribute which must be contained
+ * in the tag.
+ */
+ public Tag(String tagName, String attrName) {
+ name = tagName ;
+ attrList = new String[1][3] ;
+ attrList[0][0] = attrName ;
+ }
+
+ /**
+ * Creates a tag with the name specified, which must have an
+ * attribute with the value specified. The type of value
+ * assumed to be 'CDATA'.
+ * @param tagName The name of the tag.
+ * @param attrName The name of attribute which must be contained
+ * in the tag.
+ * @param attrValue Attribute value.
+ */
+ public Tag(String tagName, String attrName, String attrValue) {
+ name = tagName ;
+ attrList = new String[1][3] ;
+ attrList[0][0] = attrName ;
+ attrList[0][1] = "CDATA" ;
+ attrList[0][2] = attrValue ;
+ }
+
+ /**
+ * Creates a tag with the name specified, which must have
+ * attributes specified. The value of thesee attributes
+ * doesn't make sense.
+ * @param tagName The name of the tag.
+ * @param attrNames Array with names of attributes which must
+ * be contained in the tag.
+ */
+ public Tag(String tagName, String[] attrNames) {
+ name = tagName ;
+ attrList = new String[attrNames.length][3] ;
+ for (int i = 0; i < attrNames.length; i++) {
+ attrList[i][0] = attrNames[i] ;
+ }
+ }
+
+ /**
+ * Creates a tag with the name specified, which must have an
+ * attributes with their values specified. The type of all values
+ * assumed to be 'CDATA'.
+ * @param tagName The name of the tag.
+ * @param attrValues An array with attribute names and their values.
+ * <code>attrValues[N][0]</code> element contains the name of Nth
+ * attribute, and <code>attrValues[N][1]</code> element contains
+ * value of Nth attribute, if value is <code>null</code> then the
+ * attribute value can be any.
+ */
+ public Tag(String tagName, String[][] attrValues) {
+ name = tagName ;
+ attrList = new String[attrValues.length][3] ;
+ for (int i = 0; i < attrValues.length; i++) {
+ attrList[i][0] = attrValues[i][0] ;
+ attrList[i][1] = "CDATA" ;
+ attrList[i][2] = attrValues[i][1] ;
+ }
+ }
+
+ /**
+ * Gets tag String description.
+ */
+ public String toString() {
+ String ret = "<" + name ;
+ for (int i = 0; i < attrList.length; i++) {
+ ret += " " + attrList[i][0] + "=";
+ if (attrList[i][2] == null) {
+ ret += "(not specified)";
+ } else {
+ ret += "\"" + attrList[i][2] + "\"";
+ }
+ }
+ ret += ">";
+
+ return ret ;
+ }
+
+ protected boolean checkAttr(int attrListIdx, XAttributeList list) {
+ short j = 0 ;
+ int listLen = list.getLength();
+ while(j < listLen) {
+ if (attrList[attrListIdx][0].equals(list.getNameByIndex(j))) {
+ if (attrList[attrListIdx][2] == null) return true ;
+ return attrList[attrListIdx][2].equals(list.getValueByIndex(j)) ;
+ }
+ j++ ;
+ }
+ return false ;
+ }
+
+ /**
+ * Checks if this tag matches tag passed in parameters.
+ * I.e. if tag specifies only it's name it mathes if names
+ * are equal (attributes don't make sense). If there are
+ * some attributes names specified in this tag method checks
+ * if all names present in attribute list <code>list</code>
+ * (attributes' values don't make sense). If attributes specified
+ * with values method checks if these attributes exist and
+ * have appropriate values.
+ */
+ public boolean isMatchTo(String tagName, XAttributeList list) {
+ if (!name.equals(tagName)) return false;
+ boolean result = true ;
+ for (int i = 0; i < attrList.length; i++) {
+ result &= checkAttr(i, list) ;
+ }
+ return result ;
+ }
+ }
+
+ /**
+ * Class realises extended XML data checking. It has possibilities
+ * to check if a tag exists, if it has some attributes with
+ * values, and if this tag is contained in another tag (which
+ * also can specify any attributes). It can check if some
+ * character data exists inside any tag specified.
+ */
+ public static class XMLChecker extends XMLWellFormChecker {
+ protected HashSet tagSet = new HashSet() ;
+ protected Vector tags = new Vector() ;
+ protected Vector chars = new Vector() ;
+ protected Vector tagStack = new Vector() ;
+ protected Vector attrStack = new Vector() ;
+
+ public XMLChecker(PrintWriter log, boolean writeXML) {
+ super(log, writeXML) ;
+ }
+
+ public void addTag(Tag tag) {
+ tags.add(new Tag[] {tag, null}) ;
+ tagSet.add(tag.name) ;
+ }
+
+ public void addTagEnclosed(Tag tag, Tag outerTag) {
+ tags.add(new Tag[] {tag, outerTag}) ;
+ tagSet.add(tag.name) ;
+ }
+
+ public void addCharacters(String ch) {
+ chars.add(new Object[] {ch.trim(), null}) ;
+ }
+
+ public void addCharactersEnclosed(String ch, Tag outerTag) {
+ chars.add(new Object[] {ch.trim(), outerTag}) ;
+ }
+
+ public void startElement(String name, XAttributeList attr) {
+ try {
+ super.startElement(name, attr);
+
+ if (tagSet.contains(name)) {
+ for (int i = 0; i < tags.size(); i++) {
+ Tag[] tag = (Tag[]) tags.elementAt(i);
+ if (tag[0].isMatchTo(name, attr)) {
+ if (tag[1] == null) {
+ tags.remove(i--);
+ } else {
+ boolean isInStack = false ;
+ for (int j = 0; j < tagStack.size(); j++) {
+ if (tag[1].isMatchTo((String) tagStack.elementAt(j),
+ (XAttributeList) attrStack.elementAt(j))) {
+
+ isInStack = true ;
+ break ;
+ }
+ }
+ if (isInStack) {
+ tags.remove(i--) ;
+ }
+ }
+ }
+ }
+ }
+
+ tagStack.add(0, name) ;
+ attrStack.add(0, new AttributeList(attr));
+ } catch (Exception e) {
+ e.printStackTrace(log);
+ }
+ }
+
+ public void characters(String ch) {
+ super.characters(ch) ;
+ for (int i = 0; i < chars.size(); i++) {
+ Object[] chr = (Object[]) chars.elementAt(i);
+ if (((String) chr[0]).equals(ch)) {
+ if (chr[1] == null) {
+ chars.remove(i--);
+ } else {
+ boolean isInStack = false ;
+ for (int j = 0; j < tagStack.size(); j++) {
+ if (((Tag) chr[1]).isMatchTo((String) tagStack.elementAt(j),
+ (XAttributeList) attrStack.elementAt(j))) {
+
+ isInStack = true ;
+ break ;
+ }
+ }
+ if (isInStack) {
+ chars.remove(i--) ;
+ }
+ }
+ }
+ }
+ }
+
+ public void endElement(String name) {
+ try {
+ super.endElement(name);
+
+ if (tagStack.size() > 0) {
+ tagStack.remove(0) ;
+ attrStack.remove(0) ;
+ }
+ } catch(Exception e) {
+ e.printStackTrace(log) ;
+ }
+ }
+
+ public boolean check() {
+ if (tags.size()> 0) {
+ log.println("!!! Error: Some tags were not found :") ;
+ for (int i = 0; i < tags.size(); i++) {
+ Tag[] tag = (Tag[]) tags.elementAt(i) ;
+ log.println(" Tag " + tag[0] + " was not found");
+ if (tag[1] != null)
+ log.println(" inside tag " + tag[1]) ;
+ }
+ }
+ if (chars.size() > 0) {
+ log.println("!!! Error: Some character data blocks were not found :") ;
+ for (int i = 0; i < chars.size(); i++) {
+ Object[] ch = (Object[]) chars.elementAt(i) ;
+ log.println(" Character data \"" + ch[0] + "\" was not found ") ;
+ if (ch[1] != null)
+ log.println(" inside tag " + ch[1]) ;
+ }
+ }
+
+ if (!isWellFormed())
+ log.println("!!! Some errors were found in XML structure") ;
+
+ boolean result = tags.size() == 0 && chars.size() == 0 && isWellFormed();
+ reset();
+ return result;
+ }
+ }
+
+ /**
+ * Creates <code>XDocumentHandler</code> implementation in form
+ * of <code>com.sun.star.xml.sax.Writer</code> service, which
+ * writes XML data into a <code>com.sun.star.io.Pipe</code>
+ * created.
+ * @return Single element array which contains the handler
+ * contained in <code>Any</code> structure.
+ */
+ public static Object[] getDocumentHandler(XMultiServiceFactory xMSF) {
+ Object[] ret = new Object[1];
+ try {
+ XInterface Writer = (XInterface) xMSF.createInstance(
+ "com.sun.star.xml.sax.Writer");
+ XInterface oPipe = (XInterface) xMSF.createInstance
+ ( "com.sun.star.io.Pipe" );
+ XOutputStream xPipeOutput = (XOutputStream) UnoRuntime.
+ queryInterface(XOutputStream.class, oPipe) ;
+
+ XActiveDataSource xADS = (XActiveDataSource)
+ UnoRuntime.queryInterface(XActiveDataSource.class,Writer);
+ xADS.setOutputStream(xPipeOutput);
+ XDocumentHandler handler = (XDocumentHandler)
+ UnoRuntime.queryInterface(XDocumentHandler.class,Writer);
+
+ Any arg = new Any(new Type(XDocumentHandler.class),handler);
+
+ ret[0] = arg;
+ } catch (com.sun.star.uno.Exception e) {
+ e.printStackTrace();
+ }
+ return ret;
+ }
+
+ public static PropertyValue[] createMediaDescriptor(String[] propNames, Object[] values) {
+ PropertyValue[] props = new PropertyValue[propNames.length] ;
+
+ for (int i = 0; i < props.length; i++) {
+ props[i] = new PropertyValue() ;
+ props[i].Name = propNames[i] ;
+ if (values != null && i < values.length) {
+ props[i].Value = values[i] ;
+ }
+ }
+
+ return props ;
+ }
+
+ /**
+ * Gets the hanlder, which writes all the XML data passed to the
+ * file specified.
+ * @param xMSF Soffice <code>ServiceManager</code> factory.
+ * @param fileURL The file URL (in form file:///<path>) to which
+ * XML data is written.
+ * @return SAX handler to which XML data has to be written.
+ */
+ public static XDocumentHandler getFileXMLWriter(XMultiServiceFactory xMSF, String fileURL)
+ throws com.sun.star.uno.Exception
+ {
+ XInterface oFacc = (XInterface)xMSF.createInstance(
+ "com.sun.star.comp.ucb.SimpleFileAccess");
+ XSimpleFileAccess xFacc = (XSimpleFileAccess)UnoRuntime.queryInterface
+ (XSimpleFileAccess.class, oFacc) ;
+
+ XInterface oWriter = (XInterface)xMSF.createInstance(
+ "com.sun.star.xml.sax.Writer");
+ XActiveDataSource xWriterDS = (XActiveDataSource)
+ UnoRuntime.queryInterface(XActiveDataSource.class, oWriter);
+ XDocumentHandler xDocHandWriter = (XDocumentHandler) UnoRuntime.queryInterface
+ (XDocumentHandler.class, oWriter) ;
+
+ if (xFacc.exists(fileURL))
+ xFacc.kill(fileURL);
+ XOutputStream fOut = xFacc.openFileWrite(fileURL) ;
+ xWriterDS.setOutputStream(fOut);
+
+ return xDocHandWriter ;
+ }
+
+ /**
+ * Parses XML file and passes its data to the SAX handler specified.
+ * @param xMSF Soffice <code>ServiceManager</code> factory.
+ * @param fileURL XML file name (in form file:///<path>) to be parsed.
+ * @param handler SAX handler to which XML data from file will
+ * be transferred.
+ */
+ public static void parseXMLFile(XMultiServiceFactory xMSF,
+ String fileURL, XDocumentHandler handler) throws com.sun.star.uno.Exception
+ {
+ XInterface oFacc = (XInterface)xMSF.createInstance(
+ "com.sun.star.comp.ucb.SimpleFileAccess");
+ XSimpleFileAccess xFacc = (XSimpleFileAccess)UnoRuntime.queryInterface
+ (XSimpleFileAccess.class, oFacc) ;
+ XInputStream oIn = xFacc.openFileRead(fileURL) ;
+
+ XInterface oParser = (XInterface)xMSF.createInstance(
+ "com.sun.star.xml.sax.Parser");
+ XParser xParser = (XParser) UnoRuntime.queryInterface(XParser.class, oParser);
+
+ xParser.setDocumentHandler(handler) ;
+ InputSource inSrc = new InputSource() ;
+ inSrc.aInputStream = oIn ;
+ xParser.parseStream(inSrc) ;
+
+ oIn.closeInput();
+ }
+
+ /**
+ * Exports document (the whole or a part) into the file specified
+ * in XML format.
+ * @param xMSF Soffice <code>ServiceManager</code> factory.
+ * @param xDoc Document to be exported.
+ * @param docType Type of document (for example 'Calc', 'Writer', 'Draw')
+ * The type must start with <b>capital</b> letter.
+ * @param exportType The type of export specifies if the whole
+ * document will be exported or one of its parts (Meta info, Styles, etc.).
+ * The following types supported (it also depends of document type) :
+ * "" (empty string) - for the whole document ;
+ * "Content" - only content exported ;
+ * "Meta" - meta document info exported ;
+ * "Settings" - view settings of document exported ;
+ * "Styles" - document styles exported ;
+ * @param fileURL XML file name (in form file:///<path>) to be exported to.
+ */
+ public static void exportDocument(XMultiServiceFactory xMSF, XComponent xDoc,
+ String docType, String exportType, String fileURL)
+ throws com.sun.star.uno.Exception {
+
+ XDocumentHandler xDocHandWriter = XMLTools.getFileXMLWriter(xMSF, fileURL) ;
+
+ Any arg = new Any(new Type(XDocumentHandler.class), xDocHandWriter);
+ XInterface oExp = (XInterface)xMSF.createInstanceWithArguments(
+ "com.sun.star.comp." + docType + ".XML" + exportType + "Exporter",
+ new Object[] {arg});
+
+ XExporter xExp = (XExporter) UnoRuntime.queryInterface
+ (XExporter.class, oExp) ;
+ xExp.setSourceDocument(xDoc) ;
+
+ XFilter filter = (XFilter) UnoRuntime.queryInterface(XFilter.class, oExp) ;
+ filter.filter(XMLTools.createMediaDescriptor(
+ new String[] {"FilterName"},
+ new Object[] {"Custom filter"})) ;
+ }
+
+ /**
+ * Imports document (the whole or a part) from the file specified
+ * in XML format.
+ * @param xMSF Soffice <code>ServiceManager</code> factory.
+ * @param xDoc Target document to be imported.
+ * @param docType Type of document (for example 'Calc', 'Writer', 'Draw')
+ * The type must start with <b>capital</b> letter.
+ * @param exportType The type of export specifies if the whole
+ * document will be exported or one of its parts (Meta info, Styles, etc.).
+ * The following types supported (it hardly depends of XML data in file) :
+ * "" (empty string) - for the whole document ;
+ * "Content" - only content exported ;
+ * "Meta" - meta document info exported ;
+ * "Settings" - view settings of document exported ;
+ * "Styles" - document styles exported ;
+ * @param fileURL XML file name (in form file:///<path>) to be imported from.
+ */
+ public static void importDocument(XMultiServiceFactory xMSF, XComponent xDoc,
+ String docType, String importType, String fileURL)
+ throws com.sun.star.uno.Exception {
+
+ XInterface oImp = (XInterface)xMSF.createInstance(
+ "com.sun.star.comp." + docType + ".XML" + importType + "Importer");
+ XImporter xImp = (XImporter) UnoRuntime.queryInterface
+ (XImporter.class, oImp) ;
+ XDocumentHandler xDocHandImp = (XDocumentHandler) UnoRuntime.queryInterface
+ (XDocumentHandler.class, oImp) ;
+
+ xImp.setTargetDocument(xDoc) ;
+ parseXMLFile(xMSF, fileURL, xDocHandImp) ;
+ }
+} \ No newline at end of file
diff --git a/qadevOOo/runner/util/XSchemaHandlerImpl.java b/qadevOOo/runner/util/XSchemaHandlerImpl.java
new file mode 100644
index 000000000000..cac0754d9f20
--- /dev/null
+++ b/qadevOOo/runner/util/XSchemaHandlerImpl.java
@@ -0,0 +1,137 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package util;
+
+public class XSchemaHandlerImpl
+ implements com.sun.star.configuration.backend.XSchemaHandler {
+ protected String calls = "";
+ protected String ls = System.getProperty("line.separator");
+
+ public void addInstance(String str,
+ com.sun.star.configuration.backend.TemplateIdentifier templateIdentifier)
+ throws com.sun.star.configuration.backend.MalformedDataException,
+ com.sun.star.lang.WrappedTargetException {
+ calls += ("addInstance();" + ls);
+ }
+
+ public void addItemType(com.sun.star.configuration.backend.TemplateIdentifier templateIdentifier)
+ throws com.sun.star.configuration.backend.MalformedDataException,
+ com.sun.star.lang.WrappedTargetException {
+ calls += ("addItemType();" + ls);
+ }
+
+ public void addProperty(String str, short param,
+ com.sun.star.uno.Type type)
+ throws com.sun.star.configuration.backend.MalformedDataException,
+ com.sun.star.lang.WrappedTargetException {
+ calls += ("addProperty();" + ls);
+ }
+
+ public void addPropertyWithDefault(String str, short param, Object obj)
+ throws com.sun.star.configuration.backend.MalformedDataException,
+ com.sun.star.lang.WrappedTargetException {
+ calls += ("addPropertyWithDefault();" + ls);
+ }
+
+ public void endComponent()
+ throws com.sun.star.configuration.backend.MalformedDataException,
+ com.sun.star.lang.WrappedTargetException {
+ calls += ("endComponent();" + ls);
+ }
+
+ public void endNode()
+ throws com.sun.star.configuration.backend.MalformedDataException,
+ com.sun.star.lang.WrappedTargetException {
+ calls += ("endNode();" + ls);
+ }
+
+ public void endSchema()
+ throws com.sun.star.configuration.backend.MalformedDataException,
+ com.sun.star.lang.WrappedTargetException {
+ calls += ("endSchema();" + ls);
+ }
+
+ public void endTemplate()
+ throws com.sun.star.configuration.backend.MalformedDataException,
+ com.sun.star.lang.WrappedTargetException {
+ calls += ("endTemplate();" + ls);
+ }
+
+ public void importComponent(String str)
+ throws com.sun.star.configuration.backend.MalformedDataException,
+ com.sun.star.lang.WrappedTargetException {
+ calls += ("importComponent();" + ls);
+ }
+
+ public void startComponent(String str)
+ throws com.sun.star.configuration.backend.MalformedDataException,
+ com.sun.star.lang.WrappedTargetException {
+ calls += ("startComponent();" + ls);
+ }
+
+ public void startGroup(String str, short param)
+ throws com.sun.star.configuration.backend.MalformedDataException,
+ com.sun.star.lang.WrappedTargetException {
+ calls += ("startGroup();" + ls);
+ }
+
+ public void startGroupTemplate(com.sun.star.configuration.backend.TemplateIdentifier templateIdentifier,
+ short param)
+ throws com.sun.star.configuration.backend.MalformedDataException,
+ com.sun.star.lang.WrappedTargetException {
+ calls += ("startGroupTemplate();" + ls);
+ }
+
+ public void startSchema()
+ throws com.sun.star.configuration.backend.MalformedDataException,
+ com.sun.star.lang.WrappedTargetException {
+ calls += ("startSchema();" + ls);
+ }
+
+ public void startSet(String str, short param,
+ com.sun.star.configuration.backend.TemplateIdentifier templateIdentifier)
+ throws com.sun.star.configuration.backend.MalformedDataException,
+ com.sun.star.lang.WrappedTargetException {
+ calls += ("startSet();" + ls);
+ }
+
+ public void startSetTemplate(com.sun.star.configuration.backend.TemplateIdentifier templateIdentifier,
+ short param,
+ com.sun.star.configuration.backend.TemplateIdentifier templateIdentifier2)
+ throws com.sun.star.configuration.backend.MalformedDataException,
+ com.sun.star.lang.WrappedTargetException {
+ calls += ("startSetTemplate();" + ls);
+ }
+
+ public String getCalls() {
+ return calls;
+ }
+
+ public void cleanCalls() {
+ calls = "";
+ }
+} \ No newline at end of file
diff --git a/qadevOOo/runner/util/compare/DocComparator.java b/qadevOOo/runner/util/compare/DocComparator.java
new file mode 100644
index 000000000000..365850fa4839
--- /dev/null
+++ b/qadevOOo/runner/util/compare/DocComparator.java
@@ -0,0 +1,52 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package util.compare;
+
+import java.io.IOException;
+
+/**
+ *
+ *
+ */
+
+public interface DocComparator {
+
+ public boolean isReferenceExistent() throws IOException;
+
+ public void createReference() throws IOException;
+
+ public boolean compare() throws IOException;
+
+
+ public boolean isDiffReferenceExistent() throws IOException;
+
+ public void createDiffReference() throws IOException;
+
+ public boolean compareDiff() throws IOException;
+
+}
diff --git a/qadevOOo/runner/util/compare/DocComparatorFactory.java b/qadevOOo/runner/util/compare/DocComparatorFactory.java
new file mode 100644
index 000000000000..5f68606932c0
--- /dev/null
+++ b/qadevOOo/runner/util/compare/DocComparatorFactory.java
@@ -0,0 +1,64 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package util.compare;
+
+import lib.TestParameters;
+import util.compare.GraphicalComparator;
+
+public class DocComparatorFactory
+{
+ /**
+ * @param s is a name like 'ooo' 'pdf' or 'msoffice'
+ * @return a new DocComparator Object
+ */
+ static public DocComparator createComparator(String s, TestParameters aParams) throws IllegalArgumentException
+ {
+ if (s.toLowerCase().equals("gfx") || s.toLowerCase().equals("graphical"))
+ {
+ return GraphicalComparator.getInstance(aParams);
+ }
+/*
+ else if (s.toLowerCase().equals("xml"))
+ {
+ return new XMLCompare.create(aParams);
+ }
+*/
+ else if (s.toLowerCase().equals("pdf"))
+ {
+ // return new PDFComparator.create(aParams);
+ throw new IllegalArgumentException("PDF not implemented yet.");
+ }
+ else
+ {
+ throw new IllegalArgumentException("DocComparator for '" + s + "' not supported!");
+ }
+
+ // unreachable: return null;
+ }
+
+}
diff --git a/qadevOOo/runner/util/compare/GraphicalComparator.java b/qadevOOo/runner/util/compare/GraphicalComparator.java
new file mode 100644
index 000000000000..71109e984188
--- /dev/null
+++ b/qadevOOo/runner/util/compare/GraphicalComparator.java
@@ -0,0 +1,260 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package util.compare;
+
+import convwatch.GraphicalDifferenceCheck;
+import convwatch.GraphicalTestArguments;
+import convwatch.DirectoryHelper;
+import convwatch.FileHelper;
+
+import lib.TestParameters;
+import java.io.File;
+import java.io.FileFilter;
+import java.io.IOException;
+
+import util.compare.DocComparator;
+import convwatch.ConvWatchException;
+
+// -----------------------------------------------------------------------------
+class GraphicalComparator implements DocComparator
+{
+ GraphicalTestArguments m_aArguments;
+
+ protected GraphicalComparator(TestParameters aParams)
+ {
+ m_aArguments = new GraphicalTestArguments(aParams);
+ }
+
+ /**
+ * @return an instance of this object, but only it's interface
+ */
+ static DocComparator getInstance(TestParameters aParams)
+ {
+ // setting the default test parameter
+ // TEST aParams
+ GraphicalComparator a = new GraphicalComparator(aParams);
+ return a;
+ }
+
+ /**
+ * return a (FileFilter) function, which returns true, if the filename is a '*.prn' file
+ */
+ FileFilter getTrueIfPRNFile_FileFilter()
+ {
+ FileFilter aFileFilter = new FileFilter()
+ {
+ public boolean accept( File pathname )
+ {
+ if (pathname.getName().endsWith(".prn"))
+ {
+ return true;
+ }
+ return false;
+ }
+ };
+ return aFileFilter;
+ }
+
+ /**
+ * build a new file from _sEntry by
+ * replacing the path equals to _sInputPath with _sReferencePath and replace it's suffix by _sNewSuffix.
+ * If _sInputPath is empty, replace the whole path by _sReferencePath.
+ */
+ protected String createSpecialFile(String _sEntry, String _sInputPath, String _sReferencePath, String _sNewSuffix)
+ {
+ String fs = System.getProperty("file.separator");
+ String sNewSubDir = "";
+ if (_sInputPath.length() > 0)
+ {
+ sNewSubDir = FileHelper.removeFirstDirectorysAndBasenameFrom(_sEntry, _sInputPath);
+ }
+ String sNameNoSuffix = FileHelper.getNameNoSuffix(FileHelper.getBasename(_sEntry));
+
+ // add the sub path to the difference path
+ String sNewReferencePath;
+ if (sNewSubDir.length() > 0)
+ {
+ sNewReferencePath = _sReferencePath + fs + sNewSubDir;
+ }
+ else
+ {
+ sNewReferencePath = _sReferencePath;
+ }
+ // add the difference name
+ sNewReferencePath += fs + sNameNoSuffix + _sNewSuffix;
+ return sNewReferencePath;
+ }
+
+ boolean isReferenceOrDiffExistent(String _sNewSuffix)
+ {
+ boolean isExistent = false;
+
+ // LLA? What if sReferencePath is a directory, but directory is empty? is the result then true or false;
+
+ // wir muessen durch den InputPath durch und dann fuer jedes Dokument prufen, ob im angegebenen ReferencePath eine Reference existiert.
+ String sInputPath = m_aArguments.getInputPath();
+ if (FileHelper.isDir(sInputPath))
+ {
+ Object[] aList = DirectoryHelper.traverse(sInputPath, FileHelper.getFileFilter(), m_aArguments.includeSubDirectories());
+ for (int i=0;i<aList.length;i++)
+ {
+ // get document + path
+ String sEntry = (String)aList[i];
+ String sNewReferencePath = createSpecialFile(sEntry, sInputPath, m_aArguments.getReferencePath(), _sNewSuffix);
+ // split path from document path which only is equal to sInputPath (sub path)
+ if (FileHelper.exists(sNewReferencePath))
+ {
+ isExistent = true;
+ }
+ }
+ }
+ else
+ {
+ // sInputPath is a file
+ String sNewReferencePath = createSpecialFile(sInputPath, "", m_aArguments.getReferencePath(), _sNewSuffix);
+ if (FileHelper.exists(sNewReferencePath))
+ {
+ isExistent = true;
+ }
+ }
+ return isExistent;
+ }
+
+ /**
+ * REFERENCE_PATH must set to directory/file, where the reference (*.prn files) (should) exist
+ */
+ public boolean isReferenceExistent()
+ {
+ return isReferenceOrDiffExistent(".prn");
+ }
+
+ /**
+ * INPUT_PATH must set, to directory/file, where the documents exist.
+ * REFERENCE_PATH must set to directory/file, where the created references (*.prn files) will create.
+ */
+ public void createReference() throws IOException
+ {
+ // woher kommt das TestDocument
+ // INPUT_PATH
+ // wohin
+ // REFERENCE_PATH
+ // mit was (Reference Application)
+ // AppExecutionCmd
+ try
+ {
+ String referenceInputPath = null;
+ if(m_aArguments.getReferenceInputPath() == null)
+ {
+ GraphicalDifferenceCheck.createReferences(m_aArguments.getInputPath(), m_aArguments.getReferencePath(), m_aArguments);
+ }
+ else
+ {
+ referenceInputPath = m_aArguments.getReferenceInputPath();
+ GraphicalDifferenceCheck.createReferences(referenceInputPath, m_aArguments.getReferencePath(), m_aArguments);
+ }
+ }
+ catch (ConvWatchException e)
+ {
+ // wrap it to IOException
+ throw new java.io.IOException(e.getMessage());
+ }
+ }
+
+ /**
+ * INPUT_PATH must set, to directory/file, where the documents exist.
+ * REFERENCE_PATH must set to directory/file, where the created references (*.prn files) will create.
+ * OUTPUT_PATH must set to a directory, there the whole ouptut will create
+ */
+ public boolean compare() throws IOException
+ {
+ try
+ {
+ if (FileHelper.isDebugEnabled())
+ {
+ System.err.println(" Inputpath: '" + m_aArguments.getInputPath() + "'");
+ System.err.println(" Outputpath: '" + m_aArguments.getOutputPath() + "'");
+ System.err.println("Referencepath: '" + m_aArguments.getReferencePath() + "'");
+ }
+ return GraphicalDifferenceCheck.check(m_aArguments.getInputPath(), m_aArguments.getOutputPath(), m_aArguments.getReferencePath(), m_aArguments);
+ }
+ catch(ConvWatchException e)
+ {
+ // wrap it to IOException
+ if (FileHelper.isDebugEnabled())
+ {
+ System.err.println("Exception caught");
+ System.err.println(" Inputpath: '" + m_aArguments.getInputPath() + "'");
+ System.err.println(" Outputpath: '" + m_aArguments.getOutputPath() + "'");
+ System.err.println("Referencepath: '" + m_aArguments.getReferencePath() + "'");
+ }
+ throw new java.io.IOException(e.getMessage());
+ }
+ }
+
+ /**
+ *
+ * INPUT_PATH must set to the original documents the directory structure is taken to see if the references exist in the DIFF_PATH
+ * DIFF_PATH must set to the diff references
+ */
+ public boolean isDiffReferenceExistent() throws IOException
+ {
+ return isReferenceOrDiffExistent(".prn.diff0001.jpg");
+ }
+
+ /**
+ * INPUT_PATH must set, to directory/file, where the documents exist.
+ * REFERENCE_PATH must set to directory/file, where the created references (*.prn files) exists.
+ * OUTPUT_PATH must set to a directory, where the whole ouptut will create. Here the diffReference will create.
+ * At the momemt it's not possible to say only where the diffreferences will create.
+ */
+ public void createDiffReference() throws IOException
+ {
+ // this is the same like compareDiff(), but trash the result.
+ compareDiff();
+ }
+
+ /**
+ * INPUT_PATH must set, to directory/file, where the documents exist.
+ * REFERENCE_PATH must set to directory/file, where the created references (*.prn files) exists.
+ * OUTPUT_PATH must set to a directory, where the whole ouptut will create.
+ * DIFF_PATH must set to a directory, where the older difference references exist, it's possible to set this to the same as REFERENCE_PATH
+ * but this is not the default and will not automatically set.
+ */
+ public boolean compareDiff() throws IOException
+ {
+ try
+ {
+ return GraphicalDifferenceCheck.check(m_aArguments.getInputPath(), m_aArguments.getOutputPath(), m_aArguments.getReferencePath(), m_aArguments.getDiffPath(), m_aArguments);
+ }
+ catch(ConvWatchException e)
+ {
+ // wrap it to IOException
+ throw new java.io.IOException(e.getMessage());
+ }
+ }
+
+}
diff --git a/qadevOOo/runner/util/compare/PDFComparator.java b/qadevOOo/runner/util/compare/PDFComparator.java
new file mode 100644
index 000000000000..fb49b0db40dd
--- /dev/null
+++ b/qadevOOo/runner/util/compare/PDFComparator.java
@@ -0,0 +1,62 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package util.compare;
+
+import util.compare.DocComparator;
+import lib.TestParameters;
+import util.compare.GraphicalComparator;
+
+class PDFComparator extends GraphicalComparator implements DocComparator
+{
+ protected PDFComparator(TestParameters aParams)
+ {
+ super(aParams);
+ }
+
+ static DocComparator getInstance(TestParameters aParams)
+ {
+ aParams.put(convwatch.PropertyName.DOC_COMPARATOR_REFERENCE_TYPE, "pdf");
+ PDFComparator a = new PDFComparator(aParams);
+ return a;
+ }
+
+ // all in GraphicalComparator implemented.
+ // public boolean isReferenceExistent() throws IOException;
+ //
+ // public void createReference() throws IOException;
+ //
+ // public boolean compare() throws IOException;
+ //
+ //
+ // public boolean isDiffReferenceExistent() throws IOException;
+ //
+ // public void createDiffReference() throws IOException;
+ //
+ // public boolean compareDiff() throws IOException;
+}
+
diff --git a/qadevOOo/runner/util/compare/XMLComparator.java b/qadevOOo/runner/util/compare/XMLComparator.java
new file mode 100644
index 000000000000..470dbaa3ada1
--- /dev/null
+++ b/qadevOOo/runner/util/compare/XMLComparator.java
@@ -0,0 +1,58 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package util.compare;
+
+//import java.io.IOException;
+//import util.compare.DocComparator;
+//import lib.TestParameters;
+
+/**
+ * This Interface isn't ready yet.
+ *
+ */
+/*
+class XMLComparator implements DocComparator
+{
+ static DocComparator getInstance(TestParameters aParams)
+ {
+ return null;
+ }
+ public boolean isReferenceExistent() throws IOException;
+
+ public void createReference() throws IOException;
+
+ public boolean compare() throws IOException;
+
+
+ public boolean isDiffReferenceExistent() throws IOException;
+
+ public void createDiffReference() throws IOException;
+
+ public boolean compareDiff() throws IOException;
+}
+*/
diff --git a/qadevOOo/runner/util/compare/makefile.mk b/qadevOOo/runner/util/compare/makefile.mk
new file mode 100644
index 000000000000..2983e8aa581b
--- /dev/null
+++ b/qadevOOo/runner/util/compare/makefile.mk
@@ -0,0 +1,54 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+PRJ=..$/..$/..
+
+PRJNAME = OOoRunner
+PACKAGE = util.compare
+TARGET = runner_util_compare
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+# --- Files --------------------------------------------------------
+
+JARFILES = ridl.jar unoil.jar jurt.jar juh.jar java_uno.jar
+JAVAFILES = \
+ DocComparatorFactory.java \
+ DocComparator.java \
+ GraphicalComparator.java \
+ PDFComparator.java
+
+# doesn't implement yet.
+# PDFComparator.java \
+# XMLComparator.java
+
+JAVACLASSFILES= $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class)
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
diff --git a/qadevOOo/runner/util/db/DataSource.java b/qadevOOo/runner/util/db/DataSource.java
new file mode 100644
index 000000000000..60c613edd854
--- /dev/null
+++ b/qadevOOo/runner/util/db/DataSource.java
@@ -0,0 +1,163 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ */
+
+package util.db;
+
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.container.NoSuchElementException;
+import com.sun.star.frame.XModel;
+import com.sun.star.frame.XStorable;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.sdb.XDocumentDataSource;
+import com.sun.star.sdb.XOfficeDatabaseDocument;
+import com.sun.star.sdbc.XDataSource;
+import com.sun.star.uno.Exception;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XNamingService;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import lib.StatusException;
+
+/** wraps a com.sun.star.sdb.DataSource
+ *
+ * @author fs93730
+ */
+public class DataSource
+{
+ protected DataSource( XMultiServiceFactory _orb, DataSourceDescriptor _descriptor )
+ {
+ m_orb = _orb;
+ try
+ {
+ m_dataSource = (XDataSource)UnoRuntime.queryInterface( XDataSource.class,
+ m_orb.createInstance( "com.sun.star.sdb.DataSource" ) );
+ m_properties = (XPropertySet)UnoRuntime.queryInterface( XPropertySet.class,
+ m_dataSource );
+
+ Object[] descriptorProperties = new Object[] {
+ _descriptor.Name, _descriptor.URL, _descriptor.Info, _descriptor.User, _descriptor.Password,
+ _descriptor.IsPasswordRequired };
+ String[] propertyNames = new String[] {
+ "Name", "URL", "Info", "User", "Password", "IsPasswordRequired" };
+ for ( int i=0; i < descriptorProperties.length; ++i )
+ if ( descriptorProperties[i] != null )
+ m_properties.setPropertyValue( propertyNames[i], descriptorProperties[i] );
+ }
+ catch ( Exception e )
+ {
+ throw new StatusException( "could not create/fill a css.sdb.DataSource object", e );
+ }
+ }
+
+ public XDataSource getDataSource()
+ {
+ return m_dataSource;
+ }
+
+ /**
+ * retrieves the css.sdb.OfficeDatabaseDocument associated with the data source
+ * @return
+ */
+ public DatabaseDocument getDatabaseDocument()
+ {
+ synchronized ( this )
+ {
+ if ( m_document == null )
+ m_document = new DatabaseDocument( m_orb, this );
+ }
+ return m_document;
+ }
+
+ public void revokeRegistration()
+ {
+ String dataSourceName = "";
+ try
+ {
+ dataSourceName = (String)m_properties.getPropertyValue( "Name" );
+ XNamingService dbContext = (XNamingService)UnoRuntime.queryInterface( XNamingService.class,
+ m_orb.createInstance( "com.sun.star.sdb.DatabaseContext" ) );
+ dbContext.revokeObject( dataSourceName );
+ }
+ catch ( Exception e )
+ {
+ throw new StatusException( "DataSource.revokeRegistration: could not revoke the object (" + dataSourceName + ")", e );
+ }
+ }
+
+ public void registerAs( final String _registrationName, final boolean _revokeIfRegistered )
+ {
+ String doing = null;
+ try
+ {
+ doing = "creating database context";
+ XNamingService dbContext = UnoRuntime.queryInterface( XNamingService.class,
+ m_orb.createInstance( "com.sun.star.sdb.DatabaseContext" ) );
+
+ if ( _revokeIfRegistered )
+ {
+ doing = "revoking previously registered data source";
+ try
+ {
+ dbContext.revokeObject( _registrationName );
+ }
+ catch( NoSuchElementException e )
+ { /* allowed here */ }
+ }
+
+ // if the document associated with the database document has not yet been saved, then we need to do so
+ DatabaseDocument doc = getDatabaseDocument();
+ String docURL = doc.getURL();
+ if ( docURL.length() == 0 )
+ {
+ final java.io.File tempFile = java.io.File.createTempFile( _registrationName + "_", ".odb" );
+ if ( tempFile.exists() )
+ // we did not really want to create that file, we just wanted its local name, but
+ // createTempFile actually creates it => throw it away
+ // (This is necessary since some JVM/platform combinations seem to actually lock the file)
+ tempFile.delete();
+ String localPart = tempFile.toURI().toURL().toString();
+ localPart = localPart.substring( localPart.lastIndexOf( '/' ) + 1 );
+ docURL = util.utils.getOfficeTemp( m_orb ) + localPart;
+ doing = "storing database document to temporary location (" + docURL + ")";
+ doc.storeAsURL( docURL );
+ }
+
+ // register the data soource
+ doing = "registering the data source at the database context";
+ dbContext.registerObject( _registrationName, m_dataSource );
+ }
+ catch( final java.lang.Exception e )
+ {
+ throw new StatusException( "DataSource.registerAs: error during " + doing, e );
+ }
+ }
+
+ private XMultiServiceFactory m_orb = null;
+ private XDataSource m_dataSource = null;
+ private XPropertySet m_properties = null;
+ private DatabaseDocument m_document = null;
+}
diff --git a/qadevOOo/runner/util/db/DataSourceDescriptor.java b/qadevOOo/runner/util/db/DataSourceDescriptor.java
new file mode 100644
index 000000000000..9faeeb3f51e0
--- /dev/null
+++ b/qadevOOo/runner/util/db/DataSourceDescriptor.java
@@ -0,0 +1,74 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ */
+
+package util.db;
+
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.lang.XMultiServiceFactory;
+
+/** a descriptor for creating a com.sun.star.sdb.DataSource
+ *
+ * @author fs93730
+ */
+public class DataSourceDescriptor
+{
+ /**
+ * Representation of <code>'Name'</code> property.
+ */
+ public String Name = null ;
+ /**
+ * Representation of <code>'URL'</code> property.
+ */
+ public String URL = null ;
+ /**
+ * Representation of <code>'Info'</code> property.
+ */
+ public PropertyValue[] Info = null ;
+ /**
+ * Representation of <code>'User'</code> property.
+ */
+ public String User = null ;
+ /**
+ * Representation of <code>'Password'</code> property.
+ */
+ public String Password = null ;
+ /**
+ * Representation of <code>'IsPasswordRequired'</code> property.
+ */
+ public Boolean IsPasswordRequired = null ;
+
+ public DataSourceDescriptor( XMultiServiceFactory _orb )
+ {
+ m_orb = _orb;
+ }
+
+ public DataSource createDataSource()
+ {
+ return new DataSource( m_orb, this );
+ }
+
+ private XMultiServiceFactory m_orb = null;
+}
diff --git a/qadevOOo/runner/util/db/DatabaseDocument.java b/qadevOOo/runner/util/db/DatabaseDocument.java
new file mode 100644
index 000000000000..9022315fbfa4
--- /dev/null
+++ b/qadevOOo/runner/util/db/DatabaseDocument.java
@@ -0,0 +1,90 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ */
+
+package util.db;
+
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.frame.XModel;
+import com.sun.star.frame.XStorable;
+import com.sun.star.io.IOException;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.sdb.XDocumentDataSource;
+import com.sun.star.sdb.XOfficeDatabaseDocument;
+import com.sun.star.uno.UnoRuntime;
+
+/**
+ * encapsulates a css.sdb.DatabaseDocument
+ */
+public class DatabaseDocument
+{
+ protected DatabaseDocument( final XMultiServiceFactory _orb, final DataSource _dataSource )
+ {
+ m_orb = _orb;
+ m_dataSource = _dataSource;
+
+ XDocumentDataSource docDataSource = (XDocumentDataSource)UnoRuntime.queryInterface(
+ XDocumentDataSource.class, m_dataSource.getDataSource() );
+ m_databaseDocument = (XOfficeDatabaseDocument)UnoRuntime.queryInterface(XOfficeDatabaseDocument.class,
+ docDataSource.getDatabaseDocument() );
+
+ m_model = (XModel)UnoRuntime.queryInterface( XModel.class, m_databaseDocument );
+ m_storeDoc = (XStorable)UnoRuntime.queryInterface( XStorable.class, m_databaseDocument );
+ }
+
+ public DataSource getDataSource()
+ {
+ return m_dataSource;
+ }
+
+ public XOfficeDatabaseDocument getDatabaseDocument()
+ {
+ return m_databaseDocument;
+ }
+
+ /**
+ * passes through to XModel.getURL.
+ */
+ public String getURL()
+ {
+ return m_model.getURL();
+ }
+
+ /**
+ * simplified version (taking no arguments except the target URL) of XStorage.storeAsURL
+ * @param _url
+ * specifies the location to where to store the document
+ */
+ public void storeAsURL( final String _url ) throws IOException
+ {
+ m_storeDoc.storeAsURL( _url, new PropertyValue[] { } );
+ }
+
+ private XMultiServiceFactory m_orb;
+ private DataSource m_dataSource;
+ private XOfficeDatabaseDocument m_databaseDocument;
+ private XModel m_model;
+ private XStorable m_storeDoc;
+}
diff --git a/qadevOOo/runner/util/dbg.java b/qadevOOo/runner/util/dbg.java
new file mode 100644
index 000000000000..259500fe0c8f
--- /dev/null
+++ b/qadevOOo/runner/util/dbg.java
@@ -0,0 +1,347 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package util;
+
+import com.sun.star.uno.XInterface;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.Type;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.beans.XPropertySetInfo;
+import com.sun.star.beans.Property;
+import com.sun.star.beans.PropertyAttribute;
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.lang.XTypeProvider;
+import com.sun.star.lang.XServiceInfo;
+import java.io.PrintWriter;
+import java.lang.reflect.Method;
+
+/**
+ * This class accumulates all kinds of methods for accessing debug information
+ * from UNO implementations.
+ */
+public class dbg {
+
+ /**
+ * Prints information about the supported interfaces of an implementation
+ * to standard out.
+ * @param xTarget The implementation which should be analysed.
+ * @see com.sun.star.uno.XInterface
+ */
+ public static void printInterfaces(XInterface xTarget) {
+ printInterfaces(xTarget, false);
+ }
+
+ /**
+ * Prints information about the supported interfaces of an implementation
+ * to standard out. Extended information can be printed.
+ * @param xTarget The implementation which should be analysed.
+ * @param extendedInfo Should extended information be printed?
+ * @see com.sun.star.uno.XInterface
+ */
+ public static void printInterfaces(XInterface xTarget,
+ boolean extendedInfo){
+ Type[] types = getInterfaceTypes(xTarget);
+ if( null != types ) {
+ int nLen = types.length;
+ for( int i = 0; i < nLen ; i++ ) {
+ System.out.println(types[i].getTypeName());
+ if (extendedInfo) {
+ printInterfaceInfo(types[i]);
+ System.out.println();
+ }
+ }
+ }
+ }
+
+ /**
+ * Returns all interface types of an implementation as a type array.
+ * @param xTarget The implementation which should be analyzed.
+ * @return An array with all interface types; null if there are none.
+ * @see com.sun.star.uno.XInterface
+ */
+ public static Type[] getInterfaceTypes(XInterface xTarget) {
+ Type[] types = null;
+ XTypeProvider xTypeProvider = (XTypeProvider)
+ UnoRuntime.queryInterface( XTypeProvider.class, xTarget);
+ if( xTypeProvider != null )
+ types = xTypeProvider.getTypes();
+ return types;
+ }
+
+ /**
+ * Returns true if a specified target implements the interface with the
+ * given name. Note that the comparison is not case sensitive.
+ * @param xTarget The implementation which should be analysed.
+ * @param ifcName The name of the interface that is tested. The name can
+ * be full qualified, such as 'com.sun.star.io.XInputStream', or only
+ * consist of the interface name, such as 'XText'.
+ * @return True, if xTarget implements the interface named ifcType
+ * @see com.sun.star.uno.XInterface
+ */
+ public static boolean implementsInterface(
+ XInterface xTarget, String ifcName) {
+ Type[] types = getInterfaceTypes(xTarget);
+ if( null != types ) {
+ int nLen = types.length;
+ for( int i = 0; i < nLen ; i++ ) {
+ if(types[i].getTypeName().toLowerCase().endsWith(
+ ifcName.toLowerCase()))
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Prints information about an interface type.
+ *
+ * @param aType The type of the given interface.
+ * @see com.sun.star.uno.Type
+ */
+ public static void printInterfaceInfo(Type aType) {
+ try {
+ Class zClass = aType.getZClass();
+ Method[] methods = zClass.getDeclaredMethods();
+ for (int i=0; i<methods.length; i++) {
+ System.out.println("\t" + methods[i].getReturnType().getName()
+ + " " + methods[i].getName() + "()");
+ }
+ }
+ catch (Exception ex) {
+ System.out.println("Exception occured while printing InterfaceInfo");
+ ex.printStackTrace();
+ }
+ }
+
+ /**
+ * Prints a string array to standard out.
+ *
+ * @param entries : The array to be printed.
+ */
+ public static void printArray( String [] entries ) {
+ for ( int i=0; i< entries.length;i++ ) {
+ System.out.println(entries[i]);
+ }
+ }
+
+ /**
+ * Print all information about the property <code>name</code> from
+ * the property set <code>PS</code> to standard out.
+ * @param PS The property set which should contain a property called
+ * <code>name</code>.
+ * @param name The name of the property.
+ * @see com.sun.star.beans.XPropertySet
+ */
+ public static void printPropertyInfo(XPropertySet PS, String name) {
+ printPropertyInfo(PS, name, new PrintWriter(System.out)) ;
+ }
+
+ /**
+ * Print all information about the property <code>name</code> from
+ * the property set <code>PS</code> to a print writer.
+ * @param PS The property set which should contain a property called
+ * <code>name</code>.
+ * @param name The name of the property.
+ * @param out The print writer which is used as output.
+ * @see com.sun.star.beans.XPropertySet
+ */
+ public static void printPropertyInfo(XPropertySet PS, String name,
+ PrintWriter out) {
+ try {
+ XPropertySetInfo PSI = PS.getPropertySetInfo();
+ Property[] props = PSI.getProperties();
+ Property prop = PSI.getPropertyByName(name);
+ out.println("Property name is " + prop.Name);
+ out.println("Property handle is " + prop.Handle);
+ out.println("Property type is " + prop.Type.getTypeName());
+ out.println("Property current value is " +
+ PS.getPropertyValue(name));
+ out.println("Attributes :");
+ short attr = prop.Attributes;
+
+ if ((attr & PropertyAttribute.BOUND) != 0)
+ out.println("\t-BOUND");
+
+ if ((attr & PropertyAttribute.CONSTRAINED) != 0)
+ out.println("\t-CONSTRAINED");
+
+ if ((attr & PropertyAttribute.MAYBEAMBIGUOUS) != 0)
+ out.println("\t-MAYBEAMBIGUOUS");
+
+ if ((attr & PropertyAttribute.MAYBEDEFAULT) != 0)
+ out.println("\t-MAYBEDEFAULT");
+
+ if ((attr & PropertyAttribute.MAYBEVOID) != 0)
+ out.println("\t-MAYBEVOID");
+
+ if ((attr & PropertyAttribute.READONLY) != 0)
+ out.println("\t-READONLY");
+
+ if ((attr & PropertyAttribute.REMOVEABLE) != 0)
+ out.println("\t-REMOVEABLE");
+
+ if ((attr & PropertyAttribute.TRANSIENT) != 0)
+ out.println("\t-TRANSIENT");
+ } catch(com.sun.star.uno.Exception e) {
+ out.println("Exception!!!!");
+ e.printStackTrace(out);
+ }
+ }
+
+ /**
+ * Print the names and the values of a sequnze of <code>PropertyValue</code>
+ * to to standard out.
+ * @param ps The property which should displayed
+ * @see com.sun.star.beans.PropertyValue
+ */
+
+ public static void printProperyValueSequenzePairs(PropertyValue[] ps){
+ for( int i = 0; i < ps.length; i++){
+ printProperyValuePairs(ps[i], new PrintWriter(System.out));
+ }
+ }
+
+ /**
+ * Print the names and the values of a sequenze of <code>PropertyValue</code>
+ * to a print writer.
+ * @param ps The property which should displayed
+ * @param out The print writer which is used as output.
+ * @see com.sun.star.beans.PropertyValue
+ */
+ public static void printProperyValueSequenzePairs(PropertyValue[] ps, PrintWriter out){
+ for( int i = 0; i < ps.length; i++){
+ printProperyValuePairs(ps[i], out);
+ }
+ }
+
+ /**
+ * Print the name and the value of a <code>PropertyValue</code> to to standard out.
+ * @param ps The property which should displayed
+ * @see com.sun.star.beans.PropertyValue
+ */
+ public static void printProperyValuePairs(PropertyValue ps){
+ printProperyValuePairs(ps, new PrintWriter(System.out));
+ }
+
+ /**
+ * Print the name and the value of a <code>PropertyValue</code> to a print writer.
+ * @param ps The property which should displayed
+ * @param out The print writer which is used as output.
+ * @see com.sun.star.beans.PropertyValue
+ */
+ public static void printProperyValuePairs(PropertyValue ps, PrintWriter out){
+
+ if (ps.Value instanceof String[] ){
+ String[] values = (String[]) ps.Value;
+ String oneValue = "value is an empty String[]";
+ if (values.length > 0){
+ oneValue = "['";
+ for( int i=0; i < values.length; i++){
+ oneValue += values[i];
+ if (i+1 < values.length) oneValue += "';'";
+ }
+ oneValue += "']";
+ }
+ out.println("--------");
+ out.println(" Name: '" + ps.Name + "' contains String[]:");
+ out.println(oneValue);
+ out.println("--------");
+
+ } else if (ps.Value instanceof PropertyValue){
+ out.println("--------");
+ out.println(" Name: '" + ps.Name + "' contains PropertyValue:");
+ printProperyValuePairs((PropertyValue)ps.Value, out);
+ out.println("--------");
+
+ } else if (ps.Value instanceof PropertyValue[]){
+ out.println("--------");
+ out.println(" Name: '" + ps.Name + "' contains PropertyValue[]:");
+ printProperyValueSequenzePairs((PropertyValue[])ps.Value, out);
+ out.println("--------");
+
+ } else {
+ out.println("Name: '" + ps.Name + "' Value: '" + ps.Value.toString() + "'");
+ }
+ }
+
+ /**
+ * Print the names of all properties inside this property set
+ * @param ps The property set which is printed.
+ * @see com.sun.star.beans.XPropertySet
+ */
+ public static void printPropertiesNames(XPropertySet ps) {
+ XPropertySetInfo psi = ps.getPropertySetInfo();
+ Property[] props = psi.getProperties();
+ for (int i = 0; i < props.length; i++)
+ System.out.println(i + ". " + props[i].Name);
+ }
+
+ /**
+ * Print the supported services of a UNO object.
+ * @param aObject A UNO object.
+ */
+ public static void getSuppServices (Object aObject) {
+ XServiceInfo xSI = (XServiceInfo)
+ UnoRuntime.queryInterface(XServiceInfo.class,aObject);
+ printArray(xSI.getSupportedServiceNames());
+ String str="Therein not Supported Service";
+ boolean notSupportedServices = false;
+ for (int i=0;i<xSI.getSupportedServiceNames().length;i++) {
+ if (! xSI.supportsService(xSI.getSupportedServiceNames()[i])) {
+ notSupportedServices = true;
+ str+="\n" + xSI.getSupportedServiceNames()[i];
+ }
+ }
+ if (notSupportedServices)
+ System.out.println(str);
+ }
+
+ /**
+ * Get the unique implementation id of a UNO object.
+ * @param xTarget An implementation of a UNO object.
+ * @return The implementation id.
+ */
+ public static String getImplID( XInterface xTarget ) {
+ String str = "";
+ XTypeProvider xTypeProvider = (XTypeProvider)
+ UnoRuntime.queryInterface( XTypeProvider.class, xTarget);
+ if( xTypeProvider != null ) {
+ byte[] id = xTypeProvider.getImplementationId();
+ str = "ImplementationID: ";
+ for (int i=0; i<id.length;i++) {
+ Byte b = new Byte(id[i]);
+ str += b.intValue();
+ }
+ } else {
+ str = "No Implementation ID available";
+ }
+ return str;
+ }
+
+
+}
diff --git a/qadevOOo/runner/util/makefile.mk b/qadevOOo/runner/util/makefile.mk
new file mode 100644
index 000000000000..7b4d72385e24
--- /dev/null
+++ b/qadevOOo/runner/util/makefile.mk
@@ -0,0 +1,87 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..
+
+PRJNAME = OOoRunner
+PACKAGE = util
+TARGET = runner_util
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+# --- Files --------------------------------------------------------
+
+JARFILES = ridl.jar jurt.jar unoil.jar
+
+JAVAFILES = AccessibilityTools.java \
+ BasicMacroTools.java \
+ BookmarkDsc.java \
+ ControlDsc.java \
+ dbg.java \
+ DBTools.java \
+ DefaultDsc.java \
+ DesktopTools.java \
+ DrawTools.java \
+ DynamicClassLoader.java \
+ FootnoteDsc.java \
+ FormTools.java \
+ FrameDsc.java \
+ InstCreator.java \
+ InstDescr.java \
+ ParagraphDsc.java \
+ ReferenceMarkDsc.java \
+ RegistryTools.java \
+ ShapeDsc.java \
+ SOfficeFactory.java \
+ StyleFamilyDsc.java \
+ PropertyName.java \
+ SysUtils.java \
+ TableDsc.java \
+ TextSectionDsc.java \
+ XLayerImpl.java \
+ XLayerHandlerImpl.java \
+ XSchemaHandlerImpl.java \
+ UITools.java \
+ utils.java \
+ ValueChanger.java \
+ ValueComparer.java \
+ WaitUnreachable.java \
+ WriterTools.java \
+ XInstCreator.java \
+ XMLTools.java
+
+JAVACLASSFILES= $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class)
+
+# --- Targets ------------------------------------------------------
+
+
+.INCLUDE : target.mk
+
+TST:
+ @echo $(JAVACLASSFILES)
diff --git a/qadevOOo/runner/util/utils.java b/qadevOOo/runner/util/utils.java
new file mode 100644
index 000000000000..3f882f10fafb
--- /dev/null
+++ b/qadevOOo/runner/util/utils.java
@@ -0,0 +1,1020 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package util;
+
+import com.sun.star.frame.XController;
+import com.sun.star.frame.XDispatch;
+import com.sun.star.frame.XDispatchProvider;
+import com.sun.star.frame.XModel;
+import com.sun.star.lang.XComponent;
+import java.lang.System;
+import java.util.StringTokenizer;
+import java.io.*;
+import java.util.ArrayList;
+import java.io.RandomAccessFile;
+import java.net.Socket;
+import java.net.ServerSocket;
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.beans.Property;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.ucb.InteractiveAugmentedIOException;
+import com.sun.star.ucb.XSimpleFileAccess;
+import com.sun.star.lang.XServiceInfo;
+
+import com.sun.star.util.URL;
+import com.sun.star.util.XURLTransformer;
+
+import com.sun.star.uno.AnyConverter;
+import com.sun.star.uno.Type;
+import com.sun.star.uno.XComponentContext;
+import com.sun.star.util.XMacroExpander;
+import java.text.DecimalFormat;
+import java.util.Calendar;
+
+import java.util.Collections;
+import java.util.GregorianCalendar;
+
+public class utils {
+
+ /**
+ *
+ * This method adds the DOCPTH to a given file
+ *
+ * @param sDocName the file which should be completed to the test doc path
+ * @return $TESTDOCPATH/sDocName
+ */
+ public static String getFullTestDocName(String sDocName) {
+ String docpth = System.getProperty("DOCPTH");
+ if (docpth.endsWith("\\") || docpth.endsWith("/")) {
+ docpth = docpth.substring(0, docpth.length() - 1);
+ }
+
+ System.out.println("docpth:" + docpth);
+
+ String pthSep = System.getProperty("file.separator");
+
+ if (docpth.equals("unknown")) {
+ System.out.println("try to get tDoc from $SRC_ROOT/qadevOOo");
+ String srcRoot = System.getProperty(PropertyName.SRC_ROOT);
+ if (srcRoot != null) {
+ File srcR = new File(srcRoot);
+ String[] list = srcR.list(new FilenameFilter() {
+
+ public boolean accept(File dir, String name) {
+ return name.startsWith("qadevOOo");
+ }
+ });
+
+ if (list[0] != null) {
+ String tDoc = srcRoot.concat(pthSep).concat(list[0]).concat(pthSep).concat("testdocs");
+
+ if (new File(tDoc).exists()) {
+ docpth = tDoc;
+ }
+ }
+ }
+ }
+
+ if (docpth.startsWith("http:")) {
+ return docpth + "/" + sDocName;
+ }
+ String testdocPth = "";
+
+ if (docpth.equals("unknown")) {
+ System.out.println("try to get tDoc from OBJDSCS");
+ String objdscPth = System.getProperty("OBJDSCS");
+ if (objdscPth != null) {
+ int i = objdscPth.indexOf("objdsc");
+ String arcPth = objdscPth.substring(0, i - 1);
+ testdocPth = arcPth + pthSep + "doc" + pthSep + "java" +
+ pthSep + "testdocs" + pthSep + sDocName;
+ }
+ } else {
+ testdocPth = docpth + pthSep + sDocName;
+ }
+ return testdocPth;
+ }
+
+ /**
+ *
+ * This method adds the DOCPTH to a given file
+ * and changes the format to an file URL
+ *
+ */
+ public static String getFullTestURL(String sDocName) {
+ String fullDocPath = getFullTestDocName(sDocName);
+ if (fullDocPath.startsWith("http:")) {
+ return fullDocPath;
+ }
+ if (fullDocPath.startsWith("file:")) {
+ return fullDocPath;
+ }
+ String prefix = null;
+
+ // Windows: \\\\margritte\\qaapi\\workspace\\qadev\\testdocs/emptyChart.sds
+ if (fullDocPath.startsWith("\\\\")) {
+ prefix = "file:";
+ }
+
+ fullDocPath = fullDocPath.replace('\\', '/');
+ if (prefix == null) {
+ if (fullDocPath.startsWith("//")) {
+ prefix = "file:/";
+ } else if (fullDocPath.startsWith("/")) {
+ prefix = "file://";
+ } else {
+ prefix = "file:///";
+ }
+ }
+ if (!fullDocPath.endsWith("/")) {
+ File aFile = new File(fullDocPath);
+ if (aFile.isDirectory()) {
+ fullDocPath += "/";
+ }
+ }
+ String fulldocURL = prefix + fullDocPath;
+ return fulldocURL;
+ }
+
+ /**
+ *
+ * This method changes a given URL to a valid file URL
+ *
+ */
+ public static String getFullURL(String sDocName) {
+ String fullDocPath = sDocName;
+ fullDocPath = fullDocPath.replace('\\', '/');
+
+ if (fullDocPath.startsWith("http:")) {
+ return fullDocPath;
+ }
+ if (fullDocPath.startsWith("ftp:")) {
+ return fullDocPath;
+ }
+ String prefix = "";
+ if (!fullDocPath.startsWith("file:///")) {
+ if (fullDocPath.startsWith("//")) {
+ prefix = "file:";
+ } else {
+ if (fullDocPath.startsWith("/")) {
+ prefix = "file://";
+// if (helper.OSHelper.isLinuxIntel())
+// {
+// prefix = "file:/";
+// }
+ }
+ else
+ {
+ prefix = "file:///";
+ }
+ }
+ }
+ if (!fullDocPath.endsWith("/")) {
+ File aFile = new File(fullDocPath);
+ if (aFile.isDirectory()) {
+ fullDocPath += "/";
+ }
+ }
+ String fulldocURL = prefix + fullDocPath;
+
+ return fulldocURL;
+ }
+
+ /**
+ *
+ * This method creates folders needed
+ *
+ */
+ public static void make_Directories(String first, String path) {
+ String already_done = null;
+ String fs = System.getProperty("file.separator");
+ 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();
+ }
+ return;
+ }
+
+ /**
+ *
+ * This method get the version for a given TestBase/platform combination
+ *
+ */
+ public static String getVersion(String aFile, String aPlatform, String aTestbase) {
+ if ((aFile == null) || (aPlatform == null) || (aTestbase == null)) {
+ return "/";
+ }
+
+ File the_file = new File(aFile);
+ try {
+ RandomAccessFile raf = new RandomAccessFile(the_file, "r");
+ String res = "";
+ while (!res.equals("[" + aTestbase.toUpperCase() + "]")) {
+ res = raf.readLine();
+ }
+ res = "=/";
+ while ((!res.startsWith(aPlatform)) || (res.startsWith("["))) {
+ res = raf.readLine();
+ }
+ raf.close();
+ if (res.startsWith("[")) {
+ res = "/";
+ }
+ return res.substring(res.indexOf("=") + 1);
+
+ } catch (Exception e) {
+ System.out.println("Couldn't find version");
+ return "/";
+ }
+ }
+
+ /**
+ *
+ * This method get's the user dir of the connected office
+ *
+ */
+ public static String getOfficeUserPath(XMultiServiceFactory msf) {
+ String userPath = null;
+
+ // get a folder wich is located in the user dir
+ try {
+ userPath = (String) getOfficeSettingsValue(msf, "UserConfig");
+ } catch (Exception e) {
+ System.out.println("Couldn't get Office User Path");
+ e.printStackTrace();
+ }
+
+ // strip the returned folder to the user dir
+ if (userPath.charAt(userPath.length() - 1) == '/') {
+ userPath = userPath.substring(0, userPath.length() - 1);
+ }
+ int index = userPath.lastIndexOf('/');
+ if (index != -1) {
+ userPath = userPath.substring(0, index);
+ }
+
+ return userPath;
+ }
+
+ /**
+ * In the office there are some sttetings available. This function
+ * returns the value of the given setting name. For Example the setting name "Temp"
+ * "Temp" returns the temp folder of the office instance.
+ * @param msf a XMultiServiceFactory
+ * @param setting the name of the setting the value should be returned.
+ * For example "Temp" reutrns the temp folder of the current office instance.
+ * @see com.sun.star.util.PathSettings
+ * @return the value as String
+ */
+ public static String getOfficeSettingsValue(XMultiServiceFactory msf, String setting) {
+
+ String settingPath = null;
+ try {
+ Object settings = msf.createInstance("com.sun.star.comp.framework.PathSettings");
+ XPropertySet pthSettings = null;
+ try {
+ pthSettings = (XPropertySet) AnyConverter.toObject(
+ new Type(XPropertySet.class), settings);
+ } catch (com.sun.star.lang.IllegalArgumentException iae) {
+ System.out.println("### couldn't get Office Settings");
+ }
+ settingPath = (String) pthSettings.getPropertyValue(setting);
+
+ } catch (Exception e) {
+ System.out.println("Couldn't get stting value for " + setting);
+ e.printStackTrace();
+ }
+ return settingPath;
+ }
+
+ public static void setOfficeSettingsValue(XMultiServiceFactory msf, String setting, String value) {
+
+ String settingPath = null;
+ try {
+ Object settings = msf.createInstance("com.sun.star.comp.framework.PathSettings");
+ XPropertySet pthSettings = null;
+ try {
+ pthSettings = (XPropertySet) AnyConverter.toObject(
+ new Type(XPropertySet.class), settings);
+ } catch (com.sun.star.lang.IllegalArgumentException iae) {
+ System.out.println("### couldn't get Office Settings");
+ }
+ pthSettings.setPropertyValue(setting, value);
+
+ } catch (Exception e) {
+ System.out.println("Couldn't set '" + setting + "' to value '" + value + "'");
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * This method returns the temp dicrectory of the user.
+ * Since Java 1.4 it is not possible to read environment variables. To workaround
+ * this, the Java parameter -D could be used.
+ */
+ public static String getUsersTempDir() {
+ String tempDir = System.getProperty("my.temp");
+ if (tempDir == null) {
+ tempDir = System.getProperty("my.tmp");
+ if (tempDir == null) {
+ tempDir = System.getProperty("java.io.tmpdir");
+ }
+ }
+ // remove ending file separator
+ if (tempDir.endsWith(System.getProperty("file.separator"))) {
+ tempDir = tempDir.substring(0, tempDir.length() - 1);
+ }
+
+ return tempDir;
+ }
+
+ /**
+ *
+ * This method get's the temp dir of the connected office
+ *
+ */
+ public static String getOfficeTemp(XMultiServiceFactory msf) {
+ String url = getOfficeUserPath(msf) + "/test-temp/";
+ try {
+ new File(new URI(url)).mkdir();
+ } catch (URISyntaxException e) {
+ throw new RuntimeException(e);
+ }
+ return url;
+ }
+
+ /**
+ * Gets StarOffice temp directory without 'file:///' prefix.
+ * For example is usefull for Registry URL specifying.
+ * @msf Office factory for accessing its settings.
+ * @return SOffice temporary directory in form for example
+ * 'd:/Office60/user/temp/'.
+ */
+ public static String getOfficeTempDir(XMultiServiceFactory msf) {
+
+ String dir = getOfficeTemp(msf);
+
+ int idx = dir.indexOf("file:///");
+
+ if (idx < 0) {
+ return dir;
+ }
+
+ dir = dir.substring("file:///".length());
+
+ idx = dir.indexOf(":");
+
+ // is the last character a '/' or a '\'?
+ boolean lastCharSet = dir.endsWith("/") || dir.endsWith("\\");
+
+ if (idx < 0) { // linux or solaris
+ dir = "/" + dir;
+ dir += lastCharSet ? "" : "/";
+ } else { // windows
+ dir += lastCharSet ? "" : "\\";
+ }
+
+ return dir;
+ }
+
+ /**
+ * Gets StarOffice temp directory without 'file:///' prefix.
+ * and System dependend file separator
+ */
+ public static String getOfficeTempDirSys(XMultiServiceFactory msf) {
+
+ String dir = getOfficeTemp(msf);
+ String sysDir = "";
+
+ int idx = dir.indexOf("file://");
+
+ // remove leading 'file://'
+ if (idx < 0) {
+ sysDir = dir;
+ } else {
+ sysDir = dir.substring("file://".length());
+ }
+
+ // append '/' if not there (e.g. linux)
+ if (sysDir.charAt(sysDir.length() - 1) != '/') {
+ sysDir += "/";
+ }
+
+ // remove leading '/' and replace others with '\' on windows machines
+ if (sysDir.indexOf(":") != -1) {
+ sysDir = sysDir.substring(1);
+ sysDir = sysDir.replace('/', '\\');
+ }
+ return sysDir;
+ }
+
+ /**
+ * converts a fileURL to a system URL
+ * @param a file URL
+ * @return a system URL
+ */
+ public static String getSystemURL(String fileURL) {
+ String sysDir = "";
+
+ int idx = fileURL.indexOf("file://");
+
+ // remove leading 'file://'
+ if (idx < 0) {
+ sysDir = fileURL;
+ } else {
+ sysDir = fileURL.substring("file://".length());
+ }
+
+ // remove leading '/' and replace others with '\' on windows machines
+ if (sysDir.indexOf(":") != -1) {
+ sysDir = sysDir.substring(1);
+ sysDir = sysDir.replace('/', '\\');
+ }
+ return sysDir;
+ }
+
+ /**
+ * This method check via Office the existance of the given file URL
+ * @param msf the multiservice factory
+ * @param fileURL the file which existance should be checked
+ * @return true if the file exists, else false
+ */
+ public static boolean fileExists(XMultiServiceFactory msf, String fileURL) {
+ boolean exists = false;
+ try {
+
+ Object fileacc = msf.createInstance("com.sun.star.comp.ucb.SimpleFileAccess");
+ XSimpleFileAccess simpleAccess = (XSimpleFileAccess) UnoRuntime.queryInterface(XSimpleFileAccess.class,
+ fileacc);
+ if (simpleAccess.exists(fileURL)) {
+ exists = true;
+ }
+
+ } catch (Exception e) {
+ System.out.println("Couldn't access file '" + fileURL + "'");
+ e.printStackTrace();
+ exists = false;
+ }
+ return exists;
+ }
+
+ /**
+ * This method deletes via office the given file URL. It checks the existance
+ * of <CODE>fileURL</CODE>. If exists it will be deletet.
+ * @param msf the multiservice factory
+ * @param fileURL the file to delete
+ * @return true if the file could be deletet or the file does not exist
+ */
+ public static boolean deleteFile(XMultiServiceFactory xMsf, String fileURL) {
+ boolean delete = true;
+ try {
+
+ Object fileacc = xMsf.createInstance("com.sun.star.comp.ucb.SimpleFileAccess");
+ XSimpleFileAccess simpleAccess = (XSimpleFileAccess) UnoRuntime.queryInterface(XSimpleFileAccess.class,
+ fileacc);
+ if (simpleAccess.exists(fileURL)) {
+ simpleAccess.kill(fileURL);
+ }
+
+ } catch (Exception e) {
+ System.out.println("Couldn't delete file '" + fileURL + "'");
+ e.printStackTrace();
+ delete = false;
+ }
+ return delete;
+ }
+
+ /**
+ * This method copies via office a given file to a new one
+ * @param msf the multi service factory
+ * @param oldF the source file
+ * @param newF the destination file
+ * @return true at success
+ */
+ public static boolean copyFile(XMultiServiceFactory xMsf, String source, String destinaion) {
+ boolean res = false;
+ try {
+ Object fileacc = xMsf.createInstance("com.sun.star.comp.ucb.SimpleFileAccess");
+ XSimpleFileAccess simpleAccess = (XSimpleFileAccess) UnoRuntime.queryInterface(XSimpleFileAccess.class,
+ fileacc);
+ if (!simpleAccess.exists(destinaion)) {
+ simpleAccess.copy(source, destinaion);
+ }
+
+ res = true;
+ } catch (Exception e) {
+ System.out.println("Couldn't copy file '" + source + "' -> '" + destinaion + "'");
+ e.printStackTrace();
+ res = false;
+ }
+ return res;
+ }
+
+ private static void overwriteFile_impl(
+ XMultiServiceFactory xMsf, String oldF, String newF)
+ throws InteractiveAugmentedIOException
+ {
+ try {
+ Object fileacc = xMsf.createInstance("com.sun.star.comp.ucb.SimpleFileAccess");
+
+ XSimpleFileAccess simpleAccess = (XSimpleFileAccess) UnoRuntime.queryInterface(XSimpleFileAccess.class,
+ fileacc);
+ if (simpleAccess.exists(newF)) {
+ simpleAccess.kill(newF);
+ }
+ simpleAccess.copy(oldF, newF);
+ } catch (InteractiveAugmentedIOException e) {
+ throw e;
+ } catch (com.sun.star.uno.Exception e) {
+ System.out.println("Couldn't copy " + oldF + " to " + newF + ":");
+ e.printStackTrace();
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
+ * Copies file to a new location using OpenOffice.org features. If the target
+ * file already exists, the file is deleted.
+ *
+ * @returns <code>true</code> if the file was successfully copied,
+ * <code>false</code> if some errors occured (e.g. file is locked, used
+ * by another process).
+ */
+ public static boolean tryOverwriteFile(
+ XMultiServiceFactory xMsf, String oldF, String newF)
+ {
+ try {
+ overwriteFile_impl(xMsf, oldF, newF);
+ } catch (InteractiveAugmentedIOException e) {
+ return false;
+ }
+ return true;
+ }
+
+ public static void doOverwriteFile(
+ XMultiServiceFactory xMsf, String oldF, String newF)
+ {
+ try {
+ overwriteFile_impl(xMsf, oldF, newF);
+ } catch (InteractiveAugmentedIOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public static boolean hasPropertyByName(XPropertySet props, String aName) {
+ Property[] list = props.getPropertySetInfo().getProperties();
+ boolean res = false;
+ for (int i = 0; i < list.length; i++) {
+ String the_name = list[i].Name;
+ if (aName.equals(the_name)) {
+ res = true;
+ }
+ }
+ return res;
+ }
+
+ /**
+ *
+ * This method returns the implementation name of a given object
+ *
+ */
+ public static String getImplName(Object aObject) {
+ String res = "Error getting Implementation name";
+ try {
+ XServiceInfo xSI = (XServiceInfo) UnoRuntime.queryInterface(XServiceInfo.class, aObject);
+ res = xSI.getImplementationName();
+ } catch (Exception e) {
+ res = "Error getting Implementation name ( " + e + " )";
+ }
+
+ return res;
+ }
+
+ /**
+ *
+ * This method checks if an Object is void
+ *
+ */
+ public static boolean isVoid(Object aObject) {
+ if (aObject instanceof com.sun.star.uno.Any) {
+ com.sun.star.uno.Any oAny = (com.sun.star.uno.Any) aObject;
+ return (oAny.getType().getTypeName().equals("void"));
+ } else {
+ return false;
+ }
+
+ }
+
+ /**
+ *
+ * This method replaces a substring with another
+ *
+ */
+ public static String replacePart(String all, String toReplace, String replacement) {
+ return replaceAll13(all, toReplace, replacement);
+ }
+
+ /**
+ * Scan localhost for the next free port-number from a starting port
+ * on. If the starting port is smaller than 1024, port number starts with
+ * 10000 as default, because numbers < 1024 are never free on unix machines.
+ * @param startPort The port where scanning starts.
+ * @return The next free port.
+ */
+ public static int getNextFreePort(int startPort) {
+ if (startPort < 1024) {
+ startPort = 10000;
+ }
+ for (int port = startPort; port < 65536; port++) {
+ System.out.println("Scan port " + port);
+ try {
+ // first trying to establish a server-socket on localhost
+ // fails if there is already a server running
+ ServerSocket sSock = new ServerSocket(port);
+ sSock.close();
+ } catch (IOException e) {
+ System.out.println(" -> server: occupied port " + port);
+ continue;
+ }
+ try {
+ // now trying to establish a client-socket
+ // fails if there is no server on any connectable machine
+ Socket sock = new Socket("localhost", port);
+ System.out.println(" -> socket: occupied port: " + port);
+ } catch (IOException e) {
+ System.out.println(" -> free port");
+ return port;
+ }
+ }
+ return 65535;
+ }
+
+ public static URL parseURL(XMultiServiceFactory xMSF, String url) {
+ URL[] rUrl = new URL[1];
+ rUrl[0] = new URL();
+ rUrl[0].Complete = url;
+
+ XURLTransformer xTrans = null;
+ try {
+ Object inst = xMSF.createInstance("com.sun.star.util.URLTransformer");
+ xTrans = (XURLTransformer) UnoRuntime.queryInterface(XURLTransformer.class, inst);
+ } catch (com.sun.star.uno.Exception e) {
+ }
+
+ xTrans.parseStrict(rUrl);
+
+ return rUrl[0];
+ }
+
+ public static String getOfficeURL(XMultiServiceFactory msf) {
+ try {
+ Object settings = msf.createInstance("com.sun.star.util.PathSettings");
+ XPropertySet settingProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, settings);
+ String path = (String) settingProps.getPropertyValue("Module");
+ return path;
+ } catch (Exception e) {
+ System.out.println("Couldn't get Office Settings ");
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ /** returns the path to the office binary folder
+ *
+ * @param msf The XMultiSeriveFactory
+ * @return the path to the office binrary or an empty string on any error
+ */
+ public static String getOfficeBinPath(XMultiServiceFactory msf) {
+ String sysBinDir = "";
+ try {
+ sysBinDir = utils.getSystemURL(utils.expandMacro(msf, "$SYSBINDIR"));
+ } catch (java.lang.Exception e) {
+ }
+
+ return sysBinDir;
+ }
+
+ /**
+ * Get an array of all property names from the property set. With the include
+ * and exclude parameters the properties can be filtered. <br>
+ * Set excludePropertyAttribute = 0 and includePropertyAttribute = 0
+ * to include all and exclude none.
+ * @param props The instance of XPropertySet
+ * @param includePropertyAttribute Properties without these attributes are filtered and will not be returned.
+ * @param excludePropertyAttribute Properties with these attributes are filtered and will not be returned.
+ * @return A String array with all property names.
+ * @see com.sun.star.beans.XPropertySet
+ * @see com.sun.star.beans.Property
+ * @see com.sun.star.beans.PropertyAttribute
+ */
+ public static String[] getFilteredPropertyNames(XPropertySet props, short includePropertyAttribute,
+ short excludePropertyAttribute) {
+ Property[] the_props = props.getPropertySetInfo().getProperties();
+ ArrayList l = new ArrayList();
+ for (int i = 0; i < the_props.length; i++) {
+ boolean exclude = ((the_props[i].Attributes & excludePropertyAttribute) != 0);
+ boolean include = (includePropertyAttribute == 0) ||
+ ((the_props[i].Attributes & includePropertyAttribute) != 0);
+ if (include && !exclude) {
+ l.add(the_props[i].Name);
+ }
+ }
+ Collections.sort(l);
+ String[] names = new String[l.size()];
+ names = (String[]) l.toArray(names);
+ return names;
+ }
+
+ /** Causes the thread to sleep some time.
+ * It can be used f.e. like:
+ * util.utils.shortWait(tParam.getInt("ShortWait"));
+ */
+ public static void shortWait(int milliseconds) {
+ try {
+ Thread.currentThread().sleep(milliseconds);
+ } catch (InterruptedException e) {
+ System.out.println("While waiting :" + e);
+ }
+ }
+
+ /**
+ * Validate the AppExecutionCommand. Returned is an error message, starting
+ * with "Error:", or a warning, if the command might work.
+ * @param appExecCommand The application execution command that is checked.
+ * @param os The operating system where the check runs.
+ * @return The error message, or OK, if no error was detected.
+ */
+ public static String validateAppExecutionCommand(String appExecCommand, String os) {
+ String errorMessage = "OK";
+ appExecCommand = replaceAll13(appExecCommand, "\"", "");
+ appExecCommand = replaceAll13(appExecCommand, "'", "");
+ StringTokenizer commandTokens = new StringTokenizer(appExecCommand, " \t");
+ String officeExecutable = "";
+ String officeExecCommand = "soffice";
+ // is there a 'soffice' in the command? 2do: eliminate case sensitivity on windows
+ int index = -1;
+ while (commandTokens.hasMoreTokens() && index == -1) {
+ officeExecutable += commandTokens.nextToken() + " ";
+ index = officeExecutable.indexOf(officeExecCommand);
+ }
+ if (index == -1) {
+ errorMessage = "Error: Your 'AppExecutionCommand' parameter does not " +
+ "contain '" + officeExecCommand + "'.";
+ } else {
+ // does the directory exist?
+ officeExecutable = officeExecutable.trim();
+ String officePath = officeExecutable.substring(0, index);
+ File f = new File(officePath);
+ if (!f.exists() || !f.isDirectory()) {
+ errorMessage = "Error: Your 'AppExecutionCommand' parameter does not " +
+ "point to a valid system directory: " + officePath;
+ } else {
+ // is it an office installation?
+ f = new File(officeExecutable);
+ // one try for windows platform can't be wrong...
+ if (!f.exists() || !f.isFile()) {
+ f = new File(officeExecutable + ".exe");
+ }
+ if (!f.exists() || !f.isFile()) {
+ errorMessage = "Error: Your 'AppExecutionCommand' parameter does not " +
+ "point to a valid office installation.";
+ } else {
+ // do we have the accept parameter?
+ boolean gotNoAccept = true;
+ while (commandTokens.hasMoreElements()) {
+ String officeParam = commandTokens.nextToken();
+ if (officeParam.indexOf("-accept=") != -1) {
+ gotNoAccept = false;
+ errorMessage = validateConnectString(officeParam, true);
+ }
+ }
+ if (gotNoAccept) {
+ errorMessage = "Error: Your 'AppExecutionCommand' parameter does not " +
+ "contain a '-accept' parameter for connecting the office.";
+ }
+ }
+ }
+ }
+ return errorMessage;
+ }
+
+ /**
+ * Validate the connection string. Returned is an error message, starting
+ * with "Error:", or a warning, if the command might work.
+ * @param connectString The connection string that is checked.
+ * @param checkAppExecutionCommand If the AppExecutionCommand is checked, the error messages willbe different.
+ * @return The error message, or OK, if no error was detected.
+ */
+ public static String validateConnectString(String connectString, boolean checkAppExecutionCommand) {
+ String acceptPrefix = "";
+ if (checkAppExecutionCommand) {
+ acceptPrefix = "-accept=";
+ }
+
+ String errorMessage = "OK";
+ // a warning, if an unknown connection method is used
+ if (connectString.indexOf("socket") != -1) {
+ if (connectString.indexOf(acceptPrefix + "socket,host=") == -1 ||
+ connectString.indexOf("port=") == -1) {
+ if (checkAppExecutionCommand) {
+ errorMessage = "Error: The '-accept' parameter contains a syntax error: It should be like: '-accept=socket,host=localhost,port=8100;urp;";
+ } else {
+ errorMessage = "Error: The 'ConnectionString' parameter contains a syntax error: It should be like: 'socket,host=localhost,port=8100'";
+ }
+ }
+ } else if (connectString.indexOf("pipe") != -1) {
+ if (connectString.indexOf(acceptPrefix + "pipe,name=") == -1) {
+ if (checkAppExecutionCommand) {
+ errorMessage = "Error: The '-accept' parameter contains a syntax error: It should be like: '-accept=pipe,name=myuniquename;urp;'";
+ } else {
+ errorMessage = "Error: The 'ConnectionString' parameter contains a syntax error: It should be like: 'pipe,name=myuniquename'";
+ }
+ }
+ } else {
+ if (checkAppExecutionCommand) {
+ errorMessage = "Warning: The '-accept' parameter contains an unknown connection method.";
+ } else {
+ errorMessage = "Warning: The 'ConnectionString' parameter contains an unknown connection method.";
+ }
+ }
+ return errorMessage;
+ }
+
+ /**
+ * String.replaceAll() ist available since Java 1.4 but the runner must be buldabale with Java 1.3
+ * @param originalString
+ * @param searchString
+ * @param replaceString
+ * @return modified string
+ */
+ public static String replaceAll13(String originalString, String searchString, String replaceString) {
+
+ StringBuffer changeStringBuffer = new StringBuffer(originalString);
+ int searchLength = searchString.length();
+ int replaceLength = replaceString.length();
+ int index = originalString.indexOf(searchString);
+ while (index != -1) {
+ changeStringBuffer = changeStringBuffer.replace(index, index + searchLength, replaceString);
+ originalString = changeStringBuffer.toString();
+ index = originalString.indexOf(searchString, index + replaceLength);
+ }
+ return originalString;
+ }
+
+ /**
+ * expand macrofied strings like <CODE>${$ORIGIN/bootstrap.ini:UserInstallation}</CODE> or
+ * <CODE>$_OS</CODE>
+ * @param xMSF the MultiServiceFactory
+ * @param expand the string to expand
+ * @throws java.lang.Exception was thrown on any exception
+ * @return return the expanded string
+ * @see com.sun.star.util.theMacroExpander
+ */
+ public static String expandMacro(XMultiServiceFactory xMSF, String expand) throws java.lang.Exception {
+ try {
+ XPropertySet xPS = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xMSF);
+ XComponentContext xContext = (XComponentContext) UnoRuntime.queryInterface(XComponentContext.class,
+ xPS.getPropertyValue("DefaultContext"));
+ XMacroExpander xME = (XMacroExpander) UnoRuntime.queryInterface(XMacroExpander.class,
+ xContext.getValueByName("/singletons/com.sun.star.util.theMacroExpander"));
+ return xME.expandMacros(expand);
+ } catch (Exception e) {
+ throw new Exception("could not expand macro: " + e.toString(), e);
+ }
+
+ }
+
+ /**
+ * returns the platform of the office.<br>
+ * Since the runner and the office could run on different platform this function delivers the
+ * platform the office is running.
+ * @param xMSF the XMultiServiceFactory
+ * @return unxsols, unxsoli, unxlngi, wntmsci
+ */
+ public static String getOfficeOS(XMultiServiceFactory xMSF) {
+ String platform = "unknown";
+
+ try {
+ String theOS = expandMacro(xMSF, "$_OS");
+
+ if (theOS.equals("Windows")) {
+ platform = "wntmsci";
+ } else if (theOS.equals("Linux")) {
+ platform = "unxlngi";
+ } else {
+ if (theOS.equals("Solaris")) {
+ String theArch = expandMacro(xMSF, "$_ARCH");
+ if (theArch.equals("SPARC")) {
+ platform = "unxsols";
+ } else if (theArch.equals("x86")) {
+ platform = "unxsoli";
+ }
+ }
+ }
+ } catch (Exception ex) {
+ }
+ return platform;
+ }
+
+ /**
+ * dispatches given <CODE>URL</CODE> to the document <CODE>XComponent</CODE>
+ * @param xMSF the <CODE>XMultiServiceFactory</CODE>
+ * @param xDoc the document where to dispatch
+ * @param URL the <CODE>URL</CODE> to dispatch
+ * @throws java.lang.Exception throws <CODE>java.lang.Exception</CODE> on any error
+ */
+ public static void dispatchURL(XMultiServiceFactory xMSF, XComponent xDoc, String URL) throws java.lang.Exception {
+ XModel aModel = (XModel) UnoRuntime.queryInterface(XModel.class, xDoc);
+
+ XController xCont = aModel.getCurrentController();
+
+ dispatchURL(xMSF, xCont, URL);
+
+ }
+
+ /**
+ * dispatches given <CODE>URL</CODE> to the <CODE>XController</CODE>
+ * @param xMSF the <CODE>XMultiServiceFactory</CODE>
+ * @param xComp the <CODE>XController</CODE> to query for a XDispatchProvider
+ * @param URL the <CODE>URL</CODE> to dispatch
+ * @throws java.lang.Exception throws <CODE>java.lang.Exception</CODE> on any error
+ */
+ public static void dispatchURL(XMultiServiceFactory xMSF, XController xCont, String URL) throws java.lang.Exception {
+ try {
+
+ XDispatchProvider xDispProv = (XDispatchProvider) UnoRuntime.queryInterface(XDispatchProvider.class, xCont);
+
+ XURLTransformer xParser = (com.sun.star.util.XURLTransformer) UnoRuntime.queryInterface(
+ XURLTransformer.class,
+ xMSF.createInstance("com.sun.star.util.URLTransformer"));
+
+ // Because it's an in/out parameter we must use an array of URL objects.
+ URL[] aParseURL = new URL[1];
+ aParseURL[0] = new URL();
+ aParseURL[0].Complete = URL;
+ xParser.parseStrict(aParseURL);
+
+ URL aURL = aParseURL[0];
+
+ XDispatch xDispatcher = xDispProv.queryDispatch(aURL, "", 0);
+ xDispatcher.dispatch(aURL, null);
+
+ utils.shortWait(3000);
+
+ } catch (Exception e) {
+ throw new Exception("ERROR: could not dispatch URL '" + URL + "': " + e.toString());
+ }
+ }
+
+ /** returns a String which contains the current date and time<br>
+ * format: [DD.MM.YYYY - HH:MM:SS::mm]
+ *
+ ** @return a String which contains the current date and time
+ */
+ public static String getDateTime() {
+
+ Calendar cal = new GregorianCalendar();
+ DecimalFormat dfmt = new DecimalFormat("00");
+ String dateTime = dfmt.format(cal.get(Calendar.DAY_OF_MONTH)) + "." +
+ dfmt.format(cal.get(Calendar.MONTH) + 1) + "." +
+ dfmt.format(cal.get(Calendar.YEAR)) + " - " +
+ dfmt.format(cal.get(Calendar.HOUR_OF_DAY)) + ":" +
+ dfmt.format(cal.get(Calendar.MINUTE)) + ":" +
+ dfmt.format(cal.get(Calendar.SECOND)) + "," +
+ dfmt.format(cal.get(Calendar.MILLISECOND));
+ return "[" + dateTime + "]";
+ }
+}