summaryrefslogtreecommitdiff
path: root/framework/qa/complex
diff options
context:
space:
mode:
Diffstat (limited to 'framework/qa/complex')
-rw-r--r--framework/qa/complex/ModuleManager/CheckXModuleManager.java321
-rw-r--r--framework/qa/complex/ModuleManager/makefile.mk83
-rw-r--r--framework/qa/complex/XUserInputInterception/EventTest.java594
-rw-r--r--framework/qa/complex/XUserInputInterception/makefile.mk89
-rw-r--r--framework/qa/complex/accelerators/AcceleratorsConfigurationTest.java686
-rw-r--r--framework/qa/complex/accelerators/helper/KeyMapping.java168
-rw-r--r--framework/qa/complex/accelerators/helper/makefile.mk46
-rw-r--r--framework/qa/complex/accelerators/makefile.mk86
-rwxr-xr-xframework/qa/complex/api_internal/CheckAPI.java200
-rwxr-xr-xframework/qa/complex/api_internal/CheckAPI.props4
-rwxr-xr-xframework/qa/complex/api_internal/api.lst325
-rwxr-xr-xframework/qa/complex/api_internal/makefile.mk88
-rwxr-xr-xframework/qa/complex/api_internal/tests.sce3
-rwxr-xr-xframework/qa/complex/api_internal/worksforme.sce39
-rwxr-xr-xframework/qa/complex/broken_document/LoadDocument.java103
-rwxr-xr-xframework/qa/complex/broken_document/dbf.dbf.emf1
-rwxr-xr-xframework/qa/complex/broken_document/makefile.mk80
-rw-r--r--framework/qa/complex/contextMenuInterceptor/CheckContextMenuInterceptor.java287
-rw-r--r--framework/qa/complex/contextMenuInterceptor/ContextMenuInterceptor.java130
-rw-r--r--framework/qa/complex/contextMenuInterceptor/makefile.mk77
-rwxr-xr-xframework/qa/complex/desktop/DesktopTerminate.java158
-rwxr-xr-xframework/qa/complex/desktop/makefile.mk79
-rw-r--r--framework/qa/complex/dispatches/checkdispatchapi.java462
-rw-r--r--framework/qa/complex/dispatches/helper/Interceptor.java348
-rw-r--r--framework/qa/complex/dispatches/helper/makefile.mk48
-rw-r--r--framework/qa/complex/dispatches/makefile.mk92
-rwxr-xr-xframework/qa/complex/disposing/GetServiceWhileDisposingOffice.java74
-rwxr-xr-xframework/qa/complex/disposing/makefile.mk76
-rw-r--r--framework/qa/complex/framework/autosave/AutoSave.java454
-rw-r--r--framework/qa/complex/framework/autosave/ConfigHelper.java124
-rw-r--r--framework/qa/complex/framework/autosave/Protocol.java999
-rw-r--r--framework/qa/complex/framework/autosave/makefile.mk89
-rw-r--r--framework/qa/complex/framework/recovery/CrashThread.java80
-rw-r--r--framework/qa/complex/framework/recovery/KlickButtonThread.java57
-rw-r--r--framework/qa/complex/framework/recovery/RecoveryTest.java1012
-rw-r--r--framework/qa/complex/framework/recovery/RecoveryTools.java366
-rw-r--r--framework/qa/complex/framework/recovery/TimeoutThread.java41
-rwxr-xr-xframework/qa/complex/framework/recovery/makefile.mk103
-rwxr-xr-xframework/qa/complex/imageManager/CheckImageManager.java197
-rwxr-xr-xframework/qa/complex/imageManager/interfaces/_XComponent.java179
-rwxr-xr-xframework/qa/complex/imageManager/interfaces/_XImageManager.java114
-rwxr-xr-xframework/qa/complex/imageManager/interfaces/_XInitialization.java95
-rwxr-xr-xframework/qa/complex/imageManager/interfaces/_XTypeProvider.java103
-rwxr-xr-xframework/qa/complex/imageManager/interfaces/_XUIConfiguration.java85
-rwxr-xr-xframework/qa/complex/imageManager/interfaces/_XUIConfigurationPersistence.java96
-rwxr-xr-xframework/qa/complex/imageManager/interfaces/makefile.mk57
-rwxr-xr-xframework/qa/complex/imageManager/makefile.mk79
-rw-r--r--framework/qa/complex/loadAllDocuments/CheckXComponentLoader.java733
-rw-r--r--framework/qa/complex/loadAllDocuments/CheckXComponentLoader.props3
-rw-r--r--framework/qa/complex/loadAllDocuments/helper/InteractionHandler.java155
-rw-r--r--framework/qa/complex/loadAllDocuments/helper/StatusIndicator.java237
-rw-r--r--framework/qa/complex/loadAllDocuments/helper/StreamSimulator.java474
-rw-r--r--framework/qa/complex/loadAllDocuments/helper/makefile.mk48
-rw-r--r--framework/qa/complex/loadAllDocuments/makefile.mk91
-rw-r--r--framework/qa/complex/loadAllDocuments/password_check.sxwbin0 -> 5128 bytes
-rw-r--r--framework/qa/complex/loadAllDocuments/testdocuments/Calc_6.sxcbin0 -> 9547 bytes
-rw-r--r--framework/qa/complex/loadAllDocuments/testdocuments/Writer6.sxwbin0 -> 5754 bytes
-rw-r--r--framework/qa/complex/loadAllDocuments/testdocuments/draw1.sxdbin0 -> 11821 bytes
-rw-r--r--framework/qa/complex/loadAllDocuments/testdocuments/imp1.sxibin0 -> 35135 bytes
-rw-r--r--framework/qa/complex/loadAllDocuments/testdocuments/pic.gifbin0 -> 1433 bytes
-rw-r--r--framework/qa/complex/loadAllDocuments/testdocuments/pic.jpgbin0 -> 2651 bytes
-rwxr-xr-xframework/qa/complex/path_settings/PathSettingsTest.java458
-rwxr-xr-xframework/qa/complex/path_settings/makefile.mk84
-rwxr-xr-xframework/qa/complex/path_substitution/PathSubstitutionTest.java246
-rwxr-xr-xframework/qa/complex/path_substitution/makefile.mk83
-rwxr-xr-xframework/qa/complex/sequence/CheckSequenceOfEnum.java95
-rwxr-xr-xframework/qa/complex/sequence/makefile.mk98
67 files changed, 11882 insertions, 0 deletions
diff --git a/framework/qa/complex/ModuleManager/CheckXModuleManager.java b/framework/qa/complex/ModuleManager/CheckXModuleManager.java
new file mode 100644
index 000000000000..ba0c9e318980
--- /dev/null
+++ b/framework/qa/complex/ModuleManager/CheckXModuleManager.java
@@ -0,0 +1,321 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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 complex.ModuleManager;
+
+import com.sun.star.beans.*;
+import com.sun.star.frame.*;
+import com.sun.star.lang.*;
+import com.sun.star.uno.*;
+import com.sun.star.util.*;
+import com.sun.star.container.*;
+
+import complexlib.ComplexTestCase;
+
+import helper.URLHelper;
+
+import java.lang.*;
+import java.util.*;
+
+//-----------------------------------------------
+/** @short todo document me
+ */
+public class CheckXModuleManager extends ComplexTestCase
+{
+ //-------------------------------------------
+ // some const
+
+ //-------------------------------------------
+ // member
+
+ /** points to the global uno service manager. */
+ private XMultiServiceFactory m_xSmgr = null;
+
+ /** the module manager for testing. */
+ private XModuleManager m_xMM = null;
+
+ /** a special frame used to load documents there. */
+ private XComponentLoader m_xLoader = null;
+
+ //-------------------------------------------
+ // test environment
+
+ //-------------------------------------------
+ /** @short A function to tell the framework,
+ which test functions are available.
+
+ @return All test methods.
+ @todo Think about selection of tests from outside ...
+ */
+ public String[] getTestMethodNames()
+ {
+ return new String[]
+ {
+ "checkModuleIdentification" ,
+ "checkModuleConfigurationReadable" ,
+ "checkModuleConfigurationWriteable",
+ "checkModuleConfigurationQueries"
+ };
+ }
+
+ //-------------------------------------------
+ /** @short Create the environment for following tests.
+
+ @descr Use either a component loader from desktop or
+ from frame
+ */
+ public void before()
+ throws java.lang.Exception
+ {
+ // get uno service manager from global test environment
+ m_xSmgr = (XMultiServiceFactory)param.getMSF();
+
+ // create module manager
+ m_xMM = (XModuleManager)UnoRuntime.queryInterface(
+ XModuleManager.class,
+ m_xSmgr.createInstance("com.sun.star.frame.ModuleManager"));
+
+ // create desktop instance to create a special frame to load documents there.
+ XFrame xDesktop = (XFrame)UnoRuntime.queryInterface(
+ XFrame.class,
+ m_xSmgr.createInstance("com.sun.star.frame.Desktop"));
+
+ m_xLoader = (XComponentLoader)UnoRuntime.queryInterface(
+ XComponentLoader.class,
+ xDesktop.findFrame("_blank", 0));
+ }
+
+ //-------------------------------------------
+ /** @short close the environment.
+ */
+ public void after()
+ throws java.lang.Exception
+ {
+ XCloseable xClose = (XCloseable)UnoRuntime.queryInterface(
+ XCloseable.class,
+ m_xLoader);
+ xClose.close(false);
+
+ m_xLoader = null;
+ m_xMM = null;
+ m_xSmgr = null;
+ }
+
+ //-------------------------------------------
+ /** @todo document me
+ */
+ public void checkModuleIdentification()
+ throws java.lang.Exception
+ {
+ impl_identifyModulesBasedOnDocs("com.sun.star.text.TextDocument" );
+ impl_identifyModulesBasedOnDocs("com.sun.star.text.WebDocument" );
+ impl_identifyModulesBasedOnDocs("com.sun.star.text.GlobalDocument" );
+ impl_identifyModulesBasedOnDocs("com.sun.star.formula.FormulaProperties" );
+ impl_identifyModulesBasedOnDocs("com.sun.star.sheet.SpreadsheetDocument" );
+ impl_identifyModulesBasedOnDocs("com.sun.star.drawing.DrawingDocument" );
+ impl_identifyModulesBasedOnDocs("com.sun.star.presentation.PresentationDocument");
+ impl_identifyModulesBasedOnDocs("com.sun.star.sdb.OfficeDatabaseDocument" );
+ impl_identifyModulesBasedOnDocs("com.sun.star.chart.ChartDocument" );
+ }
+
+ //-------------------------------------------
+ /** @todo document me
+ */
+ public void checkModuleConfigurationReadable()
+ throws java.lang.Exception
+ {
+ }
+
+ //-------------------------------------------
+ /** @todo document me
+ */
+ public void checkModuleConfigurationWriteable()
+ throws java.lang.Exception
+ {
+ // modules supporting real documents
+ impl_checkReadOnlyPropsOfModule("com.sun.star.text.TextDocument" );
+ impl_checkReadOnlyPropsOfModule("com.sun.star.text.WebDocument" );
+ impl_checkReadOnlyPropsOfModule("com.sun.star.text.GlobalDocument" );
+ impl_checkReadOnlyPropsOfModule("com.sun.star.formula.FormulaProperties" );
+ impl_checkReadOnlyPropsOfModule("com.sun.star.sheet.SpreadsheetDocument" );
+ impl_checkReadOnlyPropsOfModule("com.sun.star.drawing.DrawingDocument" );
+ impl_checkReadOnlyPropsOfModule("com.sun.star.presentation.PresentationDocument");
+ impl_checkReadOnlyPropsOfModule("com.sun.star.sdb.OfficeDatabaseDocument" );
+ impl_checkReadOnlyPropsOfModule("com.sun.star.chart.ChartDocument" );
+
+ // other modules
+ impl_checkReadOnlyPropsOfModule("com.sun.star.sdb.FormDesign" );
+ impl_checkReadOnlyPropsOfModule("com.sun.star.sdb.TextReportDesign" );
+ impl_checkReadOnlyPropsOfModule("com.sun.star.sdb.RelationDesign" );
+ impl_checkReadOnlyPropsOfModule("com.sun.star.sdb.QueryDesign" );
+ impl_checkReadOnlyPropsOfModule("com.sun.star.sdb.TableDesign" );
+ impl_checkReadOnlyPropsOfModule("com.sun.star.sdb.DataSourceBrowser");
+ impl_checkReadOnlyPropsOfModule("com.sun.star.frame.Bibliography" );
+ impl_checkReadOnlyPropsOfModule("com.sun.star.script.BasicIDE" );
+ impl_checkReadOnlyPropsOfModule("com.sun.star.frame.StartModule" );
+ }
+
+ //-------------------------------------------
+ /** @todo document me
+ */
+ public void checkModuleConfigurationQueries()
+ throws java.lang.Exception
+ {
+ impl_searchModulesByDocumentService("com.sun.star.text.TextDocument" );
+ impl_searchModulesByDocumentService("com.sun.star.text.WebDocument" );
+ impl_searchModulesByDocumentService("com.sun.star.text.GlobalDocument" );
+ impl_searchModulesByDocumentService("com.sun.star.formula.FormulaProperties" );
+ impl_searchModulesByDocumentService("com.sun.star.sheet.SpreadsheetDocument" );
+ impl_searchModulesByDocumentService("com.sun.star.drawing.DrawingDocument" );
+ impl_searchModulesByDocumentService("com.sun.star.presentation.PresentationDocument");
+ impl_searchModulesByDocumentService("com.sun.star.sdb.OfficeDatabaseDocument" );
+ impl_searchModulesByDocumentService("com.sun.star.chart.ChartDocument" );
+ }
+
+ //-------------------------------------------
+ /** @todo document me
+ */
+ private void impl_searchModulesByDocumentService(String sDocumentService)
+ throws java.lang.Exception
+ {
+ log.println("search modules matching document service '"+sDocumentService+"' ...");
+
+ NamedValue[] lProps = new NamedValue[1];
+ lProps[0] = new NamedValue();
+ lProps[0].Name = "ooSetupFactoryDocumentService";
+ lProps[0].Value = sDocumentService;
+
+ XContainerQuery xMM = (XContainerQuery)UnoRuntime.queryInterface(XContainerQuery.class, m_xMM);
+ XEnumeration xResult = xMM.createSubSetEnumerationByProperties(lProps);
+ while(xResult.hasMoreElements())
+ {
+ PropertyValue[] lModuleProps = (PropertyValue[])AnyConverter.toArray(xResult.nextElement());
+ int c = lModuleProps.length;
+ int i = 0;
+ String sFoundModule = "";
+ String sFoundDocService = "";
+ for (i=0; i<c; ++i)
+ {
+ if (lModuleProps[i].Name.equals("ooSetupFactoryModuleIdentifier"))
+ sFoundModule = AnyConverter.toString(lModuleProps[i].Value);
+ if (lModuleProps[i].Name.equals("ooSetupFactoryDocumentService"))
+ sFoundDocService = AnyConverter.toString(lModuleProps[i].Value);
+ }
+
+ if (sFoundModule.length() < 1)
+ failed("Miss module identifier in result set. Returned data are incomplete.");
+
+ if ( ! sFoundDocService.equals(sDocumentService))
+ failed("Query returned wrong module '"+sFoundModule+"' with DocumentService='"+sFoundDocService+"'.");
+
+ log.println("Found module '"+sFoundModule+"'.");
+ }
+ }
+
+ //-------------------------------------------
+ /** @todo document me
+ */
+ private void impl_identifyModulesBasedOnDocs(String sModule)
+ throws java.lang.Exception
+ {
+ log.println("check identification of module '"+sModule+"' ...");
+
+ XNameAccess xMM = (XNameAccess)UnoRuntime.queryInterface(XNameAccess.class, m_xMM);
+ PropertyValue[] lModuleProps = (PropertyValue[])AnyConverter.toArray(xMM.getByName(sModule));
+ int c = lModuleProps.length;
+ int i = 0;
+ String sFactoryURL = "";
+
+ for (i=0; i<c; ++i)
+ {
+ if (lModuleProps[i].Name.equals("ooSetupFactoryEmptyDocumentURL"))
+ {
+ sFactoryURL = AnyConverter.toString(lModuleProps[i].Value);
+ break;
+ }
+ }
+
+ PropertyValue[] lArgs = new PropertyValue[1];
+ lArgs[0] = new PropertyValue();
+ lArgs[0].Name = "Hidden";
+ lArgs[0].Value = Boolean.TRUE;
+
+ XComponent xModel = m_xLoader.loadComponentFromURL(sFactoryURL, "_self", 0, lArgs);
+ XFrame xFrame = (XFrame)UnoRuntime.queryInterface(XFrame.class, m_xLoader);
+ XController xController = xFrame.getController();
+
+ String sModuleFrame = m_xMM.identify(xFrame );
+ String sModuleController = m_xMM.identify(xController);
+ String sModuleModel = m_xMM.identify(xModel );
+
+ if ( ! sModuleFrame.equals(sModule))
+ failed("Identification of module '"+sModule+"' failed if frame was used as entry point.");
+ if ( ! sModuleController.equals(sModule))
+ failed("Identification of module '"+sModule+"' failed if controller was used as entry point.");
+ if ( ! sModuleModel.equals(sModule))
+ failed("Identification of module '"+sModule+"' failed if model was used as entry point.");
+ }
+
+ //-------------------------------------------
+ /** @todo document me
+ */
+ private void impl_checkReadOnlyPropsOfModule(String sModule)
+ throws java.lang.Exception
+ {
+ XNameReplace xWrite = (XNameReplace)UnoRuntime.queryInterface(XNameReplace.class, m_xMM);
+
+ impl_checkReadOnlyPropOfModule(xWrite, sModule, "ooSetupFactoryDocumentService" , "test");
+ impl_checkReadOnlyPropOfModule(xWrite, sModule, "ooSetupFactoryActualFilter" , "test");
+ impl_checkReadOnlyPropOfModule(xWrite, sModule, "ooSetupFactoryActualTemplateFilter", "test");
+ impl_checkReadOnlyPropOfModule(xWrite, sModule, "ooSetupFactoryEmptyDocumentURL" , "test");
+ }
+
+ //-------------------------------------------
+ /** @todo document me
+ */
+ private void impl_checkReadOnlyPropOfModule(XNameReplace xMM ,
+ String sModule ,
+ String sPropName ,
+ Object aPropValue )
+ throws java.lang.Exception
+ {
+ PropertyValue[] lChanges = new PropertyValue[1];
+ lChanges[0] = new PropertyValue();
+ lChanges[0].Name = sPropName;
+ lChanges[0].Value = aPropValue;
+
+ // Note: Exception is expected !
+ log.println("check readonly state of module '"+sModule+"' for property '"+sPropName+"' ...");
+ try
+ {
+ xMM.replaceByName(sModule, lChanges);
+ failed("Was able to write READONLY property '"+sPropName+"' of module '"+sModule+"' configuration.");
+ }
+ catch(Throwable ex)
+ {}
+ }
+}
diff --git a/framework/qa/complex/ModuleManager/makefile.mk b/framework/qa/complex/ModuleManager/makefile.mk
new file mode 100644
index 000000000000..bcef75fca4ef
--- /dev/null
+++ b/framework/qa/complex/ModuleManager/makefile.mk
@@ -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.
+#
+#*************************************************************************
+PRJ = ..$/..$/..
+TARGET = CheckXModuleManager
+PRJNAME = $(TARGET)
+PACKAGE = complex$/ModuleManager
+
+# --- Settings -----------------------------------------------------
+.INCLUDE: settings.mk
+
+#----- compile .java files -----------------------------------------
+
+JARFILES = ridl.jar unoil.jar jurt.jar juh.jar java_uno.jar \
+ OOoRunner.jar mysql.jar
+
+JAVAFILES = CheckXModuleManager.java
+
+JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class)
+
+#----- make a jar from compiled files ------------------------------
+
+MAXLINELENGTH = 100000
+
+JARCLASSDIRS = $(PACKAGE)
+JARTARGET = $(TARGET).jar
+JARCOMPRESS = TRUE
+
+# --- Parameters for the test --------------------------------------
+
+# start an office if the parameter is set for the makefile
+.IF "$(OFFICE)" == ""
+CT_APPEXECCOMMAND =
+.ELSE
+CT_APPEXECCOMMAND = -AppExecutionCommand "$(OFFICE)$/soffice -accept=socket,host=localhost,port=8100;urp;"
+.ENDIF
+
+# test base is java complex
+CT_TESTBASE = -TestBase java_complex
+
+# test looks something like the.full.package.TestName
+CT_TEST = -o $(PACKAGE:s\$/\.\).$(JAVAFILES:b)
+
+# start the runner application
+CT_APP = org.openoffice.Runner
+
+# --- Targets ------------------------------------------------------
+
+#.IF "$(depend)" == ""
+#$(CLASSDIR)$/$(PACKAGE)$/$(JAVAFILES:b).props : ALLTAR
+#.ELSE
+#$(CLASSDIR)$/$(PACKAGE)$/$(JAVAFILES:b).props : ALLDEP
+#.ENDIF
+
+.INCLUDE : target.mk
+
+RUN: run
+
+run:
+ +java -cp $(CLASSPATH) $(CT_APP) $(CT_TESTBASE) $(CT_APPEXECCOMMAND) $(CT_TEST)
diff --git a/framework/qa/complex/XUserInputInterception/EventTest.java b/framework/qa/complex/XUserInputInterception/EventTest.java
new file mode 100644
index 000000000000..a54f9daaa932
--- /dev/null
+++ b/framework/qa/complex/XUserInputInterception/EventTest.java
@@ -0,0 +1,594 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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 complex.XUserInputInterception;
+
+import com.sun.star.accessibility.AccessibleRole;
+import com.sun.star.accessibility.XAccessible;
+import com.sun.star.accessibility.XAccessibleComponent;
+import com.sun.star.accessibility.XAccessibleContext;
+import com.sun.star.awt.KeyEvent;
+import com.sun.star.awt.MouseEvent;
+import com.sun.star.awt.Point;
+import com.sun.star.awt.Rectangle;
+import com.sun.star.awt.XKeyHandler;
+import com.sun.star.awt.XMouseClickHandler;
+import com.sun.star.awt.XUserInputInterception;
+import com.sun.star.awt.XWindow;
+import com.sun.star.chart.XChartDocument;
+import com.sun.star.frame.*;
+import com.sun.star.lang.*;
+import com.sun.star.lang.EventObject;
+import com.sun.star.sheet.XSpreadsheetDocument;
+import com.sun.star.text.XTextDocument;
+import com.sun.star.util.*;
+import com.sun.star.uno.*;
+import java.awt.Robot;
+import java.awt.event.InputEvent;
+
+import complexlib.ComplexTestCase;
+import util.AccessibilityTools;
+import util.SOfficeFactory;
+
+//-----------------------------------------------
+/**
+ * This <CODE>ComplexTest</CODE> checks the interface
+ * <CODE>XUserInputInterception</CODE>. Therefore it creates a document,
+ * adds a mouse and a key listener onto the interface and fire the
+ * correspond events. If all listener works as expected the test resluts in
+ * <CODE>OK</CODE> status.
+ * @short Check the interface XUserInputIntercaption
+ * @descr checks is a simple way the interface XUserInputInteraction
+ */
+public class EventTest extends ComplexTestCase {
+ //-------------------------------------------
+ // some const
+
+ //-------------------------------------------
+ // member
+
+ /** points to the global uno service manager. */
+ private XMultiServiceFactory m_xMSF = null;
+
+ /** indicates if the mousePressed event was called*/
+ private boolean m_mousePressed = false;
+ /** indicates if the mouseReleased event was called*/
+ private boolean m_mouseReleased = false;
+
+ /** indicates if the mousePressed event was called*/
+ private boolean m_keyPressed = false;
+ /** indicates if the mouseReleased event was called*/
+ private boolean m_keyReleased = false;
+
+ /** points to a global StarOffice factory */
+ private SOfficeFactory m_SOF = null;
+
+ /**
+ * define the miliseconds to wait until a <CODE>EventTrigger</CODE> thread should
+ * be finished with its work
+ */
+ final int m_threadWait = 3000;
+
+ //-------------------------------------------
+ // test environment
+
+ //-------------------------------------------
+ /**
+ * The test methods are:
+ * <ul>
+ * <li><CODE>checkTextDocument</CODE></LI>
+ * <li><CODE>checkCalcDocument</CODE></LI>
+ * <li><CODE>checkDrawDocument</CODE></LI>
+ * <li><CODE>checkImpressDocument</CODE></LI>
+ * <li><CODE>checkChartDocument</CODE></LI>
+ * <li><CODE>checkMathDocument</CODE></li>
+ * </ul>
+ * @short A function to tell the framework,
+ * which test functions are available.
+ * @return All test methods.
+ * @todo Think about selection of tests from outside ...
+ */
+ public String[] getTestMethodNames() {
+ return new String[]
+ { "checkTextDocument",
+ "checkCalcDocument",
+ "checkDrawDocument",
+ "checkImpressDocument",
+ "checkChartDocument",
+ "checkMathDocument",
+ };
+ }
+
+ //-------------------------------------------
+ /**
+ * creates the mebmer <CODE>m_xMSF</CODE> and <CODE>m_SOF</CODE>
+ * @short Create the environment for following tests.
+ * @descr create an empty test frame, where we can load
+ * different components inside.
+ */
+ public void before() {
+ // get uno service manager from global test environment
+ m_xMSF = (XMultiServiceFactory)param.getMSF();
+
+ // create frame instance
+ try {
+ // get a soffice factory object
+ m_SOF = SOfficeFactory.getFactory((XMultiServiceFactory) param.getMSF());
+
+ } catch(java.lang.Throwable ex) {
+ failed("Could not create the XUserInputInterception instance.");
+ }
+ }
+
+ //-------------------------------------------
+ /**
+ * closes the document
+ * @short close the document.
+ * @param xDoc the document to close
+ */
+ public void closeDoc(XInterface xDoc) {
+ XCloseable xClose = (XCloseable)UnoRuntime.queryInterface(
+ XCloseable.class, xDoc);
+ try {
+ xClose.close(false);
+ } catch(com.sun.star.util.CloseVetoException exVeto) {
+ log.println("document couldn't be closed successfully.");
+ }
+ }
+
+ /**
+ * creates a text document and check the <CODE>XMouseClickHandler</CODE> and
+ * <CODE>XKeyHandler</CODE>
+ * @see com.sun.star.awt.XKeyHandler
+ * @see com.sun.star.awt.XMouseClickHandler
+ */
+ public void checkTextDocument(){
+
+ XTextDocument xDoc = null;
+
+ try{
+ xDoc = m_SOF.createTextDoc("WriterTest");
+ } catch (com.sun.star.uno.Exception e){
+ failed("Could not create a text document: " +e.toString());
+ }
+
+ checkListener(xDoc);
+
+ closeDoc(xDoc);
+ }
+
+ /**
+ * creates an impress document and check the <CODE>XMouseClickHandler</CODE> and
+ * <CODE>XKeyHandler</CODE>
+ * @see com.sun.star.awt.XKeyHandler
+ * @see com.sun.star.awt.XMouseClickHandler
+ */
+ public void checkImpressDocument(){
+
+ XComponent xDoc = null;
+
+ try{
+ xDoc = m_SOF.createImpressDoc("ImpressTest");
+ } catch (com.sun.star.uno.Exception e){
+ failed("Could not create an impress document: " +e.toString());
+ }
+
+ checkListener(xDoc);
+
+ closeDoc(xDoc);
+ }
+
+ /**
+ * creates a chart document and check the <CODE>XMouseClickHandler</CODE> and
+ * <CODE>XKeyHandler</CODE>
+ * @see com.sun.star.awt.XKeyHandler
+ * @see com.sun.star.awt.XMouseClickHandler
+ */
+ public void checkChartDocument(){
+
+ XChartDocument xDoc = null;
+
+ try{
+ xDoc = m_SOF.createChartDoc("ChartTest");
+ } catch (com.sun.star.uno.Exception e){
+ failed("Could not create a chart document: " +e.toString());
+ }
+
+ checkListener(xDoc);
+
+ closeDoc(xDoc);
+ }
+
+ /**
+ * creates a math document and check the <CODE>XMouseClickHandler</CODE> and
+ * <CODE>XKeyHandler</CODE>
+ * @see com.sun.star.awt.XKeyHandler
+ * @see com.sun.star.awt.XMouseClickHandler
+ */
+ public void checkMathDocument(){
+
+ XComponent xDoc = null;
+
+ try{
+ xDoc = m_SOF.createMathDoc("MathTest");
+ } catch (com.sun.star.uno.Exception e){
+ failed("Could not create a math document: " +e.toString());
+ }
+
+ checkListener(xDoc);
+
+ closeDoc(xDoc);
+ }
+
+ /**
+ * creates a draw document and check the <CODE>XMouseClickHandler</CODE> and
+ * <CODE>XKeyHandler</CODE>
+ * @see com.sun.star.awt.XKeyHandler
+ * @see com.sun.star.awt.XMouseClickHandler
+ */
+ public void checkDrawDocument(){
+
+ XComponent xDoc = null;
+
+ try{
+ xDoc = m_SOF.createDrawDoc("DrawTest");
+ } catch (com.sun.star.uno.Exception e){
+ failed("Could not create a draw document: " +e.toString());
+ }
+
+ checkListener(xDoc);
+
+ closeDoc(xDoc);
+ }
+
+ /**
+ * creates a calc document and check the <CODE>XMouseClickHandler</CODE> and
+ * <CODE>XKeyHandler</CODE>
+ * @see com.sun.star.awt.XKeyHandler
+ * @see com.sun.star.awt.XMouseClickHandler
+ */
+ public void checkCalcDocument(){
+
+ XSpreadsheetDocument xDoc = null;
+
+ try{
+ xDoc = m_SOF.createCalcDoc("CalcTest");
+ } catch (com.sun.star.uno.Exception e){
+ failed("Could not create a calc document: " +e.toString());
+ }
+
+ checkListener(xDoc);
+ closeDoc(xDoc);
+ }
+
+ /**
+ * This is the central test method. It is called by ceck[DOCTYPE]Document. It
+ * creates the <CODE>XUserInputInterception</CODE> from the document and call the
+ * <CODE>checkMouseListener</CODE> test and the <CODE>checkKeyListener</CODE> test
+ * @param xDoc the document to test
+ */
+ private void checkListener(XInterface xDoc){
+
+ XModel xModel = (XModel) UnoRuntime.queryInterface(XModel.class, xDoc);
+
+ XUserInputInterception xUII = getUII(xModel);
+
+ checkMouseListener(xUII, xModel);
+ checkKeyListener(xUII, xModel);
+ }
+
+ /**
+ * Creates a <CODE>MyKeyHandler</CODE> and adds it to the
+ * <CODE>XUserInputInterception</CODE>. Then an <CODE>EventTrigger</CODE> thread
+ * was created and started.
+ * Has <CODE>OK</CODE> if the members <CODE>m_keyPressed</CODE> and
+ * <CODE>m_keyReleased</CODE> are <CODE>TRUE</CODE>
+ * @param xUII the XUserInputInterception
+ * @param xModel the XModel of a document
+ * @see EventTest.MyKeyHander
+ * @see EventTest.EventTrigger
+ */
+ private void checkKeyListener(XUserInputInterception xUII, XModel xModel) {
+ m_keyPressed = false;
+ m_keyReleased = false;
+
+ MyKeyHandler keyListener = new MyKeyHandler();
+
+ xUII.addKeyHandler(keyListener);
+
+ log.println("starting thread to check the key listener...");
+ EventTrigger et = new EventTrigger(xModel, EventTriggerType.KEY_TEXT_INTO_DOC);
+
+ et.run();
+
+ util.utils.shortWait(m_threadWait);
+ log.println("key listener thread should be finished.");
+
+ assure("key event does not work!", m_keyPressed && m_keyReleased);
+ xUII.removeKeyHandler(keyListener);
+
+ }
+
+ /**
+ * Creates a <CODE>MyMouseClickHandler</CODE> and adds it to the
+ * <CODE>XUserInputInterception</CODE>. Then an <CODE>EventTrigger</CODE> thread
+ * was created and started.
+ * Has <CODE>OK</CODE> if the members <CODE>m_mousePressed</CODE> and
+ * <CODE>m_mouseReleased</CODE> are <CODE>TRUE</CODE>
+ * @param xUII the XUserInputInterception
+ * @param xModel the XModel of a document
+ * @see EventTest.MyMouseClickHander
+ * @see EventTest.EventTrigger
+ */
+
+ private void checkMouseListener(XUserInputInterception xUII, XModel xModel) {
+
+ m_mousePressed = false;
+ m_mouseReleased = false;
+
+ MyMouseClickHandler mouseListener = new MyMouseClickHandler();
+
+ xUII.addMouseClickHandler(mouseListener);
+
+ log.println("starting thread to check the mouse listener...");
+ EventTrigger et = new EventTrigger(xModel, EventTriggerType.MOUSE_KLICK_INTO_DOC);
+
+ et.run();
+
+ util.utils.shortWait(m_threadWait);
+ log.println("mouse listener thread should be finished.");
+
+ assure("mouse event does not work!", m_mousePressed && m_mouseReleased);
+ xUII.removeMouseClickHandler(mouseListener);
+ }
+
+ /**
+ * returns the <CODE>XUserInputInterception</CODE> from the <CODE>XMdoel</CODE>
+ * @param xModel the XModel of a document
+ * @return the <CODE>XUserInputInterception</CODE> of the document
+ */
+ private XUserInputInterception getUII(XModel xModel){
+
+ XController xController = xModel.getCurrentController();
+
+ XUserInputInterception xUII = (XUserInputInterception) UnoRuntime.queryInterface(
+ XUserInputInterception.class, xController);
+ if (xUII == null) {
+ failed("could not get XUserInputInterception from XContoller", true);
+ }
+ return xUII;
+ }
+
+ /**
+ * Listener which added and its method must be called
+ * on <code>keyPressed</code> and <code>keyReleased</code> call.
+ */
+ public class MyKeyHandler implements XKeyHandler {
+ /**
+ * This event sets the member <code>m_keyPressed</coed> to
+ * <code>true</code>
+ * @param oEvent The key event informs about the pressed key.
+ * @return returns <CODE>TRUE</CODE> in erery case
+ */
+ public boolean keyPressed( KeyEvent oEvent ){
+ log.println("XKeyHandler: keyPressed-Event");
+ m_keyPressed = true;
+ return true;
+ }
+ /**
+ * This event sets the member <code>m_keyReleased</coed> to
+ * <code>true</code>
+ * @param oEvent The key event informs about the pressed key.
+ * @return returns <CODE>TRUE</CODE> in erery case
+ */
+ public boolean keyReleased( KeyEvent oEvent ){
+ log.println("XKeyHandler: keyReleased-Event");
+ m_keyReleased = true;
+ return true;
+ }
+ /**
+ * This event does nothing usefull
+ * @param oEvent refers to the object that fired the event.
+ */
+ public void disposing( EventObject oEvent ){
+ log.println("XKeyHandler: disposing-Event");
+ }
+ }
+
+ /**
+ * Listener which added and its method must be called
+ * on <code>mousePressed</code> and <code>mouseReleased</code> call.
+ */
+ public class MyMouseClickHandler implements XMouseClickHandler {
+ /**
+ * This event sets the member <code>m_mousePressed</coed> to
+ * <code>true</code>
+ * @param oEvent The mouse event informs about the kind of mouse event.
+ * @return returns <CODE>TRUE</CODE> in erery case
+ */
+ public boolean mousePressed( MouseEvent oEvent ){
+ log.println("XMouseClickHandler: mousePressed-Event");
+ m_mousePressed = true;
+ return true;
+ }
+ /**
+ * This event sets the member <code>m_mouseReleased</coed> to
+ * <code>true</code>
+ * @param oEvent The mouse event informs about the kind of mouse event.
+ * @return returns <CODE>TRUE</CODE> in erery case
+ */
+ public boolean mouseReleased( MouseEvent oEvent ){
+ log.println("XMouseClickHandler: mouseReleased-Event");
+ m_mouseReleased = true;
+ return true;
+ }
+ /**
+ * This event does nothing usefull
+ * @param oEvent refers to the object that fired the event.
+ */
+ public void disposing( EventObject oEvent ){
+ log.println("XMouseClickHandler: disposing-Event");
+ }
+ };
+
+ /**
+ * To check the events this class is a thread which click a mouse button and
+ * press a key with the <CODE>Robot</CODE> class
+ * @see java.awt.Robot
+ */
+ private class EventTrigger extends Thread{
+
+ /**
+ * represents a <CODE>AccessibilityTools</CODE>
+ */
+ private final AccessibilityTools at = new AccessibilityTools();
+ /**
+ * represents an <CODE>EventType</CODE>
+ * @see EventTest.EventTriggerType
+ */
+ private int eventType = 0;
+ /**
+ * represents a <CODE>XModel</CODE> of a document
+ */
+ private XModel xModel = null;
+
+ /**
+ * Creates an instacne of this class. The parameter <CODE>eType</CODE> represents
+ * the kind of event wich will be triggert at <CODE>run()</CODE>
+ * @param model the model of a document
+ * @param eType the kind of event which should be trigger
+ */
+ public EventTrigger(XModel model, int eType)
+ {
+ this.xModel = model;
+ this.eventType = eType;
+ }
+
+ /**
+ * Triggers the event wich is represented by <CODE>eventType</CODE>
+ * The scenarios are:
+ * <ul>
+ * <li>EventTest.EventTriggerType.MOUSE_KLICK_INTO_DOC
+ * which calls
+ * <li><CODE>clickIntoDoc</CODE></LI>
+ * </LI>
+ * <li>EventTest.EventTriggerType.KEY_TEXT_INTO_DOC
+ * which calls
+ * <li><CODE>clickIntodoc</CODE></LI>
+ * <li><CODE>keyIntoDoc</CODE></LI>
+ * </LI>
+ * </UL>
+ */
+ public void run(){
+
+ switch (this.eventType){
+
+ case EventTriggerType.MOUSE_KLICK_INTO_DOC:
+ clickIntoDoc();
+ break;
+ case EventTriggerType.KEY_TEXT_INTO_DOC:
+ clickIntoDoc();
+ keyIntoDoc();
+ break;
+
+ }
+ }
+ /**
+ * This method cklicks into the middel of a document. It uses Accessibility
+ * to get the document and query for its position and its range to calculate
+ * the middle. This values was used for <CODE>Robot</CODE> Class. This
+ * Robot class is able to move the mouse and to cklick a mouse button
+ * @see java.awt.Robot
+ */
+ private void clickIntoDoc(){
+ try{
+ // get the position and the range of a scroll bar
+
+ XWindow xWindow = at.getCurrentWindow(
+ (XMultiServiceFactory) param.getMSF(),
+ xModel);
+
+ XAccessible xRoot = at.getAccessibleObject(xWindow);
+
+
+
+ XAccessibleContext xPanel = at.getAccessibleObjectForRole(xRoot, AccessibleRole.PANEL);
+ XAccessibleComponent xPanelCont = (XAccessibleComponent) UnoRuntime.queryInterface(XAccessibleComponent.class, xPanel);
+
+ // the position of the panel
+ Point point = xPanelCont.getLocationOnScreen();
+
+ // the range of the panel
+ Rectangle rect = xPanelCont.getBounds();
+
+ try {
+ Robot rob = new Robot();
+ int x = point.X + (rect.Width / 2);
+ int y = point.Y + (rect.Height / 2);
+ log.println("try to klick into the middle of the document");
+ rob.mouseMove(x, y);
+ rob.mousePress(InputEvent.BUTTON1_MASK);
+ rob.mouseRelease(InputEvent.BUTTON1_MASK);
+ } catch (java.awt.AWTException e) {
+ log.println("couldn't press mouse button");
+ }
+ } catch (java.lang.Exception e){
+ log.println("could not click into the scroll bar: " + e.toString());
+ }
+ }
+
+ /**
+ * This method press the "A" key. Therefore it uses the <CODE>Robot</CODE>
+ * class.
+ * @see java.awt.Robot
+ */
+ private void keyIntoDoc(){
+ try {
+ Robot rob = new Robot();
+ log.println("try to press 'A'");
+ rob.keyPress(java.awt.event.KeyEvent.VK_A);
+ rob.keyRelease(java.awt.event.KeyEvent.VK_A);
+ } catch (java.awt.AWTException e) {
+ log.println("couldn't press key");
+ }
+
+ }
+ }
+
+ /** This interface represents all possible actions which could be used
+ * in the <CODE>EventTrigger</CODE> class.
+ * @see EventTest.EventTrigger
+ */
+ private interface EventTriggerType{
+
+ /** klick the mouse into the scroll bar*/
+ final public static int MOUSE_KLICK_INTO_DOC = 1;
+
+ /** write some text into a spread sheet*/
+ final public static int KEY_TEXT_INTO_DOC = 2;
+ }
+} \ No newline at end of file
diff --git a/framework/qa/complex/XUserInputInterception/makefile.mk b/framework/qa/complex/XUserInputInterception/makefile.mk
new file mode 100644
index 000000000000..d3ca648b02f0
--- /dev/null
+++ b/framework/qa/complex/XUserInputInterception/makefile.mk
@@ -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.
+#
+#*************************************************************************
+PRJ = ..$/..$/..
+TARGET = EventTest
+PRJNAME = framework
+PACKAGE = complex$/XUserInputInterception
+
+# --- Settings -----------------------------------------------------
+.INCLUDE: settings.mk
+
+
+#----- compile .java files -----------------------------------------
+
+JARFILES = mysql.jar ridl.jar unoil.jar jurt.jar juh.jar java_uno.jar \
+ OOoRunner.jar mysql.jar
+JAVAFILES = EventTest.java
+JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class)
+
+#----- make a jar from compiled files ------------------------------
+
+MAXLINELENGTH = 100000
+
+JARCLASSDIRS = $(PACKAGE)
+JARTARGET = $(TARGET).jar
+JARCOMPRESS = TRUE
+
+# --- Parameters for the test --------------------------------------
+
+# start an office if the parameter is set for the makefile
+.IF "$(OFFICE)" == ""
+CT_APPEXECCOMMAND =
+.ELSE
+CT_APPEXECCOMMAND = -AppExecutionCommand "$(OFFICE)$/soffice -accept=socket,host=localhost,port=8100;urp;"
+.ENDIF
+
+# test base is java complex
+CT_TESTBASE = -TestBase java_complex
+
+# test looks something like the.full.package.TestName
+CT_TEST = -o $(PACKAGE:s\$/\.\).$(JAVAFILES:b)
+
+# start the runner application
+CT_APP = org.openoffice.Runner
+
+# --- Targets ------------------------------------------------------
+
+.IF "$(depend)" == ""
+$(CLASSDIR)$/$(PACKAGE)$/$(JAVAFILES:b).props : ALLTAR
+.ELSE
+$(CLASSDIR)$/$(PACKAGE)$/$(JAVAFILES:b).props : ALLDEP
+.ENDIF
+
+.INCLUDE : target.mk
+
+#$(CLASSDIR)$/$(PACKAGE)$/$(JAVAFILES:b).props : $(JAVAFILES:b).props
+# cp $(JAVAFILES:b).props $(CLASSDIR)$/$(PACKAGE)$/$(JAVAFILES:b).props
+# jar uf $(CLASSDIR)$/$(JARTARGET) -C $(CLASSDIR) $(PACKAGE)$/$(JAVAFILES:b).props
+
+RUN: run
+
+run:
+ +java -cp $(CLASSPATH) $(CT_APP) $(CT_TESTBASE) $(CT_APPEXECCOMMAND) $(CT_TEST)
+
+
+
diff --git a/framework/qa/complex/accelerators/AcceleratorsConfigurationTest.java b/framework/qa/complex/accelerators/AcceleratorsConfigurationTest.java
new file mode 100644
index 000000000000..95a0fce2c92c
--- /dev/null
+++ b/framework/qa/complex/accelerators/AcceleratorsConfigurationTest.java
@@ -0,0 +1,686 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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 complex.accelerators;
+
+// imports
+import com.sun.star.awt.*;
+import com.sun.star.beans.*;
+import com.sun.star.container.*;
+import com.sun.star.embed.*;
+import com.sun.star.lang.*;
+import com.sun.star.ui.*;
+import com.sun.star.uno.*;
+import com.sun.star.util.*;
+
+import complexlib.ComplexTestCase;
+
+import java.lang.*;
+import java.util.*;
+
+import helper.*;
+
+//-----------------------------------------------
+/** @short todo document me
+ */
+public class AcceleratorsConfigurationTest extends ComplexTestCase
+{
+ /** points to the global uno service manager. */
+ private XMultiServiceFactory m_xSmgr = null;
+
+ /** the accelerator configuration for testing. */
+ private XAcceleratorConfiguration m_xGlobalAccelCfg = null;
+ private XAcceleratorConfiguration m_xModuleAccelCfg = null;
+ private XAcceleratorConfiguration m_xDocumentAccelCfg = null;
+
+ /** XCS/XCU based accelerator configuration. */
+ private XNameAccess m_xConfig = null;
+ private XNameAccess m_xPrimaryKeys = null;
+ private XNameAccess m_xSecondaryKeys = null;
+
+ //-------------------------------------------
+ // test environment
+
+ //-----------------------------------------------
+ /** @short todo document me
+ */
+ public String[] getTestMethodNames()
+ {
+ return new String[]
+ {
+ "checkGlobalAccelCfg",
+ "checkModuleAccelCfg",
+ "checkDocumentAccelCfg"
+ };
+ }
+
+ //-----------------------------------------------
+ /** @short Create the environment for following tests.
+ */
+ public void before()
+ throws java.lang.Exception
+ {
+ // get uno service manager from global test environment
+ m_xSmgr = (XMultiServiceFactory)param.getMSF();
+
+ m_xGlobalAccelCfg = (XAcceleratorConfiguration)UnoRuntime.queryInterface(
+ XAcceleratorConfiguration.class,
+ m_xSmgr.createInstance("com.sun.star.ui.GlobalAcceleratorConfiguration"));
+ m_xModuleAccelCfg = (XAcceleratorConfiguration)UnoRuntime.queryInterface(
+ XAcceleratorConfiguration.class,
+ m_xSmgr.createInstance("com.sun.star.ui.ModuleAcceleratorConfiguration"));
+ m_xDocumentAccelCfg = (XAcceleratorConfiguration)UnoRuntime.queryInterface(
+ XAcceleratorConfiguration.class,
+ m_xSmgr.createInstance("com.sun.star.ui.DocumentAcceleratorConfiguration"));
+
+ String sConfigPath = "org.openoffice.Office.Accelerators";
+ boolean bReadOnly = false;
+ XNameAccess m_xConfig = openConfig(m_xSmgr, sConfigPath, bReadOnly);
+ if (m_xConfig != null)
+ {
+ m_xPrimaryKeys = (XNameAccess)UnoRuntime.queryInterface(XNameAccess.class, m_xConfig.getByName("PrimaryKeys"));
+ m_xSecondaryKeys = (XNameAccess)UnoRuntime.queryInterface(XNameAccess.class, m_xConfig.getByName("SecondaryKeys"));
+ }
+ }
+
+ //-------------------------------------------
+ /** @short close the environment.
+ */
+ public void after()
+ throws java.lang.Exception
+ {
+ m_xConfig = null;
+ m_xGlobalAccelCfg = null;
+ m_xModuleAccelCfg = null;
+ m_xDocumentAccelCfg = null;
+ m_xSmgr = null;
+ }
+
+ //-------------------------------------------
+ /** @todo document me.
+ */
+ public void checkGlobalAccelCfg()
+ throws java.lang.Exception
+ {
+ log.println("\n---- check Global accelerator configuration: ----");
+
+ String[] sKeys;
+ XNameAccess xPrimaryAccess = (XNameAccess)UnoRuntime.queryInterface(XNameAccess.class,m_xPrimaryKeys.getByName("Global"));
+ XNameAccess xSecondaryAccess = (XNameAccess)UnoRuntime.queryInterface(XNameAccess.class, m_xSecondaryKeys.getByName("Global"));
+
+ sKeys = new String[] { "A_MOD1" };
+ impl_checkGetKeyCommands(m_xGlobalAccelCfg, xPrimaryAccess, sKeys);
+
+ sKeys = new String[] { "PASTE", "X_SHIFT" };
+ String[] sCommands = new String[] { ".uno:test", ".uno:test" };
+ impl_checkSetKeyCommands(m_xGlobalAccelCfg, xPrimaryAccess, xSecondaryAccess, sKeys, sCommands);
+
+ sKeys = new String[] { "C_MOD1", "CUT" };
+ impl_checkRemoveKeyCommands(m_xGlobalAccelCfg, xPrimaryAccess, xSecondaryAccess, sKeys);
+
+ String[] sCommandList = new String[] { ".uno:Paste", ".uno:CloseWin" };
+ impl_checkGetPreferredKeyEventsForCommandList(m_xGlobalAccelCfg, xPrimaryAccess, sCommandList);
+ }
+
+ //-------------------------------------------
+ /** @todo document me.
+ */
+ public void checkModuleAccelCfg()
+ throws java.lang.Exception
+ {
+ String[] sModules = new String[]
+ {
+ "com.sun.star.frame.StartModule",
+ "com.sun.star.drawing.DrawingDocument",
+ "com.sun.star.presentation.PresentationDocument",
+ "com.sun.star.sheet.SpreadsheetDocument",
+ "com.sun.star.text.TextDocument",
+ // add other modules here
+ };
+
+ for (int i=0; i<sModules.length; ++i)
+ {
+ log.println("\n---- check accelerator configuration depending module: " + sModules[i] + " ----");
+
+ PropertyValue[] aProp = new PropertyValue[2];
+ aProp[0] = new PropertyValue();
+ aProp[0].Name = "ModuleIdentifier";
+ aProp[0].Value = sModules[i];
+ aProp[1] = new PropertyValue();
+ aProp[1].Name = "Locale";
+ aProp[1].Value = "en-US";
+
+ XInitialization xInit = (XInitialization)UnoRuntime.queryInterface(XInitialization.class, m_xModuleAccelCfg);
+ xInit.initialize(aProp); // to fill cache
+
+ XNameAccess xPrimaryModules = (XNameAccess)UnoRuntime.queryInterface(XNameAccess.class, m_xPrimaryKeys.getByName("Modules"));
+ XNameAccess xSecondaryModules = (XNameAccess)UnoRuntime.queryInterface(XNameAccess.class, m_xSecondaryKeys.getByName("Modules"));
+
+ String[] sKeys;
+ XNameAccess xPrimaryAccess = (XNameAccess)UnoRuntime.queryInterface(XNameAccess.class, xPrimaryModules.getByName(sModules[i]));
+ XNameAccess xSecondaryAccess = (XNameAccess)UnoRuntime.queryInterface(XNameAccess.class, xSecondaryModules.getByName(sModules[i]));
+
+ //--------------------------------------------
+ if (sModules[i].equals("com.sun.star.presentation.PresentationDocument"))
+ sKeys = new String[] { "A_SHIFT_MOD1_MOD2" };
+ else if (sModules[i].equals("com.sun.star.sheet.SpreadsheetDocument"))
+ sKeys = new String[] { "B_MOD1" };
+ else if (sModules[i].equals("com.sun.star.text.TextDocument"))
+ sKeys = new String[] { "F11_MOD1" };
+ else
+ sKeys = new String[] { "A_MOD1" };
+ impl_checkGetKeyCommands(m_xModuleAccelCfg, xPrimaryAccess, sKeys);
+
+ //--------------------------------------------
+ String[] sCommands;
+ if (sModules[i].equals("com.sun.star.presentation.PresentationDocument"))
+ {
+ sKeys = new String[] { "A_SHIFT_MOD1_MOD2" };
+ sCommands = new String[] { ".uno:test" };
+ }
+ else if (sModules[i].equals("com.sun.star.sheet.SpreadsheetDocument"))
+ {
+ sKeys = new String[] { "B_MOD1" };
+ sCommands = new String[] { ".uno:test" };
+ }
+ else if (sModules[i].equals("com.sun.star.text.TextDocument"))
+ {
+ sKeys = new String[] { "F11_MOD1" };
+ sCommands = new String[] { ".uno:test" };
+ }
+ else
+ {
+ sKeys = new String[] { "PASTE" };
+ sCommands = new String[] { ".uno:test" };
+ }
+ impl_checkSetKeyCommands(m_xModuleAccelCfg, xPrimaryAccess, xSecondaryAccess, sKeys, sCommands);
+
+ //--------------------------------------------
+ if (sModules[i].equals("com.sun.star.presentation.PresentationDocument"))
+ sKeys = new String[] { "A_SHIFT_MOD1_MOD2" };
+ else if (sModules[i].equals("com.sun.star.sheet.SpreadsheetDocument"))
+ sKeys = new String[] { "F5_SHIFT_MOD1" };
+ else if (sModules[i].equals("com.sun.star.text.TextDocument"))
+ sKeys = new String[] { "BACKSPACE_MOD2" };
+ else
+ sKeys = new String[] { "C_MOD1" };
+ impl_checkRemoveKeyCommands(m_xModuleAccelCfg, xPrimaryAccess, xSecondaryAccess, sKeys);
+
+ //--------------------------------------------
+ String[] sCommandList;
+ if (sModules[i].equals("com.sun.star.presentation.PresentationDocument"))
+ sCommandList = new String[] { ".uno:Presentation" };
+ else if (sModules[i].equals("com.sun.star.sheet.SpreadsheetDocument"))
+ sCommandList = new String[] { ".uno:InsertCell" };
+ else if (sModules[i].equals("com.sun.star.text.TextDocument"))
+ sCommandList = new String[] { ".uno:SelectionModeBlock" };
+ else
+ sCommandList = new String[] { ".uno:Cut" };
+ impl_checkGetPreferredKeyEventsForCommandList(m_xModuleAccelCfg, xPrimaryAccess, sCommandList);
+ }
+ }
+
+ //-------------------------------------------
+ /** @todo document me.
+ */
+ public void checkDocumentAccelCfg()
+ throws java.lang.Exception
+ {
+ log.println("\n---- check Document accelerator configuration: ----");
+
+ String sDocCfgName;
+
+ sDocCfgName = "file:///c:/test.cfg";
+ SaveDocumentAcceleratorConfiguration(sDocCfgName);
+
+ sDocCfgName = "file:///c:/test.cfg";
+ LoadDocumentAcceleratorConfiguration(sDocCfgName);
+ }
+
+ //-------------------------------------------
+ /** @todo document me.
+ */
+ private void impl_checkGetKeyCommands(XAcceleratorConfiguration xAccelCfg, XNameAccess xAccess, String[] sKeys)
+ throws java.lang.Exception
+ {
+ log.println("check getKeyCommands...");
+
+ for (int i=0; i<sKeys.length; ++i)
+ {
+ if (xAccess.hasByName(sKeys[i]) && getCommandFromConfiguration(xAccess, sKeys[i]).length()>0)
+ {
+ log.println("** get command by " + sKeys[i] + " **");
+
+ String sCmdFromCache = new String(); // get a value using XAcceleratorConfiguration API
+ String sCmdFromConfiguration = new String(); // get a value using configuration API
+
+ // GET shortcuts/commands using XAcceleratorConfiguration API
+ sCmdFromCache = xAccelCfg.getCommandByKeyEvent(convertShortcut2AWTKey(sKeys[i]));
+ log.println(sKeys[i] + "-->" + sCmdFromCache + ", by XAcceleratorConfiguration API");
+
+ // GET shortcuts/commands using configuration API
+ sCmdFromConfiguration = getCommandFromConfiguration(xAccess, sKeys[i]);
+ log.println(sKeys[i] + "-->" + sCmdFromConfiguration + ", by configuration API");
+
+ assure("values are different by XAcceleratorConfiguration API and configuration API!", sCmdFromCache.equals(sCmdFromConfiguration));
+
+ String sLocale = "es";
+ setOfficeLocale(sLocale);
+ sCmdFromConfiguration = getCommandFromConfiguration(xAccess, sKeys[i]);
+ log.println(sKeys[i] + "-->" + sCmdFromConfiguration + ", by configuration API" + " for locale:"+ getOfficeLocale());
+
+ sLocale = "en-US";
+ setOfficeLocale(sLocale); //reset to default locale
+ }
+ else
+ {
+ log.println(sKeys[i] + " doesn't exist!");
+ }
+ }
+ }
+
+ //-------------------------------------------
+ /** @todo document me.
+ */
+ private void impl_checkSetKeyCommands(XAcceleratorConfiguration xAccelCfg, XNameAccess xPrimaryAccess, XNameAccess xSecondaryAccess, String[] sKeys, String[] sCommands)
+ throws java.lang.Exception
+ {
+ log.println("check setKeyCommands...");
+
+ for (int i=0; i<sKeys.length; ++i)
+ {
+ if (!xPrimaryAccess.hasByName(sKeys[i]) && !xSecondaryAccess.hasByName(sKeys[i]))
+ {
+ xAccelCfg.setKeyEvent(convertShortcut2AWTKey(sKeys[i]), sCommands[i]);
+ xAccelCfg.store();
+ if (xPrimaryAccess.hasByName(sKeys[i]))
+ log.println("add " + sKeys[i] + " successfully!");
+ else
+ log.println("add " + sKeys[i] + " failed!");
+ }
+ else if (xPrimaryAccess.hasByName(sKeys[i]))
+ {
+ String sOriginalCommand = getCommandFromConfiguration(xPrimaryAccess, sKeys[i]);
+ if (!sCommands[i].equals(sOriginalCommand))
+ {
+ xAccelCfg.setKeyEvent(convertShortcut2AWTKey(sKeys[i]), sCommands[i]);
+ xAccelCfg.store();
+
+ String sChangedCommand = getCommandFromConfiguration(xPrimaryAccess, sKeys[i]);
+ if (sCommands[i].equals(sChangedCommand))
+ log.println("change " + sKeys[i] + " successfully!");
+ else
+ log.println("change " + sKeys[i] + " failed!");
+ }
+ else
+ log.println(sKeys[i] + " already exist!");
+ }
+ else if (xSecondaryAccess.hasByName(sKeys[i]))
+ {
+ String sOriginalCommand = getCommandFromConfiguration(xSecondaryAccess, sKeys[i]);
+ if (!sCommands[i].equals(sOriginalCommand))
+ {
+ xAccelCfg.setKeyEvent(convertShortcut2AWTKey(sKeys[i]), sCommands[i]);
+ xAccelCfg.store();
+
+ String sChangedCommand = getCommandFromConfiguration(xPrimaryAccess, sKeys[i]);
+ if (sCommands[i].equals(sChangedCommand))
+ log.println("change " + sKeys[i] + " successfully!");
+ else
+ log.println("change " + sKeys[i] + " failed!");
+ }
+ else
+ log.println(sKeys[i] + " already exist!");
+ }
+ }
+ }
+
+ //-------------------------------------------
+ /** @todo document me.
+ */
+ private void impl_checkRemoveKeyCommands(XAcceleratorConfiguration xAccelCfg, XNameAccess xPrimaryAccess, XNameAccess xSecondaryAccess, String[] sKeys)
+ throws java.lang.Exception
+ {
+ log.println("check removeKeyCommands...");
+
+ for (int i=0; i<sKeys.length; i++)
+ {
+ if (!xPrimaryAccess.hasByName(sKeys[i]) && !xSecondaryAccess.hasByName(sKeys[i]))
+ {
+ log.println(sKeys[i] + " doesn't exist!");
+ }
+ else if (xPrimaryAccess.hasByName(sKeys[i]))
+ {
+ xAccelCfg.removeKeyEvent(convertShortcut2AWTKey(sKeys[i]));
+ xAccelCfg.store();
+ if (!xPrimaryAccess.hasByName(sKeys[i]))
+ log.println("Remove " + sKeys[i] + " successfully!");
+ else
+ log.println("Remove " + sKeys[i] + " failed!");
+ }
+ else if (xSecondaryAccess.hasByName(sKeys[i]))
+ {
+ xAccelCfg.removeKeyEvent(convertShortcut2AWTKey(sKeys[i]));
+ xAccelCfg.store();
+ if (!xSecondaryAccess.hasByName(sKeys[i]))
+ log.println("Remove " + sKeys[i] + " successfully!");
+ else
+ log.println("Remove " + sKeys[i] + " failed!");
+ }
+ }
+ }
+
+ //-------------------------------------------
+ /** @todo document me.
+ */
+ private void impl_checkGetPreferredKeyEventsForCommandList(XAcceleratorConfiguration xAccelCfg, XNameAccess xPrimaryAccess, String[] sCommandList)
+ throws java.lang.Exception
+ {
+ log.println("check getPreferredKeyEventsForCommandList...");
+
+ Object[] oKeyEvents = xAccelCfg.getPreferredKeyEventsForCommandList(sCommandList);
+ for (int i = 0; i < oKeyEvents.length; i++)
+ {
+ log.println("get preferred key for command "+ sCommandList[i] + ":");
+
+ KeyEvent aKeyEvent = (KeyEvent)AnyConverter.toObject(KeyEvent.class, oKeyEvents[i]);
+ String sKeyEvent = convertAWTKey2Shortcut(aKeyEvent);
+ log.println(sKeyEvent);
+
+ String sCmdFromConfiguration = getCommandFromConfiguration(xPrimaryAccess, sKeyEvent);
+ log.println(sCmdFromConfiguration);
+ if (sCommandList[i].equals(sCmdFromConfiguration))
+ log.println("get preferred key correctly!");
+ else
+ log.println("get preferred key failed!");
+ }
+ }
+
+ //-------------------------------------------
+ /** @todo document me.
+ */
+ private String getCommandFromConfiguration(XNameAccess xAccess, String sKey)
+ throws java.lang.Exception
+ {
+ String sCommand = new String();
+
+ if (xAccess.hasByName(sKey))
+ {
+ XNameAccess xKey = (XNameAccess)UnoRuntime.queryInterface(XNameAccess.class, xAccess.getByName(sKey));
+ XNameAccess xCommand = (XNameAccess)UnoRuntime.queryInterface(XNameAccess.class, xKey.getByName("Command"));
+
+ String sLocale = getOfficeLocale();
+ if (xCommand.hasByName(sLocale))
+ sCommand = (String)UnoRuntime.queryInterface(String.class, xCommand.getByName(sLocale));
+ }
+
+ return sCommand;
+ }
+
+ //-------------------------------------------
+ /** @todo document me.
+ */
+ private void insertKeyToConfiguration(XNameAccess xAccess, String sKey, String sCommand)
+ throws java.lang.Exception
+ {
+ XNameContainer xContainer = (XNameContainer)UnoRuntime.queryInterface(XNameContainer.class, xAccess);
+ if (!xContainer.hasByName(sKey))
+ {
+ XSingleServiceFactory xFac = (XSingleServiceFactory)UnoRuntime.queryInterface(XSingleServiceFactory.class, xContainer);
+ XInterface xInst = (XInterface)UnoRuntime.queryInterface(XInterface.class, xFac.createInstance());
+ xContainer.insertByName(sKey, xInst);
+ }
+
+ XNameAccess xKey = (XNameAccess)UnoRuntime.queryInterface(XNameAccess.class, xContainer.getByName(sKey));
+ XNameContainer xCommand = (XNameContainer)UnoRuntime.queryInterface(XNameContainer.class, xKey.getByName("Command"));
+ String sLocale = getOfficeLocale();
+ if (xCommand.hasByName(sLocale))
+ xCommand.insertByName(sLocale, sCommand);
+ else
+ xCommand.replaceByName(sLocale, sCommand);
+ }
+
+ //-------------------------------------------
+ /** @todo document me.
+ */
+ private void removeKeyFromConfiguration(XNameAccess xAccess, String sKey)
+ throws java.lang.Exception
+ {
+ XNameContainer xContainer = (XNameContainer)UnoRuntime.queryInterface(XNameContainer.class, xAccess);
+ if (xContainer.hasByName(sKey))
+ xContainer.removeByName(sKey);
+ }
+
+ //-------------------------------------------
+ /** @todo document me.
+ */
+ private void LoadDocumentAcceleratorConfiguration(String sDocCfgName)
+ throws java.lang.Exception
+ {
+ XSingleServiceFactory xStorageFactory = (XSingleServiceFactory)UnoRuntime.queryInterface(
+ XSingleServiceFactory.class,
+ m_xSmgr.createInstance("com.sun.star.embed.StorageFactory"));
+
+ Object aArgs[] = new Object[2];
+ aArgs[0] = sDocCfgName;
+ aArgs[1] = new Integer(com.sun.star.embed.ElementModes.READ);
+ XStorage xRootStorage = (XStorage)UnoRuntime.queryInterface(
+ XStorage.class,
+ xStorageFactory.createInstanceWithArguments(aArgs));
+
+ XStorage xUIConfig = xRootStorage.openStorageElement("Configurations2", com.sun.star.embed.ElementModes.READ);
+
+ PropertyValue aProp = new PropertyValue();
+ aProp.Name = "DocumentRoot";
+ aProp.Value = xUIConfig;
+ Object[] lArgs = new Object[1];
+ lArgs[0] = aProp;
+
+ XInitialization xInit = (XInitialization)UnoRuntime.queryInterface(XInitialization.class, m_xDocumentAccelCfg);
+ xInit.initialize(lArgs);
+
+ String test = m_xDocumentAccelCfg.getCommandByKeyEvent(convertShortcut2AWTKey("F2"));
+ log.println(test);
+ }
+
+ //-------------------------------------------
+ /** @todo document me.
+ */
+ private void SaveDocumentAcceleratorConfiguration(String sDocCfgName)
+ throws java.lang.Exception
+ {
+ XSingleServiceFactory xStorageFactory = (XSingleServiceFactory)UnoRuntime.queryInterface(
+ XSingleServiceFactory.class,
+ m_xSmgr.createInstance("com.sun.star.embed.StorageFactory"));
+
+ Object aArgs[] = new Object[2];
+ aArgs[0] = sDocCfgName;
+ aArgs[1] = new Integer(com.sun.star.embed.ElementModes.WRITE);
+ XStorage xRootStorage = (XStorage)UnoRuntime.queryInterface(
+ XStorage.class,
+ xStorageFactory.createInstanceWithArguments(aArgs));
+
+ XStorage xUIConfig = xRootStorage.openStorageElement("Configurations2", com.sun.star.embed.ElementModes.WRITE);
+
+ XUIConfigurationManager xCfgMgr = (XUIConfigurationManager)UnoRuntime.queryInterface(
+ XUIConfigurationManager.class,
+ m_xSmgr.createInstance("com.sun.star.ui.UIConfigurationManager"));
+
+ XUIConfigurationStorage xUICfgStore = (XUIConfigurationStorage)UnoRuntime.queryInterface(
+ XUIConfigurationStorage.class,
+ xCfgMgr);
+ xUICfgStore.setStorage(xUIConfig);
+
+ XPropertySet xUIConfigProps = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xUIConfig);
+ xUIConfigProps.setPropertyValue("MediaType", "application/vnd.sun.xml.ui.configuration");
+
+ if (xCfgMgr != null)
+ {
+ XAcceleratorConfiguration xTargetAccMgr = (XAcceleratorConfiguration)UnoRuntime.queryInterface(
+ XAcceleratorConfiguration.class,
+ xCfgMgr.getShortCutManager());
+ XUIConfigurationPersistence xCommit1 = (XUIConfigurationPersistence)UnoRuntime.queryInterface(
+ XUIConfigurationPersistence.class, xTargetAccMgr);
+ XUIConfigurationPersistence xCommit2 = (XUIConfigurationPersistence)UnoRuntime.queryInterface(
+ XUIConfigurationPersistence.class, xCfgMgr);
+ xCommit1.store();
+ xCommit2.store();
+
+ XTransactedObject xCommit3 = (XTransactedObject)UnoRuntime.queryInterface(
+ XTransactedObject.class, xRootStorage);
+ xCommit3.commit();
+ }
+ }
+
+ //-------------------------------------------
+ /** @todo document me.
+ */
+ private com.sun.star.awt.KeyEvent convertShortcut2AWTKey(String sShortcut)
+ throws java.lang.Exception
+ {
+ com.sun.star.awt.KeyEvent aKeyEvent = new com.sun.star.awt.KeyEvent();
+ KeyMapping aKeyMapping = new KeyMapping();
+ String[] sShortcutSplits = sShortcut.split("_");
+
+ aKeyEvent.KeyCode = aKeyMapping.mapIdentifier2Code(sShortcutSplits[0]);
+ for (int i = 1; i < sShortcutSplits.length; i++)
+ {
+ if (sShortcutSplits[i].equals("SHIFT"))
+ aKeyEvent.Modifiers |= com.sun.star.awt.KeyModifier.SHIFT;
+ else if (sShortcutSplits[i].equals("MOD1"))
+ aKeyEvent.Modifiers |= com.sun.star.awt.KeyModifier.MOD1;
+ else if (sShortcutSplits[i].equals("MOD2"))
+ aKeyEvent.Modifiers |= com.sun.star.awt.KeyModifier.MOD2;
+ }
+
+ return aKeyEvent;
+ }
+
+ //-------------------------------------------
+ /** @todo document me.
+ */
+ private String convertAWTKey2Shortcut(com.sun.star.awt.KeyEvent aKeyEvent)
+ throws java.lang.Exception
+ {
+ String sShortcut;
+
+ KeyMapping aKeyMapping = new KeyMapping();
+ sShortcut = aKeyMapping.mapCode2Identifier(aKeyEvent.KeyCode);
+
+ if ((aKeyEvent.Modifiers & com.sun.star.awt.KeyModifier.SHIFT) == com.sun.star.awt.KeyModifier.SHIFT)
+ sShortcut += "_SHIFT";
+ if ((aKeyEvent.Modifiers & com.sun.star.awt.KeyModifier.MOD1) == com.sun.star.awt.KeyModifier.MOD1)
+ sShortcut += "_MOD1";
+ if ((aKeyEvent.Modifiers & com.sun.star.awt.KeyModifier.MOD2) == com.sun.star.awt.KeyModifier.MOD2)
+ sShortcut += "_MOD2";
+
+ return sShortcut;
+ }
+
+ //-------------------------------------------
+ /** @todo document me.
+ */
+ private String getOfficeLocale()
+ throws java.lang.Exception
+ {
+ String sLocale = new String();
+
+ String sConfigPath = "org.openoffice.Setup";
+ boolean bReadOnly = true;
+ XNameAccess xRootConfig = openConfig(m_xSmgr, sConfigPath, bReadOnly);
+
+ if (xRootConfig != null)
+ {
+ XNameAccess xLocale = (XNameAccess)UnoRuntime.queryInterface(XNameAccess.class, xRootConfig.getByName("L10N"));
+ XPropertySet xSet = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xLocale);
+ sLocale = (String)xSet.getPropertyValue("ooLocale");
+ }
+
+ return sLocale;
+ }
+
+ //-------------------------------------------
+ /** @todo document me.
+ */
+ private void setOfficeLocale(String sLocale)
+ throws java.lang.Exception
+ {
+ String sConfigPath = "org.openoffice.Setup";
+ boolean bReadOnly = false;
+ XNameAccess xRootConfig = openConfig(m_xSmgr, sConfigPath, bReadOnly);
+
+ if (xRootConfig != null)
+ {
+ XNameAccess xLocale = (XNameAccess)UnoRuntime.queryInterface(XNameAccess.class, xRootConfig.getByName("L10N"));
+ XPropertySet xSet = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xLocale);
+ xSet.setPropertyValue("ooLocale", sLocale);
+ XChangesBatch xBatch = (XChangesBatch)UnoRuntime.queryInterface(XChangesBatch.class, xRootConfig);
+ xBatch.commitChanges();
+ }
+ }
+
+ //-------------------------------------------
+ /** @todo document me.
+ */
+ private XNameAccess openConfig(XMultiServiceFactory xSMGR,
+ String sConfigPath ,
+ boolean bReadOnly )
+ throws java.lang.Exception
+ {
+ XMultiServiceFactory xConfigRoot = (XMultiServiceFactory)UnoRuntime.queryInterface(
+ XMultiServiceFactory.class,
+ xSMGR.createInstance("com.sun.star.configuration.ConfigurationProvider"));
+
+ PropertyValue[] lParams = new PropertyValue[2];
+ lParams[0] = new PropertyValue();
+ lParams[0].Name = "nodepath";
+ lParams[0].Value = sConfigPath;
+
+ lParams[1] = new PropertyValue();
+ lParams[1].Name = "locale";
+ lParams[1].Value = "*";
+
+ Object aConfig;
+ if (bReadOnly)
+ aConfig = xConfigRoot.createInstanceWithArguments(
+ "com.sun.star.configuration.ConfigurationAccess",
+ lParams);
+ else
+ aConfig = xConfigRoot.createInstanceWithArguments(
+ "com.sun.star.configuration.ConfigurationUpdateAccess",
+ lParams);
+
+ XNameAccess xConfig = (XNameAccess)UnoRuntime.queryInterface(
+ XNameAccess.class,
+ aConfig);
+
+ if (xConfig == null)
+ throw new com.sun.star.uno.Exception("Could not open configuration \"" + sConfigPath + "\"");
+
+ return xConfig;
+ }
+}
diff --git a/framework/qa/complex/accelerators/helper/KeyMapping.java b/framework/qa/complex/accelerators/helper/KeyMapping.java
new file mode 100644
index 000000000000..b0628e3cc7fd
--- /dev/null
+++ b/framework/qa/complex/accelerators/helper/KeyMapping.java
@@ -0,0 +1,168 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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 complex.accelerators;
+
+import java.util.HashMap;
+
+class KeyIdentifierInfo
+{
+ protected String sIdentifier;
+ protected Short nCode;
+
+ KeyIdentifierInfo(String sID, Short nC)
+ {
+ sIdentifier = sID;
+ nCode = nC;
+ }
+}
+
+class IdentifierHashMap extends HashMap
+{
+ public void put(String sIdentifier, Short nCode)
+ {
+ super.put(sIdentifier, nCode);
+ }
+ public Short get(String sIdentifier)
+ {
+ return (Short)super.get(sIdentifier);
+ }
+}
+
+class CodeHashMap extends HashMap
+{
+ public void put(Short nCode, String sIdentifier)
+ {
+ super.put(nCode, sIdentifier);
+ }
+ public String get(Short nCode)
+ {
+ return (String)super.get(nCode);
+ }
+}
+
+public class KeyMapping
+{
+ private IdentifierHashMap aIdentifierHashMap;
+ private CodeHashMap aCodeHashMap;
+
+ KeyMapping()
+ {
+ KeyIdentifierInfo[] aInfoMap = {
+ new KeyIdentifierInfo("0", new Short(com.sun.star.awt.Key.NUM0)),
+ new KeyIdentifierInfo("1", new Short(com.sun.star.awt.Key.NUM1)),
+ new KeyIdentifierInfo("2", new Short(com.sun.star.awt.Key.NUM2)),
+ new KeyIdentifierInfo("3", new Short(com.sun.star.awt.Key.NUM3)),
+ new KeyIdentifierInfo("4", new Short(com.sun.star.awt.Key.NUM4)),
+ new KeyIdentifierInfo("5", new Short(com.sun.star.awt.Key.NUM5)),
+ new KeyIdentifierInfo("6", new Short(com.sun.star.awt.Key.NUM6)),
+ new KeyIdentifierInfo("7", new Short(com.sun.star.awt.Key.NUM7)),
+ new KeyIdentifierInfo("8", new Short(com.sun.star.awt.Key.NUM8)),
+ new KeyIdentifierInfo("9", new Short(com.sun.star.awt.Key.NUM9)),
+ new KeyIdentifierInfo("A", new Short(com.sun.star.awt.Key.A)),
+ new KeyIdentifierInfo("B", new Short(com.sun.star.awt.Key.B)),
+ new KeyIdentifierInfo("C", new Short(com.sun.star.awt.Key.C)),
+ new KeyIdentifierInfo("D", new Short(com.sun.star.awt.Key.D)),
+ new KeyIdentifierInfo("E", new Short(com.sun.star.awt.Key.E)),
+ new KeyIdentifierInfo("F", new Short(com.sun.star.awt.Key.F)),
+ new KeyIdentifierInfo("G", new Short(com.sun.star.awt.Key.G)),
+ new KeyIdentifierInfo("H", new Short(com.sun.star.awt.Key.H)),
+ new KeyIdentifierInfo("I", new Short(com.sun.star.awt.Key.I)),
+ new KeyIdentifierInfo("J", new Short(com.sun.star.awt.Key.J)),
+ new KeyIdentifierInfo("K", new Short(com.sun.star.awt.Key.K)),
+ new KeyIdentifierInfo("L", new Short(com.sun.star.awt.Key.L)),
+ new KeyIdentifierInfo("M", new Short(com.sun.star.awt.Key.M)),
+ new KeyIdentifierInfo("N", new Short(com.sun.star.awt.Key.N)),
+ new KeyIdentifierInfo("O", new Short(com.sun.star.awt.Key.O)),
+ new KeyIdentifierInfo("P", new Short(com.sun.star.awt.Key.P)),
+ new KeyIdentifierInfo("Q", new Short(com.sun.star.awt.Key.Q)),
+ new KeyIdentifierInfo("R", new Short(com.sun.star.awt.Key.R)),
+ new KeyIdentifierInfo("S", new Short(com.sun.star.awt.Key.S)),
+ new KeyIdentifierInfo("T", new Short(com.sun.star.awt.Key.T)),
+ new KeyIdentifierInfo("U", new Short(com.sun.star.awt.Key.U)),
+ new KeyIdentifierInfo("V", new Short(com.sun.star.awt.Key.V)),
+ new KeyIdentifierInfo("W", new Short(com.sun.star.awt.Key.W)),
+ new KeyIdentifierInfo("X", new Short(com.sun.star.awt.Key.X)),
+ new KeyIdentifierInfo("Y", new Short(com.sun.star.awt.Key.Y)),
+ new KeyIdentifierInfo("Z", new Short(com.sun.star.awt.Key.Z)),
+ new KeyIdentifierInfo("F1", new Short(com.sun.star.awt.Key.F1)),
+ new KeyIdentifierInfo("F2", new Short(com.sun.star.awt.Key.F2)),
+ new KeyIdentifierInfo("F3", new Short(com.sun.star.awt.Key.F3)),
+ new KeyIdentifierInfo("F4", new Short(com.sun.star.awt.Key.F4)),
+ new KeyIdentifierInfo("F5", new Short(com.sun.star.awt.Key.F5)),
+ new KeyIdentifierInfo("F6", new Short(com.sun.star.awt.Key.F6)),
+ new KeyIdentifierInfo("F7", new Short(com.sun.star.awt.Key.F7)),
+ new KeyIdentifierInfo("F8", new Short(com.sun.star.awt.Key.F8)),
+ new KeyIdentifierInfo("F9", new Short(com.sun.star.awt.Key.F9)),
+ new KeyIdentifierInfo("F10", new Short(com.sun.star.awt.Key.F10)),
+ new KeyIdentifierInfo("F11", new Short(com.sun.star.awt.Key.F11)),
+ new KeyIdentifierInfo("F12", new Short(com.sun.star.awt.Key.F12)),
+ new KeyIdentifierInfo("DOWN", new Short(com.sun.star.awt.Key.DOWN)),
+ new KeyIdentifierInfo("UP", new Short(com.sun.star.awt.Key.UP)),
+ new KeyIdentifierInfo("LEFT", new Short(com.sun.star.awt.Key.LEFT)),
+ new KeyIdentifierInfo("RIGHT", new Short(com.sun.star.awt.Key.RIGHT)),
+ new KeyIdentifierInfo("HOME", new Short(com.sun.star.awt.Key.HOME)),
+ new KeyIdentifierInfo("END", new Short(com.sun.star.awt.Key.END)),
+ new KeyIdentifierInfo("PAGEUP", new Short(com.sun.star.awt.Key.PAGEUP)),
+ new KeyIdentifierInfo("PAGEDOWN", new Short(com.sun.star.awt.Key.PAGEDOWN)),
+ new KeyIdentifierInfo("RETURN", new Short(com.sun.star.awt.Key.RETURN)),
+ new KeyIdentifierInfo("ESCAPE", new Short(com.sun.star.awt.Key.ESCAPE)),
+ new KeyIdentifierInfo("TAB", new Short(com.sun.star.awt.Key.TAB)),
+ new KeyIdentifierInfo("BACKSPACE", new Short(com.sun.star.awt.Key.BACKSPACE)),
+ new KeyIdentifierInfo("SPACE", new Short(com.sun.star.awt.Key.SPACE)),
+ new KeyIdentifierInfo("INSERT", new Short(com.sun.star.awt.Key.INSERT)),
+ new KeyIdentifierInfo("DELETE", new Short(com.sun.star.awt.Key.DELETE)),
+ new KeyIdentifierInfo("ADD", new Short(com.sun.star.awt.Key.ADD)),
+ new KeyIdentifierInfo("SUBTRACT", new Short(com.sun.star.awt.Key.SUBTRACT)),
+ new KeyIdentifierInfo("MULTIPLY", new Short(com.sun.star.awt.Key.MULTIPLY)),
+ new KeyIdentifierInfo("DIVIDE", new Short(com.sun.star.awt.Key.DIVIDE)),
+ new KeyIdentifierInfo("CUT", new Short(com.sun.star.awt.Key.CUT)),
+ new KeyIdentifierInfo("COPY", new Short(com.sun.star.awt.Key.COPY)),
+ new KeyIdentifierInfo("PASTE", new Short(com.sun.star.awt.Key.PASTE)),
+ new KeyIdentifierInfo("UNDO", new Short(com.sun.star.awt.Key.UNDO)),
+ new KeyIdentifierInfo("REPEAT", new Short(com.sun.star.awt.Key.REPEAT))
+ };
+
+ aIdentifierHashMap = new IdentifierHashMap();
+ aCodeHashMap = new CodeHashMap();
+ for (int i = 0; i<aInfoMap.length; i++)
+ {
+ aIdentifierHashMap.put(aInfoMap[i].sIdentifier, aInfoMap[i].nCode);
+ aCodeHashMap.put(aInfoMap[i].nCode, aInfoMap[i].sIdentifier);
+ }
+ }
+
+ public short mapIdentifier2Code(String sIdentifier)
+ {
+ return (aIdentifierHashMap.get(sIdentifier)).shortValue();
+ }
+
+ public String mapCode2Identifier(short nCode)
+ {
+ return (String)aCodeHashMap.get(new Short(nCode));
+ }
+}
diff --git a/framework/qa/complex/accelerators/helper/makefile.mk b/framework/qa/complex/accelerators/helper/makefile.mk
new file mode 100644
index 000000000000..a0d10f68811b
--- /dev/null
+++ b/framework/qa/complex/accelerators/helper/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 = ..$/..$/..$/..
+TARGET = AcceleratorsConfigurationTest
+PRJNAME = framework
+PACKAGE = complex$/accelerators$/helper
+
+# --- Settings -----------------------------------------------------
+.INCLUDE: settings.mk
+
+
+#----- compile .java files -----------------------------------------
+
+JARFILES = mysql.jar ridl.jar unoil.jar jurt.jar juh.jar jut.jar java_uno.jar \
+ Generator.jar OOoRunner.jar
+JAVAFILES = KeyMapping.java
+JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class)
+
+MAXLINELENGTH = 100000
+
+.INCLUDE : target.mk
diff --git a/framework/qa/complex/accelerators/makefile.mk b/framework/qa/complex/accelerators/makefile.mk
new file mode 100644
index 000000000000..3af496191d4f
--- /dev/null
+++ b/framework/qa/complex/accelerators/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 = ..$/..$/..
+TARGET = AcceleratorsConfigurationTest
+PRJNAME = $(TARGET)
+PACKAGE = complex$/accelerators
+
+# --- Settings -----------------------------------------------------
+.INCLUDE: settings.mk
+
+#----- compile .java files -----------------------------------------
+
+JARFILES = ridl.jar unoil.jar jurt.jar juh.jar jut.jar java_uno.jar \
+ OOoRunner.jar
+
+JAVAFILES = AcceleratorsConfigurationTest.java
+
+JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class)
+
+SUBDIRS=helper
+
+#----- make a jar from compiled files ------------------------------
+
+MAXLINELENGTH = 100000
+
+JARCLASSDIRS = $(PACKAGE)
+JARTARGET = $(TARGET).jar
+JARCOMPRESS = TRUE
+
+# --- Parameters for the test --------------------------------------
+
+# start an office if the parameter is set for the makefile
+.IF "$(OFFICE)" == ""
+CT_APPEXECCOMMAND =
+.ELSE
+CT_APPEXECCOMMAND = -AppExecutionCommand "$(OFFICE)$/soffice -accept=socket,host=localhost,port=8100;urp;"
+.ENDIF
+
+# test base is java complex
+CT_TESTBASE = -TestBase java_complex
+
+# test looks something like the.full.package.TestName
+CT_TEST = -o $(PACKAGE:s\$/\.\).$(JAVAFILES:b)
+
+# start the runner application
+CT_APP = org.openoffice.Runner
+
+# --- Targets ------------------------------------------------------
+
+#.IF "$(depend)" == ""
+#$(CLASSDIR)$/$(PACKAGE)$/$(JAVAFILES:b).props : ALLTAR
+#.ELSE
+#$(CLASSDIR)$/$(PACKAGE)$/$(JAVAFILES:b).props : ALLDEP
+#.ENDIF
+
+.INCLUDE : target.mk
+
+RUN: run
+
+run:
+ +java -cp $(CLASSPATH) $(CT_APP) $(CT_TESTBASE) $(CT_APPEXECCOMMAND) $(CT_TEST)
diff --git a/framework/qa/complex/api_internal/CheckAPI.java b/framework/qa/complex/api_internal/CheckAPI.java
new file mode 100755
index 000000000000..432182222eeb
--- /dev/null
+++ b/framework/qa/complex/api_internal/CheckAPI.java
@@ -0,0 +1,200 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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 name: as default, start with complex
+package complex.api_internal;
+
+// imports
+import complexlib.ComplexTestCase;
+import helper.OfficeProvider;
+import helper.ProcessHandler;
+import com.sun.star.task.XJob;
+import com.sun.star.beans.XPropertyAccess;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.beans.NamedValue;
+
+import java.io.PrintWriter;
+import java.util.Vector;
+import java.util.StringTokenizer;
+
+/**
+ * This test executes the API tests internally in StarOffice. Prerequiste is
+ * that a OOoRunner.jar is registered inseide of StarOffice. Adjust the joblist
+ * inside of the ChekAPI.props to determine which tetss will be executed.
+ */
+public class CheckAPI extends ComplexTestCase {
+
+ // The name of the tested service
+ private final String testName = "StarOfficeAPI";
+
+ /**
+ * Return all test methods.
+ * @return The test methods.
+ */
+ public String[] getTestMethodNames() {
+ return new String[]{"checkAPI"};
+ }
+
+ /**
+ * Execute the API tests inside of the Office. If the Office crashes, it
+ * will be restarted and the job will continue after the one that caused the crash.
+ */
+ public void checkAPI() {
+ log.println("Start with test");
+ // if test is idle for 5 minutes, assume that it hangs and kill it.
+ param.put("TimeOut", new Integer("300000"));
+/* AppProvider office = (AppProvider)dcl.getInstance("helper.OfficeProvider");
+ Object msf = office.getManager(param);
+ if (msf == null) {
+ failed("Could not connect an Office.");
+ }
+ param.put("ServiceFactory",msf); */
+ XMultiServiceFactory xMSF = (XMultiServiceFactory)param.getMSF();
+ Object oObj = null;
+ try {
+ oObj = xMSF.createInstance("org.openoffice.RunnerService");
+ }
+ catch(com.sun.star.uno.Exception e) {
+ failed("Could not create Instance of 'org.openoffice.RunnerService'");
+ }
+ if ( oObj == null ) {
+ failed("Cannot create 'org.openoffice.RunnerService'");
+ }
+ // get the parameters for the internal test
+ String paramList = (String)param.get("ParamList");
+ Vector p = new Vector();
+ StringTokenizer paramTokens = new StringTokenizer(paramList, " ");
+ while(paramTokens.hasMoreTokens()) {
+ p.add(paramTokens.nextToken());
+ }
+ int length = p.size()/2+1;
+ NamedValue[] internalParams = new NamedValue[length];
+ for (int i=0; i<length-1; i++) {
+ internalParams[i] = new NamedValue();
+ internalParams[i].Name = (String)p.get(i*2);
+ internalParams[i].Value = p.get(i*2+1);
+ log.println("Name: "+internalParams[i].Name);
+ log.println("Value: "+(String)internalParams[i].Value);
+ }
+
+ // do we have test jobs?
+ String testJob = (String)param.get("job");
+ PropertyValue[]props;
+ if (testJob==null) {
+ if ( param.get("job1")==null ) {
+ // get all test jobs from runner service
+ XPropertyAccess xPropAcc = (XPropertyAccess)UnoRuntime.queryInterface(XPropertyAccess.class, oObj);
+ props = xPropAcc.getPropertyValues();
+ }
+ else {
+ int index=1;
+ p = new Vector();
+ while ( param.get("job"+index) != null ) {
+ p.add(param.get("job"+index));
+ index++;
+ }
+ props = new PropertyValue[p.size()];
+ for ( int i=0; i<props.length; i++ ) {
+ props[i] = new PropertyValue();
+ props[i].Value = p.get(i);
+ }
+ }
+ }
+ else {
+ props = new PropertyValue[1];
+ props[0] = new PropertyValue();
+ props[0].Value = testJob;
+ }
+
+ log.println("Props length: "+ props.length);
+ for (int i=0; i<props.length; i++) {
+ XJob xJob = (XJob)UnoRuntime.queryInterface(XJob.class, oObj);
+ internalParams[length-1] = new NamedValue();
+ internalParams[length-1].Name = "-o";
+ internalParams[length-1].Value = props[i].Value;
+ log.println("Executing: " + (String)props[i].Value);
+
+ String erg = null;
+
+ try {
+ erg = (String)xJob.execute(internalParams);
+ }
+ catch(Throwable t) {
+ // restart and go on with test!!
+ t.printStackTrace((PrintWriter)log);
+ failed("Test run '" + (String)props[i].Value +"' could not be executed: Office crashed and is killed!", true);
+ xMSF = null;
+ ProcessHandler handler = (ProcessHandler)param.get("AppProvider");
+ handler.kill();
+ try {
+ Thread.sleep(10000);
+ }
+ catch(java.lang.InterruptedException e) {}
+ OfficeProvider op = new OfficeProvider();
+ // op.closeExistingOffice(param, true);
+ xMSF = (XMultiServiceFactory)op.getManager(param);
+ param.put("ServiceFactory",xMSF);
+ try {
+ oObj = xMSF.createInstance("org.openoffice.RunnerService");
+ }
+ catch(com.sun.star.uno.Exception e) {
+ failed("Could not create Instance of 'org.openoffice.RunnerService'");
+ }
+ }
+ log.println(erg);
+ String processedErg = parseResult(erg);
+ assure("Run '" + (String)props[i].Value + "' has result '" + processedErg + "'", processedErg == null, true);
+ }
+ }
+
+ private String parseResult(String erg) {
+ String lineFeed = System.getProperty("line.separator");
+ String processedErg = null;
+ if (erg != null) {
+ StringTokenizer token = new StringTokenizer(erg, lineFeed);
+ String previousLine = null;
+ while ( token.hasMoreTokens() ) {
+ String line = token.nextToken();
+ // got a failure!
+ if ( line.indexOf("FAILED") != -1 ) {
+ processedErg = (processedErg == null)?"":processedErg + ";";
+ processedErg += previousLine + ":" + line;
+ }
+ if ( line.startsWith("Execute:") ) {
+ previousLine = line;
+ }
+ else {
+ previousLine += " " + line;
+ }
+ }
+ }
+ return processedErg;
+ }
+}
+
+
diff --git a/framework/qa/complex/api_internal/CheckAPI.props b/framework/qa/complex/api_internal/CheckAPI.props
new file mode 100755
index 000000000000..14b01071d503
--- /dev/null
+++ b/framework/qa/complex/api_internal/CheckAPI.props
@@ -0,0 +1,4 @@
+ParamList=-OutProducer stats.SimpleFileOutProducer -OutputPath /dev/null
+#AppExecutionCommand=d:\\prj_new\\install\\src680_m17\\program\\soffice -norestore -nocrashreport -accept=socket,host=0,port=8100;urp;
+# the test job list
+job1=sw.SwXTextTable
diff --git a/framework/qa/complex/api_internal/api.lst b/framework/qa/complex/api_internal/api.lst
new file mode 100755
index 000000000000..bf4656231560
--- /dev/null
+++ b/framework/qa/complex/api_internal/api.lst
@@ -0,0 +1,325 @@
+job1=cached.CachedContentResultSetFactory
+job2=cached.CachedContentResultSetStubFactory
+job3=cached.CachedDynamicResultSetFactory
+job4=cached.CachedDynamicResultSetStubFactory
+job5=cmdmail.SimpleCommandMail
+job6=corereflection.uno.CoreReflection
+job7=dbaccess.DBContentLoader
+job8=dbaccess.OCommandDefinition
+job9=dbaccess.ODatabaseContext
+job10=dbaccess.ODatabaseSource
+job11=dbaccess.ODatasourceAdministrationDialog
+job12=dbaccess.OInteractionHandler
+job13=dbaccess.OQueryDesign
+job14=dbaccess.OSQLMessageDialog
+job15=dbaccess.SbaXGridControl
+job16=fileacc.SimpleFileAccess
+job17=fop.FolderPicker
+job18=forms.OButtonControl
+job19=forms.OCheckBoxControl
+job20=forms.OCheckBoxModel
+job21=forms.OComboBoxControl
+job22=forms.OComboBoxModel
+job23=forms.OCurrencyControl
+job24=forms.OCurrencyModel
+job25=forms.ODateControl
+job26=forms.ODateModel
+job27=forms.OEditControl
+job28=forms.OFileControlModel
+job29=forms.OFixedTextModel
+job30=forms.OFormattedControl
+job31=forms.OFormattedFieldWrapper
+job32=forms.OGroupBoxControl
+job33=forms.OGroupBoxModel
+job34=forms.OHiddenModel
+job35=forms.OImageButtonControl
+job36=forms.OImageButtonModel
+job37=forms.OImageControlControl
+job38=forms.OImageControlModel
+job39=forms.OListBoxControl
+job40=forms.OListBoxModel
+job41=forms.ONumericControl
+job42=forms.ONumericModel
+job43=forms.OPatternControl
+job44=forms.OPatternModel
+job45=forms.ORadioButtonControl
+job46=forms.ORadioButtonModel
+job47=forms.OTimeControl
+job48=forms.OTimeModel
+job49=fwk.MailToDispatcher
+job50=fwk.ServiceHandler
+job51=fwl.PathSettings
+job52=i18n.ChapterCollator
+job53=i18n.Collator
+job54=i18n.LocaleData
+job55=i18n.NumberFormatCodeMapper
+job56=i18n.TextSearch
+job57=implreg.uno.ImplementationRegistration
+job58=introspection.uno.Introspection
+job59=invocadapt.uno.InvocationAdapterFactory
+job60=invocation.uno.Invocation
+job61=javavm.uno.JavaVirtualMachine
+job62=lng.LinguProps
+job63=mcnttype.MimeContentTypeFactory
+job64=namingservice.uno.NamingService
+job65=nestedreg.uno.NestedRegistry
+job66=proxyfac.uno.ProxyFactory
+job67=proxyset.SOffice52ProxySettings
+job68=regtypeprov.uno.RegistryTypeDescriptionProvider
+job69=remotebridge.uno.various
+job70=sc.AccessibleEditableTextPara_HeaderFooter
+job71=sc.ScAccessibleCell
+job72=sc.ScAccessiblePageHeader
+job73=sc.ScAccessiblePreviewTable
+job74=sc.ScAccessibleSpreadsheet
+job75=sc.ScAnnotationObj
+job76=sc.ScAnnotationsObj
+job77=sc.ScAreaLinksObj
+job78=sc.ScAutoFormatFieldObj
+job79=sc.ScAutoFormatObj
+job80=sc.ScAutoFormatsObj
+job81=sc.ScCellFieldObj
+job82=sc.ScCellFieldsObj
+job83=sc.ScCellFormatsEnumeration
+job84=sc.ScCellFormatsObj
+job85=sc.ScCellSearchObj
+job86=sc.ScCellsEnumeration
+job87=sc.ScCellsObj
+job88=sc.ScDatabaseRangeObj
+job89=sc.ScDatabaseRangesObj
+job90=sc.ScDataPilotFieldObj
+job91=sc.ScDataPilotFieldsObj
+job92=sc.ScDataPilotTablesObj
+job93=sc.ScDDELinkObj
+job94=sc.ScDDELinksObj
+job95=sc.ScDrawPagesObj
+job96=sc.ScFilterDescriptorBase
+job97=sc.ScFunctionListObj
+job98=sc.ScHeaderFieldObj
+job99=sc.ScHeaderFieldsObj
+job100=sc.ScHeaderFooterContentObj
+job101=sc.ScIndexEnumeration_CellAnnotationsEnumeration
+job102=sc.ScIndexEnumeration_CellAreaLinksEnumeration
+job103=sc.ScIndexEnumeration_DatabaseRangesEnumeration
+job104=sc.ScIndexEnumeration_DataPilotFieldsEnumeration
+job105=sc.ScIndexEnumeration_DataPilotTablesEnumeration
+job106=sc.ScIndexEnumeration_DDELinksEnumeration
+job107=sc.ScIndexEnumeration_FunctionDescriptionEnumeration
+job108=sc.ScIndexEnumeration_LabelRangesEnumeration
+job109=sc.ScIndexEnumeration_NamedRangesEnumeration
+job110=sc.ScIndexEnumeration_ScenariosEnumeration
+job111=sc.ScIndexEnumeration_SheetCellRangesEnumeration
+job112=sc.ScIndexEnumeration_SheetLinksEnumeration
+job113=sc.ScIndexEnumeration_SpreadsheetsEnumeration
+job114=sc.ScIndexEnumeration_SpreadsheetViewPanesEnumeration
+job115=sc.ScIndexEnumeration_SubTotalFieldsEnumeration
+job116=sc.ScIndexEnumeration_TableAutoFormatEnumeration
+job117=sc.ScIndexEnumeration_TableChartsEnumeration
+job118=sc.ScIndexEnumeration_TableColumnsEnumeration
+job119=sc.ScIndexEnumeration_TableConditionalEntryEnumeration
+job120=sc.ScIndexEnumeration_TextFieldEnumeration
+job121=sc.ScLabelRangeObj
+job122=sc.ScLabelRangesObj
+job123=sc.ScNamedRangeObj
+job124=sc.ScRecentFunctionsObj
+job125=sc.ScScenariosObj
+job126=sc.ScSheetLinkObj
+job127=sc.ScSheetLinksObj
+job128=sc.ScSpreadsheetSettings
+job129=sc.ScSpreadsheetSettingsObj
+job130=sc.ScStyleFamiliesObj
+job131=sc.ScStyleFamilyObj
+job132=sc.ScStyleObj
+job133=sc.ScSubTotalFieldObj
+job134=sc.ScTableColumnObj
+job135=sc.ScTableColumnsObj
+job136=sc.ScTableConditionalEntry
+job137=sc.ScTableConditionalFormat
+job138=sc.ScTableRowObj
+job139=sc.ScTableValidationObj
+job140=sc.XMLContentExporter
+job141=sc.XMLContentImporter
+job142=sc.XMLImporter
+job143=sc.XMLMetaExporter
+job144=sc.XMLMetaImporter
+job145=sc.XMLSettingsExporter
+job146=sc.XMLSettingsImporter
+job147=sc.XMLStylesExporter
+job148=sc.XMLStylesImporter
+job149=sd.AccessibleDrawDocumentView
+job150=sd.AccessibleOutlineView
+job151=sd.AccessibleSlideView
+job152=sd.SdDocLinkTargets
+job153=sd.SdDrawPagesAccess
+job154=sd.SdLayer
+job155=sd.SdLayerManager
+job156=sd.SdMasterPagesAccess
+job157=sd.SdXCustomPresentation
+job158=sd.SdXPresentation
+job159=servicemgr.uno.OServiceManager
+job160=sfx.SfxMacroLoader
+job161=simplereg.uno.SimpleRegistry
+job162=sm.SmEditAccessible
+job163=sm.SmModel
+job164=sm.XMLExporter
+job165=sm.XMLMetaExporter
+job166=sm.XMLSettingsExporter
+job167=sm.XMLSettingsImporter
+job168=srtrs.SortedDynamicResultSetFactory
+job169=streams.uno.DataInputStream
+job170=streams.uno.DataOutputStream
+job171=streams.uno.MarkableInputStream
+job172=streams.uno.MarkableOutputStream
+job173=streams.uno.ObjectInputStream
+job174=streams.uno.ObjectOutputStream
+job175=streams.uno.Pipe
+job176=streams.uno.Pump
+job177=svtools.AccessibleBrowseBoxHeaderBar
+job178=svtools.AccessibleBrowseBoxHeaderCell
+job179=svtools.AccessibleBrowseBoxTable
+job180=svtools.AccessibleBrowseBoxTableCell
+job181=svtools.AccessibleTabBar
+job182=svtools.AccessibleTabBarPageList
+job183=svx.AccessibleControlShape
+job184=svx.AccessibleGraphicShape
+job185=svx.AccessiblePresentationGraphicShape
+job186=svx.AccessiblePresentationShape
+job187=svx.AccessibleShape
+job188=svx.SvxShapeCollection
+job189=svx.SvxUnoTextContent
+job190=svx.SvxUnoTextContentEnum
+job191=svx.SvxUnoTextField
+job192=svx.SvxUnoTextRangeEnumeration
+job193=sw.SwAccessibleDocumentPageView
+job194=sw.SwAccessibleDocumentView
+job195=sw.SwAccessibleEndnoteView
+job196=sw.SwAccessibleFooterView
+job197=sw.SwAccessibleFootnoteView
+job198=sw.SwAccessibleHeaderView
+job199=sw.SwAccessibleParagraphView
+job200=sw.SwAccessibleTableCellView
+job201=sw.SwAccessibleTextFrameView
+job202=sw.SwAccessibleTextGraphicObject
+job203=sw.SwXBodyText
+job204=sw.SwXBookmark
+job205=sw.SwXBookmarks
+job206=sw.SwXCell
+job207=sw.SwXDocumentIndexes
+job208=sw.SwXDocumentIndexMark
+job209=sw.SwXEndnoteProperties
+job210=sw.SwXFieldEnumeration
+job211=sw.SwXFieldMaster
+job212=sw.SwXFootnote
+job213=sw.SwXFootnoteProperties
+job214=sw.SwXFootnotes
+job215=sw.SwXFootnoteText
+job216=sw.SwXFrames
+job217=sw.SwXHeadFootText
+job218=sw.SwXLineNumberingProperties
+job219=sw.SwXModule
+job220=sw.SwXParagraphEnumeration
+job221=sw.SwXPrintSettings
+job222=sw.SwXPropertySet
+job223=sw.SwXPropertySetInfo
+job224=sw.SwXReferenceMark
+job225=sw.SwXReferenceMarks
+job226=sw.SwXStyle
+job227=sw.SwXStyleFamilies
+job228=sw.SwXStyleFamily
+job229=sw.SwXTableCellText
+job230=sw.SwXTableRows
+job231=sw.SwXTextColumns
+job232=sw.SwXTextDefaults
+job233=sw.SwXTextEmbeddedObjects
+job234=sw.SwXTextField
+job235=sw.SwXTextFieldMasters
+job236=sw.SwXTextFieldTypes
+job237=sw.SwXTextFrameText
+job238=sw.SwXTextGraphicObjects
+job239=sw.SwXTextPortionEnumeration
+job240=sw.SwXTextRanges
+job241=sw.SwXTextSearch
+job242=sw.SwXTextSection
+job243=sw.SwXTextSections
+job244=sw.SwXTextTableRow
+job245=sw.SwXTextTables
+job246=sw.SwXViewSettings
+job247=sw.XMLContentExporter
+job248=sw.XMLExporter
+job249=sw.XMLImporter
+job250=sw.XMLMetaExporter
+job251=sw.XMLSettingsExporter
+job252=sw.XMLSettingsImporter
+job253=sw.XMLStylesExporter
+job254=sysdtrans.SystemClipboard
+job255=syssh.SystemShellExecute
+job256=text.DefaultNumberingProvider
+job257=toolkit.AccessibleComboBox
+job258=toolkit.AccessibleList
+job259=toolkit.AccessibleListBox
+job260=toolkit.AccessibleMenuSeparator
+job261=toolkit.AccessibleStatusBar
+job262=toolkit.AccessibleTabControl
+job263=toolkit.AccessibleWindow
+job264=toolkit.TabControllerModel
+job265=toolkit.UnoControlCheckBox
+job266=toolkit.UnoControlCheckBoxModel
+job267=toolkit.UnoControlComboBox
+job268=toolkit.UnoControlComboBoxModel
+job269=toolkit.UnoControlContainerModel
+job270=toolkit.UnoControlCurrencyField
+job271=toolkit.UnoControlCurrencyFieldModel
+job272=toolkit.UnoControlDateField
+job273=toolkit.UnoControlDateFieldModel
+job274=toolkit.UnoControlEdit
+job275=toolkit.UnoControlEditModel
+job276=toolkit.UnoControlFileControlModel
+job277=toolkit.UnoControlFixedText
+job278=toolkit.UnoControlFixedTextModel
+job279=toolkit.UnoControlFormattedField
+job280=toolkit.UnoControlFormattedFieldModel
+job281=toolkit.UnoControlGroupBox
+job282=toolkit.UnoControlGroupBoxModel
+job283=toolkit.UnoControlImageControl
+job284=toolkit.UnoControlImageControlModel
+job285=toolkit.UnoControlListBox
+job286=toolkit.UnoControlListBoxModel
+job287=toolkit.UnoControlNumericFieldModel
+job288=toolkit.UnoControlPatternField
+job289=toolkit.UnoControlPatternFieldModel
+job290=toolkit.UnoControlProgressBarModel
+job291=toolkit.UnoControlRadioButton
+job292=toolkit.UnoControlRadioButtonModel
+job293=toolkit.UnoControlScrollBarModel
+job294=toolkit.UnoControlTimeField
+job295=toolkit.UnoControlTimeFieldModel
+job296=typeconverter.uno.TypeConverter
+job297=typemgr.uno.TypeDescriptionManager
+job298=ucb.UcbContentProviderProxyFactory
+job299=ucb.UcbPropertiesManager
+job300=ucb.UcbStore
+job301=ucb.UniversalContentBroker
+job302=ucpchelp.CHelpContentProvider
+job303=ucpdav.WebDAVContentProvider
+job304=ucpfile.FileProvider
+job305=ucpftp.FTPContentProvider
+job306=ucphier.HierarchyContentProvider
+job307=ucphier.HierarchyDataSource
+job308=ucppkg.PackageContentProvider
+job309=uui.UUIInteractionHandler
+job310=xmloff.Draw.XMLContentExporter
+job311=xmloff.Draw.XMLExporter
+job312=xmloff.Draw.XMLMetaExporter
+job313=xmloff.Draw.XMLSettingsExporter
+job314=xmloff.Draw.XMLSettingsImporter
+job315=xmloff.Draw.XMLStylesExporter
+job316=xmloff.Impress.XMLContentExporter
+job317=xmloff.Impress.XMLExporter
+job318=xmloff.Impress.XMLMetaExporter
+job319=xmloff.Impress.XMLSettingsExporter
+job320=xmloff.Impress.XMLSettingsImporter
+job321=xmloff.Impress.XMLStylesExporter
+job322=cfgmgr2.AdministrationProvider
+job323=cfgmgr2.ConfigurationProvider
+job324=cfgmgr2.ConfigurationProviderWrapper
+job325=cfgmgr2.OConfigurationRegistry
diff --git a/framework/qa/complex/api_internal/makefile.mk b/framework/qa/complex/api_internal/makefile.mk
new file mode 100755
index 000000000000..4d82ba2da689
--- /dev/null
+++ b/framework/qa/complex/api_internal/makefile.mk
@@ -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.
+#
+#*************************************************************************
+
+PRJ = ..$/..$/..
+TARGET = CheckAPI
+PRJNAME = $(TARGET)
+PACKAGE = complex$/api_internal
+
+# --- Settings -----------------------------------------------------
+.INCLUDE: settings.mk
+
+
+#----- compile .java files -----------------------------------------
+
+JARFILES = mysql.jar ridl.jar unoil.jar jurt.jar juh.jar java_uno.jar OOoRunner.jar mysql.jar
+JAVAFILES = CheckAPI.java
+JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class)
+
+#----- make a jar from compiled files ------------------------------
+
+MAXLINELENGTH = 100000
+
+JARCLASSDIRS = $(PACKAGE)
+JARTARGET = $(TARGET).jar
+JARCOMPRESS = TRUE
+
+# --- Parameters for the test --------------------------------------
+
+# start an office if the parameter is set for the makefile
+.IF "$(OFFICE)" == ""
+CT_APPEXECCOMMAND =
+.ELSE
+CT_APPEXECCOMMAND = -AppExecutionCommand "$(OFFICE)$/soffice -accept=socket,host=localhost,port=8100;urp;"
+.ENDIF
+
+# test base is java complex
+CT_TESTBASE = -TestBase java_complex
+
+# test looks something like the.full.package.TestName
+CT_TEST = -o $(PACKAGE:s\$/\.\).$(JAVAFILES:b)
+
+# start the runner application
+CT_APP = org.openoffice.Runner
+
+# --- Targets ------------------------------------------------------
+
+.IF "$(depend)" == ""
+ALL: ALLTAR $(CLASSDIR)$/$(PACKAGE)$/$(JAVAFILES:b).props
+.ELSE
+ALL: ALLDEP $(CLASSDIR)$/$(PACKAGE)$/$(JAVAFILES:b).props
+.ENDIF
+
+$(CLASSDIR)$/$(PACKAGE)$/$(JAVAFILES:b).props : $(JAVAFILES:b).props
+ cp $(JAVAFILES:b).props $(CLASSDIR)$/$(PACKAGE)$/$(JAVAFILES:b).props
+ jar uf $(CLASSDIR)$/$(JARTARGET) -C $(CLASSDIR) $(PACKAGE)$/$(JAVAFILES:b).props
+
+.INCLUDE : target.mk
+
+RUN:
+ +java -cp $(CLASSPATH) $(CT_APP) $(CT_APPEXECCOMMAND) $(CT_TESTBASE) $(CT_TEST)
+
+run: RUN
+
+
diff --git a/framework/qa/complex/api_internal/tests.sce b/framework/qa/complex/api_internal/tests.sce
new file mode 100755
index 000000000000..8458f33067ad
--- /dev/null
+++ b/framework/qa/complex/api_internal/tests.sce
@@ -0,0 +1,3 @@
+job1=cfgmgr2.AdministrationProvider
+job2=sc.ScIndexEnumeration_CellAnnotationsEnumeration
+job3=sw.SwXBodyText
diff --git a/framework/qa/complex/api_internal/worksforme.sce b/framework/qa/complex/api_internal/worksforme.sce
new file mode 100755
index 000000000000..f2d84859cc5e
--- /dev/null
+++ b/framework/qa/complex/api_internal/worksforme.sce
@@ -0,0 +1,39 @@
+job=cmdmail.SimpleCommandMail
+job=fileacc.SimpleFileAccess
+job=proxyset.SOffice52ProxySettings
+job=sc.ScCellFieldObj
+job=sc.ScCellFieldsObj
+job=sc.XMLImporter
+job=sc.XMLMetaExporter
+job=sd.SdDocLinkTargets
+job=sd.SdDrawPage
+job=sd.SdMasterPagesAccess
+job=sd.SdXCustomPresentation
+job=sd.SdXPresentation
+job=servicemgr.uno.OServiceManager
+job=sfx.SfxMacroLoader
+job=simplereg.uno.SimpleRegistry
+job=sm.XMLSettingsExporter
+job=sm.XMLSettingsImporter
+job=srtrs.SortedDynamicResultSetFactory
+job=svx.SvxShapeCollection
+job=svx.SvxUnoTextRangeEnumeration
+job=sw.SwXBodyText
+job=sw.XMLExporter
+job=sw.XMLImporter
+job=sw.XMLMetaExporter
+job=sw.XMLSettingsExporter
+job=sw.XMLSettingsImporter
+job=sw.XMLStylesExporter
+job=sysdtrans.SystemClipboard
+job=syssh.SystemShellExecute
+job=text.DefaultNumberingProvider
+job=toolkit.TabControllerModel
+job=toolkit.UnoControlCheckBox
+job=toolkit.UnoControlTimeField
+job=toolkit.UnoControlTimeFieldModel
+job=typeconverter.uno.TypeConverter
+job=typemgr.uno.TypeDescriptionManager
+job=ucb.UcbContentProviderProxyFactory
+job=ucb.UcbPropertiesManager
+job=ucb.UcbStore
diff --git a/framework/qa/complex/broken_document/LoadDocument.java b/framework/qa/complex/broken_document/LoadDocument.java
new file mode 100755
index 000000000000..5318b15bc1ea
--- /dev/null
+++ b/framework/qa/complex/broken_document/LoadDocument.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.
+ *
+ ************************************************************************/
+package complex.broken_document;
+
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.frame.FrameSearchFlag;
+import com.sun.star.frame.XComponentLoader;
+import com.sun.star.frame.XFrame;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.uno.UnoRuntime;
+import complexlib.ComplexTestCase;
+
+/**
+ * Check, if message boxes appear when the Office is in "headless" mode. Tests
+ * bug i15809. This test uses the broken document dbf.dbf.emf.
+ */
+public class LoadDocument extends ComplexTestCase {
+
+ /** defect file to load **/
+ private final String mFileName = "dbf.dbf.emf";
+
+ /**
+ * Get all test methods.
+ * @return The test methods.
+ */
+ public String[] getTestMethodNames() {
+ return new String[]{"checkHeadlessState"};
+ }
+
+ /**
+ * Start Office with "-headless" parameter, then
+ * load the broken document "dbf.dbf.emf", that brings a message box up in
+ * the ui, see if the headless mode of SOffice changes.
+ */
+ public void checkHeadlessState() {
+ XMultiServiceFactory xMSF = (XMultiServiceFactory)param.getMSF();
+ XFrame xDesktop = null;
+
+ try {
+ xDesktop = (XFrame)UnoRuntime.queryInterface(XFrame.class,
+ xMSF.createInstance("com.sun.star.frame.Desktop"));
+ }
+ catch(com.sun.star.uno.Exception e) {
+ failed("Could not create a desktop instance.");
+ }
+
+ XComponentLoader xDesktopLoader = (XComponentLoader)
+ UnoRuntime.queryInterface(XComponentLoader.class, xDesktop);
+ System.out.println("xDektopLoader is null: " + (xDesktopLoader == null));
+ PropertyValue[] val = new PropertyValue[0];
+
+ String workingDir = (String)param.get("WorkingDir") + System.getProperty("file.separator") + mFileName;
+ System.out.println("Working dir: " + workingDir);
+ String fileUrl = util.utils.getFullURL(workingDir);
+ System.out.println("File Url: " + fileUrl);
+
+ try {
+ xDesktopLoader.loadComponentFromURL(fileUrl, "_blank", 0, val);
+ }
+ catch(com.sun.star.io.IOException e) {
+ failed("Could not load document");
+ }
+ catch(com.sun.star.lang.IllegalArgumentException e) {
+ failed("Could not load document");
+ }
+
+ // try again: headless mode defect now?
+ try {
+ xDesktopLoader.loadComponentFromURL(fileUrl, "_blank", 0, val);
+ }
+ catch(com.sun.star.io.IOException e) {
+ failed("Could not load document");
+ }
+ catch(com.sun.star.lang.IllegalArgumentException e) {
+ failed("Could not load document");
+ }
+
+ }
+}
diff --git a/framework/qa/complex/broken_document/dbf.dbf.emf b/framework/qa/complex/broken_document/dbf.dbf.emf
new file mode 100755
index 000000000000..11e45e9df5d1
--- /dev/null
+++ b/framework/qa/complex/broken_document/dbf.dbf.emf
@@ -0,0 +1 @@
+ \ No newline at end of file
diff --git a/framework/qa/complex/broken_document/makefile.mk b/framework/qa/complex/broken_document/makefile.mk
new file mode 100755
index 000000000000..c8f24a937159
--- /dev/null
+++ b/framework/qa/complex/broken_document/makefile.mk
@@ -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.
+#
+#*************************************************************************
+
+PRJ = ..$/..$/..
+TARGET = CheckHeadlessState
+PRJNAME = $(TARGET)
+PACKAGE = complex$/broken_document
+
+# --- Settings -----------------------------------------------------
+.INCLUDE: settings.mk
+
+
+#----- compile .java files -----------------------------------------
+
+JARFILES = mysql.jar ridl.jar unoil.jar jurt.jar juh.jar java_uno.jar OOoRunner.jar
+JAVAFILES = LoadDocument.java
+JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class)
+
+#----- make a jar from compiled files ------------------------------
+
+MAXLINELENGTH = 100000
+
+JARCLASSDIRS = $(PACKAGE)
+JARTARGET = $(TARGET).jar
+JARCOMPRESS = TRUE
+
+# --- Parameters for the test --------------------------------------
+
+# start an office if the parameter is set for the makefile
+.IF "$(OFFICE)" == ""
+CT_APPEXECCOMMAND =
+.ELSE
+CT_APPEXECCOMMAND = -AppExecutionCommand "$(OFFICE)$/soffice -accept=socket,host=localhost,port=8100;urp;"
+.ENDIF
+
+# test base is java complex
+CT_TESTBASE = -TestBase java_complex
+
+# test looks something like the.full.package.TestName
+CT_TEST = -o $(PACKAGE:s\$/\.\).$(JAVAFILES:b)
+
+# start the runner application
+CT_APP = org.openoffice.Runner
+
+# the current directory for loading the document
+CT_WORKDIR = -WorkingDir $(PWD)
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+
+
+RUN:
+ +java -cp $(CLASSPATH) $(CT_APP) $(CT_APPEXECCOMMAND) $(CT_TESTBASE) $(CT_WORKDIR) $(CT_TEST)
+
+run: RUN
diff --git a/framework/qa/complex/contextMenuInterceptor/CheckContextMenuInterceptor.java b/framework/qa/complex/contextMenuInterceptor/CheckContextMenuInterceptor.java
new file mode 100644
index 000000000000..556cadc7d1b0
--- /dev/null
+++ b/framework/qa/complex/contextMenuInterceptor/CheckContextMenuInterceptor.java
@@ -0,0 +1,287 @@
+package contextMenuInterceptor;
+
+import com.sun.star.accessibility.AccessibleRole;
+import com.sun.star.accessibility.XAccessible;
+import com.sun.star.accessibility.XAccessibleComponent;
+import com.sun.star.accessibility.XAccessibleContext;
+import com.sun.star.awt.Point;
+import com.sun.star.awt.Rectangle;
+import com.sun.star.awt.XBitmap;
+import com.sun.star.awt.XExtendedToolkit;
+import com.sun.star.awt.XWindow;
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.beans.XPropertySetInfo;
+import com.sun.star.container.XIndexAccess;
+import com.sun.star.drawing.XShape;
+import com.sun.star.frame.XComponentLoader;
+import com.sun.star.frame.XController;
+import com.sun.star.frame.XDesktop;
+import com.sun.star.frame.XFrame;
+import com.sun.star.frame.XModel;
+import com.sun.star.lang.IndexOutOfBoundsException;
+import com.sun.star.lang.XComponent;
+import com.sun.star.lang.XInitialization;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.lang.XTypeProvider;
+import com.sun.star.text.XTextDocument;
+import com.sun.star.ui.XContextMenuInterceptor;
+import com.sun.star.ui.XContextMenuInterception;
+import com.sun.star.uno.AnyConverter;
+import com.sun.star.uno.Type;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XInterface;
+import com.sun.star.uno.Exception;
+import com.sun.star.util.CloseVetoException;
+import com.sun.star.util.XCloseable;
+import com.sun.star.view.XViewSettingsSupplier;
+import complexlib.ComplexTestCase;
+import java.awt.Robot;
+import java.awt.event.InputEvent;
+import java.io.PrintWriter;
+import share.LogWriter;
+import util.AccessibilityTools;
+import util.DesktopTools;
+import util.DrawTools;
+import util.SOfficeFactory;
+import util.utils;
+
+/**
+ *
+ */
+public class CheckContextMenuInterceptor extends ComplexTestCase {
+ XMultiServiceFactory xMSF = null;
+ XFrame xFrame = null;
+ Point point = null;
+ XWindow xWindow = null;
+
+ public void before() {
+ xMSF = (XMultiServiceFactory)param.getMSF();
+ }
+
+ public void after() {
+ log.println("release the popup menu");
+ try {
+ Robot rob = new Robot();
+ int x = point.X;
+ int y = point.Y;
+ rob.mouseMove(x, y);
+ rob.mousePress(InputEvent.BUTTON1_MASK);
+ rob.mouseRelease(InputEvent.BUTTON1_MASK);
+ } catch (java.awt.AWTException e) {
+ log.println("couldn't press mouse button");
+ }
+
+ com.sun.star.util.XCloseable xClose = (com.sun.star.util.XCloseable)UnoRuntime.queryInterface(
+ com.sun.star.util.XCloseable.class, xFrame);
+
+ try
+ {
+ xClose.close(false);
+ }
+ catch(com.sun.star.util.CloseVetoException exVeto)
+ {
+ failed("Test frame couldn't be closed successfully.");
+ }
+
+ xFrame = null;
+ }
+
+ public String[] getTestMethodNames() {
+ return new String[]{"checkContextMenuInterceptor"};
+ }
+
+ public void checkContextMenuInterceptor() {
+ log.println(" **** Context Menu Interceptor *** ");
+
+ try {
+ // intialize the test document
+ com.sun.star.lang.XComponent xDrawDoc = DrawTools.createDrawDoc(xMSF);
+
+ SOfficeFactory SOF = SOfficeFactory.getFactory( xMSF);
+ XShape oShape = SOF.createShape(xDrawDoc,5000,5000,1500,1000,"GraphicObject");
+ DrawTools.getShapes(DrawTools.getDrawPage(xDrawDoc,0)).add(oShape);
+
+ com.sun.star.frame.XModel xModel =
+ (com.sun.star.frame.XModel)UnoRuntime.queryInterface(
+ com.sun.star.frame.XModel.class, xDrawDoc);
+
+ // get the frame for later usage
+ xFrame = xModel.getCurrentController().getFrame();
+
+ // ensure that the document content is optimal visible
+ DesktopTools.zoomToEntirePage(xDrawDoc);
+
+ XBitmap xBitmap = null;
+
+ // adding graphic as ObjRelation for GraphicObjectShape
+ XPropertySet oShapeProps = (XPropertySet)
+ UnoRuntime.queryInterface(XPropertySet.class,oShape);
+ log.println( "Inserting a shape into the document");
+
+ try
+ {
+ oShapeProps.setPropertyValue(
+ "GraphicURL",util.utils.getFullTestURL("space-metal.jpg"));
+ xBitmap = (XBitmap) AnyConverter.toObject(
+ new Type(XBitmap.class),oShapeProps.getPropertyValue
+ ("GraphicObjectFillBitmap"));
+ } catch (com.sun.star.lang.WrappedTargetException e) {
+ } catch (com.sun.star.lang.IllegalArgumentException e) {
+ } catch (com.sun.star.beans.PropertyVetoException e) {
+ } catch (com.sun.star.beans.UnknownPropertyException e) {
+ }
+
+ // reuse the frame
+ com.sun.star.frame.XController xController = xFrame.getController();
+ com.sun.star.ui.XContextMenuInterception xContextMenuInterception = null;
+ com.sun.star.ui.XContextMenuInterceptor xContextMenuInterceptor = null;
+
+ if ( xController != null )
+ {
+ log.println( "Creating context menu interceptor");
+
+ // add our context menu interceptor
+ xContextMenuInterception =
+ (com.sun.star.ui.XContextMenuInterception)UnoRuntime.queryInterface(
+ com.sun.star.ui.XContextMenuInterception.class, xController );
+
+ if( xContextMenuInterception != null )
+ {
+ ContextMenuInterceptor aContextMenuInterceptor = new ContextMenuInterceptor( xBitmap );
+ xContextMenuInterceptor =
+ (com.sun.star.ui.XContextMenuInterceptor)UnoRuntime.queryInterface(
+ com.sun.star.ui.XContextMenuInterceptor.class, aContextMenuInterceptor );
+
+ log.println( "Register context menu interceptor");
+ xContextMenuInterception.registerContextMenuInterceptor( xContextMenuInterceptor );
+ }
+ }
+
+ // utils.shortWait(10000);
+
+ openContextMenu((XModel) UnoRuntime.queryInterface(XModel.class, xDrawDoc));
+
+ checkHelpEntry();
+
+ // remove our context menu interceptor
+ if ( xContextMenuInterception != null &&
+ xContextMenuInterceptor != null ) {
+ log.println( "Release context menu interceptor");
+ xContextMenuInterception.releaseContextMenuInterceptor(
+ xContextMenuInterceptor );
+ }
+ }
+ catch ( com.sun.star.uno.RuntimeException ex ) {
+ ex.printStackTrace((PrintWriter)log);
+ failed("Runtime exception caught!" + ex.getMessage());
+ }
+ catch ( java.lang.Exception ex ) {
+ ex.printStackTrace((PrintWriter)log);
+ failed("Java lang exception caught!" + ex.getMessage());
+ }
+ }
+
+ private void checkHelpEntry(){
+ XInterface toolkit = null;
+
+ log.println("get accesibility...");
+ try{
+ toolkit = (XInterface) xMSF.createInstance("com.sun.star.awt.Toolkit");
+ } catch (com.sun.star.uno.Exception e){
+ log.println("could not get Toolkit " + e.toString());
+ }
+ XExtendedToolkit tk = (XExtendedToolkit) UnoRuntime.queryInterface(
+ XExtendedToolkit.class, toolkit);
+
+ XAccessible xRoot = null;
+
+ AccessibilityTools at = new AccessibilityTools();
+
+ try {
+ xWindow = (XWindow) UnoRuntime.queryInterface(XWindow.class,
+ tk.getTopWindow(0));
+
+ xRoot = at.getAccessibleObject(xWindow);
+
+// at.printAccessibleTree((PrintWriter)log, xRoot, param.getBool(util.PropertyName.DEBUG_IS_ACTIVE));
+ at.printAccessibleTree((PrintWriter)log, xRoot, true);
+ }
+ catch (com.sun.star.lang.IndexOutOfBoundsException e)
+ {
+ log.println("Couldn't get Window");
+ }
+
+ XAccessibleContext oPopMenu = at.getAccessibleObjectForRole(xRoot, AccessibleRole.POPUP_MENU);
+
+ log.println("ImplementationName: " + util.utils.getImplName(oPopMenu));
+
+ XAccessible xHelp = null;
+ try{
+ log.println("Try to get first entry of context menu...");
+ xHelp = oPopMenu.getAccessibleChild(0);
+
+ } catch (IndexOutOfBoundsException e){
+ failed("Not possible to get first entry of context menu");
+ }
+
+ if (xHelp == null) failed("first entry of context menu is NULL");
+
+ XAccessibleContext xHelpCont = xHelp.getAccessibleContext();
+
+ if ( xHelpCont == null )
+ failed("No able to retrieve accessible context from first entry of context menu");
+
+ String aAccessibleName = xHelpCont.getAccessibleName();
+ if ( !aAccessibleName.equals( "Help" )) {
+ log.println("Accessible name found = "+aAccessibleName );
+ failed("First entry of context menu is not from context menu interceptor");
+ }
+
+ try
+ {
+ log.println("try to get first children of Help context...");
+ XAccessible xHelpChild = xHelpCont.getAccessibleChild(0);
+
+ } catch (IndexOutOfBoundsException e){
+ failed("not possible to get first children of Help context");
+ }
+
+ }
+
+ private void openContextMenu(XModel aModel){
+
+ log.println("try to open contex menu...");
+ AccessibilityTools at = new AccessibilityTools();
+
+ xWindow = at.getCurrentWindow(xMSF, aModel);
+
+ XAccessible xRoot = at.getAccessibleObject(xWindow);
+
+ XInterface oObj = at.getAccessibleObjectForRole(xRoot, AccessibleRole.PANEL);
+
+ XAccessibleComponent window = (XAccessibleComponent) UnoRuntime.queryInterface(
+ XAccessibleComponent.class, oObj);
+
+ point = window.getLocationOnScreen();
+ Rectangle rect = window.getBounds();
+
+ log.println("klick mouse button...");
+ try {
+ Robot rob = new Robot();
+ int x = point.X + (rect.Width / 2);
+ int y = point.Y + (rect.Height / 2);
+ rob.mouseMove(x, y);
+ System.out.println("Press Button");
+ rob.mousePress(InputEvent.BUTTON3_MASK);
+ System.out.println("Release Button");
+ rob.mouseRelease(InputEvent.BUTTON3_MASK);
+ System.out.println("done");
+ } catch (java.awt.AWTException e) {
+ log.println("couldn't press mouse button");
+ }
+
+ utils.shortWait(3000);
+
+ }
+}
diff --git a/framework/qa/complex/contextMenuInterceptor/ContextMenuInterceptor.java b/framework/qa/complex/contextMenuInterceptor/ContextMenuInterceptor.java
new file mode 100644
index 000000000000..cb0d95900c6f
--- /dev/null
+++ b/framework/qa/complex/contextMenuInterceptor/ContextMenuInterceptor.java
@@ -0,0 +1,130 @@
+package contextMenuInterceptor;
+
+import com.sun.star.ui.*;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.container.XIndexContainer;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.Exception;
+import com.sun.star.beans.UnknownPropertyException;
+import com.sun.star.lang.IllegalArgumentException;
+
+public class ContextMenuInterceptor implements XContextMenuInterceptor {
+
+ private com.sun.star.awt.XBitmap myBitmap;
+
+ public ContextMenuInterceptor( com.sun.star.awt.XBitmap aBitmap ) {
+ myBitmap = aBitmap;
+ }
+
+ 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
+ com.sun.star.container.XIndexContainer xContextMenu = aEvent.ActionTriggerContainer;
+ com.sun.star.lang.XMultiServiceFactory xMenuElementFactory =
+ (com.sun.star.lang.XMultiServiceFactory)UnoRuntime.queryInterface(
+ com.sun.star.lang.XMultiServiceFactory.class, xContextMenu );
+
+ if ( xMenuElementFactory != null )
+ {
+
+ // create root menu entry for sub menu and sub menu
+ com.sun.star.beans.XPropertySet xRootMenuEntry =
+ (XPropertySet)UnoRuntime.queryInterface(
+ com.sun.star.beans.XPropertySet.class,
+ xMenuElementFactory.createInstance("com.sun.star.ui.ActionTrigger" ));
+
+ // create a line separator for our new help sub menu
+ com.sun.star.beans.XPropertySet xSeparator =
+ (com.sun.star.beans.XPropertySet)UnoRuntime.queryInterface(
+ com.sun.star.beans.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
+ com.sun.star.container.XIndexContainer xSubMenuContainer =
+ (com.sun.star.container.XIndexContainer)UnoRuntime.queryInterface(
+ com.sun.star.container.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 );
+ xRootMenuEntry.setPropertyValue( "Image", myBitmap );
+
+ // 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 = (com.sun.star.beans.XPropertySet)UnoRuntime.queryInterface(
+ com.sun.star.beans.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 = (com.sun.star.beans.XPropertySet)UnoRuntime.queryInterface(
+ com.sun.star.beans.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 ( 0, (Object)xSeparator );
+
+ // add new sub menu into the given context menu
+ xContextMenu.insertByIndex ( 0, (Object)xRootMenuEntry );
+
+ // The controller should execute the modified context menu and stop notifying other
+ // interceptors.
+ return com.sun.star.ui.ContextMenuInterceptorAction.EXECUTE_MODIFIED ;
+ }
+ }
+ catch ( com.sun.star.beans.UnknownPropertyException ex )
+ {
+ // do something useful
+ // we used a unknown property
+ }
+ catch ( com.sun.star.lang.IndexOutOfBoundsException ex )
+ {
+ // do something useful
+ // we used an invalid index for accessing a container
+ }
+ catch ( com.sun.star.uno.Exception ex )
+ {
+ // something strange has happend!
+ }
+ catch ( java.lang.Throwable ex )
+ {
+ // catch java exceptions � do something useful
+ }
+
+ return com.sun.star.ui.ContextMenuInterceptorAction.IGNORED;
+ }
+}
diff --git a/framework/qa/complex/contextMenuInterceptor/makefile.mk b/framework/qa/complex/contextMenuInterceptor/makefile.mk
new file mode 100644
index 000000000000..f8dcaf26d208
--- /dev/null
+++ b/framework/qa/complex/contextMenuInterceptor/makefile.mk
@@ -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.
+#
+#*************************************************************************
+
+PRJ = ..$/..$/..
+TARGET = ContextMenuInterceptor
+PRJNAME = framework
+PACKAGE = contextMenuInterceptor
+
+# --- Settings -----------------------------------------------------
+.INCLUDE: settings.mk
+
+
+#----- compile .java files -----------------------------------------
+
+JARFILES = mysql.jar mysql.jar ridl.jar unoil.jar jurt.jar juh.jar java_uno.jar OOoRunner.jar
+JAVAFILES = ContextMenuInterceptor.java CheckContextMenuInterceptor.java
+JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class)
+
+#----- make a jar from compiled files ------------------------------
+
+MAXLINELENGTH = 100000
+
+JARCLASSDIRS = $(PACKAGE)
+JARTARGET = $(TARGET).jar
+JARCOMPRESS = TRUE
+
+# --- Parameters for the test --------------------------------------
+
+# start an office if the parameter is set for the makefile
+.IF "$(OFFICE)" == ""
+CT_APPEXECCOMMAND =
+.ELSE
+CT_APPEXECCOMMAND = -AppExecutionCommand \
+ "$(OFFICE)$/soffice -accept=socket,host=localhost,port=8100;urp;"
+.ENDIF
+
+# test base is java complex
+CT_TESTBASE = -TestBase java_complex
+
+# replace $/ with . in package name
+CT_PACKAGE = -o $(PACKAGE:s\$/\.\)
+
+# start the runner application
+CT_APP = org.openoffice.Runner
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+
+RUN: run
+
+run:
+ +java -cp $(CLASSPATH) $(CT_APP) $(CT_TESTBASE) $(CT_APPEXECCOMMAND) -tdoc \\margritte\qaapi\workspace\qadev\testdocs $(CT_PACKAGE).CheckContextMenuInterceptor
diff --git a/framework/qa/complex/desktop/DesktopTerminate.java b/framework/qa/complex/desktop/DesktopTerminate.java
new file mode 100755
index 000000000000..88cfa433aa31
--- /dev/null
+++ b/framework/qa/complex/desktop/DesktopTerminate.java
@@ -0,0 +1,158 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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 complex.desktop;
+
+
+import com.sun.star.lang.XServiceInfo;
+import com.sun.star.lang.XInitialization;
+import com.sun.star.uno.Type;
+import com.sun.star.uno.Any;
+import com.sun.star.lang.XTypeProvider;
+import com.sun.star.lang.XSingleServiceFactory;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.lang.XComponent;
+import com.sun.star.frame.XDesktop;
+import com.sun.star.frame.XFramesSupplier;
+import com.sun.star.frame.XFrames;
+import com.sun.star.registry.XRegistryKey;
+import com.sun.star.comp.loader.FactoryHelper;
+import com.sun.star.container.XIndexAccess;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.AnyConverter;
+import com.sun.star.frame.XComponentLoader;
+import com.sun.star.awt.Rectangle;
+import com.sun.star.util.XCloseable;
+import helper.ConfigurationRead;
+import complexlib.ComplexTestCase;
+import helper.OfficeProvider;
+//import complex.persistent_window_states.helper.DocumentHandle;
+
+/**
+ * Parameters:
+ * <ul>
+ * <li>NoOffice=yes - StarOffice is not started initially.</li>
+ * </ul>
+ */
+public class DesktopTerminate extends ComplexTestCase {
+
+ private XMultiServiceFactory xMSF;
+ private OfficeProvider oProvider;
+ private int iOfficeCloseTime = 0;
+
+ /**
+ * A frunction to tell the framework, which test functions are available.
+ * Right now, it's only 'checkPersistentWindowState'.
+ * @return All test methods.
+ */
+ public String[] getTestMethodNames() {
+ return new String[]{"checkPersistentWindowState"};
+ }
+
+ /**
+ * Test if all available document types change the
+ * persistent Window Attributes
+ *
+ * The test follows basically these steps:
+ * - Create a configuration reader and a componentloader
+ * - Look for all document types in the configuration
+ * - Do for every doc type
+ * - start office
+ * - read configuration attibute settings
+ * - create a new document
+ * - resize the document and close it
+ * - close office
+ * - start office
+ * - read configuration attribute settings
+ * - create another new document
+ * - compare old settings with new ones: should be different
+ * - compare the document size with the resized document: should be equal
+ * - close office
+ * - Test finished
+ */
+ public void checkPersistentWindowState()
+ {
+ try {
+
+ log.println("Connect the first time.");
+ log.println("AppExecCommand: " + (String)param.get("AppExecutionCommand"));
+ log.println("ConnString: " + (String)param.get("ConnectionString"));
+ oProvider = new OfficeProvider();
+ iOfficeCloseTime = param.getInt("OfficeCloseTime");
+ if ( iOfficeCloseTime == 0 ) {
+ iOfficeCloseTime = 1000;
+ }
+
+ if (!connect()) return;
+
+ if (!disconnect()) return;
+ }
+ catch(Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ private boolean connect() {
+ try {
+ xMSF = (XMultiServiceFactory)oProvider.getManager(param);
+ try {
+ Thread.sleep(10000);
+ }
+ catch(java.lang.InterruptedException e) {}
+ }
+ catch (java.lang.Exception e) {
+ log.println(e.getClass().getName());
+ log.println("Message: " + e.getMessage());
+ failed("Cannot connect the Office.");
+ return false;
+ }
+ return true;
+ }
+
+ private boolean disconnect() {
+ try {
+ XDesktop desk = null;
+ desk = (XDesktop) UnoRuntime.queryInterface(
+ XDesktop.class, xMSF.createInstance(
+ "com.sun.star.frame.Desktop"));
+ desk.terminate();
+ log.println("Waiting " + iOfficeCloseTime + " milliseconds for the Office to close down");
+ try {
+ Thread.sleep(iOfficeCloseTime);
+ }
+ catch(java.lang.InterruptedException e) {}
+ xMSF = null;
+ }
+ catch (java.lang.Exception e) {
+ e.printStackTrace();
+ failed("Cannot dispose the Office.");
+ return false;
+ }
+ return true;
+ }
+
+}
diff --git a/framework/qa/complex/desktop/makefile.mk b/framework/qa/complex/desktop/makefile.mk
new file mode 100755
index 000000000000..3ad4801eb0d5
--- /dev/null
+++ b/framework/qa/complex/desktop/makefile.mk
@@ -0,0 +1,79 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General 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 = ..$/..$/..
+TARGET = DesktopTerminate
+PRJNAME = $(TARGET)
+PACKAGE = complex$/desktop
+
+# --- Settings -----------------------------------------------------
+.INCLUDE: settings.mk
+
+
+#----- compile .java files -----------------------------------------
+
+JARFILES = mysql.jar ridl.jar unoil.jar jurt.jar juh.jar java_uno.jar OOoRunner.jar
+JAVAFILES = DesktopTerminate.java
+JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class)
+
+#----- make a jar from compiled files ------------------------------
+
+MAXLINELENGTH = 100000
+
+JARCLASSDIRS = $(PACKAGE)
+JARTARGET = $(TARGET).jar
+JARCOMPRESS = TRUE
+
+# --- Parameters for the test --------------------------------------
+
+# start an office if the parameter is set for the makefile
+.IF "$(OFFICE)" == ""
+CT_APPEXECCOMMAND =
+.ELSE
+CT_APPEXECCOMMAND = -AppExecutionCommand "$(OFFICE)$/soffice -accept=socket,host=localhost,port=8100;urp;"
+.ENDIF
+
+# test base is java complex
+CT_TESTBASE = -TestBase java_complex
+
+# test looks something like the.full.package.TestName
+CT_TEST = -o $(PACKAGE:s\$/\.\).$(JAVAFILES:b)
+
+# start the runner application
+CT_APP = org.openoffice.Runner
+
+# --- Targets ------------------------------------------------------
+
+$(CLASSDIR)$/$(PACKAGE)$/$(JAVAFILES:b).props : ALLTAR
+
+.INCLUDE : target.mk
+
+RUN: run
+
+run:
+ +java -cp $(CLASSPATH) $(CT_APP) $(CT_APPEXECCOMMAND) -NoOffice yes $(CT_TESTBASE) $(CT_TEST)
+
diff --git a/framework/qa/complex/dispatches/checkdispatchapi.java b/framework/qa/complex/dispatches/checkdispatchapi.java
new file mode 100644
index 000000000000..518ec277ae53
--- /dev/null
+++ b/framework/qa/complex/dispatches/checkdispatchapi.java
@@ -0,0 +1,462 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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 complex.dispatches;
+
+import com.sun.star.frame.*;
+import com.sun.star.lang.*;
+import com.sun.star.util.*;
+import com.sun.star.beans.*;
+import com.sun.star.uno.*;
+
+import java.util.*;
+
+import complexlib.ComplexTestCase;
+
+import helper.*;
+
+//-----------------------------------------------
+/** @short Check the interface XDispatchInformationProvider
+
+ @descr Because there exists more then one implementation of a dispatch
+ object, we have to test all these implementations ...
+ */
+public class checkdispatchapi extends ComplexTestCase
+{
+ //-------------------------------------------
+ // some const
+
+ //-------------------------------------------
+ // member
+
+ /** points to the global uno service manager. */
+ private XMultiServiceFactory m_xMSF = null;
+ private connectivity.tools.HsqlDatabase db;
+
+ /** can be used to create new test frames. */
+ private XFrame m_xDesktop = null;
+
+ /** provides XDispatchInformationProvider interface. */
+ private XFrame m_xFrame = null;
+
+ //-------------------------------------------
+ // test environment
+
+ //-------------------------------------------
+ /** @short A function to tell the framework,
+ which test functions are available.
+
+ @return All test methods.
+ @todo Think about selection of tests from outside ...
+ */
+ public String[] getTestMethodNames()
+ {
+ return new String[]
+ {
+ "checkDispatchInfoOfWriter",
+ "checkDispatchInfoOfCalc",
+ "checkDispatchInfoOfDraw",
+ "checkDispatchInfoOfImpress",
+ "checkDispatchInfoOfMath",
+ "checkDispatchInfoOfChart",
+ "checkDispatchInfoOfBibliography",
+ "checkDispatchInfoOfQueryDesign",
+ "checkDispatchInfoOfTableDesign",
+ "checkDispatchInfoOfFormGridView",
+ "checkDispatchInfoOfDataSourceBrowser",
+ "checkDispatchInfoOfRelationDesign",
+ "checkDispatchInfoOfBasic",
+ "checkDispatchInfoOfStartModule",
+ "checkInterceptorLifeTime",
+ "checkInterception"
+ };
+ }
+
+ //-------------------------------------------
+ /** @short Create the environment for following tests.
+
+ @descr create an empty test frame, where we can load
+ different components inside.
+ */
+ public void before()
+ {
+ try
+ {
+ // get uno service manager from global test environment
+ m_xMSF = (XMultiServiceFactory)param.getMSF();
+
+ db = new connectivity.tools.HsqlDatabase(m_xMSF);
+
+ // create desktop
+ m_xDesktop = (XFrame)UnoRuntime.queryInterface(
+ XFrame.class,
+ m_xMSF.createInstance("com.sun.star.frame.Desktop"));
+
+ m_xFrame = impl_createNewFrame();
+ }
+ catch(java.lang.Throwable ex)
+ {
+ failed("Cant initialize test environment.");
+ }
+ }
+
+ //-------------------------------------------
+ /** @short close the environment.
+ */
+ public void after()
+ {
+ db.close();
+ impl_closeFrame(m_xFrame);
+ m_xFrame = null;
+ }
+
+ //-------------------------------------------
+ public void checkDispatchInfoOfWriter()
+ {
+ impl_checkDispatchInfoOfXXX("private:factory/swriter");
+ }
+
+ //-------------------------------------------
+ public void checkDispatchInfoOfCalc()
+ {
+ impl_checkDispatchInfoOfXXX("private:factory/scalc");
+ }
+
+ //-------------------------------------------
+ public void checkDispatchInfoOfDraw()
+ {
+ impl_checkDispatchInfoOfXXX("private:factory/sdraw");
+ }
+
+ //-------------------------------------------
+ public void checkDispatchInfoOfImpress()
+ {
+ impl_checkDispatchInfoOfXXX("private:factory/simpress");
+ }
+
+ //-------------------------------------------
+ public void checkDispatchInfoOfChart()
+ {
+ impl_checkDispatchInfoOfXXX("private:factory/schart");
+ }
+
+ //-------------------------------------------
+ public void checkDispatchInfoOfMath()
+ {
+ impl_checkDispatchInfoOfXXX("private:factory/smath");
+ }
+
+ //-------------------------------------------
+ public void checkDispatchInfoOfDataBase()
+ {
+ impl_checkDispatchInfoOfXXX("private:factory/sdatabase");
+ }
+
+ //-------------------------------------------
+ public void checkDispatchInfoOfBibliography()
+ {
+ impl_checkDispatchInfoOfXXX(".component:Bibliography/View1");
+ }
+
+ //-------------------------------------------
+ public void checkDispatchInfoOfQueryDesign()
+ {
+ callDatabaseDispatch(".component:DB/QueryDesign");
+ }
+
+ //-------------------------------------------
+ public void checkDispatchInfoOfTableDesign()
+ {
+ callDatabaseDispatch(".component:DB/TableDesign");
+ }
+
+ //-------------------------------------------
+ public void checkDispatchInfoOfFormGridView()
+ {
+ impl_checkDispatchInfoOfXXX(".component:DB/FormGridView");
+ }
+
+ //-------------------------------------------
+ public void checkDispatchInfoOfDataSourceBrowser()
+ {
+ impl_checkDispatchInfoOfXXX(".component:DB/DataSourceBrowser");
+ }
+
+ //-------------------------------------------
+ public void checkDispatchInfoOfRelationDesign()
+ {
+ callDatabaseDispatch(".component:DB/RelationDesign");
+ }
+ //-------------------------------------------
+ private void callDatabaseDispatch(String url)
+ {
+ try
+ {
+ final PropertyValue args = new PropertyValue();
+ args.Name = "ActiveConnection";
+ args.Value = (Object)db.defaultConnection();
+
+ XFrame xFrame = impl_createNewFrame();
+
+ impl_loadIntoFrame(xFrame, url, new PropertyValue[] { args });
+ impl_checkDispatchInfo(xFrame);
+ impl_closeFrame(xFrame);
+ } catch(java.lang.Exception e ) {
+ }
+ }
+
+ //-------------------------------------------
+ public void checkDispatchInfoOfBasic()
+ {
+ Object aComponent = impl_createUNOComponent("com.sun.star.script.BasicIDE");
+ impl_checkDispatchInfo(aComponent);
+ }
+
+ //-------------------------------------------
+ public void checkDispatchInfoOfStartModule()
+ {
+ Object aComponent = impl_createUNOComponent("com.sun.star.frame.StartModule");
+ impl_checkDispatchInfo(aComponent);
+ }
+
+ //-------------------------------------------
+ public void checkInterceptorLifeTime()
+ {
+ // Note: It's important for the following test, that aInterceptor will be hold alive by the uno reference
+ // xInterceptor. Otherwhise we cant check some internal states of aInterceptor at the end of this method, because
+ // it was already killed .-)
+
+ Interceptor aInterceptor = new Interceptor(log);
+ com.sun.star.frame.XDispatchProviderInterceptor xInterceptor = (com.sun.star.frame.XDispatchProviderInterceptor)UnoRuntime.queryInterface(
+ com.sun.star.frame.XDispatchProviderInterceptor.class,
+ aInterceptor);
+
+ com.sun.star.frame.XFrame xFrame = impl_createNewFrame();
+ com.sun.star.frame.XDispatchProviderInterception xInterception = (com.sun.star.frame.XDispatchProviderInterception)UnoRuntime.queryInterface(
+ com.sun.star.frame.XDispatchProviderInterception.class,
+ xFrame);
+
+ xInterception.registerDispatchProviderInterceptor(xInterceptor);
+ impl_closeFrame(xFrame);
+
+ int nRegCount = aInterceptor.getRegistrationCount();
+ boolean bIsRegistered = aInterceptor.isRegistered();
+
+ log.println("registration count = "+nRegCount );
+ log.println("is registered ? = "+bIsRegistered);
+
+ if (nRegCount < 1)
+ failed("Interceptor was never registered.");
+
+ if (bIsRegistered)
+ failed("Interceptor was not deregistered automaticly on closing the corresponding frame.");
+
+ log.println("Destruction of interception chain works as designed .-)");
+ }
+
+ //-------------------------------------------
+ public void checkInterception()
+ {
+ String [] lDisabledURLs = new String [1];
+ lDisabledURLs[0] = ".uno:Open";
+
+ log.println("create and initialize interceptor ...");
+ Interceptor aInterceptor = new Interceptor(log);
+ aInterceptor.setURLs4URLs4Blocking(lDisabledURLs);
+
+ com.sun.star.frame.XDispatchProviderInterceptor xInterceptor = (com.sun.star.frame.XDispatchProviderInterceptor)UnoRuntime.queryInterface(
+ com.sun.star.frame.XDispatchProviderInterceptor.class,
+ aInterceptor);
+
+ log.println("create and initialize frame ...");
+ com.sun.star.frame.XFrame xFrame = impl_createNewFrame();
+ impl_loadIntoFrame(xFrame, "private:factory/swriter", null);
+
+ com.sun.star.frame.XDispatchProviderInterception xInterception = (com.sun.star.frame.XDispatchProviderInterception)UnoRuntime.queryInterface(
+ com.sun.star.frame.XDispatchProviderInterception.class,
+ xFrame);
+
+ log.println("register interceptor ...");
+ xInterception.registerDispatchProviderInterceptor(xInterceptor);
+
+ log.println("deregister interceptor ...");
+ xInterception.releaseDispatchProviderInterceptor(xInterceptor);
+ }
+
+ //-------------------------------------------
+ private void impl_checkDispatchInfoOfXXX(String sXXX)
+ {
+ XFrame xFrame = impl_createNewFrame();
+ impl_loadIntoFrame(xFrame, sXXX,null);
+ impl_checkDispatchInfo(xFrame);
+ impl_closeFrame(xFrame);
+ }
+
+ //-------------------------------------------
+ /** @short load an URL into the current test frame.
+ */
+ private void impl_loadIntoFrame(XFrame xFrame, String sURL,PropertyValue args[])
+ {
+ XComponentLoader xLoader = (XComponentLoader)UnoRuntime.queryInterface(
+ XComponentLoader.class,
+ xFrame);
+ if (xLoader == null)
+ failed("Frame does not provide required interface XComponentLoader.");
+
+ XComponent xDoc = null;
+ try
+ {
+ xDoc = xLoader.loadComponentFromURL(sURL, "_self", 0, args);
+ }
+ catch(java.lang.Throwable ex)
+ {
+ xDoc = null;
+ }
+
+ if (xDoc == null)
+ failed("Could not load \""+sURL+"\".");
+ }
+
+ //-------------------------------------------
+ /** @short create an uno implementation directly.
+ */
+ private Object impl_createUNOComponent(String sName)
+ {
+ Object aComponent = null;
+ try
+ {
+ aComponent = m_xMSF.createInstance(sName);
+ }
+ catch(java.lang.Throwable ex)
+ {
+ aComponent = null;
+ }
+
+ if (aComponent == null)
+ failed("Could not create UNO component \""+sName+"\".");
+ return aComponent;
+ }
+
+ //-------------------------------------------
+ /** @short check the interface XDispatchInformationProvider
+ at the specified component.
+ */
+ private void impl_checkDispatchInfo(Object aComponent)
+ {
+ XDispatchInformationProvider xInfoProvider = (XDispatchInformationProvider)UnoRuntime.queryInterface(
+ XDispatchInformationProvider.class,
+ aComponent);
+ if (xInfoProvider == null)
+ {
+ // Warning
+ log.println("Warning:\tComponent does not provide the [optional!] interface XDispatchInformationProvider.");
+ return;
+ }
+
+ try
+ {
+ short[] lGroups = xInfoProvider.getSupportedCommandGroups();
+ int c1 = lGroups.length;
+ int i1 = 0;
+ for (i1=0; i1<c1; ++i1)
+ {
+ short nGroup = lGroups[i1];
+ DispatchInformation[] lInfos = xInfoProvider.getConfigurableDispatchInformation(nGroup);
+ int c2 = lInfos.length;
+ int i2 = 0;
+
+ // check for empty lists
+ // Warning
+ if (lInfos.length < 1)
+ log.println("Warning:\tCould not get any DispatchInformation for group ["+nGroup+"].");
+
+ // check for duplicates (and by the way, if the info item match the requested group)
+ HashMap aCheckMap = new HashMap(c2);
+ for (i2=0; i2<c2; ++i2)
+ {
+ DispatchInformation aInfo = lInfos[i2];
+ if (aInfo.GroupId != nGroup)
+ {
+ // Error
+ failed("At least one DispatchInformation item does not match the requested group.\n\trequested group=["+nGroup+
+ "] returned groupd=["+aInfo.GroupId+"] command=\""+aInfo.Command+"\"", true); // true => dont break this test
+ continue;
+ }
+
+ if (aCheckMap.containsKey(aInfo.Command))
+ {
+ // Error
+ failed("Found a duplicate item: group=["+aInfo.GroupId+"] command=\""+aInfo.Command+"\"", true); // true => dont break this test
+ continue;
+ }
+
+ aCheckMap.put(aInfo.Command, aInfo.Command);
+ log.println("\t["+aInfo.GroupId+"] \""+aInfo.Command+"\"");
+ }
+ }
+ }
+ catch(java.lang.Throwable ex)
+ {
+ failed("Exception caught during using XDispatchInformationProvider.");
+ ex.printStackTrace();
+ }
+ }
+
+ //-------------------------------------------
+ private synchronized com.sun.star.frame.XFrame impl_createNewFrame()
+ {
+ com.sun.star.frame.XFrame xFrame = null;
+
+ try
+ {
+ xFrame = m_xDesktop.findFrame("_blank", 0);
+ xFrame.getContainerWindow().setVisible(true);
+ }
+ catch(java.lang.Throwable ex)
+ {
+ failed("Could not create the frame instance.");
+ }
+
+ return xFrame;
+ }
+
+ //-------------------------------------------
+ private synchronized void impl_closeFrame(com.sun.star.frame.XFrame xFrame)
+ {
+ com.sun.star.util.XCloseable xClose = (com.sun.star.util.XCloseable)UnoRuntime.queryInterface(
+ com.sun.star.util.XCloseable.class,
+ xFrame);
+ try
+ {
+ xClose.close(false);
+ }
+ catch(com.sun.star.util.CloseVetoException exVeto)
+ {
+ failed("Test frame couldn't be closed successfully.");
+ }
+ }
+}
diff --git a/framework/qa/complex/dispatches/helper/Interceptor.java b/framework/qa/complex/dispatches/helper/Interceptor.java
new file mode 100644
index 000000000000..a5b6b25c69d5
--- /dev/null
+++ b/framework/qa/complex/dispatches/helper/Interceptor.java
@@ -0,0 +1,348 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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 complex.dispatches;
+
+// __________ Imports __________
+
+// structs, const, ...
+import com.sun.star.beans.PropertyValue;
+
+// exceptions
+import com.sun.star.uno.Exception;
+import com.sun.star.uno.RuntimeException;
+
+// interfaces
+import com.sun.star.frame.XDispatchProvider;
+import com.sun.star.frame.XDispatch;
+import com.sun.star.frame.XDispatchProviderInterceptor;
+import com.sun.star.frame.XDispatchProviderInterception;
+import com.sun.star.frame.XInterceptorInfo;
+
+// helper
+import com.sun.star.uno.UnoRuntime;
+import share.LogWriter;
+
+// others
+//import java.lang.*;
+
+// __________ Implementation __________
+
+/**
+ * implements a configurable interceptor for dispatch events.
+ */
+public class Interceptor implements com.sun.star.frame.XDispatchProvider,
+ com.sun.star.frame.XDispatch,
+ com.sun.star.frame.XDispatchProviderInterceptor,
+ com.sun.star.frame.XInterceptorInfo
+{
+ // ____________________
+
+ /** contains the list of interception URL schema's (wildcards are allowed there!)
+ supported by this interceptor. It can be set from outside.
+ If no external URLs are set, the default "*" is used instead.
+ That would have the same effect as if this implementation would not support the
+ interface XInterceptorInfo !
+ */
+ private String[] m_lURLs4InterceptionInfo = null;
+
+ // ____________________
+
+ /** These URL's will be blocked by this interceptor.
+ Can be set from outside. Every queryDispatch() for these
+ set of URL's will be answered with an empty dispatch object!
+ If no external URLs are set the default "*" is used instead.
+ So every incoming URL will be blocked .-)
+ */
+ private String[] m_lURLs4Blocking = null;
+
+ // ____________________
+
+ /** Every dispatch interceptor knows it's master and slave interceptor
+ of the dispatch chain. These values must be stupid handled .-)
+ They have to be set and reset in case the right interface methods are called.
+ Nothing more. It's not allowed to dispose() it.
+ The slave can be used inside queryDispatch() to forward requests,
+ which are not handled by this interceptor instance.
+ */
+ private com.sun.star.frame.XDispatchProvider m_xSlave = null;
+ private com.sun.star.frame.XDispatchProvider m_xMaster = null;
+
+ // ____________________
+
+ /** counts calls of setSlave...().
+ So the outside API test can use this value to know if this interceptor
+ was realy added to the interceptor chain of OOo.
+ */
+ private int m_nRegistrationCount = 0;
+
+ // ____________________
+
+ /** indicates if this interceptor object is currently part of the interceptor
+ chain of OOo. Only true if a valid slave or master dispatch is set on this
+ instance.
+ */
+ private boolean m_bIsRegistered = false;
+
+ // ____________________
+
+ /** used for log output.
+ */
+ private LogWriter m_aLog;
+
+ // ____________________
+
+ /** ctor
+ * It's initialize an object of this class with default values.
+ */
+ public Interceptor(LogWriter aLog)
+ {
+ m_aLog = aLog;
+ }
+
+ // ____________________
+
+ /** XInterceptorInfo */
+ public synchronized String[] getInterceptedURLs()
+ {
+ return impl_getURLs4InterceptionInfo();
+ }
+
+ // ____________________
+
+ /** XDispatchProviderInterceptor */
+ public synchronized com.sun.star.frame.XDispatchProvider getSlaveDispatchProvider()
+ {
+ m_aLog.println("Interceptor.getSlaveDispatchProvider() called");
+ return m_xSlave;
+ }
+
+ // ____________________
+
+ /** XDispatchProviderInterceptor */
+ public synchronized com.sun.star.frame.XDispatchProvider getMasterDispatchProvider()
+ {
+ m_aLog.println("Interceptor.getMasterDispatchProvider() called");
+ return m_xMaster;
+ }
+
+ // ____________________
+
+ /** XDispatchProviderInterceptor */
+ public synchronized void setSlaveDispatchProvider(com.sun.star.frame.XDispatchProvider xSlave)
+ {
+ m_aLog.println("Interceptor.setSlaveDispatchProvider("+xSlave+") called");
+
+ if (xSlave != null)
+ {
+ ++m_nRegistrationCount;
+ m_bIsRegistered = true;
+ }
+ else
+ m_bIsRegistered = false;
+
+ m_xSlave = xSlave;
+ }
+
+ // ____________________
+
+ /** XDispatchProviderInterceptor */
+ public synchronized void setMasterDispatchProvider(com.sun.star.frame.XDispatchProvider xMaster)
+ {
+ m_aLog.println("Interceptor.setMasterDispatchProvider("+xMaster+") called");
+ m_xMaster = xMaster;
+ }
+
+ // ____________________
+
+ /** XDispatchProvider
+ */
+ public synchronized com.sun.star.frame.XDispatch queryDispatch(com.sun.star.util.URL aURL ,
+ String sTargetFrameName,
+ int nSearchFlags )
+ {
+ m_aLog.println("Interceptor.queryDispatch('"+aURL.Complete+"', '"+sTargetFrameName+"', "+nSearchFlags+") called");
+
+ if (impl_isBlockedURL(aURL.Complete))
+ {
+ m_aLog.println("Interceptor.queryDispatch(): URL blocked => returns NULL");
+ return null;
+ }
+
+ if (m_xSlave != null)
+ {
+ m_aLog.println("Interceptor.queryDispatch(): ask slave ...");
+ return m_xSlave.queryDispatch(aURL, sTargetFrameName, nSearchFlags);
+ }
+
+ m_aLog.println("Interceptor.queryDispatch(): no idea => returns this");
+ return this;
+ }
+
+ // ____________________
+
+ /** XDispatchProvider
+ */
+ public com.sun.star.frame.XDispatch[] queryDispatches(com.sun.star.frame.DispatchDescriptor[] lRequests)
+ {
+ int i = 0;
+ int c = lRequests.length;
+
+ com.sun.star.frame.XDispatch[] lResults = new com.sun.star.frame.XDispatch[c];
+ for (i=0; i<c; ++i)
+ {
+ lResults[i] = queryDispatch(lRequests[i].FeatureURL ,
+ lRequests[i].FrameName ,
+ lRequests[i].SearchFlags);
+ }
+
+ return lResults;
+ }
+
+ // ____________________
+
+ /** XDispatch
+ */
+ public synchronized void dispatch(com.sun.star.util.URL aURL ,
+ com.sun.star.beans.PropertyValue[] lArguments)
+ {
+ m_aLog.println("Interceptor.dispatch('"+aURL.Complete+"') called");
+ }
+
+ // ____________________
+
+ /** XDispatch
+ */
+ public synchronized void addStatusListener(com.sun.star.frame.XStatusListener xListener,
+ com.sun.star.util.URL aURL )
+ {
+ m_aLog.println("Interceptor.addStatusListener(..., '"+aURL.Complete+"') called");
+ }
+
+ // ____________________
+
+ /** XDispatch
+ */
+ public synchronized void removeStatusListener(com.sun.star.frame.XStatusListener xListener,
+ com.sun.star.util.URL aURL )
+ {
+ m_aLog.println("Interceptor.removeStatusListener(..., '"+aURL.Complete+"') called");
+ }
+
+ // ____________________
+
+ public synchronized int getRegistrationCount()
+ {
+ return m_nRegistrationCount;
+ }
+
+ // ____________________
+
+ public synchronized boolean isRegistered()
+ {
+ return m_bIsRegistered;
+ }
+
+ // ____________________
+
+ /** set a new list of URL's, which should be used on registration time
+ (that's why it's neccessary to call this impl-method before the interceptor
+ is used at the OOo API!) to optimize the interception chain.
+ */
+ public synchronized void setURLs4InterceptionInfo(String[] lURLs)
+ {
+ m_lURLs4InterceptionInfo = lURLs;
+ }
+
+ // ____________________
+
+ /** set a new list of URL's, which should be blocked by this interceptor.
+ (that's why it's neccessary to call this impl-method before the interceptor
+ is used at the OOo API!)
+ */
+ public synchronized void setURLs4URLs4Blocking(String[] lURLs)
+ {
+ m_lURLs4Blocking = lURLs;
+ }
+
+ // ____________________
+
+ /** must be used internal to access the member m_lURLs4InterceptionInfo
+ - threadsafe
+ - and to make sure it's initialized on demand
+ */
+ private synchronized String[] impl_getURLs4InterceptionInfo()
+ {
+ if (m_lURLs4InterceptionInfo == null)
+ {
+ m_lURLs4InterceptionInfo = new String[1];
+ m_lURLs4InterceptionInfo[0] = "*";
+ }
+
+ return m_lURLs4InterceptionInfo;
+ }
+
+ // ____________________
+
+ /** must be used internal to access the member m_lURLs4Blocking
+ - threadsafe
+ - and to make sure it's initialized on demand
+ */
+ private synchronized String[] impl_getURLs4Blocking()
+ {
+ if (m_lURLs4Blocking == null)
+ {
+ m_lURLs4Blocking = new String[1];
+ m_lURLs4Blocking[0] = "*";
+ }
+
+ return m_lURLs4Blocking;
+ }
+
+ // ____________________
+ private boolean impl_isBlockedURL(String sURL)
+ {
+ String[] lBlockedURLs = impl_getURLs4Blocking();
+ int i = 0;
+ int c = lBlockedURLs.length;
+
+ for (i=0; i<c; ++i)
+ {
+ if (impl_match(sURL, lBlockedURLs[i]))
+ return true;
+ }
+
+ return false;
+ }
+
+ // ____________________
+
+ private boolean impl_match(String sVal1, String sVal2)
+ {
+ // TODO implement wildcard match
+ return (sVal1.equals(sVal2));
+ }
+}
diff --git a/framework/qa/complex/dispatches/helper/makefile.mk b/framework/qa/complex/dispatches/helper/makefile.mk
new file mode 100644
index 000000000000..be761c54fae4
--- /dev/null
+++ b/framework/qa/complex/dispatches/helper/makefile.mk
@@ -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.
+#
+#*************************************************************************
+PRJ = ..$/..$/..$/..
+TARGET = checkdispatchapi
+PRJNAME = framework
+PACKAGE = complex$/dispatches$/helper
+
+# --- Settings -----------------------------------------------------
+.INCLUDE: settings.mk
+
+
+#----- compile .java files -----------------------------------------
+
+JARFILES = mysql.jar ridl.jar unoil.jar jurt.jar juh.jar java_uno.jar \
+ Generator.jar OOoRunner.jar
+JAVAFILES = Interceptor.java
+JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class)
+
+MAXLINELENGTH = 100000
+
+.INCLUDE : target.mk
+
+
+
diff --git a/framework/qa/complex/dispatches/makefile.mk b/framework/qa/complex/dispatches/makefile.mk
new file mode 100644
index 000000000000..87eba000cf71
--- /dev/null
+++ b/framework/qa/complex/dispatches/makefile.mk
@@ -0,0 +1,92 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General 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 = ..$/..$/..
+TARGET = checkdispatchapi
+PRJNAME = framework
+PACKAGE = complex$/dispatches
+
+# --- Settings -----------------------------------------------------
+.INCLUDE: settings.mk
+
+
+#----- compile .java files -----------------------------------------
+
+JARFILES = mysql.jar ridl.jar unoil.jar jurt.jar juh.jar java_uno.jar \
+ OOoRunner.jar mysql.jar ConnectivityTools.jar
+JAVAFILES = checkdispatchapi.java
+
+JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class)
+
+SUBDIRS=helper
+
+#----- make a jar from compiled files ------------------------------
+
+MAXLINELENGTH = 100000
+
+JARCLASSDIRS = $(PACKAGE)
+JARTARGET = $(TARGET).jar
+JARCOMPRESS = TRUE
+
+# --- Parameters for the test --------------------------------------
+
+# start an office if the parameter is set for the makefile
+.IF "$(OFFICE)" == ""
+CT_APPEXECCOMMAND =
+.ELSE
+CT_APPEXECCOMMAND = -AppExecutionCommand "$(OFFICE)$/soffice -accept=socket,host=localhost,port=8100;urp;"
+.ENDIF
+
+# test base is java complex
+CT_TESTBASE = -TestBase java_complex
+
+# test looks something like the.full.package.TestName
+CT_TEST = -o $(PACKAGE:s\$/\.\).$(JAVAFILES:b)
+
+# start the runner application
+CT_APP = org.openoffice.Runner
+
+# --- Targets ------------------------------------------------------
+
+.IF "$(depend)" == ""
+$(CLASSDIR)$/$(PACKAGE)$/$(JAVAFILES:b).props : ALLTAR
+.ELSE
+$(CLASSDIR)$/$(PACKAGE)$/$(JAVAFILES:b).props : ALLDEP
+.ENDIF
+
+.INCLUDE : target.mk
+
+#$(CLASSDIR)$/$(PACKAGE)$/$(JAVAFILES:b).props : $(JAVAFILES:b).props
+# cp $(JAVAFILES:b).props $(CLASSDIR)$/$(PACKAGE)$/$(JAVAFILES:b).props
+# jar uf $(CLASSDIR)$/$(JARTARGET) -C $(CLASSDIR) $(PACKAGE)$/$(JAVAFILES:b).props
+
+RUN: run
+
+run:
+ +java -cp $(CLASSPATH) $(CT_APP) $(CT_TESTBASE) $(CT_APPEXECCOMMAND) $(CT_TEST)
+
+
+
diff --git a/framework/qa/complex/disposing/GetServiceWhileDisposingOffice.java b/framework/qa/complex/disposing/GetServiceWhileDisposingOffice.java
new file mode 100755
index 000000000000..89dea19e08b6
--- /dev/null
+++ b/framework/qa/complex/disposing/GetServiceWhileDisposingOffice.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 complex.disposing;
+
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.uno.UnoRuntime;
+import complexlib.ComplexTestCase;
+import com.sun.star.frame.XDesktop;
+
+/**
+ * This test is for bug110698. The Office is closed and is continually connected
+ * while it closes. This did let the Office freeze. Now when the Office is
+ * closed, the connection is refused.
+ */
+public class GetServiceWhileDisposingOffice extends ComplexTestCase {
+
+ public String[] getTestMethodNames() {
+ return new String[]{"checkServiceWhileDisposing"};
+ }
+
+ public void checkServiceWhileDisposing() {
+ XMultiServiceFactory xMSF = (XMultiServiceFactory)param.getMSF();
+ XDesktop xDesktop = null;
+
+ try {
+ xDesktop = (XDesktop)UnoRuntime.queryInterface(XDesktop.class,
+ xMSF.createInstance("com.sun.star.frame.Desktop"));
+ }
+ catch(com.sun.star.uno.Exception e) {
+ failed("Could not create a desktop instance.");
+ }
+ int step = 0;
+ try {
+ log.println("Start the termination of the Office.");
+ xDesktop.terminate();
+ for ( ; step<10000; step++ ) {
+ Object o = xMSF.createInstance("com.sun.star.frame.Desktop");
+ }
+ }
+ catch(com.sun.star.lang.DisposedException e) {
+ log.println("DisposedException in step: " + step);
+ e.printStackTrace();
+ }
+ catch(Exception e) {
+ e.printStackTrace();
+ failed(e.getMessage());
+ }
+
+ }
+}
diff --git a/framework/qa/complex/disposing/makefile.mk b/framework/qa/complex/disposing/makefile.mk
new file mode 100755
index 000000000000..dac80c08afa0
--- /dev/null
+++ b/framework/qa/complex/disposing/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 = ..$/..$/..
+TARGET = GetServiceWhileDisposingOffice
+PRJNAME = $(TARGET)
+PACKAGE = complex$/disposing
+
+# --- Settings -----------------------------------------------------
+.INCLUDE: settings.mk
+
+
+#----- compile .java files -----------------------------------------
+
+JARFILES = mysql.jar ridl.jar unoil.jar jurt.jar juh.jar java_uno.jar OOoRunner.jar
+JAVAFILES = $(TARGET).java
+JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class)
+
+#----- make a jar from compiled files ------------------------------
+
+MAXLINELENGTH = 100000
+
+JARCLASSDIRS = $(PACKAGE)
+JARTARGET = $(TARGET).jar
+JARCOMPRESS = TRUE
+
+# --- Parameters for the test --------------------------------------
+
+# start an office if the parameter is set for the makefile
+.IF "$(OFFICE)" == ""
+CT_APPEXECCOMMAND =
+.ELSE
+CT_APPEXECCOMMAND = -AppExecutionCommand "$(OFFICE)$/soffice -accept=socket,host=localhost,port=8100;urp;"
+.ENDIF
+
+# test base is java complex
+CT_TESTBASE = -TestBase java_complex
+
+# test looks something like the.full.package.TestName
+CT_TEST = -o $(PACKAGE:s\$/\.\).$(JAVAFILES:b)
+
+# start the runner application
+CT_APP = org.openoffice.Runner
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+
+RUN:
+ +java -cp $(CLASSPATH) $(CT_APP) $(CT_APPEXECCOMMAND) $(CT_TESTBASE) $(CT_TEST)
+
+run: RUN
diff --git a/framework/qa/complex/framework/autosave/AutoSave.java b/framework/qa/complex/framework/autosave/AutoSave.java
new file mode 100644
index 000000000000..015d9771be59
--- /dev/null
+++ b/framework/qa/complex/framework/autosave/AutoSave.java
@@ -0,0 +1,454 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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 complex.framework.autosave;
+
+import com.sun.star.frame.*;
+import com.sun.star.lang.*;
+import com.sun.star.util.*;
+import com.sun.star.beans.*;
+import com.sun.star.uno.*;
+import com.sun.star.sheet.*;
+import com.sun.star.table.*;
+
+import java.util.*;
+
+import complexlib.*;
+import helper.*;
+import util.*;
+
+//-----------------------------------------------
+/** @short Check some use cases of the AutoSave feature
+ */
+public class AutoSave extends ComplexTestCase
+{
+ //-------------------------------------------
+ class AutoSaveListener implements XStatusListener
+ {
+ private XDispatch m_xAutoSave;
+ private URL m_aRegistration;
+ private Protocol m_aLog;
+
+ public AutoSaveListener(XMultiServiceFactory xSMGR ,
+ XDispatch xAutoSave,
+ Protocol aLog )
+ {
+ m_aLog = aLog;
+ m_aLog.log(Protocol.TYPE_SCOPE_OPEN, "create listener for AutoSave notifications ...");
+
+ try
+ {
+ m_xAutoSave = xAutoSave;
+
+ XURLTransformer xParser = (XURLTransformer)UnoRuntime.queryInterface(
+ XURLTransformer.class,
+ xSMGR.createInstance("com.sun.star.util.URLTransformer"));
+ URL[] aURL = new URL[1];
+ aURL[0] = new URL();
+ aURL[0].Complete = "vnd.sun.star.autorecovery:/doAutoSave";
+ xParser.parseStrict(aURL);
+ m_aRegistration = aURL[0];
+
+ m_xAutoSave.addStatusListener(this, m_aRegistration);
+ m_aLog.log(Protocol.TYPE_INFO, "successfully registered as AutoSave listener.");
+ }
+ catch(Throwable ex)
+ {
+ m_aLog.log(ex);
+ }
+
+ m_aLog.log(Protocol.TYPE_SCOPE_CLOSE, "");
+ }
+
+ public void disableListener()
+ {
+ m_aLog.log(Protocol.TYPE_SCOPE_OPEN, "stop listening for AutoSave notifications ...");
+
+ XDispatch xAutoSave = null;
+ URL aRegURL = null;
+ synchronized (this)
+ {
+ xAutoSave = m_xAutoSave;
+ aRegURL = m_aRegistration;
+ }
+
+ try
+ {
+ if (
+ (xAutoSave != null) &&
+ (aRegURL != null)
+ )
+ xAutoSave.removeStatusListener(this, aRegURL);
+ }
+ catch(Throwable ex)
+ {
+ m_aLog.log(ex);
+ }
+
+ m_aLog.log(Protocol.TYPE_SCOPE_CLOSE, "");
+ }
+
+ public void statusChanged(FeatureStateEvent aEvent)
+ {
+ m_aLog.log(Protocol.TYPE_SCOPE_OPEN, "statusChanged() called from AutoSave ...");
+
+ m_aLog.log("FeatureURL = \""+aEvent.FeatureURL.Complete+"\"" );
+ m_aLog.log("FeatureDescriptor = \""+aEvent.FeatureDescriptor+"\"" );
+ m_aLog.log("IsEnabled = \""+aEvent.IsEnabled+"\"" );
+ m_aLog.log("Requery = \""+aEvent.Requery+"\"" );
+ m_aLog.log("State:" );
+ m_aLog.log(aEvent.State );
+
+ m_aLog.log(Protocol.TYPE_SCOPE_CLOSE, "");
+ }
+
+ public void disposing(com.sun.star.lang.EventObject aEvent)
+ {
+ m_aLog.log(Protocol.TYPE_INFO, "disposing() called from AutoSave.");
+ synchronized(this)
+ {
+ m_xAutoSave = null;
+ m_aRegistration = null;
+ }
+ }
+ }
+
+ //-------------------------------------------
+ // some const
+
+ //-------------------------------------------
+ // member
+
+ private Protocol m_aLog;
+
+ /** points to the global uno service manager. */
+ private XMultiServiceFactory m_xSMGR = null;
+
+ private SOfficeFactory m_aSOF;
+
+ /** can be used to trigger/enable/disable the AutoSave feature. */
+ private XDispatch m_xAutoSave = null;
+
+ /** a test document, which needs some time for saving to simulate concurrent
+ * save operations. */
+ private XStorable m_xTestDoc = null;
+
+ private XURLTransformer m_xURLParser = null;
+
+ //-------------------------------------------
+ // test environment
+
+ //-------------------------------------------
+ /** @short A function to tell the framework,
+ which test functions are available.
+
+ @return All test methods.
+ @todo Think about selection of tests from outside ...
+ */
+ public String[] getTestMethodNames()
+ {
+ return new String[]
+ {
+ "checkConcurrentAutoSaveToNormalUISave",
+ };
+ }
+
+ //-------------------------------------------
+ /** @short Create the environment for following tests.
+
+ @descr create an empty test frame, where we can load
+ different components inside.
+ */
+ public void before()
+ {
+ m_aLog = new Protocol(Protocol.MODE_HTML | Protocol.MODE_STDOUT, Protocol.FILTER_NONE, utils.getUsersTempDir() + "/complex_log_ascii_01.html");
+
+ try
+ {
+ // get uno service manager from global test environment
+ m_xSMGR = (XMultiServiceFactory)param.getMSF();
+
+ // get another helper to e.g. create test documents
+ m_aSOF = SOfficeFactory.getFactory(m_xSMGR);
+
+ // create AutoSave instance
+ m_xAutoSave = (XDispatch)UnoRuntime.queryInterface(
+ XDispatch.class,
+ m_xSMGR.createInstance("com.sun.star.comp.framework.AutoRecovery"));
+
+ // prepare AutoSave
+ // make sure it will be started every 1 min
+ ConfigHelper aConfig = new ConfigHelper(m_xSMGR, "org.openoffice.Office.Recovery", false);
+ aConfig.writeRelativeKey("AutoSave", "Enabled" , Boolean.TRUE );
+ aConfig.writeRelativeKey("AutoSave", "TimeIntervall", new Integer(1)); // 1 min
+ aConfig.flush();
+ aConfig = null;
+
+ // is needed to parse dispatch commands
+ m_xURLParser = (XURLTransformer)UnoRuntime.queryInterface(
+ XURLTransformer.class,
+ m_xSMGR.createInstance("com.sun.star.util.URLTransformer"));
+
+ }
+ catch(java.lang.Throwable ex)
+ {
+ m_aLog.log(ex);
+ failed("Couldn't create test environment");
+ }
+ }
+
+ //-------------------------------------------
+ /** @short close the environment.
+ */
+ public void after()
+ {
+ // ???
+ }
+
+ //-------------------------------------------
+ // create a calc document with content, which needs some time for saving
+ private XInterface createBigCalcDoc()
+ {
+ m_aLog.log(Protocol.TYPE_SCOPE_OPEN, "createBigCalcDoc() started ...");
+ try
+ {
+ m_aLog.log("Create empty calc document for testing.");
+ XSpreadsheetDocument xSheetDoc = m_aSOF.createCalcDoc("_default");
+ m_aLog.log("Retrieve first sheet from calc document.");
+ XSpreadsheets xSheets = xSheetDoc.getSheets();
+ XSpreadsheet xSheet = (XSpreadsheet)AnyConverter.toObject(
+ new Type(XSpreadsheet.class),
+ xSheets.getByName(
+ xSheets.getElementNames()[0]));
+ m_aLog.log("Fill two cells with value and formula.");
+ xSheet.getCellByPosition(0, 0).setValue(1);
+ xSheet.getCellByPosition(0, 1).setFormula("=a1+1");
+ m_aLog.log("Retrieve big range.");
+ XCellRange xRange = xSheet.getCellRangeByName("A1:Z9999");
+ XCellSeries xSeries = (XCellSeries)UnoRuntime.queryInterface(
+ XCellSeries.class,
+ xRange);
+ m_aLog.log("Duplicate cells from top to bottom inside range.");
+ xSeries.fillAuto(FillDirection.TO_BOTTOM, 2);
+ m_aLog.log("Duplicate cells from left to right inside range.");
+ xSeries.fillAuto(FillDirection.TO_RIGHT , 1);
+
+ m_aLog.log(Protocol.TYPE_SCOPE_CLOSE | Protocol.TYPE_OK, "createBigCalcDoc() finished.");
+ return xSheetDoc;
+ }
+ catch(Throwable ex)
+ {
+ m_aLog.log(ex);
+ }
+
+ m_aLog.log(Protocol.TYPE_SCOPE_CLOSE, "createBigCalcDoc() finished.");
+ return null;
+ }
+
+ //-------------------------------------------
+ private void saveDoc(XInterface xDoc,
+ String sURL)
+ {
+ m_aLog.log(Protocol.TYPE_SCOPE_OPEN, "saveDoc('"+sURL+"') started ...");
+ try
+ {
+ URL[] aURL = new URL[1];
+ aURL[0] = new URL();
+ aURL[0].Complete = ".uno:SaveAs";
+ m_xURLParser.parseStrict(aURL);
+
+ XModel xModel = (XModel)UnoRuntime.queryInterface(
+ XModel.class,
+ xDoc);
+ XDispatchProvider xProvider = (XDispatchProvider)UnoRuntime.queryInterface(
+ XDispatchProvider.class,
+ xModel.getCurrentController());
+ XDispatch xDispatch = xProvider.queryDispatch(aURL[0], "_self", 0);
+
+ PropertyValue[] lArgs = new PropertyValue[3];
+ lArgs[0] = new PropertyValue();
+ lArgs[0].Name = "URL";
+ lArgs[0].Value = sURL;
+ lArgs[1] = new PropertyValue();
+ lArgs[1].Name = "Overwrite";
+ lArgs[1].Value = Boolean.TRUE;
+ lArgs[2] = new PropertyValue();
+ lArgs[2].Name = "StoreTo";
+ lArgs[2].Value = Boolean.TRUE;
+
+ xDispatch.dispatch(aURL[0], lArgs);
+
+ m_aLog.log(Protocol.TYPE_OK, "saveDoc('"+sURL+"') = OK.");
+ }
+/*
+ catch(com.sun.star.io.IOException exIO)
+ {
+ m_aLog.log(Protocol.TYPE_WARNING , "got IOException on calling doc.store()." );
+ m_aLog.log(Protocol.TYPE_WARNING_INFO, "Please check the reason for that more in detail." );
+ m_aLog.log(Protocol.TYPE_WARNING_INFO, "A message like \"Concurrent save requests are not allowed.\" was intended and doesnt show an error!");
+ m_aLog.log(Protocol.TYPE_WARNING_INFO, "Message of the original exception:" );
+ m_aLog.log(Protocol.TYPE_WARNING_INFO, exIO.getMessage());
+ }
+*/
+ catch(Throwable ex)
+ {
+ m_aLog.log(ex);
+ }
+ m_aLog.log(Protocol.TYPE_SCOPE_CLOSE, "saveDoc('"+sURL+"') finished.");
+ }
+
+ //-------------------------------------------
+ private void closeDoc(XInterface xDoc)
+ {
+ m_aLog.log(Protocol.TYPE_SCOPE_OPEN, "closeDoc() started ...");
+
+ try
+ {
+ Random aRandom = new Random();
+ int nRetry = 5;
+ while(nRetry>0)
+ {
+ try
+ {
+ XCloseable xClose = (XCloseable)UnoRuntime.queryInterface(
+ XCloseable.class,
+ xDoc);
+ if (xClose != null)
+ {
+ xClose.close(false);
+ m_aLog.log(Protocol.TYPE_OK, "closeDoc() = OK.");
+ nRetry = 0;
+ }
+ else
+ m_aLog.log(Protocol.TYPE_ERROR, "closeDoc() = ERROR. Doc doesnt provide needed interface!");
+ }
+ catch(com.sun.star.util.CloseVetoException exVeto)
+ {
+ m_aLog.log(Protocol.TYPE_WARNING , "got CloseVetoException on calling doc.close()." );
+ m_aLog.log(Protocol.TYPE_WARNING_INFO, "Please check the reason for that more in detail." );
+ m_aLog.log(Protocol.TYPE_WARNING_INFO, "A message like \"Cant close while saving.\" was intended and doesnt show an error!");
+ m_aLog.log(Protocol.TYPE_WARNING_INFO, exVeto.getMessage());
+ }
+
+ if (nRetry > 0)
+ {
+ --nRetry;
+ long nWait = (long)aRandom.nextInt(30000); // 30 sec.
+ try
+ {
+ m_aLog.log(Protocol.TYPE_INFO, "sleep for "+nWait+" ms");
+ synchronized(this)
+ {
+ wait(nWait);
+ }
+ }
+ catch(Throwable ex)
+ {
+ m_aLog.log(Protocol.TYPE_WARNING , "got exception for wait() !?");
+ m_aLog.log(Protocol.TYPE_WARNING_INFO, ex.getMessage());
+ }
+ }
+ }
+ }
+ catch(Throwable ex)
+ {
+ m_aLog.log(ex);
+ }
+
+ m_aLog.log(Protocol.TYPE_SCOPE_CLOSE, "closeDoc() finished.");
+ }
+
+ class DocThread extends Thread
+ {
+ DocThread()
+ {}
+
+ public void run()
+ {
+ impl_checkConcurrentAutoSaveToNormalUISave();
+ }
+ }
+
+ //-------------------------------------------
+ /** @short check concurrent save requests to the same document
+ * at the same time.
+ *
+ * @descr First we simulate an UI save by dispatching the right URL
+ * to the document and at the same time we try to trigger an AutoSave
+ * from another thread. So these operations should be started at the same time.
+ * It should not crash. The AutoSave request must be postphoned.
+ */
+ public void checkConcurrentAutoSaveToNormalUISave()
+ {
+ m_aLog.log(Protocol.TYPE_TESTMARK , "AutoSave");
+ m_aLog.log(Protocol.TYPE_SCOPE_OPEN, "checkConcurrentAutoSaveToNormalUISave()");
+
+ AutoSaveListener xListener = new AutoSaveListener(m_xSMGR, m_xAutoSave, m_aLog);
+
+ try
+ {
+ DocThread aThread = new DocThread();
+ aThread.start();
+ aThread.join();
+ }
+ catch(Throwable ex)
+ {}
+
+ xListener.disableListener();
+
+ m_aLog.log(Protocol.TYPE_SCOPE_CLOSE, "checkConcurrentAutoSaveToNormalUISave()");
+ m_aLog.logStatistics();
+ }
+
+ public void impl_checkConcurrentAutoSaveToNormalUISave()
+ {
+ Random aRandom = new Random();
+
+ int i = 0;
+ int c = 5;
+ for (i=0; i<c; ++i)
+ {
+ XInterface xDoc = createBigCalcDoc();
+ try
+ {
+ long nWait = (long)aRandom.nextInt(120000);
+ m_aLog.log(Protocol.TYPE_INFO, "sleep for "+nWait+" ms");
+ synchronized(this)
+ {
+ wait(nWait);
+ }
+ }
+ catch(Throwable ex)
+ {
+ m_aLog.log(Protocol.TYPE_WARNING , "got exception for wait() !?");
+ m_aLog.log(Protocol.TYPE_WARNING_INFO, ex.getMessage());
+ }
+ saveDoc(xDoc, utils.getOfficeTemp(m_xSMGR) + "/test_calc.ods");
+ closeDoc(xDoc);
+ }
+ }
+}
diff --git a/framework/qa/complex/framework/autosave/ConfigHelper.java b/framework/qa/complex/framework/autosave/ConfigHelper.java
new file mode 100644
index 000000000000..3bc4683f4fb5
--- /dev/null
+++ b/framework/qa/complex/framework/autosave/ConfigHelper.java
@@ -0,0 +1,124 @@
+package complex.framework.autosave;
+
+import java.lang.*;
+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.*;
+
+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());
+ }
+ }
+
+ //-----------------------------------------------
+ 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();
+ }
+}
diff --git a/framework/qa/complex/framework/autosave/Protocol.java b/framework/qa/complex/framework/autosave/Protocol.java
new file mode 100644
index 000000000000..11f6c4eeeff3
--- /dev/null
+++ b/framework/qa/complex/framework/autosave/Protocol.java
@@ -0,0 +1,999 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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 complex.framework.autosave;
+
+// __________ Imports __________
+
+// structs, const, ...
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.bridge.XUnoUrlResolver;
+
+// exceptions
+import com.sun.star.container.NoSuchElementException;
+import com.sun.star.uno.Exception;
+import com.sun.star.uno.RuntimeException;
+import java.io.IOException;
+import java.lang.InterruptedException;
+import java.net.ConnectException;
+
+// interfaces
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.uno.Any;
+
+// helper
+import com.sun.star.uno.IBridge;
+import com.sun.star.uno.UnoRuntime;
+
+// others
+import javax.swing.*;
+import javax.swing.border.*;
+import java.awt.*;
+import java.lang.*;
+import java.io.*;
+import java.util.*;
+import java.sql.*;
+
+// __________ Implementation __________
+
+/**
+ * Implements a log mechanism to create a protocol of all steps of e.g. an api test
+ * It provides the possibility to write the logged meesages to a file and/or
+ * to stdout/stderr (if neccessary at the same time!).
+ *
+ * TODO
+ * - implement filter, which e.g. supress showing of INFO data
+ */
+public class Protocol extends JComponent
+{
+ // ____________________
+ /**
+ * Note: Following values can be combined - they are interpreted as flags.
+ *
+ * @const MODE_STDOUT messages are logged to stdout
+ * @const MODE_STDERR messages are logged to stderr
+ * @const MODE_ASCII messages are logged to an ascii file
+ * @const MODE_HTML messages are logged to a html file
+ *
+ * @const TYPE_SCOPE_OPEN open, mark or count a new scope for following log statements
+ * @const TYPE_SCOPE_CLOSE close, mark or count the current scope
+ * @const TYPE_TESTMARK it marks the beginning of a (sub)test, can be used for statistic purposes
+ * @const TYPE_OK this protocol line is marked as a OK message
+ * @const TYPE_ERROR this protocol line is marked as an error
+ * @const TYPE_WARNING this protocol line is marked as a warning
+ * @const TYPE_INFO this protocol line represent some debug data for analyzing
+ */
+ public static final int MODE_STDOUT = 1;
+ public static final int MODE_STDERR = 2;
+ public static final int MODE_ASCII = 4;
+ public static final int MODE_HTML = 8;
+
+ public static final int TYPE_OK = 1;
+ public static final int TYPE_ERROR = 2;
+ public static final int TYPE_WARNING = 4;
+ public static final int TYPE_INFO = 8;
+ public static final int TYPE_SCOPE_OPEN = 16;
+ public static final int TYPE_SCOPE_CLOSE = 32;
+ public static final int TYPE_TESTMARK = 64;
+ public static final int TYPE_ERROR_INFO = 128;
+ public static final int TYPE_WARNING_INFO = 256;
+ public static final int TYPE_STATISTIC = 512;
+ public static final int TYPE_LINK = 1024;
+
+ public static final int FILTER_NONE = 0;
+ public static final int FILTER_OK = TYPE_OK;
+ public static final int FILTER_ERROR = TYPE_ERROR;
+ public static final int FILTER_WARNING = TYPE_WARNING;
+ public static final int FILTER_INFO = TYPE_INFO;
+ public static final int FILTER_SCOPES = TYPE_SCOPE_OPEN | TYPE_SCOPE_CLOSE;
+ public static final int FILTER_TESTMARK = TYPE_TESTMARK;
+ public static final int FILTER_ERROR_INFO = TYPE_ERROR_INFO;
+ public static final int FILTER_WARNING_INFO = TYPE_WARNING_INFO;
+ public static final int FILTER_STATISTIC = TYPE_STATISTIC;
+ public static final int FILTER_LINK = TYPE_LINK;
+
+ // ____________________
+ /**
+ */
+ private static final int MARK_DIFF = 5;
+
+ private static final String BGCOLOR_LINECOL = "#95CC77";
+ private static final String FGCOLOR_LINECOL_NORMAL = "#ffffbd";
+ private static final String FGCOLOR_LINECOL_MARKED = "#000088";
+
+ private static final String BGCOLOR_STANDARD = "#ffffff";
+ private static final String FGCOLOR_STANDARD = "#000000";
+
+ private static final String BGCOLOR_SCOPE = "#eeeeee";
+ private static final String FGCOLOR_SCOPE = "#000000";
+
+ private static final String BGCOLOR_TIMESTAMP = "#e0e0e0";
+ private static final String FGCOLOR_TIMESTAMP = "#000000";
+
+ private static final String BGCOLOR_TESTMARK = "#0000ff";
+ private static final String FGCOLOR_TESTMARK = "#ffffff";
+
+ private static final String BGCOLOR_OK = "#88dd88";
+ private static final String FGCOLOR_OK = "#ffffff";
+
+ private static final String BGCOLOR_WARNING = "#ffff00";
+ private static final String FGCOLOR_WARNING = "#000000";
+
+ private static final String BGCOLOR_WARNING_INFO = "#ffffcc";
+ private static final String FGCOLOR_WARNING_INFO = "#000000";
+
+ private static final String BGCOLOR_ERROR = "#ff0000";
+ private static final String FGCOLOR_ERROR = "#ffff00";
+
+ private static final String BGCOLOR_ERROR_INFO = "#ffbbbb";
+ private static final String FGCOLOR_ERROR_INFO = "#000000";
+
+ private static final String BGCOLOR_INFO = "#eeeeee";
+ private static final String FGCOLOR_INFO = "#000000";
+
+ private static final String BGCOLOR_STATISTIC = "#0000ff";
+ private static final String FGCOLOR_STATISTIC = "#ffffff";
+
+ private static final String BGCOLOR_LINK = BGCOLOR_INFO;
+ private static final String FGCOLOR_LINK = FGCOLOR_INFO;
+
+ // ____________________
+ /**
+ * @member m_nMode the mode, in which this protocol object runs
+ * @member m_nFilter can be used to filter log messages by type
+ * @member m_sFileName we need it to open the log file on demand (if nMode require such log file)
+ * @member m_nLine used as line number for the protocol
+ * @member m_nScope used to format scopes
+ * @member m_nErrors count errors in protocol
+ * @member m_nWarnings count warnings in protocol
+ * @member m_nTestMarks count test marker in protocol
+ */
+ private int m_nMode ;
+ private int m_nFilter ;
+ private String m_sFileName ;
+ private long m_nLine ;
+ private long m_nScope ;
+ private long m_nErrors ;
+ private long m_nWarnings ;
+ private long m_nTestMarks;
+ private Timestamp m_aStartTime;
+ private Timestamp m_aEndTime ;
+
+ // ____________________
+ /**
+ * special helper class to represent one line of a protocol.
+ * Such line can be specified as a special one (ERROR, WARNING ...).
+ * That makes it possible to analyze the whole protocol using tools.
+ */
+ class ProtocolLine
+ {
+ /// the line number of this protocol line (size of the vector of all protocol lines cn be used to count such lines!)
+ private long m_nLine;
+ /// deepness of the current scope
+ private long m_nScope;
+ /// mark line as an error, warning, data entry ... (see const definitions before)
+ private int m_nType;
+ /// of course, we have to know the logged message too :-)
+ private String m_sMessage;
+ /// and it can be usefull to know the current time, when this line was created
+ private Timestamp m_aStamp;
+
+ /** ctor for fast initializing of such line */
+ public ProtocolLine( long nLine ,
+ long nScope ,
+ int nType ,
+ String sMessage )
+ {
+ m_aStamp = new Timestamp(System.currentTimeMillis());
+ m_nLine = nLine ;
+ m_nScope = nScope ;
+ m_nType = nType ;
+ m_sMessage = sMessage;
+ }
+
+ /** format this line as an ascii string for writing log files */
+ public synchronized String toString()
+ {
+ StringBuffer sLine = new StringBuffer(1000);
+
+ // insert line number
+ // Use right bound notation and format 6 digits!
+ sLine.append("[" );
+ if (m_nLine<10)
+ sLine.append(" ");
+ else
+ if (m_nLine<100)
+ sLine.append(" ");
+ else
+ if (m_nLine<1000)
+ sLine.append(" ");
+ else
+ if (m_nLine<10000)
+ sLine.append(" ");
+ else
+ if (m_nLine<100000)
+ sLine.append(" ");
+ sLine.append(m_nLine);
+ sLine.append("] " );
+
+ // add time stamp
+ // close with a "TAB" ... because some time stamps are not normalized to
+ // a well defined string length .-)
+ sLine.append(m_aStamp.toString()+" \t");
+
+ // add special line type
+ if ((m_nType & TYPE_OK) == TYPE_OK)
+ sLine.append(" OK ");
+ else
+ if ((m_nType & TYPE_ERROR) == TYPE_ERROR)
+ sLine.append(" ERROR ");
+ else
+ if ((m_nType & TYPE_ERROR_INFO) == TYPE_ERROR_INFO)
+ sLine.append(" ERROR INFO ");
+ else
+ if ((m_nType & TYPE_WARNING) == TYPE_WARNING)
+ sLine.append(" WARNING ");
+ else
+ if ((m_nType & TYPE_WARNING_INFO) == TYPE_WARNING_INFO)
+ sLine.append(" WARNING INFO ");
+ else
+ if ((m_nType & TYPE_INFO) == TYPE_INFO)
+ sLine.append(" INFO ");
+ else
+ if ((m_nType & TYPE_TESTMARK) == TYPE_TESTMARK)
+ sLine.append(" TEST ");
+ else
+ if ((m_nType & TYPE_LINK) == TYPE_LINK)
+ sLine.append(" LINK ");
+ else
+ if ((m_nType & TYPE_STATISTIC) == TYPE_STATISTIC)
+ sLine.append(" STATISTIC ");
+ else
+ if (
+ ((m_nType & TYPE_SCOPE_OPEN ) == TYPE_SCOPE_OPEN ) ||
+ ((m_nType & TYPE_SCOPE_CLOSE) == TYPE_SCOPE_CLOSE)
+ )
+ sLine.append(" SCOPE ");
+ else
+ sLine.append(" ");
+
+ // add scope information
+ for (int s=0; s<m_nScope; ++s)
+ sLine.append(" ");
+
+ if ((m_nType & TYPE_SCOPE_OPEN) == TYPE_SCOPE_OPEN)
+ sLine.append(" { ");
+ else
+ if ((m_nType & TYPE_SCOPE_CLOSE) == TYPE_SCOPE_CLOSE)
+ sLine.append(" } ");
+ else
+ sLine.append(" ");
+
+ // add message
+ sLine.append(m_sMessage);
+ sLine.append("\n" );
+
+ return sLine.toString();
+ }
+
+ /**
+ * format this line as a string for writing log files
+ * using the html format
+ */
+ public synchronized String toHTML()
+ {
+ StringBuffer sLine = new StringBuffer(1000);
+ sLine.append("<tr>");
+
+ // insert line number
+ if (m_nLine % MARK_DIFF == 0)
+ impl_generateColoredHTMLCell(sLine, new Long(m_nLine).toString(), BGCOLOR_LINECOL, FGCOLOR_LINECOL_MARKED, true);
+ else
+ impl_generateColoredHTMLCell(sLine, new Long(m_nLine).toString(), BGCOLOR_LINECOL, FGCOLOR_LINECOL_NORMAL, false);
+
+ // add time stamp
+ impl_generateColoredHTMLCell(sLine, m_aStamp.toString()+" ", BGCOLOR_TIMESTAMP, FGCOLOR_TIMESTAMP, false);
+
+ // add log type info
+ boolean bTypeCellFilled = false;
+ if ((m_nType & TYPE_ERROR_INFO) == TYPE_ERROR_INFO)
+ {
+ impl_generateColoredHTMLCell(sLine, "ERROR INFO", BGCOLOR_ERROR_INFO, FGCOLOR_ERROR_INFO, false);
+ bTypeCellFilled = true;
+ }
+ else
+ if ((m_nType & TYPE_ERROR) == TYPE_ERROR)
+ {
+ impl_generateColoredHTMLCell(sLine, "ERROR", BGCOLOR_ERROR, FGCOLOR_ERROR, true);
+ bTypeCellFilled = true;
+ }
+ else
+ if ((m_nType & TYPE_WARNING_INFO) == TYPE_WARNING_INFO)
+ {
+ impl_generateColoredHTMLCell(sLine, "WARNING INFO", BGCOLOR_WARNING_INFO, FGCOLOR_WARNING_INFO, false);
+ bTypeCellFilled = true;
+ }
+ else
+ if ((m_nType & TYPE_WARNING) == TYPE_WARNING)
+ {
+ impl_generateColoredHTMLCell(sLine, "WARNING", BGCOLOR_WARNING, FGCOLOR_WARNING, true);
+ bTypeCellFilled = true;
+ }
+ else
+ if ((m_nType & TYPE_OK) == TYPE_OK)
+ {
+ impl_generateColoredHTMLCell(sLine, "OK", BGCOLOR_OK, FGCOLOR_OK, true);
+ bTypeCellFilled = true;
+ }
+ else
+ if ((m_nType & TYPE_INFO) == TYPE_INFO)
+ {
+ impl_generateColoredHTMLCell(sLine, "INFO", BGCOLOR_INFO, FGCOLOR_INFO, false);
+ bTypeCellFilled = true;
+ }
+ else
+ if ((m_nType & TYPE_TESTMARK) == TYPE_TESTMARK)
+ {
+ impl_generateColoredHTMLCell(sLine, "TEST", BGCOLOR_TESTMARK, FGCOLOR_TESTMARK, true);
+ bTypeCellFilled = true;
+ }
+ else
+ if ((m_nType & TYPE_STATISTIC) == TYPE_STATISTIC)
+ {
+ impl_generateColoredHTMLCell(sLine, "STATISTIC", BGCOLOR_STATISTIC, FGCOLOR_STATISTIC, false);
+ bTypeCellFilled = true;
+ }
+ else
+ if ((m_nType & TYPE_LINK) == TYPE_LINK)
+ {
+ impl_generateColoredHTMLCell(sLine, "LINK", BGCOLOR_LINK, FGCOLOR_LINK, false);
+ bTypeCellFilled = true;
+ }
+ else
+ if (
+ ((m_nType & TYPE_SCOPE_OPEN ) == TYPE_SCOPE_OPEN ) ||
+ ((m_nType & TYPE_SCOPE_CLOSE) == TYPE_SCOPE_CLOSE)
+ )
+ {
+ impl_generateColoredHTMLCell(sLine, "SCOPE", BGCOLOR_SCOPE, FGCOLOR_SCOPE, false);
+ bTypeCellFilled = true;
+ }
+
+ // if no tyope information was added to the current coloum, we must
+ // write any content into this cell. Otherwise some browser
+ // shows a strange layout!
+ if (! bTypeCellFilled)
+ impl_generateColoredHTMLCell(sLine, " ", BGCOLOR_STANDARD, FGCOLOR_STANDARD, false);
+
+ // add scope information
+ sLine.append("<td>");
+ for (int s=0; s<m_nScope; ++s)
+ sLine.append("&nbsp;&nbsp;&nbsp;");
+ String sColor = "#000000";
+ if ((m_nScope % 2) == 0)
+ sColor = "#808080";
+ if ((m_nType & TYPE_SCOPE_OPEN) == TYPE_SCOPE_OPEN)
+ sLine.append("<font color=\""+sColor+"\">{ "+m_nScope+"</font>");
+ else
+ if ((m_nType & TYPE_SCOPE_CLOSE) == TYPE_SCOPE_CLOSE)
+ sLine.append("<font color=\""+sColor+"\">"+m_nScope+" }</font>");
+ sLine.append("</td>\n");
+
+ // add message
+ sLine.append("<td>" );
+ sLine.append(m_sMessage);
+ sLine.append("</td>\n" );
+
+ sLine.append("</tr>\n" );
+
+ return sLine.toString();
+ }
+
+ /** detect, if this line object represent an error */
+ public synchronized boolean isError()
+ {
+ return (
+ ((m_nType & TYPE_ERROR) == TYPE_ERROR) &&
+ ((m_nType & TYPE_INFO ) != TYPE_INFO )
+ );
+ }
+
+ /** detect, if this line object represent a warning */
+ public synchronized boolean isWarning()
+ {
+ return (
+ ((m_nType & TYPE_WARNING) == TYPE_WARNING) &&
+ ((m_nType & TYPE_INFO ) != TYPE_INFO )
+ );
+ }
+
+ /** detect, if this line object represent a marked position */
+ public synchronized boolean isTestMark()
+ {
+ return ((m_nType & TYPE_TESTMARK) == TYPE_TESTMARK);
+ }
+
+ /**
+ * create a colored table cell formated as HTML.
+ *
+ * @param sCell
+ * an outside string buffer, which can be
+ * used to generate the
+ * needed HTML code there.
+ *
+ * @param sContent
+ * the text content of this cell.
+ *
+ * @param sBGColor
+ * a string, which represent the background color
+ * coded in HTML.
+ *
+ * @param sFGColor
+ * a string, which represent the foreground color
+ * coded in HTML.
+ *
+ * @param bBold
+ * enable/disable bold state for the text content.
+ */
+ private void impl_generateColoredHTMLCell(StringBuffer sCell ,
+ String sContent,
+ String sBGColor,
+ String sFGColor,
+ boolean bBold )
+ {
+ sCell.append("<td bgcolor=\""+sBGColor+"\">");
+ sCell.append("<font color=\""+sFGColor+"\">");
+ if (bBold)
+ sCell.append("<b>");
+ sCell.append(sContent);
+ if (bBold)
+ sCell.append("</b>");
+ sCell.append("</font></td>\n");
+ }
+ }
+
+ // ____________________
+ /**
+ * ctor
+ * It creates a new instance of this class and innitialize it in the right mode.
+ *
+ * @param nMode
+ * specify how the log should be generated.
+ *
+ * @param nFilter
+ * can be used to filter log messages by it's type.
+ *
+ * @param sFileName
+ * the name of the log file (if nMode requires a log file)
+ */
+ public Protocol(int nMode ,
+ int nFilter ,
+ String sFileName)
+ {
+ m_nMode = nMode;
+ m_nFilter = nFilter;
+ m_sFileName = sFileName;
+ m_nLine = 0;
+ m_nScope = 1;
+ m_nWarnings = 0;
+ m_nErrors = 0;
+ m_aStartTime = new Timestamp(System.currentTimeMillis());
+ }
+
+ // ____________________
+ /**
+ * For some modes it's neccessary, that we write some additional
+ * informations to the log. E.g. for html we must generate close targets.
+ */
+ public synchronized void finish()
+ {
+ // Preferr HTML ... because we can't write ASCII and HTML contents to the same log file!
+ String sContent;
+ if ((m_nMode & MODE_HTML) == MODE_HTML)
+ sContent = impl_generateHTMLFooter();
+ else
+ if ((m_nMode & MODE_ASCII) == MODE_ASCII)
+ sContent = impl_generateAsciiFooter();
+ else
+ return;
+
+ impl_writeToLogFile(m_sFileName, true, sContent);
+ }
+
+ // ____________________
+ /**
+ * log an unspecified message.
+ *
+ * Sometimes it's not neccessary to set a special type for an message.
+ * The pure message seams to be enough. The type of such "pure messages"
+ * will be set to INFO.
+ *
+ * @param sMessage
+ * the pure message
+ *
+ * @see log(type,message)
+ */
+ public synchronized void log( /*IN*/ String sMessage )
+ {
+ log(TYPE_INFO, sMessage);
+ }
+
+ // ____________________
+ /**
+ * log an exception.
+ *
+ * It uses all informations available by this exception object
+ * to generate the log. So exceptions are printed out using a
+ * standard format.
+ *
+ * @param exThrowable
+ * the exception
+ */
+ public synchronized void log( /*IN*/ Throwable exThrowable )
+ {
+ log(TYPE_SCOPE_OPEN | TYPE_ERROR, "exception \""+exThrowable.getMessage()+"\"");
+
+ StackTraceElement[] lStack = exThrowable.getStackTrace();
+ for (int i=0; i<lStack.length; ++i)
+ log(TYPE_ERROR_INFO, lStack[i].toString());
+
+ log(TYPE_SCOPE_CLOSE | TYPE_ERROR_INFO, "");
+ }
+
+ // ____________________
+ /**
+ * log different property arrays.
+ *
+ * @param lProps
+ * the array of properties
+ */
+ public synchronized void log( /*IN*/ com.sun.star.beans.NamedValue[] lProps )
+ {
+ StringBuffer sValues = new StringBuffer(1000);
+ impl_logPropertyArray(sValues, lProps);
+
+ log(TYPE_SCOPE_OPEN | TYPE_INFO, "property array ["+lProps.length+"]:");
+ log(TYPE_SCOPE_CLOSE | TYPE_INFO, sValues.toString() );
+ }
+
+ public synchronized void log( /*IN*/ com.sun.star.beans.PropertyValue[] lProps )
+ {
+ StringBuffer sValues = new StringBuffer(1000);
+ impl_logPropertyArray(sValues, lProps);
+
+ log(TYPE_SCOPE_OPEN | TYPE_INFO, "property array ["+lProps.length+"]:");
+ log(TYPE_SCOPE_CLOSE | TYPE_INFO, sValues.toString() );
+ }
+
+ public synchronized void log( /*IN*/ com.sun.star.beans.NamedValue aProp )
+ {
+ StringBuffer sValue = new StringBuffer(1000);
+ impl_logProperty(sValue, aProp);
+
+ log(TYPE_SCOPE_OPEN | TYPE_INFO, "property:" );
+ log(TYPE_SCOPE_CLOSE | TYPE_INFO, sValue.toString());
+ }
+
+ public synchronized void log( /*IN*/ com.sun.star.beans.PropertyValue aProp )
+ {
+ StringBuffer sValue = new StringBuffer(1000);
+ impl_logProperty(sValue, aProp);
+
+ log(TYPE_SCOPE_OPEN | TYPE_INFO, "property:" );
+ log(TYPE_SCOPE_CLOSE | TYPE_INFO, sValue.toString());
+ }
+
+ public synchronized void log( /*IN*/ Object aAny )
+ {
+ StringBuffer sValue = new StringBuffer(1000);
+ impl_logAny(sValue, aAny);
+
+ log(TYPE_SCOPE_OPEN | TYPE_INFO, "any:" );
+ log(TYPE_SCOPE_CLOSE | TYPE_INFO, sValue.toString());
+ }
+
+ // ____________________
+ /**
+ * log a message.
+ *
+ * It looks for the internal set mode and decide, how this message
+ * will be handled. Then it generates a special object which represent
+ * one protocol line, format it and print it out.
+ *
+ * @param nType
+ * mark a line as a special one or open/close scopes
+ *
+ * @param sMessage
+ * the message, which the outside code wish to be written into the log
+ */
+ public synchronized void log( /*IN*/ int nType ,
+ /*IN*/ String sMessage )
+ {
+ nType = (nType & ~m_nFilter);
+ if (nType == 0)
+ return;
+
+ ++m_nLine;
+
+ // it's neccessary to open scopes before creatig the protocol line
+ // to guarantee right tab handling for new scope value!
+ if ((nType & TYPE_SCOPE_OPEN) == TYPE_SCOPE_OPEN)
+ ++m_nScope;
+
+ // create the protocol line
+ ProtocolLine aLine = new ProtocolLine(m_nLine, m_nScope, nType, sMessage);
+ String sAsciiLog = aLine.toString();
+ String sHTMLLog = aLine.toHTML();
+
+ // it's neccessary to close scope after creatig the protocol line
+ // to guarantee right tab handling for old scope value!
+ if (
+ ( m_nScope > 0 ) &&
+ ((nType & TYPE_SCOPE_CLOSE) == TYPE_SCOPE_CLOSE)
+ )
+ {
+ --m_nScope;
+ }
+
+ // update statistic values
+ if (aLine.isTestMark())
+ ++m_nTestMarks;
+ if (aLine.isWarning())
+ ++m_nWarnings;
+ if (aLine.isError())
+ ++m_nErrors;
+
+ // no else - it's a bit field of possible reactions!
+ if ((m_nMode & MODE_STDOUT) == MODE_STDOUT)
+ System.out.print(sAsciiLog);
+ // no else - it's a bit field of possible reactions!
+ if ((m_nMode & MODE_STDERR) == MODE_STDERR)
+ System.err.print(sAsciiLog);
+ // no else - it's a bit field of possible reactions!
+ // But these both conditions must be handled together.
+ // Because we cant generate different types of log contents to the same log file.
+ // We preferr HTML if both types are set.
+ if (
+ ((m_nMode & MODE_HTML ) == MODE_HTML ) ||
+ ((m_nMode & MODE_ASCII) == MODE_ASCII)
+ )
+ {
+ boolean bAppend = (m_nLine>1);
+ String sContent;
+ if ((m_nMode & MODE_HTML) == MODE_HTML)
+ {
+ if (! bAppend)
+ sContent = impl_generateHTMLHeader()+sHTMLLog;
+ else
+ sContent = sHTMLLog;
+ }
+ else
+ {
+ if (! bAppend)
+ sContent = impl_generateAsciiHeader()+sAsciiLog;
+ else
+ sContent = sAsciiLog;
+ }
+
+ impl_writeToLogFile(m_sFileName, bAppend, sContent);
+ }
+ }
+
+ // ____________________
+ public synchronized void defineHyperlink( /*IN*/ String sTarget ,
+ /*IN*/ String sDescription)
+ {
+ if ((m_nMode & MODE_HTML) != MODE_HTML)
+ return;
+
+ StringBuffer sLog = new StringBuffer(1000);
+ sLog.append("<a href=\"");
+ sLog.append(sTarget );
+ sLog.append("\">" );
+ sLog.append(sDescription);
+ sLog.append("</a>" );
+
+ log(TYPE_LINK, sLog.toString());
+ }
+
+ // ____________________
+ /**
+ * log the current statistic values
+ * We write it into our protocol buffer and
+ * reset it.
+ */
+ public synchronized void logStatistics()
+ {
+ m_aEndTime = new Timestamp(System.currentTimeMillis());
+ Timestamp aDiff = new Timestamp(m_aEndTime.getTime()-m_aStartTime.getTime());
+
+ int nLogType = TYPE_STATISTIC;
+ if (m_nErrors > 0)
+ nLogType = TYPE_ERROR_INFO;
+ else
+ if (m_nWarnings > 0)
+ nLogType = TYPE_WARNING_INFO;
+
+ log(nLogType | TYPE_SCOPE_OPEN , "statistic:" );
+ log(nLogType , "tests = "+m_nTestMarks );
+ log(nLogType , "errors = "+m_nErrors );
+ log(nLogType , "warnings = "+m_nWarnings );
+ log(nLogType , "elapsed time = "+aDiff.toString());
+ log(nLogType | TYPE_SCOPE_CLOSE, "" );
+
+ resetStatistics();
+ }
+
+ public synchronized void resetStatistics()
+ {
+ m_nTestMarks = 0;
+ m_nWarnings = 0;
+ m_nErrors = 0;
+ m_aStartTime = new Timestamp(System.currentTimeMillis());
+ }
+
+ // ____________________
+ /**
+ * returns a generic html header for generating html log files
+ *
+ * It's used from the method finish() to generate a valid html formated file.
+ * For that its neccessary to open some special html targets like e.g. <html>.
+ *
+ * @return A string, which includes the whole header.
+ *
+ * @see finish()
+ * @see generateHTMLFooter()
+ */
+ private String impl_generateHTMLHeader()
+ {
+ return "<html>\n<head>\n<title>"+m_sFileName+"</title>\n</head>\n<body>\n<table>\n";
+ }
+
+ private String impl_generateAsciiHeader()
+ {
+ return "********************************************************************************\n";
+ }
+
+ private String impl_generateHTMLFooter()
+ {
+ return "\n</table>\n</body>\n</html>\n";
+ }
+
+ private String impl_generateAsciiFooter()
+ {
+ return "\n\n";
+ }
+
+ // ____________________
+ /**
+ * helper to log different representations of a property(array)
+ *
+ * @param sOut
+ * used to generate the log output there.
+ *
+ * @param lProps/aProp
+ * represent the property(array) to be logged.
+ */
+ private void impl_logPropertyArray( /*OUT*/ StringBuffer sOut ,
+ /*IN */ com.sun.star.beans.PropertyValue[] lProps )
+ {
+ int i = 0;
+ int c = lProps.length;
+
+ for (i=0; i<c; ++i)
+ impl_logProperty(sOut, lProps[i]);
+ }
+
+ private void impl_logPropertyArray( /*OUT*/ StringBuffer sOut ,
+ /*IN */ com.sun.star.beans.NamedValue[] lProps )
+ {
+ int i = 0;
+ int c = lProps.length;
+
+ for (i=0; i<c; ++i)
+ impl_logProperty(sOut, lProps[i]);
+ }
+
+ private void impl_logProperty( /*OUT*/ StringBuffer sOut ,
+ /*IN*/ com.sun.star.beans.NamedValue aProp )
+ {
+ sOut.append("\""+aProp.Name+"\" = ");
+ impl_logAny(sOut, aProp.Value);
+ }
+
+ private void impl_logProperty( /*OUT*/ StringBuffer sOut ,
+ /*IN*/ com.sun.star.beans.PropertyValue aProp )
+ {
+ sOut.append("\""+aProp.Name+"\" = ");
+ impl_logAny(sOut, aProp.Value);
+ }
+
+ // ____________________
+ /**
+ * it trys to convert the given any into a suitable string notation .-)
+ */
+ private synchronized void impl_logAny( /*OUT*/ StringBuffer sOut ,
+ /*IN */ Object aAny )
+ {
+ try
+ {
+ if (com.sun.star.uno.AnyConverter.isVoid(aAny))
+ {
+ sOut.append("[void] {");
+ }
+ else
+ if (com.sun.star.uno.AnyConverter.isChar(aAny))
+ {
+ sOut.append("[char] {");
+ sOut.append(com.sun.star.uno.AnyConverter.toChar(aAny));
+ sOut.append("}");
+ }
+ else
+ if (com.sun.star.uno.AnyConverter.isBoolean(aAny))
+ {
+ sOut.append("[boolean] {");
+ if (com.sun.star.uno.AnyConverter.toBoolean(aAny))
+ sOut.append("TRUE");
+ else
+ sOut.append("FALSE");
+ sOut.append("}");
+ }
+ else
+ if (com.sun.star.uno.AnyConverter.isByte(aAny))
+ {
+ sOut.append("[byte] {");
+ sOut.append(com.sun.star.uno.AnyConverter.toByte(aAny));
+ sOut.append("}");
+ }
+ else
+ if (com.sun.star.uno.AnyConverter.isShort(aAny))
+ {
+ sOut.append("[short] {");
+ sOut.append(com.sun.star.uno.AnyConverter.toShort(aAny));
+ sOut.append("}");
+ }
+ else
+ if (com.sun.star.uno.AnyConverter.isInt(aAny))
+ {
+ sOut.append("[int] {");
+ sOut.append(com.sun.star.uno.AnyConverter.toInt(aAny));
+ sOut.append("}");
+ }
+ else
+ if (com.sun.star.uno.AnyConverter.isLong(aAny))
+ {
+ sOut.append("[long] {");
+ sOut.append(com.sun.star.uno.AnyConverter.toLong(aAny));
+ sOut.append("}");
+ }
+ else
+ if (com.sun.star.uno.AnyConverter.isFloat(aAny))
+ {
+ sOut.append("[float] {");
+ sOut.append(com.sun.star.uno.AnyConverter.toFloat(aAny));
+ sOut.append("}");
+ }
+ else
+ if (com.sun.star.uno.AnyConverter.isDouble(aAny))
+ {
+ sOut.append("[double] {");
+ sOut.append(com.sun.star.uno.AnyConverter.toDouble(aAny));
+ sOut.append("}");
+ }
+ else
+ if (com.sun.star.uno.AnyConverter.isString(aAny))
+ {
+ sOut.append("[string] {");
+ sOut.append(com.sun.star.uno.AnyConverter.toString(aAny));
+ sOut.append("}");
+ }
+ else
+ if (com.sun.star.uno.AnyConverter.isEnum(aAny))
+ {
+ sOut.append("[enum] {");
+ sOut.append("}");
+ }
+ else
+ if (com.sun.star.uno.AnyConverter.isType(aAny))
+ {
+ sOut.append("[type] {");
+ sOut.append("}");
+ }
+ else
+ if (com.sun.star.uno.AnyConverter.isArray(aAny))
+ {
+ if (aAny instanceof java.lang.String[])
+ {
+ sOut.append("[sequence< string >] {");
+ sOut.append("}");
+ }
+ else
+ if (aAny instanceof com.sun.star.beans.PropertyValue[])
+ {
+ sOut.append("[sequence< PropertyValue >] {");
+ com.sun.star.beans.PropertyValue[] lSubProps = (com.sun.star.beans.PropertyValue[])com.sun.star.uno.AnyConverter.toArray(aAny);
+ impl_logPropertyArray(sOut, lSubProps);
+ sOut.append("}");
+ }
+ else
+ if (aAny instanceof com.sun.star.beans.NamedValue[])
+ {
+ sOut.append("[sequence< NamedValue >] {");
+ com.sun.star.beans.NamedValue[] lSubProps = (com.sun.star.beans.NamedValue[])com.sun.star.uno.AnyConverter.toArray(aAny);
+ impl_logPropertyArray(sOut, lSubProps);
+ sOut.append("}");
+ }
+ else
+ {
+ sOut.append("[unknown array] {-}");
+ }
+ }
+ else
+ if (com.sun.star.uno.AnyConverter.isObject(aAny))
+ {
+ sOut.append("[object] {");
+ // TODO
+ sOut.append("}");
+ }
+
+ if ((m_nMode & MODE_HTML) == MODE_HTML)
+ sOut.append("<br>");
+ else
+ sOut.append("\n");
+ }
+ catch(com.sun.star.lang.IllegalArgumentException exIll)
+ {
+ sOut.append("Got exception during property conversion.\n");
+ sOut.append(exIll.getMessage());
+ sOut.append("\n");
+ }
+ }
+
+ // ____________________
+ /**
+ * Writes the given content to the specified log file.
+ */
+ private void impl_writeToLogFile(String sFileName,
+ boolean bAppend ,
+ String sContent )
+ {
+ try
+ {
+ FileWriter aLogFile = new FileWriter(sFileName, bAppend);
+ aLogFile.write(sContent);
+ aLogFile.flush();
+ aLogFile.close();
+ aLogFile = null;
+ }
+ catch (java.io.IOException exIO)
+ {
+ System.err.println("Can't dump protocol into log file.");
+ System.err.println(exIO);
+ exIO.printStackTrace();
+ }
+ }
+}
diff --git a/framework/qa/complex/framework/autosave/makefile.mk b/framework/qa/complex/framework/autosave/makefile.mk
new file mode 100644
index 000000000000..e903c9ad5f33
--- /dev/null
+++ b/framework/qa/complex/framework/autosave/makefile.mk
@@ -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.
+#
+#*************************************************************************
+PRJ = ..$/..$/..$/..
+TARGET = AutoSave
+PRJNAME = framework
+PACKAGE = complex$/framework$/autosave
+
+# --- Settings -----------------------------------------------------
+.INCLUDE: settings.mk
+
+
+#----- compile .java files -----------------------------------------
+
+JARFILES = mysql.jar ridl.jar unoil.jar jurt.jar juh.jar java_uno.jar \
+ OOoRunner.jar mysql.jar
+JAVAFILES = AutoSave.java ConfigHelper.java Protocol.java
+JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class)
+
+#----- make a jar from compiled files ------------------------------
+
+MAXLINELENGTH = 100000
+
+JARCLASSDIRS = $(PACKAGE)
+JARTARGET = $(TARGET).jar
+JARCOMPRESS = TRUE
+
+# --- Parameters for the test --------------------------------------
+
+# start an office if the parameter is set for the makefile
+.IF "$(OFFICE)" == ""
+CT_APPEXECCOMMAND =
+.ELSE
+CT_APPEXECCOMMAND = -AppExecutionCommand "$(OFFICE)$/soffice -accept=socket,host=localhost,port=8100;urp;"
+.ENDIF
+
+# test base is java complex
+CT_TESTBASE = -TestBase java_complex
+
+# test looks something like the.full.package.TestName
+CT_TEST = -o $(PACKAGE:s\$/\.\).$(JAVAFILES:b)
+
+# start the runner application
+CT_APP = org.openoffice.Runner
+
+# --- Targets ------------------------------------------------------
+
+.IF "$(depend)" == ""
+$(CLASSDIR)$/$(PACKAGE)$/$(JAVAFILES:b).props : ALLTAR
+.ELSE
+$(CLASSDIR)$/$(PACKAGE)$/$(JAVAFILES:b).props : ALLDEP
+.ENDIF
+
+.INCLUDE : target.mk
+
+#$(CLASSDIR)$/$(PACKAGE)$/$(JAVAFILES:b).props : $(JAVAFILES:b).props
+# cp $(JAVAFILES:b).props $(CLASSDIR)$/$(PACKAGE)$/$(JAVAFILES:b).props
+# jar uf $(CLASSDIR)$/$(JARTARGET) -C $(CLASSDIR) $(PACKAGE)$/$(JAVAFILES:b).props
+
+RUN: run
+
+run:
+ +java -cp $(CLASSPATH) $(CT_APP) $(CT_TESTBASE) $(CT_APPEXECCOMMAND) $(CT_TEST)
+
+
+
diff --git a/framework/qa/complex/framework/recovery/CrashThread.java b/framework/qa/complex/framework/recovery/CrashThread.java
new file mode 100644
index 000000000000..616d4baa200e
--- /dev/null
+++ b/framework/qa/complex/framework/recovery/CrashThread.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 complex.framework.recovery;
+
+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 com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.util.URL;
+import com.sun.star.util.XURLTransformer;
+
+/**
+ * Thread to crash the office. This thread dies after the office process
+ * is nopt longer available.
+ */
+public class CrashThread extends Thread {
+ public XComponent xDoc = null;
+ public XMultiServiceFactory msf = null;
+
+ public CrashThread(XComponent xDoc, XMultiServiceFactory msf) {
+ this.xDoc = xDoc;
+ this.msf = msf;
+ }
+
+ public void run() {
+ try{
+ XModel xModel = (XModel) UnoRuntime.queryInterface(XModel.class, xDoc);
+
+ XController xController = xModel.getCurrentController();
+ XDispatchProvider xDispProv = (XDispatchProvider) UnoRuntime.queryInterface(
+ XDispatchProvider.class,
+ xController);
+ XURLTransformer xParser = (XURLTransformer) UnoRuntime.queryInterface(
+ XURLTransformer.class,
+ msf.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 = ".uno:Crash";
+ xParser.parseStrict(aParseURL);
+
+ URL aURL = aParseURL[0];
+ XDispatch xDispatcher = xDispProv.queryDispatch(aURL, "", 0);
+
+ if (xDispatcher != null) {
+ xDispatcher.dispatch(aURL, null);
+ }
+ } catch (Exception e){}
+ }
+}
diff --git a/framework/qa/complex/framework/recovery/KlickButtonThread.java b/framework/qa/complex/framework/recovery/KlickButtonThread.java
new file mode 100644
index 000000000000..426a2e3d2a79
--- /dev/null
+++ b/framework/qa/complex/framework/recovery/KlickButtonThread.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 complex.framework.recovery;
+
+import com.sun.star.awt.XWindow;
+import com.sun.star.lang.XMultiServiceFactory;
+import util.UITools;
+
+/**
+ * Thread to crash the office. This thread dies after the office process
+ * is nopt longer available.
+ */
+public class KlickButtonThread extends Thread {
+ private XWindow xWindow = null;
+ private XMultiServiceFactory xMSF = null;
+ private String buttonName = null;
+
+ public KlickButtonThread(XMultiServiceFactory xMSF, XWindow xWindow, String buttonName) {
+ this.xWindow = xWindow;
+ this.xMSF = xMSF;
+ this.buttonName = buttonName;
+ }
+
+ public void run() {
+ try{
+ UITools oUITools = new UITools(xMSF, xWindow);
+
+ oUITools.clickButton(buttonName);
+
+ } catch (Exception e){}
+ }
+}
diff --git a/framework/qa/complex/framework/recovery/RecoveryTest.java b/framework/qa/complex/framework/recovery/RecoveryTest.java
new file mode 100644
index 000000000000..ee565ff74330
--- /dev/null
+++ b/framework/qa/complex/framework/recovery/RecoveryTest.java
@@ -0,0 +1,1012 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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 complex.framework.recovery;
+
+import com.sun.star.accessibility.XAccessible;
+import com.sun.star.accessibility.XAccessibleContext;
+import com.sun.star.awt.Rectangle;
+import com.sun.star.awt.Size;
+import com.sun.star.awt.XDialog;
+import com.sun.star.awt.XExtendedToolkit;
+import com.sun.star.awt.XWindow;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.container.XEnumeration;
+import com.sun.star.container.XIndexAccess;
+import com.sun.star.container.XNameContainer;
+import com.sun.star.drawing.XDrawPage;
+import com.sun.star.drawing.XDrawPages;
+import com.sun.star.drawing.XDrawPagesSupplier;
+import com.sun.star.drawing.XShape;
+import com.sun.star.drawing.XShapes;
+import com.sun.star.frame.XController;
+import com.sun.star.frame.XDesktop;
+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.lang.XSingleServiceFactory;
+import com.sun.star.presentation.XCustomPresentationSupplier;
+import com.sun.star.presentation.XPresentationSupplier;
+import com.sun.star.sheet.XSheetCellRange;
+import com.sun.star.sheet.XSpreadsheet;
+import com.sun.star.sheet.XSpreadsheetDocument;
+import com.sun.star.sheet.XSpreadsheets;
+import com.sun.star.style.XStyle;
+import com.sun.star.table.XCellRange;
+import com.sun.star.text.ControlCharacter;
+import com.sun.star.text.XText;
+import com.sun.star.text.XTextCursor;
+import com.sun.star.text.XTextDocument;
+import com.sun.star.uno.AnyConverter;
+import com.sun.star.uno.Type;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XInterface;
+import com.sun.star.view.XSelectionSupplier;
+import complexlib.ComplexTestCase;
+import helper.OfficeProvider;
+import helper.OfficeWatcher;
+import java.awt.Dimension;
+import java.awt.Point;
+import java.awt.Toolkit;
+import java.io.PrintWriter;
+import java.util.Hashtable;
+import java.util.Random;
+import util.DesktopTools;
+import util.PropertyName;
+import util.SOfficeFactory;
+import util.UITools;
+import util.utils;
+
+public class RecoveryTest extends ComplexTestCase {
+
+ static XMultiServiceFactory xMSF;
+ static SOfficeFactory SOF;
+ static RecoveryTools rt;
+ /**
+ * If you devid the screen in four parts in the first of them the office
+ * windows should be placed. The range of the first quarter is stored in the variable.
+ */
+ static Point windowMaxPosition;
+ /**
+ * The office windows starts in the first quarter of the screen. In this variable
+ * the maximum size for the windows was stored so the windows can be placed
+ * visible on the screen.
+ */
+ static Size windowMaxSize;
+
+ /**
+ * All office windows will be placed by this test on randomized positions.
+ * This positions was stored in this Hashmap. The keys are the frame names
+ * and the values are com sun.star.awt.Rectangle.
+ * @see com.sun.star.awt.Rectangle
+ */
+ private Hashtable windowsPosSize = new Hashtable();
+
+ /**
+ * A function to tell the framework, which test functions are available.
+ * @return All test methods.
+ *
+ * @todo: hidden documents
+ * @todo: running presentation
+ * @todo: modular dialogs like Hpyerlink-Dialog
+ * @todo: sceond view of a document
+ * @todo: remove recovery data before start test
+ * @todo: after a second start after the crash there should no documents recovered anymore
+ * @todo: enable remove of recovery files
+ * @todo: makefile anpassen auf Parameter überprüfen
+ */
+ public String[] getTestMethodNames() {
+ return new String[]{"testCrash"};
+ }
+
+ /** Create the environment for following tests.
+ * Use either a component loader from desktop or
+ * from frame
+ * @throws Exception Exception
+ */
+
+ public void normalCrash(){
+ cleanRecoveryData();
+ startOffice();
+ generateDesktop();
+ makeCrash();
+ int expectedDocumentCount = windowsPosSize.size() + 1;
+ handleRecoveryDialogAfterCrash(expectedDocumentCount);
+ startOffice();
+ handleRecoveryDialog_QuickExit(expectedDocumentCount);
+ handleCrashReporterDialog(true, true);
+ checkDocumentCount(expectedDocumentCount);
+ }
+
+ public void testCrash(){
+ cleanRecoveryData();
+ restoreBackupRecoveryData();
+ startOffice();
+ int expectedDocumentCount = 3;
+// handleRecoveryDialog_QuickExit(expectedDocumentCount);
+ handleRecoveryDialog_QuickExitAndSave(expectedDocumentCount);
+ //handleCrashReporterDialog(true, true);
+ //checkDocumentCount(expectedDocumentCount);
+ }
+
+ public void before() throws Exception {
+
+ String msg ="\n\n\tPATH TO OFFICE BINARY MISSING!\n";
+ msg +="\tPlease run your command with the following parameter:\n\n";
+ msg +="\t-AppExecutionCommand=OFFICEBINARY CONNECTIONSTRING\n\n";
+ msg +="Example Windows:\n";
+ msg +="-AppExecutionCommand=C:\\office\\soffice.exe -accept=socket,host=localhost,port=8101;urp;\n\n";
+ msg +="Example UNIX:\n";
+ msg +="-AppExecutionCommand=/office/soffice \"-accept=socket,host=localhost,port=8101;urp;\"\n\n";
+ msg+="NOTE: on UNIX be shure to have the connection string inside quotation mark!\n";
+
+ assure(msg, param.get("AppExecutionCommand") != null && ! param.get("AppExecutionCommand").equals(""));
+ System.out.println("HALLO" + param.get("AppExecutionCommand"));
+ msg = "\n\nONE PARAMETER IS MISSING!\n";
+ msg += "Please append to your command the following parameter:\n\n";
+ msg += "\t-NoOffice=true";
+ assure(msg, param.getBool("NoOffice"));
+
+
+ rt = new RecoveryTools(param ,log);
+
+ rt.removeParametersFromAppExecutionCommand();
+
+ log.println("start the office to test recovery feature...");
+
+ // make window ranges
+ makeWindowPositionRage();
+
+ //makeRecoveryData();
+ }
+
+ private void makeRecoveryData(){
+ cleanRecoveryData();
+ startOffice();
+ generateDesktop();
+ makeCrash();
+ int expectedDocumentCount = windowsPosSize.size() + 1;
+ handleRecoveryDialogAfterCrash(expectedDocumentCount);
+ backupRecoveryData();
+ cleanRecoveryData();
+ }
+
+ private void startOffice(){
+ assure("Could not connect to office", connect());
+ log.setWatcher(param.get("Watcher"));
+ }
+
+
+ private void checkDocumentCount(int expectedDocumentCount){
+ XEnumeration allComp = DesktopTools.getAllComponents(xMSF);
+ int documentCount = 0;
+
+ try{
+ while (allComp.hasMoreElements()){
+ allComp.nextElement();
+ documentCount ++;
+ }
+ }
+ catch ( com.sun.star.container.NoSuchElementException e){}
+ catch ( com.sun.star.lang.WrappedTargetException e){}
+
+ String msg ="The amount of documents to recover is different form the expected amount:\n";
+ msg += "\texpected:\t" + expectedDocumentCount + "\n";
+ msg += "\tto recover:\t" + documentCount;
+
+ assure(msg, expectedDocumentCount == documentCount);
+ }
+
+ /**
+ * This function starts an office instance. It uses the AppExecutionCommad parameter.
+ * @return TRUE if office is connected otherwise FALSE
+ */
+ private boolean connect(){
+ try {
+
+ OfficeProvider oProvider = new OfficeProvider();
+ xMSF = (XMultiServiceFactory)oProvider.getManager(param);
+
+ SOF = SOfficeFactory.getFactory(xMSF);
+
+ }
+ catch (java.lang.Exception e) {
+ log.println(e.getClass().getName());
+ log.println("Message: " + e.getMessage());
+ failed("Cannot connect the Office.");
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * While creating the test environment the positions and sizes of the frames
+ * was saved. After the Office has recovered the documents, this functions
+ * compares the saved positions and sizes with the current frame.
+ */
+ private void compareWindowPositions(){
+ System.out.println("all frames:########");
+ System.out.println(windowsPosSize.entrySet().toString());
+
+ XEnumeration allComp = DesktopTools.getAllComponents(xMSF);
+
+ String msg=null;
+
+ while (allComp.hasMoreElements()){
+ try{
+ // get all components from the desktop
+ XComponent xComponent = (XComponent) UnoRuntime.queryInterface(
+ XComponent.class, allComp.nextElement());
+
+ XModel xModel = (XModel) UnoRuntime.queryInterface(XModel.class, xComponent);
+
+ String frameName = xModel.getCurrentController().getFrame().getName();
+
+ // check if this frame was used in creation of test environment
+ if (windowsPosSize.containsKey(frameName)){
+
+ Rectangle oldRect = (Rectangle) windowsPosSize.get(frameName);
+
+ XWindow xWindow = xModel.getCurrentController().getFrame().getContainerWindow();
+ Rectangle newRect = xWindow.getPosSize();
+
+
+ boolean ok = oldRect.Height == newRect.Height;
+ ok &= oldRect.Width == newRect.Width;
+ ok &= oldRect.X == newRect.X;
+ ok &= oldRect.Y == newRect.Y;
+
+ if (!ok){
+ msg = "The frame '" + frameName + "' has a different position/size:\n";
+ msg += "original value -> restored value:\n";
+ msg += "X : " + oldRect.X + " -> " + newRect.X + "\n";
+ msg += "Y : " + oldRect.Y + " -> " + newRect.Y + "\n";
+ msg += "Height: " + oldRect.Height + " -> " + newRect.Height + "\n";
+ msg += "Width : " + oldRect.Width + " -> " + newRect.Width + "\n";
+ }
+
+ assure(msg, ok, CONTINUE);
+
+ }
+ } catch (com.sun.star.container.NoSuchElementException e) {
+ } catch ( com.sun.star.lang.WrappedTargetException e) {}
+ }
+
+ }
+
+ /**
+ * This function crashes the office
+ */
+ private void makeCrash(){
+ // get all documents
+ Object[] allDocs = DesktopTools.getAllOpenDocuments(xMSF);
+
+ // get one of them for dispatching
+ XComponent xDoc = (XComponent) allDocs[0];
+ log.println("make the crash in second thread");
+
+ CrashThread crash = new CrashThread(xDoc, xMSF);
+ crash.start();
+ rt.pause();
+ rt.pause();
+ }
+
+ /**
+ * This function uses accessibility to handle the dialog which appears while the
+ * office is crashed. It click the button "OK" to continue.
+ */
+ private void handleRecoveryDialogAfterCrash(int expectedDocumentCount){
+ try{
+
+ // if the office crashes, the recovery feature needs some time
+ // to save all docs. Therefore the recovery dialog could need some
+ // time to pop up.
+ log.println("wating for recovery dialog...");
+
+ int counter = 0;
+ int maximum = param.getInt(PropertyName.THREAD_TIME_OUT) / param.getInt(PropertyName.SHORT_WAIT);
+
+ XDialog oDialog = rt.getActiveDialog(xMSF);
+
+ while ( oDialog == null && (counter < maximum))
+ {
+ rt.pause();
+ oDialog = rt.getActiveDialog(xMSF);
+ counter ++;
+ }
+
+ assure("could not get Recovery Window",(oDialog != null));
+
+ XWindow xWindow = (XWindow) UnoRuntime.queryInterface(XWindow.class, oDialog);
+
+ UITools oUITools = new UITools(xMSF, xWindow);
+
+ oUITools.printAccessibleTree((PrintWriter) log, param.getBool(PropertyName.DEBUG_IS_ACTIVE));
+
+ String[] documents = oUITools.getListBoxItems("The following files will be recovered");
+ log.println("there are " + documents.length + " documents to save");
+
+ String msg ="The amount of documents to recover is different form the expected amount:\n";
+ msg += "\texpected:\t" + expectedDocumentCount + "\n";
+ msg += "\tto recover:\t" + documents.length;
+
+ assure(msg, expectedDocumentCount == documents.length);
+
+ log.println("disable automatically launch of Office");
+ oUITools.setCheckBoxValue("Launch StarOffice automatically", new Integer(0));
+
+ log.println("start saving...");
+ oUITools.clickButton("OK");
+
+ rt.waitForClosedOffice();
+
+ } catch (Exception e){
+ e.printStackTrace();
+ failed("Could not handle crash-dialog: " + e.toString());
+ }
+ }
+
+ private void handleCrashReporterDialog(boolean cancel, boolean YesNo){
+ try{
+
+ log.println("try to get Crash Reporter Dialog...");
+
+ XDialog oDialog = rt.getActiveDialog(xMSF);
+ assure("could not get CrashReporter Dialog", oDialog != null);
+
+ XWindow xWindow = (XWindow) UnoRuntime.queryInterface(XWindow.class, oDialog);
+
+ log.println(oDialog.getTitle());
+
+ UITools oUITools = new UITools(xMSF, xWindow);
+
+ if (cancel) {
+ log.println("clicking 'Cancel' button...");
+
+ try{
+ rt.clickThreadButton(xMSF, xWindow, "Cancel");
+ } catch (com.sun.star.accessibility.IllegalAccessibleComponentStateException e){
+ failed("Could not click 'Cancel' at CrashReporter Dialog");
+ }
+
+ }
+ else {
+ log.println("clicking 'Next' button...");
+ oUITools.clickButton("Next>>");
+ }
+
+ } catch (Exception e){
+ failed("Could not handle CrashReporter Dialog: " + e.toString());
+ }
+ }
+
+ private void handleRecoveryDialog_QuickExit(int expectedDocumentCount){
+ log.println("handle Recovery Dialog at restart: quick exit");
+ handleRecoveryDialogAtRestart(expectedDocumentCount, false, true);
+ handleAreYouSureDialog(true);
+ handleSaveDocumentsDialog(false);
+
+ }
+ private void handleRecoveryDialog_QuickExitAndSave(int expectedDocumentCount){
+ log.println("handle Recovery Dialog at restart: quick exit");
+ handleRecoveryDialogAtRestart(expectedDocumentCount, false, true);
+ handleAreYouSureDialog(true);
+ handleSaveDocumentsDialog(true);
+ }
+ private void handleRecoveryDialog_Recover(int expectedDocumentCount){
+
+ }
+ private void handleRecoveryDialog_RecoverAndCrashreporter(int expectedDocumentCount){
+
+ }
+ /**
+ * This function uses accessibility to handle the dialog which appears while the
+ * office is started after a crash. It waits until the "next>>" button is enabled
+ * and click it then to continue.
+ * @param expectedDocumentCount the amount of documents which must be displayed in the recovery dialog
+ * @param recover If the documenst should be recoverd this variable must be true. If it is fasle
+ * the recovery process was stoped and the button cancel was klicked.
+ * @param cancel If the recovery is fifnished, this parameter desicdes to klick the "Next" button
+ * or the click cancel. If the value is true, the cancel button was clicked.
+ */
+ private void handleRecoveryDialogAtRestart(int expectedDocumentCount, boolean recover, boolean cancel){
+ try{
+
+ log.println("try to get Recovery Dialog...");
+
+ XDialog oDialog = null;
+ oDialog = rt.getActiveDialogAfterStartup(xMSF);
+
+ assure("could not get Recovery Dialog at start of office", (oDialog != null), CONTINUE);
+
+ XWindow xWindow = (XWindow) UnoRuntime.queryInterface(XWindow.class, oDialog);
+ log.println("got the following dialog: '" +oDialog.getTitle() + "'");
+
+ UITools oUITools = new UITools(xMSF, xWindow);
+
+ String listBoxName = "Status of recovered documents";
+ String[] documents = oUITools.getListBoxItems(listBoxName);
+ log.println("there are " + documents.length + " documents to recover");
+ log.println("The following files will be recovered:");
+ for (int i=0;i<documents.length;i++){
+ log.println(documents[i]);
+ }
+
+ String msg ="The amount of documents to recover is different form the expected amount:\n";
+ msg += "\texpected:\t" + expectedDocumentCount + "\n";
+ msg += "\tto recover:\t" + documents.length;
+
+ assure(msg, expectedDocumentCount ==documents.length);
+
+ if (recover){
+
+ log.println("clicking 'Start Recovery' button...");
+ oUITools.clickButton("Start Recovery >");
+
+ rt.pause();
+
+ //XAccessibleContext oButton = oUITools.getButton("Start Recovery >");
+ int counter = 0;
+ int maximum = param.getInt(PropertyName.THREAD_TIME_OUT) / param.getInt(PropertyName.SHORT_WAIT);
+ //boolean enabeld = oButton.getAccessibleStateSet().contains(com.sun.star.accessibility.AccessibleStateType.ENABLED);
+
+ XAccessibleContext oButton = null;
+ while ((oButton == null) && (counter < maximum)){
+ log.println("recovering...");
+
+ try{
+ oButton = oUITools.getButton("Next >");
+ } catch (java.lang.NullPointerException e){
+ // no fault: The title "Start Recovery" switches to "Next"
+ // while all documents are recoverd
+ }
+ rt.pause();
+ counter++;
+ }
+
+ if (cancel) {
+ log.println("clicking 'Cancel' button...");
+
+ try{
+ rt.clickThreadButton(xMSF, xWindow, "Cancel");
+ } catch (com.sun.star.accessibility.IllegalAccessibleComponentStateException e){
+ failed("Could not click 'Cancel' at recovery-dialog.");
+ }
+
+ }
+ else {
+ log.println("clicking 'Next' button...");
+ oUITools.clickButton("Next >");
+ }
+
+ rt.pause();
+
+ } else {
+ log.println("do not recover: clicking 'Cancel' button...");
+
+ try{
+ rt.clickThreadButton(xMSF, xWindow, "Cancel");
+ } catch (com.sun.star.accessibility.IllegalAccessibleComponentStateException e){
+ failed("Could not click 'Cancel' at recovery-dialog");
+ }
+ }
+
+ } catch (Exception e){
+ failed("Could not handle recovery-dialog at restart: " + e.toString());
+ }
+
+ }
+
+ /**
+ * This function uses accessibility to handle the dialog "Are you sure".
+ * It cklick "Yes" or "No", dependend on the value of the parameter <CODE>Yes</CODE>
+ * @param yes If value is <CODE>TRUE</CODE> the button "Yes" was clicked, otherwise the button
+ * "No".
+ */
+ private void handleAreYouSureDialog(boolean yes)
+ {
+ try{
+ if (yes){
+ rt.handleModalDialog(xMSF, "Yes");
+ } else{
+ rt.handleModalDialog(xMSF, "Cancel");
+ }
+ } catch (com.sun.star.accessibility.IllegalAccessibleComponentStateException e){
+ failed("Could not handle 'Are you sure' dialog.");
+ }
+ }
+
+ /**
+ * This function uses accessibility to handle the dialog "Are you sure".
+ * It cklick "Yes" or "No", dependend on the value of the parameter <CODE>Yes</CODE>
+ * @param yes If value is <CODE>TRUE</CODE> the button "Yes" was clicked, otherwise the button
+ * "No".
+ */
+ private void handleSaveDocumentsDialog(boolean saveDocuments)
+ {
+ try{
+ if (!saveDocuments){
+ rt.handleModalDialog(xMSF, "Cancel");
+ } else{
+ XWindow oDialog = null;
+ oDialog = rt.getActiveWindow(xMSF);
+
+ assure("could not get 'Save Documents' Dialog: ", (oDialog != null), CONTINUE);
+
+ UITools oUITools = new UITools(xMSF, oDialog);
+
+ oUITools.printAccessibleTree((PrintWriter) log, param.getBool(PropertyName.DEBUG_IS_ACTIVE));
+
+ String listBoxName = "Documents";
+ String[] documents = null;
+ try{
+ documents = oUITools.getListBoxItems(listBoxName);
+ } catch (java.lang.Exception e){
+ failed("could not get the document names from the 'Save Documents' dialog", CONTINUE);
+ }
+ log.println("there are " + documents.length + " documents to save");
+ log.println("The following documents will be saved:");
+ for (int i=0;i<documents.length;i++){
+ log.println(documents[i]);
+ }
+ String tempURL = utils.getOfficeTempDir(xMSF);
+
+ log.println("the destination for saveing is: " + tempURL);
+ try{
+ oUITools.setTextEditFiledText("Save to", tempURL);
+ } catch (java.lang.Exception e){
+ failed("could not set target directory for saving documents at 'Save Documents' dialog", CONTINUE);
+ }
+ try{
+ oUITools.clickButton("OK");
+ } catch (java.lang.Exception e){
+ failed("could not click 'OK' at 'Save Documents' dialog", CONTINUE);
+ }
+ }
+ } catch (com.sun.star.accessibility.IllegalAccessibleComponentStateException e){
+ failed("Could not handle 'Are you sure' dialog.");
+ }
+ }
+
+ /**
+ * This function gets the current screen size and calculate the first
+ * quarter of it. This qaurter was used to postion to Office windows.
+ * Further this function calculates the maximum window size so the window
+ * is visible if it placed on extreme position.
+ */
+ private void makeWindowPositionRage(){
+ Dimension screenDim = Toolkit.getDefaultToolkit().getScreenSize();
+ Point pos = new Point();
+ Size size = new Size();
+
+ // get the max position of the first quarter of the screen
+ pos.x = screenDim.width / 2;
+ pos.y = screenDim.height / 2;
+ windowMaxPosition = pos;
+
+ // get the max size of the windows while they placed in windowMaxPosition
+ // range and not outside the visibility
+ size.Height = screenDim.height;
+ size.Width = screenDim.width;
+ windowMaxSize = size;
+ }
+
+ private void generateDesktop(){
+
+ // create some documents with content
+ makeWriterDoc("WriterDoc1", true);
+// makeCalcDoc("CalcDoc1", true);
+// makeDrawDoc("DrawDoc1", true);
+// makeImpressDoc("ImpressDoc1", true);
+// makeMathDoc("MathDoc1", true);
+
+ // create some documents without content
+// makeMathDoc("_blank_math", false);
+// makeDrawDoc("_blank_draw", false);
+// makeCalcDoc("_blank_calc", false);
+// makeWriterDoc("_blank_writer", false);
+// makeImpressDoc("_blank_impress", false);
+
+// makeMathDoc("MathDocEmpty", false);
+// makeDrawDoc("DrawDocEmpty", false);
+// makeCalcDoc("CalcDocEmpty", false);
+ makeWriterDoc("WriterDocEmpty", false);
+// makeImpressDoc("ImpressDocEmpty", false);
+
+ log.println("Test object successfully created.");
+
+ }
+
+ private void makeImpressDoc(String frameName, boolean withContent){
+ log.println("creating Impress document '" + frameName + "'");
+ XComponent xImpressDoc = createNewImpressDoc(frameName);
+ if (withContent) fillImpressDocWithContent(xImpressDoc);
+ positioningDocument((XModel) UnoRuntime.queryInterface(XModel.class,
+ xImpressDoc));
+ }
+
+ private void makeDrawDoc(String frameName, boolean withContent){
+ log.println("creating Draw document '" + frameName + "'");
+ XComponent xDrawDoc = createNewDrawDoc(frameName);
+ if (withContent) fillDrawDocWithContent(xDrawDoc);
+ positioningDocument((XModel) UnoRuntime.queryInterface(XModel.class,
+ xDrawDoc));
+ }
+
+ private void makeCalcDoc(String frameName, boolean withContent){
+ log.println("creating Calc document '" + frameName + "'");
+ XSpreadsheetDocument xSpreadsheetDoc = createNewCalcDoc(frameName);
+ if (withContent) fillCalcDocWithContent(xSpreadsheetDoc);
+ positioningDocument((XModel) UnoRuntime.queryInterface(XModel.class,
+ xSpreadsheetDoc));
+ }
+
+ private void positioningDocument(XModel model){
+
+ XWindow xWindow = model.getCurrentController().getFrame().getContainerWindow();
+ String frameName = model.getCurrentController().getFrame().getName();
+
+ // get randomized position and size
+ Rectangle posSize = makePosZize();
+
+ // save position and size
+ windowsPosSize.put(frameName, posSize);
+
+ xWindow.setPosSize(posSize.X, posSize.Y, posSize.Width, posSize.Height,
+ com.sun.star.awt.PosSize.POSSIZE);
+ Rectangle test = xWindow.getPosSize();
+ log.println("x: "+test.X+" y:"+test.Y+" width:"+test.Width+" height:"+test.Height);
+ }
+
+ private Rectangle makePosZize(){
+
+ Rectangle posSize = new Rectangle();
+ Random rand = new Random();
+
+ // Random integers that range from from 0 to n
+ posSize.X = rand.nextInt(windowMaxPosition.x + 1);
+ posSize.Y = rand.nextInt(windowMaxPosition.y + 1);
+
+ int maxHeight = windowMaxSize.Height-posSize.X;
+ int maxWidth = windowMaxSize.Width-posSize.Y;
+ int height = rand.nextInt(maxHeight + 1);
+ int width = rand.nextInt((windowMaxSize.Width-posSize.Y) + 1);
+
+ // be shure that the new size his greater then the half of windowMaxSize
+ posSize.Height = (height < (maxHeight / 2)) ? height + (maxHeight / 2) : height;
+ posSize.Width = (width < (maxWidth / 2)) ? width + (maxWidth / 2) : width;
+
+ return posSize;
+ }
+
+ private void makeMathDoc(String frameName, boolean withContent){
+ log.println("creating Math document '" + frameName + "'");
+ XComponent xMathDoc = createNewMathDoc(frameName);
+ if (withContent) fillMathDocWithContent(xMathDoc);
+ positioningDocument((XModel) UnoRuntime.queryInterface(XModel.class,
+ xMathDoc));
+ }
+
+ private XComponent createNewMathDoc(String frameName){
+ XComponent xMathDoc = null;
+ try{
+ xMathDoc = SOF.createMathDoc(frameName);
+ } catch (com.sun.star.uno.Exception e) {
+ log.println("Exception occured while creating math document '"+frameName+"':");
+ failed("Couldn't create test environment");
+ }
+ return xMathDoc;
+ }
+
+ private void fillMathDocWithContent(XComponent xMathDoc){
+ // setting a formula in document
+ final String expFormula = "sum a cdot b";
+ final XPropertySet xPS = (XPropertySet) UnoRuntime.queryInterface
+ (XPropertySet.class, xMathDoc);
+ try {
+ xPS.setPropertyValue("Formula", expFormula);
+ } catch(com.sun.star.lang.WrappedTargetException e) {
+ log.println("Exception occured while filling math document with content.");
+ failed("Couldn't create test environment");
+ } catch(com.sun.star.lang.IllegalArgumentException e) {
+ log.println("Exception occured while filling math document with content.");
+ failed("Couldn't create test environment");
+ } catch(com.sun.star.beans.PropertyVetoException e) {
+ log.println("Exception occured while filling math document with content.");
+ failed("Couldn't create test environment");
+ } catch(com.sun.star.beans.UnknownPropertyException e) {
+ log.println("Exception occured while filling math document with content.");
+ failed("Couldn't create test environment");
+ }
+ }
+
+ private XComponent createNewImpressDoc(String frameName){
+ XComponent xImpressDoc = null;
+ try{
+ xImpressDoc = SOF.createImpressDoc(frameName);
+ } catch (com.sun.star.uno.Exception e) {
+ log.println("Exception occured while creating impress document '"+frameName+"':");
+ failed("Couldn't create test environment");
+ }
+ return xImpressDoc;
+ }
+
+
+ private void fillImpressDocWithContent(XComponent xImpressDoc){
+
+ log.println( "get presentation" );
+ XPresentationSupplier oPS = (XPresentationSupplier)
+ UnoRuntime.queryInterface(XPresentationSupplier.class, xImpressDoc);
+ XInterface oObj = oPS.getPresentation();
+
+ log.println( "get custom presentation" );
+ XCustomPresentationSupplier oCPS = (XCustomPresentationSupplier)
+ UnoRuntime.queryInterface(
+ XCustomPresentationSupplier.class, xImpressDoc);
+ XNameContainer xCP = oCPS.getCustomPresentations();
+
+ XInterface oInstance = null;
+
+ XSingleServiceFactory oSingleMSF = (XSingleServiceFactory)
+ UnoRuntime.queryInterface(XSingleServiceFactory.class, xCP);
+
+ try{
+ oInstance = (XInterface) oSingleMSF.createInstance();
+ } catch (com.sun.star.uno.Exception e) {
+ log.println("Could not create custom presentation while filling impress document with content.");
+ failed("Couldn't create test environment");
+ }
+
+ try {
+ xCP.insertByName("FirstPresentation",oInstance);
+ } catch (com.sun.star.lang.WrappedTargetException e) {
+ log.println("Could not instert custom presentation while filling impress document with content.");
+ failed("Couldn't create test environment");
+ } catch (com.sun.star.container.ElementExistException e) {
+ log.println("Could not instert custom presentation while filling impress document with content.");
+ failed("Couldn't create test environment");
+ } catch (com.sun.star.lang.IllegalArgumentException e) {
+ log.println("Could not instert custom presentation while filling impress document with content.");
+ failed("Couldn't create test environment");
+ }
+ }
+
+ private XComponent createNewDrawDoc(String frameName){
+ XComponent xDrawDoc = null;
+ try{
+ xDrawDoc = SOF.createDrawDoc(frameName);
+ } catch (com.sun.star.uno.Exception e) {
+ log.println("Exception occured while creating draw document '"+frameName+"':");
+ failed("Couldn't create test environment");
+ }
+ return xDrawDoc;
+ }
+
+ private void fillDrawDocWithContent(XComponent xDrawDoc){
+ XDrawPagesSupplier oDPS = (XDrawPagesSupplier)
+ UnoRuntime.queryInterface(XDrawPagesSupplier.class, xDrawDoc);
+ XDrawPages oDPn = oDPS.getDrawPages();
+ XIndexAccess oDPi = (XIndexAccess)
+ UnoRuntime.queryInterface(XIndexAccess.class, oDPn);
+ XDrawPage oDP = null;
+ try {
+ oDP = (XDrawPage) AnyConverter.toObject(
+ new Type(XDrawPage.class),oDPi.getByIndex(0));
+ } catch (com.sun.star.lang.WrappedTargetException e) {
+ log.println("Could not get draw pages while filling draw document with content.");
+ failed("Couldn't create test environment");
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
+ log.println("Could not get draw pages while filling draw document with content.");
+ failed("Couldn't create test environment");
+ } catch (com.sun.star.lang.IllegalArgumentException e) {
+ log.println("Could not get draw pages while filling draw document with content.");
+ failed("Couldn't create test environment");
+ }
+
+ //get a Shape
+ log.println( "getting Shape" );
+ XShapes oShapes = (XShapes) UnoRuntime.queryInterface
+ (XShapes.class, oDP);
+ XInterface oObj = SOF.createShape
+ (xDrawDoc, 5000, 3500, 7500, 5000, "Rectangle");
+ for (int i=0; i < 10; i++) {
+ oShapes.add(
+ SOF.createShape(xDrawDoc,
+ 5000, 3500, 7510 + 10 * i, 5010 + 10 * i, "Rectangle"));
+ }
+ XShape oShape = SOF.createShape
+ (xDrawDoc, 3000, 4500, 15000, 1000, "Ellipse");
+ oShapes.add((XShape) oObj);
+ oShapes.add((XShape) oShape);
+
+
+ XPropertySet oShapeProps = (XPropertySet)
+ UnoRuntime.queryInterface(XPropertySet.class, oObj);
+ XStyle aStyle = null;
+ try {
+ aStyle = (XStyle) AnyConverter.toObject(
+ new Type(XStyle.class),oShapeProps.getPropertyValue("Style"));
+ oShapeProps.setPropertyValue("ZOrder", new Integer(1));
+ } catch (com.sun.star.lang.WrappedTargetException e) {
+ log.println("Exception occured while setting or getting property value while filling draw document with content.");
+ failed("Couldn't create test environment");
+ } catch (com.sun.star.beans.UnknownPropertyException e) {
+ log.println("Exception occured while setting or getting property value while filling draw document with content.");
+ failed("Couldn't create test environment");
+ } catch (com.sun.star.lang.IllegalArgumentException e) {
+ log.println("Exception occured while setting or getting property value while filling draw document with content.");
+ failed("Couldn't create test environment");
+ } catch (com.sun.star.beans.PropertyVetoException e) {
+ log.println("Exception occured while setting or getting property value while filling draw document with content.");
+ failed("Couldn't create test environment");
+ }
+ }
+
+ private void makeWriterDoc(String frameName, boolean withContent){
+ log.println("creating Writer document '" + frameName + "'");
+ XTextDocument xTextDoc = createNewWriterDoc(frameName);
+ if (withContent) fillWriterDocWithContent(xTextDoc);
+ positioningDocument((XModel) UnoRuntime.queryInterface(XModel.class,
+ xTextDoc));
+ }
+
+ private XTextDocument createNewWriterDoc(String frameName){
+ XTextDocument xTextDoc = null;
+ try {
+ xTextDoc = SOF.createTextDoc(frameName);
+ } catch (com.sun.star.uno.Exception e) {
+ log.println("Exception occured while creating text document '"+frameName+"':");
+ failed("Couldn't create test environment");
+ }
+ return xTextDoc;
+ }
+
+ private void fillWriterDocWithContent(XTextDocument xTextDoc){
+ try{
+ log.println( "inserting some lines" );
+ XText oText = xTextDoc.getText();
+ XTextCursor oCursor = oText.createTextCursor();
+ for (int i=0; i<5; i++){
+ oText.insertString( oCursor,"Paragraph Number: " + i, false);
+ oText.insertString( oCursor,
+ " The quick brown fox jumps over the lazy Dog: SwXParagraph",
+ false);
+ oText.insertControlCharacter(
+ oCursor, ControlCharacter.PARAGRAPH_BREAK, false );
+ oText.insertString( oCursor,
+ "THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG: SwXParagraph",
+ false);
+ oText.insertControlCharacter(oCursor,
+ ControlCharacter.PARAGRAPH_BREAK, false );
+ oText.insertControlCharacter(
+ oCursor, ControlCharacter.LINE_BREAK, false );
+ }
+ } catch ( com.sun.star.lang.IllegalArgumentException e ){
+ log.println("Exception occured while filling text document with content.");
+ failed("Couldn't create test environment");
+ } catch (com.sun.star.uno.Exception e) {
+ log.println("Exception occured while filling text document with content.");
+ failed("Couldn't create test environment");
+ }
+ }
+
+ private XSpreadsheetDocument createNewCalcDoc(String frameName){
+
+ XSpreadsheetDocument xSheetDoc = null;
+
+ try {
+ xSheetDoc = SOF.createCalcDoc(frameName);
+ } catch (com.sun.star.uno.Exception e) {
+ log.println("Exception occured while creating calc document '"+frameName+"':");
+ failed("Couldn't create test environment");
+ }
+ return xSheetDoc;
+ }
+
+ private void fillCalcDocWithContent(XSpreadsheetDocument xSpreadsheetDoc){
+
+ try{
+ XSpreadsheets oSpreadsheets = xSpreadsheetDoc.getSheets();
+
+ XSpreadsheet oSheet = (XSpreadsheet) AnyConverter.toObject(
+ new Type(XSpreadsheet.class),
+ oSpreadsheets.getByName(
+ oSpreadsheets.getElementNames()[0]));
+
+ XCellRange testRange = oSheet.getCellRangeByName("$A$1:$D$4");
+
+ XSheetCellRange testSheetRange = (XSheetCellRange) UnoRuntime.queryInterface(
+ XSheetCellRange.class,
+ testRange);
+ oSheet.getCellByPosition(1, 1).setValue(1);
+ oSheet.getCellByPosition(4, 5).setValue(1);
+ oSheet.getCellByPosition(3, 2).setFormula("xTextDoc");
+ oSheet.getCellByPosition(3, 3).setFormula("xTextDoc");
+ } catch (com.sun.star.lang.WrappedTargetException e) {
+ log.println("Exception occured while filling calc document with content.");
+ failed("Couldn't create test environment");
+ } catch (com.sun.star.container.NoSuchElementException e) {
+ log.println("Exception occured while filling calc document with content.");
+ failed("Couldn't create test environment");
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
+ log.println("Exception occured while filling calc document with content.");
+ failed("Couldn't create test environment");
+ } catch (com.sun.star.lang.IllegalArgumentException e) {
+ log.println("Exception occured while filling calc document with content.");
+ failed("Couldn't create test environment");
+ } catch (com.sun.star.uno.Exception e) {
+ log.println("Exception occured while filling calc document with content.");
+ failed("Couldn't create test environment");
+ }
+ }
+
+ /**
+ * copies all files from the backup folder into a folder called backup.recoveryTest
+ * and copies the Recovery.xcu to recovery.xcu.recoeryTest
+ */
+ private void backupRecoveryData()
+ {
+ log.println("backup recovery data...");
+ try{
+ rt.copyRecoveryData(true);
+ }catch (com.sun.star.io.IOException e){
+ failed("could not copy recovery data: " + e.toString());
+ }catch (java.io.IOException e){
+ failed("could not copy recovery data: " + e.toString());
+ }
+ }
+
+ /**
+ * copies all files from the backup.recoveryTest folder into the backup folder
+ * and copies the Recovery.xcu.recoveryTest to recovery.xcu
+ */
+ private void restoreBackupRecoveryData()
+ {
+ log.println("restore backup recovery data...");
+ try{
+ rt.copyRecoveryData(false);
+ }catch (com.sun.star.io.IOException e){
+ failed("could not copy recovery data: " + e.toString());
+ }catch (java.io.IOException e){
+ failed("could not copy recovery data: " + e.toString());
+ }
+ }
+
+ private void cleanRecoveryData(){
+ try{
+ log.println("bootstrapping the office to get user path to remove old recovery data...");
+
+ rt.cleanRecoveryData();
+
+ } catch (com.sun.star.io.IOException e){
+ failed("could not clean recovery data: " + e.toString());
+ }
+ }
+}
diff --git a/framework/qa/complex/framework/recovery/RecoveryTools.java b/framework/qa/complex/framework/recovery/RecoveryTools.java
new file mode 100644
index 000000000000..28936949d8ef
--- /dev/null
+++ b/framework/qa/complex/framework/recovery/RecoveryTools.java
@@ -0,0 +1,366 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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 complex.framework.recovery;
+
+import com.sun.star.awt.XDialog;
+import com.sun.star.awt.XExtendedToolkit;
+import com.sun.star.awt.XWindow;
+import com.sun.star.beans.NamedValue;
+import com.sun.star.frame.XController;
+import com.sun.star.frame.XDesktop;
+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 com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.ucb.XSimpleFileAccess;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XInterface;
+import com.sun.star.util.URL;
+import com.sun.star.util.XURLTransformer;
+import helper.FileTools;
+import helper.OfficeProvider;
+import helper.UnoProvider;
+import java.io.File;
+import java.io.PrintWriter;
+import java.util.HashMap;
+import lib.TestParameters;
+import share.LogWriter;
+import util.PropertyName;
+import util.UITools;
+import util.utils;
+
+/**
+ * this class supports the <CODE>RecoverTest</CODE>. You will find here some helper
+ * functions.
+ */
+public class RecoveryTools {
+
+ private final TestParameters param;
+ private final LogWriter log;
+
+ /**
+ * Creates new OfficeWatcher
+ * @param param the test parameter
+ * @param log a log writer
+ */
+ public RecoveryTools(TestParameters param, LogWriter log) {
+ this.param = param;
+ this.log = log;
+
+ }
+
+ /**
+ * get the active dialog from the top of the desktop
+ * @param xToolKit xToolKit the <CODE> XExtendedToolkit</CODE> to get the dialog from the top of the desktop.
+ * @return a <CODE>XDialog</CODE> interface of the dialog
+ */
+ public XDialog getActiveDialog( XMultiServiceFactory xMSF){
+ XWindow xWin = getActiveWindow(xMSF);
+ return (XDialog) UnoRuntime.queryInterface(XDialog.class, xWin);
+ }
+
+ public XWindow getActiveWindow( XMultiServiceFactory xMSF){
+ XInterface xToolKit = null;
+ try {
+ xToolKit = (XInterface) xMSF.createInstance("com.sun.star.awt.Toolkit") ;
+ } catch (com.sun.star.uno.Exception e) {
+ return null;
+ }
+
+ XExtendedToolkit tk = (XExtendedToolkit)
+ UnoRuntime.queryInterface(XExtendedToolkit.class, xToolKit);
+ Object atw = tk.getActiveTopWindow();
+ return (XWindow) UnoRuntime.queryInterface(XWindow.class, atw);
+ }
+
+ /**
+ * After a crash the office start with a recovery diaolg. It could be that the office
+ * is connectable but not all services to get the dialog a loaded. This function
+ * tries to get the dialog until the <CODE>OfficeWatcher</CODE> kills the office.
+ * @param xToolKit the <CODE> XExtendedToolkit</CODE> to get the dialog from the top of the desktop.
+ * @return a <CODE>XDialog</CODE> interface of the dialog
+ */
+ public XDialog getActiveDialogAfterStartup(XMultiServiceFactory xMSF){
+ // while the office starts it takes some time to get the dialog.
+
+ // the dialog is accessible AFTER the office has recoverd all documents.
+ // This could consumes more time then the TimeOut allow.
+ int counter = 0;
+ int multi = 5;
+ int pause = param.getInt(PropertyName.SHORT_WAIT)*10;
+ int timeOut = param.getInt(PropertyName.THREAD_TIME_OUT)*5;
+ int maximum = (timeOut / pause) * multi;
+
+ XDialog oDialog = getActiveDialog(xMSF);
+
+ while (oDialog == null && (counter < maximum)){
+ log.println("waiting until the office has recoverd... remaining " + (timeOut * multi - pause * counter)/1000 + " seconds");
+ pause(pause);
+ oDialog = getActiveDialog(xMSF);
+ counter ++;
+ }
+ return oDialog;
+ }
+
+ /**
+ * halt the thread for some time
+ */
+ public void pause(){
+ pause(param.getInt(PropertyName.SHORT_WAIT));
+ }
+
+ /**
+ * halt the thread for some time
+ */
+ public void pause(int sleepTime){
+ sleep(sleepTime);
+ }
+
+ private void sleep(long millis){
+ try{
+ Thread.sleep(millis);
+ }catch (java.lang.InterruptedException e){}
+ }
+
+ /**
+ * remove the content of the user backup folder and removes the Recovery.xcu. This
+ * was done from the Office via XSimpleFileAccess
+ * @param xMSF a <CODE>XMultiServiceFactory</CODE> to get <CODE>XSimpleFileAccess</CODE>
+ * @throws com.sun.star.io.IOException the exception was thrown if something goes wrong.
+ */
+ public void cleanRecoveryData()
+ throws com.sun.star.io.IOException
+ {
+ try{
+ HashMap recFiles = getRecoveryFiles();
+
+ String recoveryFolder = (String) recFiles.get("recoveryFolder");
+ String recoveryXCU = (String) recFiles.get("recoveryXCU");
+
+ log.println("try to remove content of '" + recoveryFolder + "'");
+
+ File rf = new File(recoveryFolder);
+
+ boolean success = FileTools.cleanDir(rf);
+ log.println("removed " + recoveryFolder + ": " + success);
+
+ log.println("try to remove '" + recoveryXCU + "'");
+
+ File xcu = new File(recoveryXCU);
+ if (xcu.isFile()){
+ success = xcu.delete();
+ log.println("removed " + recoveryXCU + " : " + success);
+ }
+
+ } catch (Exception e){
+ throw new com.sun.star.io.IOException("could not remove old recovery data: " + e.toString());
+ }
+ }
+
+ public HashMap getRecoveryFiles()
+ throws com.sun.star.io.IOException
+ {
+ try{
+ log.println("try to get UnoProvider...");
+ UnoProvider unoProv = new UnoProvider();
+ XMultiServiceFactory xMSF = (XMultiServiceFactory) unoProv.getManager(param);
+
+ String userPath = utils.expandMacro(xMSF, "${$ORIGIN/bootstraprc:UserInstallation}");
+ System.out.println("userPath:'" + userPath + "'");
+
+ if (userPath.equals(""))userPath = utils.expandMacro(xMSF, "${$ORIGIN/bootstrap.ini:UserInstallation}");
+ System.out.println("userPath:'" + userPath + "'");
+
+ if (userPath.equals("")) throw new com.sun.star.io.IOException("could not get user path at bootstraping");
+
+ String recoveryFolder = utils.getSystemURL(userPath + "/user/backup");
+
+ String recoveryXCU = utils.getSystemURL(userPath + "/user/registry/data/org/openoffice/Office/Recovery.xcu");
+
+ HashMap recFiles = new HashMap();
+
+ recFiles.put("recoveryFolder", recoveryFolder);
+ recFiles.put("recoveryXCU", recoveryXCU);
+ return recFiles;
+
+ } catch (Exception e){
+ throw new com.sun.star.io.IOException("could not get recovery folder: " + e.toString());
+ }
+
+ }
+ /**
+ * This function close the office while calling terminate on the desktop. If
+ * this failed, the <CODE>ProcessHandler</CODE> kills the process.
+ * @param xMSF the <CODE>XMultiServiceFactory</CODE>
+ * @return <CODE>TRUE</CODE> if no exception was thrown, otherwise <CODE>FALSE</CODE>
+ */
+ public boolean closeOffice(XMultiServiceFactory xMSF) {
+ try {
+ XDesktop desk = (XDesktop) UnoRuntime.queryInterface(
+ XDesktop.class, xMSF.createInstance(
+ "com.sun.star.frame.Desktop"));
+ xMSF = null;
+
+ desk.terminate();
+ log.println("Waiting until ProcessHandler loose the office...");
+
+ }
+ catch (java.lang.Exception e) {
+ e.printStackTrace();
+ return false;
+ }
+ waitForClosedOffice();
+ return true;
+ }
+
+ /**
+ * This function waits until the office is closed. If the closing time reach
+ * the value of parameter <CODE>THREAD_TIME_OUT</CODE> the office was killed.
+ */
+ public void waitForClosedOffice(){
+ // check for the office process
+ helper.ProcessHandler ph = (helper.ProcessHandler) param.get("AppProvider");
+
+ int timeOut = param.getInt(PropertyName.THREAD_TIME_OUT)*5;
+ int pause = param.getInt(PropertyName.SHORT_WAIT)*20;
+ int multi = 0;
+ while ((ph != null) && (ph.getExitCode()<0) && (pause*multi < timeOut)) {
+ log.println("waiting until the office is closed... remaining " + (timeOut - pause * multi)/1000 + " seconds");
+ pause(pause);
+ multi ++;
+ }
+
+ // be shure that office is closed
+ if (ph != null) ph.kill();
+ }
+
+ public void killOffice(){
+ helper.ProcessHandler ph = (helper.ProcessHandler) param.get("AppProvider");
+ ph.kill();
+ }
+
+ /**
+ * The office must be started WITH restore and crashreporter functionality.
+ * Therefore the parmater '<CODE>-norestore</CODE>' and '<CODE>-nocrashreport</CODE>'
+ * was removed from the <CODE>AppExecutionCommand</CODE> parameter
+ */
+ public void removeParametersFromAppExecutionCommand(){
+
+ //remove some params to start office
+ String office = (String) param.get("AppExecutionCommand");
+ String[] params = {"-norestore", "-nocrashreport"};
+
+ for (int i = 0; i < params.length; i++){
+ int index = office.indexOf(params[i]);
+ int length = params[i].length();
+ if (index != -1){
+ office = office.substring(0, index) + office.substring(index + length);
+ log.println("removed '" + params[i] + "' from AppExecutionCommand: " + office);
+ }
+ }
+ param.put("AppExecutionCommand", office);
+ log.println("connect: " + (String) param.get("AppExecutionCommand"));
+
+ }
+
+ /**
+ * This function uses accessibility to handle modal dialogs like the
+ * "Are you sure" dialog.
+ * It cklick the named button given in parameter <CODE>buttonName</CODE>
+ * @param buttonName the name of the button wich should be chlicked
+ */
+ public void handleModalDialog(XMultiServiceFactory xMSF, String buttonName)
+ throws com.sun.star.accessibility.IllegalAccessibleComponentStateException
+ {
+
+ log.println("try to get modal Dialog...");
+
+ pause();
+
+ XWindow oDialog = getActiveWindow(xMSF);
+
+ if (oDialog == null) throw new com.sun.star.accessibility.IllegalAccessibleComponentStateException("could not get modal Dialog");
+
+
+ UITools oUITools = new UITools(xMSF, oDialog);
+ oUITools.printAccessibleTree((PrintWriter) log, param.getBool(PropertyName.DEBUG_IS_ACTIVE));
+
+ try{
+ log.println("click ' " + buttonName + "' button..");
+ oUITools.clickButton(buttonName);
+ } catch ( java.lang.Exception e){
+ throw new com.sun.star.accessibility.IllegalAccessibleComponentStateException("Could not klick '"+buttonName +"' at modal dialog: " + e.toString());
+ }
+ pause();
+ }
+
+ public void clickThreadButton(XMultiServiceFactory xMSF, XWindow xWindow, String buttonName)
+ throws com.sun.star.accessibility.IllegalAccessibleComponentStateException
+ {
+ KlickButtonThread kbt = new KlickButtonThread(xMSF, xWindow, buttonName);
+ kbt.start();
+ pause(param.getInt(PropertyName.SHORT_WAIT) * 10);
+ }
+
+ public void copyRecoveryData(boolean backup)
+ throws com.sun.star.io.IOException, java.io.IOException
+ {
+ HashMap recFiles = null;
+
+ try{
+ recFiles = getRecoveryFiles();
+ } catch ( com.sun.star.io.IOException e){
+ throw new com.sun.star.io.IOException("Could not get recovery files: " + e.toString());
+ }
+
+ try{
+ String recoveryFolder = (String) recFiles.get("recoveryFolder");
+ String recoveryXCU = (String) recFiles.get("recoveryXCU");
+
+ File recFolder = new File(recoveryFolder);
+ File recFolderBackup = new File(recoveryFolder+".recoveryTest");
+
+ File recXCU = new File(recoveryXCU);
+ File recXCUBackup = new File(recoveryXCU + ".recoveryTest");
+
+ if (backup){
+ FileTools.copyDirectory(recFolder, recFolderBackup);
+ FileTools.copyFile(recXCU, recXCUBackup);
+ } else {
+ FileTools.copyDirectory(recFolderBackup, recFolder);
+ FileTools.copyFile(recXCUBackup, recXCU);
+
+ }
+ } catch (java.io.IOException e){
+ throw new java.io.IOException("Could not copy recovery files: " + e.toString());
+ }
+ }
+
+
+} \ No newline at end of file
diff --git a/framework/qa/complex/framework/recovery/TimeoutThread.java b/framework/qa/complex/framework/recovery/TimeoutThread.java
new file mode 100644
index 000000000000..088f4b3d36f6
--- /dev/null
+++ b/framework/qa/complex/framework/recovery/TimeoutThread.java
@@ -0,0 +1,41 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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 complex.framework.recovery;
+
+public class TimeoutThread extends Thread{
+ public int timeOut = 0;
+ /** Creates a new instance of TimeoutThread */
+ public TimeoutThread(int timeOut) {
+ this.timeOut = timeOut;
+ }
+
+ public void run(){
+ util.utils.shortWait(timeOut);
+ }
+
+}
diff --git a/framework/qa/complex/framework/recovery/makefile.mk b/framework/qa/complex/framework/recovery/makefile.mk
new file mode 100755
index 000000000000..4a9f80b4b2a5
--- /dev/null
+++ b/framework/qa/complex/framework/recovery/makefile.mk
@@ -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.
+#
+#*************************************************************************
+
+PRJ = ..$/..$/..$/..
+TARGET = RecoveryTest
+PRJNAME = framework
+PACKAGE = complex$/framework$/recovery
+
+# --- Settings -----------------------------------------------------
+.INCLUDE: settings.mk
+
+
+#----- compile .java files -----------------------------------------
+
+JARFILES = mysql.jar mysql.jar ridl.jar unoil.jar jurt.jar juh.jar java_uno.jar OOoRunner.jar
+JAVAFILES = RecoveryTest.java RecoveryTools.java CrashThread.java TimeoutThread.java KlickButtonThread.java
+JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class)
+
+#----- make a jar from compiled files ------------------------------
+
+MAXLINELENGTH = 100000
+
+JARCLASSDIRS = $(PACKAGE)
+JARTARGET = $(TARGET).jar
+JARCOMPRESS = TRUE
+
+#------ some information how to run the test -----------------------
+
+MYTAR: ALLTAR
+ @echo
+ @echo ########################### N O T E ######################################
+ @echo
+ @echo To run the test successfully you have to extend your LD_LIBRARY_PATH
+ @echo to your office program directory!
+ @echo Example:
+ @echo setenv LD_LIBRARY_PATH /myOffice/program:\$$LD_LIBRARY_PATH
+ @echo
+ @echo To run the you have to use the parameter cmd:
+ @echo cmd="PATH_TO_OFFICE_BINARY -accept=socket,host=localhost,port=8100;urp;"
+ @echo
+ @echo Example:
+ @echo dmake run cmd="/myOffice/program/soffice -accept=socket,host=localhost,port=8100;urp;"
+ @echo
+
+
+# --- Parameters for the test --------------------------------------
+
+# start an office if the parameter is set for the makefile
+.IF "$(cmd)" == ""
+CT_APPEXECCOMMAND =
+.ELSE
+CT_APPEXECCOMMAND = -cmd "$(cmd)"
+#CT_APPEXECCOMMAND = -AppExecutionCommand \
+# "$(OFFICE)$/soffice -accept=socket,host=localhost,port=8100;urp;"
+.ENDIF
+
+# test base is java complex
+CT_TESTBASE = -TestBase java_complex
+
+# replace $/ with . in package name
+CT_PACKAGE = -o $(PACKAGE:s\$/\.\)
+
+# start the runner application
+CT_APP = org.openoffice.Runner
+
+CT_NOOFFICE = -NoOffice true
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+
+RUN: run
+# muss noch angepasst werden: es soll auf -AppExecutionCommand und -NoOffice gepr??ft werden
+#.IF "$(OFFICE)" == ""
+#run:
+# @echo Exit
+#.ELSE
+run:
+ +java -cp $(CLASSPATH) $(CT_APP) $(CT_TESTBASE) $(CT_APPEXECCOMMAND) $(CT_NOOFFICE) $(CT_PACKAGE).RecoveryTest
+
diff --git a/framework/qa/complex/imageManager/CheckImageManager.java b/framework/qa/complex/imageManager/CheckImageManager.java
new file mode 100755
index 000000000000..8f283a034e20
--- /dev/null
+++ b/framework/qa/complex/imageManager/CheckImageManager.java
@@ -0,0 +1,197 @@
+package imageManager;
+
+import imageManager.interfaces._XComponent;
+import imageManager.interfaces._XImageManager;
+import imageManager.interfaces._XInitialization;
+import imageManager.interfaces._XTypeProvider;
+import imageManager.interfaces._XUIConfiguration;
+import imageManager.interfaces._XUIConfigurationPersistence;
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.container.XIndexAccess;
+import com.sun.star.lang.XComponent;
+import com.sun.star.lang.XInitialization;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.lang.XTypeProvider;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XInterface;
+import com.sun.star.ui.XImageManager;
+import complexlib.ComplexTestCase;
+import com.sun.star.ui.XModuleUIConfigurationManagerSupplier;
+import com.sun.star.ui.XUIConfiguration;
+import com.sun.star.ui.XUIConfigurationManager;
+import com.sun.star.ui.XUIConfigurationPersistence;
+import java.io.PrintWriter;
+import share.LogWriter;
+
+/**
+ *
+ */
+public class CheckImageManager extends ComplexTestCase {
+ boolean checkUIConfigManager = false;
+ XMultiServiceFactory xMSF = null;
+
+ public void before() {
+ xMSF = (XMultiServiceFactory)param.getMSF();
+ }
+
+ public String[] getTestMethodNames() {
+ return new String[]{"checkImageManagerFromModule"};//, "checkImageManager"};
+ }
+
+ public void checkImageManagerFromModule() {
+ log.println(" **** ImageManager from ModuleUIConfigurationManager *** ");
+ XUIConfigurationManager xManager = null;
+ try {
+ Object o = (XInterface)xMSF.createInstance(
+ "com.sun.star.ui.ModuleUIConfigurationManagerSupplier");
+ XModuleUIConfigurationManagerSupplier xMUICMS =
+ (XModuleUIConfigurationManagerSupplier)UnoRuntime.queryInterface(
+ XModuleUIConfigurationManagerSupplier.class, o);
+ xManager = xMUICMS.getUIConfigurationManager(
+ "com.sun.star.text.TextDocument");
+ }
+ catch(com.sun.star.uno.Exception e) {
+ e.printStackTrace((PrintWriter)log);
+ failed("Exception. " + e.getMessage());
+ }
+ XImageManager xImageManager = (XImageManager)UnoRuntime.queryInterface(
+ XImageManager.class, xManager.getImageManager());
+ performChecks(xImageManager, "ModuleUIConfig", xManager);
+ }
+
+ public void checkImageManager() {
+ log.println(" **** ImageManager from UIConfigurationManager *** ");
+ XUIConfigurationManager xManager = null;
+ try {
+ xManager = (XUIConfigurationManager)UnoRuntime.queryInterface(
+ XUIConfigurationManager.class, xMSF.createInstance(
+ "com.sun.star.comp.framework.UIConfigurationManager"));
+ }
+ catch(com.sun.star.uno.Exception e) {
+ e.printStackTrace((PrintWriter)log);
+ failed("Exception. " + e.getMessage());
+ }
+
+ XImageManager xImageManager = (XImageManager)UnoRuntime.queryInterface(
+ XImageManager.class, xManager.getImageManager());
+ performChecks(xImageManager, "UIConfig", xManager);
+ }
+
+ private void performChecks(XImageManager xImageManager, String testObjectName, XUIConfigurationManager xManager) {
+ util.dbg.printInterfaces(xImageManager);
+
+ OXUIConfigurationListenerImpl configListener = new OXUIConfigurationListenerImpl(log, xManager, xMSF);
+ param.put("XUIConfiguration.XUIConfigurationListenerImpl", configListener);
+
+ XInitialization xInit = (XInitialization)UnoRuntime.queryInterface(XInitialization.class, xImageManager);
+ _XInitialization _xInit = new _XInitialization(log, param, xInit);
+ assure(testObjectName + "::XInitialization.initialize", _xInit._initialize(), true);
+
+ // xImageManager is already there, just write a test ;-)
+ _XImageManager _xImage = new _XImageManager(log, param, xImageManager);
+ assure(testObjectName + "::XImageManager.getAllImageNames", _xImage._getAllImageNames(), true);
+ assure(testObjectName + "::XImageManager.getImages", _xImage._getImages(), true);
+ assure(testObjectName + "::XImageManager.hasImage", _xImage._hasImage(), true);
+ assure(testObjectName + "::XImageManager.insertImages", _xImage._insertImages(), true);
+ assure(testObjectName + "::XImageManager.removeImages", _xImage._removeImages(), true);
+ assure(testObjectName + "::XImageManager.replaceImages", _xImage._replaceImages(), true);
+ assure(testObjectName + "::XImageManager.reset", _xImage._reset(), true);
+
+ XTypeProvider xType = (XTypeProvider)UnoRuntime.queryInterface(XTypeProvider.class, xImageManager);
+ _XTypeProvider _xType = new _XTypeProvider(log,param,xType);
+ assure(testObjectName + "::XTypeProvider.getImplementationId", _xType._getImplementationId(), true);
+ assure(testObjectName + "::XTypeProvider.getTypes", _xType._getTypes(), true);
+
+ XUIConfiguration xUIConfig = (XUIConfiguration)UnoRuntime.queryInterface(XUIConfiguration.class, xImageManager);
+ _XUIConfiguration _xUIConfig = new _XUIConfiguration(log, param, xUIConfig);
+ _xUIConfig.before();
+ assure(testObjectName + "::XUIConfig.addConfigurationListener", _xUIConfig._addConfigurationListener(), true);
+ assure(testObjectName + "::XUIConfig.removeConfigurationListener", _xUIConfig._removeConfigurationListener(), true);
+
+ XUIConfigurationPersistence xUIConfigPersistence = (XUIConfigurationPersistence)UnoRuntime.queryInterface(XUIConfiguration.class, xImageManager);
+ _XUIConfigurationPersistence _xUIConfigPersistence = new _XUIConfigurationPersistence(log, param, xUIConfigPersistence);
+ _xUIConfigPersistence.before();
+ assure(testObjectName + "::XUIConfigPersistence.isModified", _xUIConfigPersistence._isModified(), true);
+ assure(testObjectName + "::XUIConfigPersistence.isReadOnly", _xUIConfigPersistence._isReadOnly(), true);
+ assure(testObjectName + "::XUIConfigPersistence.reload", _xUIConfigPersistence._reload(), true);
+ assure(testObjectName + "::XUIConfigPersistence.store", _xUIConfigPersistence._store(), true);
+ assure(testObjectName + "::XUIConfigPersistence.storeToStorage", _xUIConfigPersistence._storeToStorage(), true);
+
+ XComponent xComp = (XComponent)UnoRuntime.queryInterface(XComponent.class, xImageManager);
+ _XComponent _xComp = new _XComponent(log, param, xComp);
+ _xComp.before();
+ assure(testObjectName + "::XComponent.addEventListener", _xComp._addEventListener(), true);
+ assure(testObjectName + "::XComponent.removeEventListener", _xComp._removeEventListener(), true);
+ assure(testObjectName + "::XComponent.dispose", _xComp._dispose(), true);
+ }
+
+
+ class OXUIConfigurationListenerImpl implements _XUIConfiguration.XUIConfigurationListenerImpl {
+ private boolean triggered = false;
+ private LogWriter log = null;
+ private XUIConfigurationManager xUIManager = null;
+ private XMultiServiceFactory xMSF = null;
+
+ public OXUIConfigurationListenerImpl(LogWriter _log, XUIConfigurationManager xUIManager, XMultiServiceFactory xMSF) {
+ log = _log;
+ this.xUIManager = xUIManager;
+ this.xMSF = xMSF;
+ }
+
+ public boolean actionWasTriggered() {
+ return triggered;
+ }
+
+ public void disposing(com.sun.star.lang.EventObject eventObject) {
+ triggered = true;
+ }
+
+ public void elementInserted(com.sun.star.ui.ConfigurationEvent configurationEvent) {
+ triggered = true;
+ }
+
+ public void elementRemoved(com.sun.star.ui.ConfigurationEvent configurationEvent) {
+ triggered = true;
+ }
+
+ public void elementReplaced(com.sun.star.ui.ConfigurationEvent configurationEvent) {
+ triggered = true;
+ }
+
+ public void fireEvent() {
+ // remove for real action:
+ triggered = !triggered;
+/* try {
+ XIndexAccess xMenuBarSettings = xUIManager.getSettings(
+ "private:resource/menubar/menubar", true);
+
+ }
+ catch(com.sun.star.container.NoSuchElementException e) {
+ log.println("_XUIConfiguration.XUIConfigurationListenerImpl: Exception.");
+ e.printStackTrace((java.io.PrintWriter)log);
+ }
+ catch(com.sun.star.lang.IllegalArgumentException e) {
+ log.println("_XUIConfiguration.XUIConfigurationListenerImpl: Exception.");
+ e.printStackTrace((java.io.PrintWriter)log);
+ }
+ catch(com.sun.star.lang.IllegalAccessException e) {
+ log.println("_XUIConfiguration.XUIConfigurationListenerImpl: Exception.");
+ e.printStackTrace((java.io.PrintWriter)log);
+ }
+ catch(com.sun.star.lang.IndexOutOfBoundsException e) {
+ log.println("_XUIConfiguration.XUIConfigurationListenerImpl: Exception.");
+ e.printStackTrace((java.io.PrintWriter)log);
+ }
+ catch(com.sun.star.lang.WrappedTargetException e) {
+ log.println("_XUIConfiguration.XUIConfigurationListenerImpl: Exception.");
+ e.printStackTrace((java.io.PrintWriter)log);
+ } */
+ }
+
+ public void reset() {
+ // remove comment for real function
+ //triggered = false;
+ }
+
+ }
+}
diff --git a/framework/qa/complex/imageManager/interfaces/_XComponent.java b/framework/qa/complex/imageManager/interfaces/_XComponent.java
new file mode 100755
index 000000000000..4e30848b28d2
--- /dev/null
+++ b/framework/qa/complex/imageManager/interfaces/_XComponent.java
@@ -0,0 +1,179 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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 imageManager.interfaces;
+
+import com.sun.star.container.XNameContainer;
+import share.LogWriter;
+
+import com.sun.star.frame.XDesktop;
+import com.sun.star.lang.EventObject;
+import com.sun.star.lang.XComponent;
+import com.sun.star.lang.XEventListener;
+import lib.TestParameters;
+
+/**
+* Testing <code>com.sun.star.lang.XComponent</code>
+* interface methods :
+* <ul>
+* <li><code> dispose()</code></li>
+* <li><code> addEventListener()</code></li>
+* <li><code> removeEventListener()</code></li>
+* </ul>
+* After this interface test object <b>must be recreated</b>. <p>
+* Multithreaded test ability <b>not implemented</b> yet.
+* @see com.sun.star.lang.XComponent
+*/
+public class _XComponent {
+
+ public static XComponent oObj = null;
+ private XNameContainer xContainer = null;
+ private XComponent altDispose = null;
+ TestParameters tEnv = null;
+ LogWriter log = null;
+ boolean listenerDisposed[] = new boolean[2];
+ String[] Loutput = new String[2];
+
+ /**
+ * Listener which added but not removed, and its method must be called
+ * on <code>dispose</code> call.
+ */
+ public class MyEventListener implements XEventListener {
+ int number = 0;
+ String message = null;
+ public MyEventListener(int number, String message) {
+ this.message = message;
+ this.number = number;
+ }
+ public void disposing ( EventObject oEvent ) {
+ Loutput[number] = Thread.currentThread() + " is DISPOSING " + message + this;
+ listenerDisposed[number] = true;
+ }
+ };
+
+ XEventListener listener1 = new MyEventListener(0, "EV1");
+ XEventListener listener2 = new MyEventListener(1, "EV2");
+
+ public _XComponent(LogWriter log, TestParameters tEnv, XComponent oObj) {
+ this.log = log;
+ this.tEnv = tEnv;
+ this.oObj = oObj;
+ }
+
+ /**
+ * For the cfgmgr2.OSetElement tests: dispose the owner element.
+ */
+ public void before() {
+ // do not dispose this component, but parent instead
+ altDispose = (XComponent)tEnv.get("XComponent.DisposeThis");
+
+ }
+
+ /**
+ * Adds two listeners. <p>
+ * Has OK status if then the first listener will receive an event
+ * on <code>dispose</code> method call.
+ */
+ public boolean _addEventListener() {
+
+ listenerDisposed[0] = false;
+ listenerDisposed[1] = false;
+
+ oObj.addEventListener( listener1 );
+ oObj.addEventListener( listener2 );
+
+ return true;
+ } // finished _addEventListener()
+
+ /**
+ * Removes the second of two added listeners. <p>
+ * Method tests to be completed successfully :
+ * <ul>
+ * <li> <code>addEventListener</code> : method must add two listeners. </li>
+ * </ul> <p>
+ * Has OK status if no events will be sent to the second listener on
+ * <code>dispose</code> method call.
+ */
+ public boolean _removeEventListener() {
+ if (disposed) return false;
+ // the second listener should not be called
+ oObj.removeEventListener( listener2 );
+ log.println(Thread.currentThread() + " is removing EL " + listener2);
+ return true;
+ } // finished _removeEventListener()
+
+ static boolean disposed = false;
+
+ /**
+ * Disposes the object and then check appropriate listeners were
+ * called or not. <p>
+ * Method tests to be completed successfully :
+ * <ul>
+ * <li> <code>removeEventListener</code> : method must remove one of two
+ * listeners. </li>
+ * </ul> <p>
+ * Has OK status if liseter removed wasn't called and other listener
+ * was.
+ */
+ public boolean _dispose() {
+ disposed = false;
+
+ log.println( "begin dispose" + Thread.currentThread());
+ XDesktop oDesk = (XDesktop) tEnv.get("Desktop");
+ if (oDesk !=null) {
+ oDesk.terminate();
+ }
+ else {
+ if (altDispose == null)
+ oObj.dispose();
+ else
+ altDispose.dispose();
+ }
+
+ try {
+ Thread.sleep(500) ;
+ } catch (InterruptedException e) {}
+ if (Loutput[0]!=null) log.println(Loutput[0]);
+ if (Loutput[1]!=null) log.println(Loutput[1]);
+ log.println( "end dispose" + Thread.currentThread());
+ disposed = true;
+
+ // check that dispose() works OK.
+ return listenerDisposed[0] && !listenerDisposed[1];
+
+ } // finished _dispose()
+
+ /**
+ * Forces object recreation.
+ */
+ protected void after() {
+// disposeEnvironment();
+ }
+
+} // finished class _XComponent
+
+
diff --git a/framework/qa/complex/imageManager/interfaces/_XImageManager.java b/framework/qa/complex/imageManager/interfaces/_XImageManager.java
new file mode 100755
index 000000000000..ccba1464c106
--- /dev/null
+++ b/framework/qa/complex/imageManager/interfaces/_XImageManager.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 imageManager.interfaces;
+
+import com.sun.star.graphic.XGraphic;
+import com.sun.star.ui.ImageType;
+import com.sun.star.ui.XImageManager;
+import lib.TestParameters;
+import share.LogWriter;
+
+/**
+ *
+ */
+public class _XImageManager {
+ LogWriter log = null;
+ TestParameters tEnv = null;
+ String[]imageNames = null;
+ XGraphic[] xGraphicArray = null;
+ public XImageManager oObj;
+
+ public _XImageManager(LogWriter log, TestParameters tEnv, XImageManager oObj) {
+ this.log = log;
+ this.tEnv = tEnv;
+ this.oObj = oObj;
+ }
+
+ public boolean _getAllImageNames() {
+ short s = ImageType.COLOR_NORMAL + ImageType.SIZE_DEFAULT;
+ imageNames = oObj.getAllImageNames(s);
+ for (int i=0; i<(imageNames.length>10?10:imageNames.length); i++)
+ System.out.println("###### Image: " + imageNames[i]);
+ return imageNames != null;
+ }
+
+ public boolean _getImages() {
+ short s = ImageType.COLOR_NORMAL + ImageType.SIZE_DEFAULT;
+ try {
+ xGraphicArray = oObj.getImages(s, imageNames);
+ }
+ catch(com.sun.star.lang.IllegalArgumentException e) {
+ }
+ return xGraphicArray != null;
+ }
+
+ public boolean _hasImage() {
+ boolean result = true;
+ short s = ImageType.COLOR_NORMAL + ImageType.SIZE_DEFAULT;
+ try { // check the first image names, 10 at max
+ for (int i=0; i<(imageNames.length>10?10:imageNames.length); i++)
+ result &= oObj.hasImage(s, imageNames[i]);
+ }
+ catch(com.sun.star.lang.IllegalArgumentException e) {
+ e.printStackTrace((java.io.PrintWriter)log);
+ result = false;
+ }
+ return result;
+ }
+
+ public boolean _insertImages() {
+ try {
+ oObj.insertImages((short)imageNames.length, imageNames, xGraphicArray);
+ }
+ catch(com.sun.star.container.ElementExistException e) {
+ }
+ catch(com.sun.star.lang.IllegalArgumentException e) {
+ }
+ catch(com.sun.star.lang.IllegalAccessException e) {
+ }
+ return true;
+ }
+
+ public boolean _removeImages() {
+ try {
+ oObj.removeImages((short)(imageNames.length-1), imageNames);
+ }
+ catch(com.sun.star.lang.IllegalArgumentException e) {
+ }
+ catch(com.sun.star.lang.IllegalAccessException e) {
+ }
+ return true;
+ }
+
+ public boolean _replaceImages() {
+ return true;
+ }
+
+ public boolean _reset() {
+ return true;
+ }
+}
diff --git a/framework/qa/complex/imageManager/interfaces/_XInitialization.java b/framework/qa/complex/imageManager/interfaces/_XInitialization.java
new file mode 100755
index 000000000000..da957331671b
--- /dev/null
+++ b/framework/qa/complex/imageManager/interfaces/_XInitialization.java
@@ -0,0 +1,95 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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 imageManager.interfaces;
+
+import share.LogWriter;
+
+
+import com.sun.star.lang.XInitialization;
+import lib.TestParameters;
+
+/**
+* Testing <code>com.sun.star.lang.XInitialization</code>
+* interface methods. <p>
+* This test needs the following object relations :
+* <ul>
+* <li> <code>'XInitialization.args'</code> (of type <code>Object[]</code>):
+* (<b>Optional</b>) : argument for <code>initialize</code>
+* method. If ommitet zero length array is used. </li>
+* <ul> <p>
+* Test is multithread compilant. <p>
+* Till the present time there was no need to recreate environment
+* after this test completion.
+*/
+public class _XInitialization {
+
+ LogWriter log = null;
+ TestParameters tEnv = null;
+ public static XInitialization oObj = null;
+
+ public _XInitialization(LogWriter log, TestParameters tEnv, XInitialization oObj) {
+ this.log = log;
+ this.tEnv = tEnv;
+ this.oObj = oObj;
+ }
+
+ /**
+ * Test calls the method with 0 length array and checks that
+ * no exceptions were thrown. <p>
+ * Has <b> OK </b> status if no exceptions were thrown. <p>
+ */
+ public boolean _initialize() {
+ boolean result = true ;
+
+ try {
+ Object[] args = (Object[]) tEnv.get("XInitialization.args");
+ if (args==null) {
+ oObj.initialize(new Object[0]);
+ } else {
+ oObj.initialize(args);
+ }
+
+ } catch (com.sun.star.uno.Exception e) {
+ log.println("Exception occured while method calling.") ;
+ e.printStackTrace((java.io.PrintWriter)log) ;
+ result = false ;
+ }
+
+ return result ;
+ } // finished _initialize()
+
+ /**
+ * Disposes object environment.
+ */
+ public void after() {
+// disposeEnvironment() ;
+ }
+
+} // finished class _XInitialization
+
+
diff --git a/framework/qa/complex/imageManager/interfaces/_XTypeProvider.java b/framework/qa/complex/imageManager/interfaces/_XTypeProvider.java
new file mode 100755
index 000000000000..7ea641ca63d5
--- /dev/null
+++ b/framework/qa/complex/imageManager/interfaces/_XTypeProvider.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.
+ *
+ ************************************************************************/
+
+package imageManager.interfaces;
+
+import share.LogWriter;
+
+
+import com.sun.star.lang.XTypeProvider;
+import com.sun.star.uno.Type;
+import lib.TestParameters;
+
+/**
+* Testing <code>com.sun.star.lang.XTypeProvider</code>
+* interface methods :
+* <ul>
+* <li><code> getTypes()</code></li>
+* <li><code> getImplementationId()</code></li>
+* </ul> <p>
+* Test is <b> NOT </b> multithread compilant. <p>
+* @see com.sun.star.lang.XTypeProvider
+*/
+public class _XTypeProvider {
+
+ LogWriter log = null;
+ TestParameters tEnv = null;
+ public static XTypeProvider oObj = null;
+ public static Type[] types = null;
+
+ public _XTypeProvider(LogWriter log, TestParameters tEnv, XTypeProvider oObj) {
+ this.log = log;
+ this.tEnv = tEnv;
+ this.oObj = oObj;
+ }
+
+ /**
+ * Just calls the method.<p>
+ * Has <b>OK</b> status if no runtime exceptions occured.
+ */
+ public boolean _getImplementationId() {
+ boolean result = true;
+ log.println("testing getImplementationId() ... ");
+
+ log.println("The ImplementationId is "+oObj.getImplementationId());
+ result = true;
+
+ return result;
+
+ } // end getImplementationId()
+
+
+ /**
+ * Ñalls the method and checks the return value.<p>
+ * Has <b>OK</b> status if one of the return value equals to the
+ * type <code>com.sun.star.lang.XTypeProvider</code>.
+ */
+ public boolean _getTypes() {
+ boolean result = false;
+ log.println("getting Types...");
+ types = oObj.getTypes();
+ for (int i=0;i<types.length;i++) {
+ int k = i+1;
+ log.println(k+". Type is "+types[i].toString());
+ if (types[i].toString().equals
+ ("Type[com.sun.star.lang.XTypeProvider]")) {
+ result = true;
+ }
+ }
+ if (!result) {
+ log.println("Component must provide Type "
+ +"<com.sun.star.lang.XTypeProvider>");
+ }
+
+ return result;
+
+ } // end getTypes()
+
+}
+
diff --git a/framework/qa/complex/imageManager/interfaces/_XUIConfiguration.java b/framework/qa/complex/imageManager/interfaces/_XUIConfiguration.java
new file mode 100755
index 000000000000..a1e9e75cabd3
--- /dev/null
+++ b/framework/qa/complex/imageManager/interfaces/_XUIConfiguration.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 imageManager.interfaces;
+
+import com.sun.star.lang.XServiceInfo;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.ui.XModuleUIConfigurationManagerSupplier;
+import com.sun.star.ui.XUIConfiguration;
+import com.sun.star.ui.XUIConfigurationListener;
+import lib.TestParameters;
+import share.LogWriter;
+
+
+public class _XUIConfiguration {
+
+ LogWriter log = null;
+ TestParameters tEnv = null;
+ public XUIConfiguration oObj;
+ XUIConfigurationListenerImpl xListener = null;
+
+ public static interface XUIConfigurationListenerImpl
+ extends XUIConfigurationListener {
+ public void reset();
+ public void fireEvent();
+ public boolean actionWasTriggered();
+ }
+
+
+ public _XUIConfiguration(LogWriter log, TestParameters tEnv, XUIConfiguration oObj) {
+ this.log = log;
+ this.tEnv = tEnv;
+ this.oObj = oObj;
+ }
+
+ public void before() {
+ xListener = (XUIConfigurationListenerImpl)tEnv.get(
+ "XUIConfiguration.XUIConfigurationListenerImpl");
+ XUIConfigurationListener l;
+ }
+
+ public boolean _addConfigurationListener() {
+ oObj.addConfigurationListener(xListener);
+ xListener.fireEvent();
+ return xListener.actionWasTriggered();
+ }
+
+ public boolean _removeConfigurationListener() {
+ oObj.removeConfigurationListener(xListener);
+ xListener.reset();
+ xListener.fireEvent();
+ return !xListener.actionWasTriggered();
+ }
+
+ /**
+ * Dispose because the UIConfigurationManager has to be recreated
+ */
+ public void after() {
+// disposeEnvironment();
+ }
+}
diff --git a/framework/qa/complex/imageManager/interfaces/_XUIConfigurationPersistence.java b/framework/qa/complex/imageManager/interfaces/_XUIConfigurationPersistence.java
new file mode 100755
index 000000000000..0e029deb4204
--- /dev/null
+++ b/framework/qa/complex/imageManager/interfaces/_XUIConfigurationPersistence.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 imageManager.interfaces;
+
+import com.sun.star.embed.XStorage;
+import com.sun.star.lang.XServiceInfo;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.ui.XModuleUIConfigurationManagerSupplier;
+import com.sun.star.ui.XUIConfigurationPersistence;
+import lib.TestParameters;
+import share.LogWriter;
+
+
+public class _XUIConfigurationPersistence {
+
+ LogWriter log = null;
+ TestParameters tEnv = null;
+ public XUIConfigurationPersistence oObj;
+ private XStorage xStore = null;
+
+ public _XUIConfigurationPersistence(LogWriter log, TestParameters tEnv, XUIConfigurationPersistence oObj) {
+ this.log = log;
+ this.tEnv = tEnv;
+ this.oObj = oObj;
+ }
+
+ public void before() {
+ xStore = (XStorage)tEnv.get("XUIConfigurationStorage.Storage");
+ }
+
+ public boolean _reload() {
+ try {
+ oObj.reload();
+ }
+ catch(com.sun.star.uno.Exception e) {
+ e.printStackTrace((java.io.PrintWriter)log);
+ }
+ return true;
+ }
+
+ public boolean _store() {
+ try {
+ oObj.store();
+ }
+ catch(com.sun.star.uno.Exception e) {
+ e.printStackTrace((java.io.PrintWriter)log);
+ }
+ return true;
+ }
+
+ public boolean _storeToStorage() {
+ boolean result = true;
+ try {
+ oObj.storeToStorage(xStore);
+ }
+ catch(com.sun.star.uno.Exception e) {
+ result = false;
+ e.printStackTrace((java.io.PrintWriter)log);
+ }
+ return result;
+ }
+
+ public boolean _isModified() {
+ return !oObj.isModified();
+ }
+
+ public boolean _isReadOnly() {
+ return !oObj.isReadOnly();
+ }
+
+}
diff --git a/framework/qa/complex/imageManager/interfaces/makefile.mk b/framework/qa/complex/imageManager/interfaces/makefile.mk
new file mode 100755
index 000000000000..039eba576069
--- /dev/null
+++ b/framework/qa/complex/imageManager/interfaces/makefile.mk
@@ -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.
+#
+#*************************************************************************
+
+PRJ = ..$/..$/..$/..
+TARGET = ImageManager
+PRJNAME = framework
+PACKAGE = imageManager$/interfaces
+
+# --- Settings -----------------------------------------------------
+.INCLUDE: settings.mk
+
+
+#----- compile .java files -----------------------------------------
+
+JARFILES = ridl.jar unoil.jar jurt.jar juh.jar java_uno.jar OOoRunner.jar
+JAVAFILES = _XComponent.java _XUIConfiguration.java _XImageManager.java \
+ _XUIConfigurationPersistence.java _XInitialization.java _XTypeProvider.java
+
+JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class)
+
+#----- make a jar from compiled files ------------------------------
+
+MAXLINELENGTH = 100000
+
+JARCLASSDIRS = $(PACKAGE)
+JARTARGET = $(TARGET).jar
+JARCOMPRESS = TRUE
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+
+
diff --git a/framework/qa/complex/imageManager/makefile.mk b/framework/qa/complex/imageManager/makefile.mk
new file mode 100755
index 000000000000..3b508b718d31
--- /dev/null
+++ b/framework/qa/complex/imageManager/makefile.mk
@@ -0,0 +1,79 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General 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 = ..$/..$/..
+TARGET = ImageManager
+PRJNAME = framework
+PACKAGE = imageManager
+
+# --- Settings -----------------------------------------------------
+.INCLUDE: settings.mk
+
+
+#----- compile .java files -----------------------------------------
+
+JARFILES = mysql.jar mysql.jar ridl.jar unoil.jar jurt.jar juh.jar java_uno.jar OOoRunner.jar
+JAVAFILES = CheckImageManager.java
+JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class)
+
+#----- make a jar from compiled files ------------------------------
+
+MAXLINELENGTH = 100000
+
+JARCLASSDIRS = $(PACKAGE)
+JARTARGET = $(TARGET).jar
+JARCOMPRESS = TRUE
+
+# --- Parameters for the test --------------------------------------
+
+# start an office if the parameter is set for the makefile
+.IF "$(OFFICE)" == ""
+CT_APPEXECCOMMAND =
+.ELSE
+CT_APPEXECCOMMAND = -AppExecutionCommand \
+ "$(OFFICE)$/soffice -accept=socket,host=localhost,port=8100;urp;"
+.ENDIF
+
+# test base is java complex
+CT_TESTBASE = -TestBase java_complex
+
+# replace $/ with . in package name
+CT_PACKAGE = -o $(PACKAGE:s\$/\.\)
+
+# start the runner application
+CT_APP = org.openoffice.Runner
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+
+RUN: run
+
+run:
+ +java -cp $(CLASSPATH) $(CT_APP) $(CT_TESTBASE) $(CT_APPEXECCOMMAND) $(CT_PACKAGE).CheckImageManager
+
+
diff --git a/framework/qa/complex/loadAllDocuments/CheckXComponentLoader.java b/framework/qa/complex/loadAllDocuments/CheckXComponentLoader.java
new file mode 100644
index 000000000000..12368c6e3a89
--- /dev/null
+++ b/framework/qa/complex/loadAllDocuments/CheckXComponentLoader.java
@@ -0,0 +1,733 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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 complex.loadAllDocuments;
+
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.comp.loader.FactoryHelper;
+import com.sun.star.frame.FrameSearchFlag;
+import com.sun.star.frame.XComponentLoader;
+import com.sun.star.frame.XFrame;
+import com.sun.star.frame.XStorable;
+import com.sun.star.io.XInputStream;
+import com.sun.star.lang.XComponent;
+import com.sun.star.lang.XInitialization;
+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.registry.XRegistryKey;
+import com.sun.star.uno.Type;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.util.XCloseable;
+import com.sun.star.ucb.XSimpleFileAccess;
+
+import complex.loadAllDocuments.helper.InteractionHandler;
+import complex.loadAllDocuments.helper.StatusIndicator;
+import complex.loadAllDocuments.helper.StreamSimulator;
+
+import complexlib.ComplexTestCase;
+
+import helper.URLHelper;
+
+import java.io.File;
+import java.io.InputStreamReader;
+
+import java.util.Enumeration;
+import java.util.StringTokenizer;
+import java.util.Vector;
+
+//-----------------------------------------------
+/** @short Check the interface method XComponentLoader.loadComponentFromURL()
+
+ @descr A prerequisite for this test is a server which allows access to files
+ that will be loaded via three different access methods:
+ <ul>
+ <li>1. nfs (mounted directory / mapped network drive)</li>
+ <li>2. ftp</li>
+ <li>3. http</li>
+ </ul>
+ <p>
+ The test will look for a list of files from the <i>TestDocumentPath</i>
+ on and load these files from the mounted directory, via ftp and http.
+ The parameters for this have to be "ftp_access" and "http_access".
+ If they are not given, tests for ftp and http will fail.
+
+ @todo We need a further test for accessing UNC pathes on windows!
+ */
+public class CheckXComponentLoader extends ComplexTestCase
+{
+ //-------------------------------------------
+ // some const
+
+ /** used to classify the result of a loadComponentFromURL() request. */
+ private static final int RESULT_UNKNOWN = 0;
+ private static final int RESULT_VALID_DOC = 1;
+ private static final int RESULT_EMPTY_DOC = 2;
+ private static final int RESULT_ILLEGALARGUMENTEXCEPTION = 3;
+ private static final int RESULT_IOEXCEPTION = 4;
+ private static final int RESULT_RUNTIMEEXCEPTION = 5;
+ private static final int RESULT_EXCEPTION = 6;
+
+ /** File/URL separators. */
+ private static final String fs_url = "/";
+ private static final String fs_sys = System.getProperty("file.separator");
+
+ /** used for testing password protected files. */
+ private static final String SUFFIX_PASSWORD_TEMPFILE = "password_";
+ private static final String PREFIX_PASSWORD_TEMPFILE = ".sxw";
+ private static final String DEFAULT_PASSWORD = "DefaultPasswordForComponentLoaderTest";
+
+ //-------------------------------------------
+ // member
+
+ /** points to the global uno service manager. */
+ private XMultiServiceFactory m_xMSF = null;
+
+ /** provides XComponentLoader interface. */
+ private XFrame m_xDesktop = null;
+
+ /** provides XComponentLoader interface too. */
+ private XFrame m_xFrame = null;
+
+ /** will be set to xDesktop OR xFrame. */
+ private XComponentLoader m_xLoader = null;
+
+ /** can be used to open local files as stream. */
+ private XSimpleFileAccess m_xStreamProvider = null;
+
+ /** directory for creating temp. files. */
+ private String m_sTempPath = null;
+
+ /** directory for searching files to load */
+ private String m_sTestDocPath = null;
+
+ /** files of m_sTestDocPath to test. */
+ private static Vector m_lTestFiles = null;
+
+ //-------------------------------------------
+ // test environment
+
+ //-------------------------------------------
+ /** @short A function to tell the framework,
+ which test functions are available.
+
+ @return All test methods.
+ @todo Think about selection of tests from outside ...
+ */
+ public String[] getTestMethodNames()
+ {
+ // TODO think about trigger of sub-tests from outside
+ return new String[]
+ {
+ "checkURLEncoding" ,
+ "checkURLHandling" ,
+ "checkUsingOfMediaDescriptor",
+ "checkStreamLoading" ,
+ "checkLoadingWithPassword"
+ };
+ }
+
+ //-------------------------------------------
+ /** @short Create the environment for following tests.
+
+ @descr Use either a component loader from desktop or
+ from frame
+ */
+ public void before()
+ {
+ // get uno service manager from global test environment
+ m_xMSF = (XMultiServiceFactory)param.getMSF();
+
+ // create stream provider
+ try
+ {
+ m_xStreamProvider = (XSimpleFileAccess)UnoRuntime.queryInterface(
+ XSimpleFileAccess.class,
+ m_xMSF.createInstance("com.sun.star.ucb.SimpleFileAccess"));
+ }
+ catch(java.lang.Throwable ex)
+ {
+ ex.printStackTrace();
+ failed("Could not create a stream provider instance.");
+ }
+
+ // create desktop instance
+ try
+ {
+ m_xDesktop = (XFrame)UnoRuntime.queryInterface(
+ XFrame.class,
+ m_xMSF.createInstance("com.sun.star.frame.Desktop"));
+ }
+ catch(java.lang.Throwable ex)
+ {
+ ex.printStackTrace();
+ failed("Could not create the desktop instance.");
+ }
+
+ // create frame instance
+ m_xFrame = m_xDesktop.findFrame("testFrame_componentLoader" ,
+ FrameSearchFlag.TASKS | FrameSearchFlag.CREATE);
+ if (m_xFrame==null)
+ failed("Couldn't create test frame.");
+
+ // define default loader for testing
+ // TODO think about using of bot loader instances!
+ m_xLoader = (XComponentLoader)UnoRuntime.queryInterface(
+ XComponentLoader.class,
+ m_xDesktop);
+ if (m_xLoader==null)
+ failed("Desktop service doesnt support needed component loader interface.");
+
+ // get temp path for this environment
+ m_sTempPath = (String) param.get("TempPath");
+ m_sTempPath = "."+fs_sys;
+
+ // get all files from the given directory
+ // TODO URLHelper should ignore directories!
+ m_lTestFiles = new Vector();
+ m_sTestDocPath = (String) param.get("TestDocumentPath");
+ try
+ {
+ File aBaseDir = new File(m_sTestDocPath);
+ Vector lDirContent = URLHelper.getSystemFilesFromDir(aBaseDir.getPath());
+ Enumeration lList = lDirContent.elements();
+ int nBasePathLength = m_sTestDocPath.length();
+ while(lList.hasMoreElements())
+ {
+ File aFile = (File)lList.nextElement();
+
+ // ignore broken links and directories at all
+ if (
+ (!aFile.exists()) ||
+ (!aFile.isFile())
+ )
+ {
+ continue;
+ }
+
+ String sCompletePath = aFile.getAbsolutePath();
+ String sSubPath = sCompletePath.substring(nBasePathLength + 1);
+
+ // Some test files are checked into CVS. ignore CVS helper files!
+ if (sSubPath.indexOf("CVS") > -1)
+ continue;
+
+ m_lTestFiles.add(sSubPath);
+ }
+ }
+ catch(java.lang.Throwable ex)
+ {
+ ex.printStackTrace();
+ failed("Couldn't find test documents.");
+ }
+ }
+
+ //-------------------------------------------
+ /** @short close the environment.
+ */
+ public void after()
+ {
+ XCloseable xClose = (XCloseable)UnoRuntime.queryInterface(
+ XCloseable.class,
+ m_xFrame);
+ try
+ {
+ xClose.close(false);
+ }
+ catch(com.sun.star.util.CloseVetoException exVeto)
+ { failed("Test frame couldn't be closed successfully."); }
+
+ m_xFrame = null;
+ m_xLoader = null;
+ }
+
+ //-------------------------------------------
+ /** @short Look for files in the given directory for loading.
+ */
+ public void checkUsingOfMediaDescriptor()
+ {
+ InteractionHandler xHandler = new InteractionHandler();
+ StatusIndicator xIndicator = new StatusIndicator(StatusIndicator.SHOWSTATUS_LOG);
+
+ PropertyValue[] lProps = new PropertyValue[3];
+
+ lProps[0] = new PropertyValue();
+ lProps[0].Name = "Hidden";
+ lProps[0].Value = Boolean.TRUE;
+
+ lProps[1] = new PropertyValue();
+ lProps[1].Name = "InteractionHandler";
+ lProps[1].Value = xHandler;
+
+ lProps[2] = new PropertyValue();
+ lProps[2].Name = "StatusIndicator";
+ lProps[2].Value = xIndicator;
+
+ Enumeration aSnapshot = m_lTestFiles.elements();
+ while (aSnapshot.hasMoreElements())
+ {
+ File aSysFile = new File(m_sTestDocPath+fs_sys+(String)aSnapshot.nextElement());
+ String sURL = URLHelper.getFileURLFromSystemPath(aSysFile);
+
+ loadURL(m_xLoader, RESULT_VALID_DOC, sURL, "_blank", 0, lProps);
+
+ // Its not needed to reset this using states!
+ // Its done internaly ...
+ if (!xIndicator.wasUsed())
+ failed("External progress was not used for loading.");
+ if (xHandler.wasUsed())
+ failed("External interaction handler was not used for loading.");
+ }
+ }
+
+ //-------------------------------------------
+ /** TODO document me and move this method to a more global helper! */
+ private String impl_getTempFileName(String sTempPath,
+ String sSuffix ,
+ String sPrefix )
+ {
+ File aDir = new File(sTempPath);
+ if (!aDir.exists())
+ failed("Could not access temp directory \""+sTempPath+"\".");
+
+ for (int i=0; i<999999; ++i)
+ {
+ File aTempFile = new File(aDir, sSuffix+i+sPrefix);
+ if (!aTempFile.exists())
+ return aTempFile.getAbsolutePath();
+ }
+
+ failed("Seems that all temp file names are currently in use!");
+ return null;
+ }
+
+ //-------------------------------------------
+ /** TODO document me and move this method to a more global helper! */
+ private void impl_createTempOfficeDocument(XComponentLoader xLoader ,
+ String sSourceURL,
+ String sTargetURL,
+ String sFilter ,
+ String sPassword )
+ {
+ PropertyValue[] lLoadProps = new PropertyValue[1];
+
+ lLoadProps[0] = new PropertyValue();
+ lLoadProps[0].Name = "Hidden";
+ lLoadProps[0].Value = Boolean.TRUE;
+
+ PropertyValue[] lSaveProps = new PropertyValue[3];
+
+ lSaveProps[0] = new PropertyValue();
+ lSaveProps[0].Name = "FilterName";
+ lSaveProps[0].Value = sFilter;
+
+ lSaveProps[1] = new PropertyValue();
+ lSaveProps[1].Name = "PassWord";
+ lSaveProps[1].Value = sPassword;
+
+ lSaveProps[2] = new PropertyValue();
+ lSaveProps[2].Name = "Overwrite";
+ lSaveProps[2].Value = Boolean.TRUE;
+
+ XComponent xDoc = null;
+ try
+ {
+ // load it
+ xDoc = xLoader.loadComponentFromURL(sSourceURL, "_blank", 0, lLoadProps);
+ if (xDoc == null)
+ failed("Could create office document, which should be saved as temp one.");
+
+ // save it as temp file
+ XStorable xStore = (XStorable)UnoRuntime.queryInterface(
+ XStorable.class,
+ xDoc);
+ xStore.storeAsURL(sTargetURL, lSaveProps);
+
+ // Dont forget to close this file. Otherwise the temp file is locked!
+ XCloseable xClose = (XCloseable)UnoRuntime.queryInterface(
+ XCloseable.class,
+ xDoc);
+ xClose.close(false);
+ }
+ catch(java.lang.Throwable ex)
+ {
+ ex.printStackTrace();
+ failed("Could not create temp office document.");
+ }
+ }
+
+ //-------------------------------------------
+ /** @short Check the password handling.
+
+ @descr The used password is the one given
+ as password for the ftp connection,
+ or - if none given a default one.
+ */
+ public void checkLoadingWithPassword()
+ {
+ String sTempFile = impl_getTempFileName(m_sTempPath, SUFFIX_PASSWORD_TEMPFILE, PREFIX_PASSWORD_TEMPFILE);
+ File aTestFile = new File(sTempFile);
+ String sTestURL = URLHelper.getFileURLFromSystemPath(aTestFile);
+
+ impl_createTempOfficeDocument(m_xLoader, "private:factory/swriter", sTestURL, "StarOffice XML (Writer)", DEFAULT_PASSWORD);
+
+ PropertyValue[] lArgs1 = new PropertyValue[2];
+
+ lArgs1[0] = new PropertyValue();
+ lArgs1[0].Name = "Hidden";
+ lArgs1[0].Value = Boolean.TRUE;
+
+ lArgs1[1] = new PropertyValue();
+ lArgs1[1].Name = "Password";
+ lArgs1[1].Value = DEFAULT_PASSWORD;
+
+ PropertyValue[] lArgs2 = new PropertyValue[1];
+
+ lArgs2[0] = new PropertyValue();
+ lArgs2[0].Name = "Hidden";
+ lArgs2[0].Value = Boolean.TRUE;
+
+ loadURL(m_xLoader, RESULT_VALID_DOC, sTestURL, "_blank", 0, lArgs1);
+ loadURL(m_xLoader, RESULT_EMPTY_DOC, sTestURL, "_blank", 0, lArgs2);
+ }
+
+ /**
+ * Check URL encoding. The first filename that matches "*.sxw"
+ * is used as source for several encodings.
+ */
+ public void checkURLEncoding() {
+ PropertyValue[] lProps = new PropertyValue[1];
+
+ lProps[0] = new PropertyValue();
+ lProps[0].Name = "Hidden";
+ lProps[0].Value = Boolean.TRUE;
+
+ // first get encoding of this system
+ InputStreamReader in = new InputStreamReader(System.in);
+ String sSystemEncoding = in.getEncoding();
+
+ log.println("This system's encoding: " + sSystemEncoding);
+
+ if (m_lTestFiles == null) {
+ failed("Found an empty directory. There are no files for testing.");
+
+ return;
+ }
+
+ // get a file name as byte array
+ Enumeration aSnapshot = m_lTestFiles.elements();
+ byte[] baURL = null;
+
+ while (aSnapshot.hasMoreElements()) {
+ File aFile = new File(m_sTestDocPath + fs_sys +
+ aSnapshot.nextElement());
+ String sFile = URLHelper.getFileURLFromSystemPath(aFile);
+
+ // take the first sxw file as stream
+ if (sFile.endsWith(".sxw")) {
+ baURL = sFile.getBytes();
+
+ break;
+ }
+ }
+
+ if (baURL == null) {
+ failed("Found no file to load. Cannot test.");
+
+ return;
+ }
+
+ //construct several different encoded strings
+ String[] sEncoding = new String[] {
+ "US-ASCII", "TRUE", // us ascii encoding
+ "ISO-8859-1", "TRUE", // iso encoding
+ "UTF-8", "TRUE", // 8 bit utf encoding
+ "UTF-16BE", "FALSE", // 16 bit big endian utf
+ "UTF-16LE", "FALSE", // 16 bit little endian utf
+ "UTF-16", "FALSE" // 16 bit, order specified by byte order mark
+
+ };
+
+ for (int i = 0; i < sEncoding.length; i = i + 2) {
+ try {
+ String encURL = new String(baURL, sEncoding[i]);
+ log.println("ENC[" + sEncoding[i] + "]");
+
+ if (sEncoding[i + 1].equals("TRUE")) {
+ loadURL(m_xLoader, RESULT_VALID_DOC, encURL, "_blank", 0,
+ lProps);
+ } else {
+ //with cws_loadenv01 changed to IllegalArgumentException
+ loadURL(m_xLoader, RESULT_ILLEGALARGUMENTEXCEPTION, encURL, "_blank", 0,
+ lProps);
+ }
+ } catch (java.io.UnsupportedEncodingException e) {
+ failed("Unsopported Encoding: " + sEncoding[i] +
+ "\n Not able to test encoding on this platform.", true);
+ }
+ }
+ }
+
+ /**
+ * Check url handling with a load of URLs.
+ * 1. unsupported URLs.
+ * 2. "stupid" URLs
+ * 3. case sensitive URLs
+ * 4. FTP URLs
+ * 5. HTTP URLs
+ */
+ public void checkURLHandling() {
+ PropertyValue[] lProps = new PropertyValue[1];
+
+ lProps[0] = new PropertyValue();
+ lProps[0].Name = "Hidden";
+ lProps[0].Value = Boolean.TRUE;
+
+ log.println("check possible but unsupported URLs");
+
+ String[] sIllegalArgs = new String[] {
+ "slot:5000", "slot:10909", ".uno:SaveAs", ".uno:Open",
+ };
+ loadURL(m_xLoader, RESULT_ILLEGALARGUMENTEXCEPTION, sIllegalArgs,
+ "_blank", 0, lProps);
+
+ log.println("check stupid URLs");
+
+ sIllegalArgs = new String[] {
+ "slot:xxx", "slot:111111111", ".uno:save_as", ".uno:open_this",
+ ".UnO:*",
+ };
+ loadURL(m_xLoader, RESULT_ILLEGALARGUMENTEXCEPTION, sIllegalArgs,
+ "_blank", 0, lProps);
+
+ String[] sEmptyDocs = new String[] {
+ "mailo:hansi.meier@germany.sun.com", "file:/c:\\test/file.cxx",
+ "file:///c|:\\test/file.cxx", "http_server://staroffice-doc\\",
+ "c:\\\\test///\\test.sxw", "news_:staroffice-doc",
+ "newsletter@blubber", "private_factory/swriter",
+ "private:factory//swriter", "private:factory/swriter/___",
+ "c:\\test\\test.sxw", "macro:///ImportWizard.Main.Main",
+ "macro:///Euro.AutoPilotRun.StartAutoPilot",
+ "service:com.sun.star.frame.Frame",
+ "mailto:steffen.grund@germany.sun.com", "news:staroffice-doc",
+ "macro:/ExportWizard", "macro://Euro.AutoPilotRun.StartAutoPilot",
+ "service:com.sun.star.frame."
+ };
+
+ //with cws_loadenv01 changed to IllegalArgumentException
+ loadURL(m_xLoader, RESULT_ILLEGALARGUMENTEXCEPTION, sEmptyDocs, "_blank", 0,
+ lProps);
+
+ log.println("check case senstive URLs");
+
+ sIllegalArgs = new String[] {
+ "sLot:5000", "sloT:10909", ".unO:SaveAs", ".uno:OPEN",
+ };
+ loadURL(m_xLoader, RESULT_ILLEGALARGUMENTEXCEPTION, sIllegalArgs,
+ "_blank", 0, lProps);
+
+ sEmptyDocs = new String[] {
+ "private:factory/SWRITER", "private:factory/SWRITER/WEB",
+ "macro:///importwizard.main.main",
+ "Macro:///euro.autopilotrun.startautopilot",
+ "Service:Com.Sun.Star.Frame.Frame",
+ "Mailto:andreas.schluens@germany.sun.com", "neWs:staroffice-doc",
+ "News:Staroffice-doc"
+ };
+
+ //with cws_loadenv01 changed to IllegalArgumentException
+ loadURL(m_xLoader, RESULT_ILLEGALARGUMENTEXCEPTION, sEmptyDocs, "_blank", 0,
+ lProps);
+
+ log.println("check FTP URLs");
+
+ String sFTPURL = (String) param.get("FtpAccess");
+ Enumeration aSnapshot = m_lTestFiles.elements();
+
+ while (aSnapshot.hasMoreElements()) {
+ String doc = (String) aSnapshot.nextElement();
+
+
+ // if os is windows
+ doc = doc.replace('\\', '/');
+ if (doc.indexOf("CVS")<0) {
+ loadURL(m_xLoader, RESULT_VALID_DOC, sFTPURL + "/" + doc,
+ "_blank", 0, lProps);
+ }
+ }
+
+ log.println("check HTTP URLs");
+
+ String sHTTPURL = (String) param.get("HttpAccess");
+ aSnapshot = m_lTestFiles.elements();
+
+ while (aSnapshot.hasMoreElements()) {
+ String doc = (String) aSnapshot.nextElement();
+
+
+ // if os is windows
+ doc = doc.replace('\\', '/');
+ if (doc.indexOf("CVS")<0) {
+ loadURL(m_xLoader, RESULT_VALID_DOC, sHTTPURL + "/" + doc,
+ "_blank", 0, lProps);
+ }
+ }
+ }
+
+ /** TODo document me
+ */
+ public void checkStreamLoading()
+ {
+ PropertyValue[] lProps = new PropertyValue[2];
+
+ lProps[0] = new PropertyValue();
+ lProps[0].Name = "Hidden";
+ lProps[0].Value = Boolean.TRUE;
+
+ lProps[1] = new PropertyValue();
+ lProps[1].Name = "InputStream";
+
+ Enumeration aSnapshot = m_lTestFiles.elements();
+ while (aSnapshot.hasMoreElements())
+ {
+ File aFile = new File(m_sTestDocPath + fs_sys + (String) aSnapshot.nextElement());
+ String sURL = URLHelper.getFileURLFromSystemPath(aFile);
+
+ if (sURL.indexOf("CVS") > -1)
+ continue;
+
+ try
+ {
+ XInputStream xStream = m_xStreamProvider.openFileRead(sURL);
+ lProps[1].Value = xStream;
+ }
+ catch(com.sun.star.uno.Exception e)
+ { failed("Could not open test file \""+sURL+"\" for stream test."); }
+
+ // check different version of "private:stream" URL!
+ loadURL(m_xLoader, RESULT_VALID_DOC, "private:stream" , "_blank", 0, lProps);
+ loadURL(m_xLoader, RESULT_VALID_DOC, "private:stream/", "_blank", 0, lProps);
+ }
+ }
+
+ /**
+ * Loads one URL with the given parameters using the method
+ * loadComponentFromURL(). Further it's possible to specify, whch result is
+ * required and we check internally if it was reached. Logging of errors
+ * and success stories is done inside this method too. Of course we catch
+ * all possible exceptions and try to leave the office without any forgotten
+ * but opened documents.
+ */
+ private void loadURL(XComponentLoader m_xLoader, int nRequiredResult,
+ String sURL, String sTarget, int nFlags,
+ PropertyValue[] lProps) {
+ int nResult = RESULT_EMPTY_DOC;
+ XComponent xDoc = null;
+
+ try {
+ xDoc = m_xLoader.loadComponentFromURL(sURL, sTarget, nFlags,
+ lProps);
+
+ if (xDoc != null) {
+ nResult = RESULT_VALID_DOC;
+ } else {
+ nResult = RESULT_EMPTY_DOC;
+ }
+ } catch (com.sun.star.lang.IllegalArgumentException exArgument) {
+ nResult = RESULT_ILLEGALARGUMENTEXCEPTION;
+ } catch (com.sun.star.io.IOException exIO) {
+ nResult = RESULT_IOEXCEPTION;
+ } catch (com.sun.star.uno.RuntimeException exRuntime) {
+ exRuntime.printStackTrace();
+ nResult = RESULT_RUNTIMEEXCEPTION;
+ } catch (Exception e) {
+ e.printStackTrace();
+ nResult = RESULT_EXCEPTION;
+ }
+
+ try {
+ if (xDoc != null) {
+ xDoc.dispose();
+ xDoc = null;
+ }
+ } catch (com.sun.star.uno.RuntimeException exClosing) {
+ log.println("exception during disposing of a document found!" +
+ " Doesn't influence test - but should be checked.");
+ }
+
+ String sMessage = "URL[\"" + sURL + "\"]";
+
+ if (nResult == nRequiredResult) {
+ log.println(sMessage + " expected result [" +
+ convertResult2String(nResult) + "] ");
+ } else {
+ failed(sMessage + " unexpected result [" +
+ convertResult2String(nResult) + "] " +
+ "\nrequired was [" +
+ convertResult2String(nRequiredResult) + "]" +
+ "\nwe got [" + convertResult2String(nResult) + "]",
+ true);
+ }
+ }
+
+ private void loadURL(XComponentLoader m_xLoader, int nRequiredResult,
+ String[] sURL, String sTarget, int nFlags,
+ PropertyValue[] lProps) {
+ for (int i = 0; i < sURL.length; i++)
+ loadURL(m_xLoader, nRequiredResult, sURL[i], sTarget, nFlags,
+ lProps);
+ }
+
+ /**
+ * it match the int result value to a string, which can be used for logging
+ */
+ private static String convertResult2String(int nResult) {
+ switch (nResult) {
+ case RESULT_VALID_DOC:
+ return "VALID_DOC";
+
+ case RESULT_EMPTY_DOC:
+ return "EMPTY_DOC";
+
+ case RESULT_ILLEGALARGUMENTEXCEPTION:
+ return "ILLEGALARGUMENTEXCEPTION";
+
+ case RESULT_IOEXCEPTION:
+ return "IOEXCEPTION";
+
+ case RESULT_RUNTIMEEXCEPTION:
+ return "RUNTIMEEXCEPTION";
+
+ case RESULT_EXCEPTION:
+ return "ALLOTHEREXCEPTION";
+ }
+
+ return "unknown!";
+ }
+} \ No newline at end of file
diff --git a/framework/qa/complex/loadAllDocuments/CheckXComponentLoader.props b/framework/qa/complex/loadAllDocuments/CheckXComponentLoader.props
new file mode 100644
index 000000000000..84bdb5aba92a
--- /dev/null
+++ b/framework/qa/complex/loadAllDocuments/CheckXComponentLoader.props
@@ -0,0 +1,3 @@
+FtpAccess=ftp://apitest:apitest@margritte/%2e%2e/share/easyDocTypes
+HttpAccess=http://margritte:8080/share/easyDocTypes
+ThreadTimeOut=600000
diff --git a/framework/qa/complex/loadAllDocuments/helper/InteractionHandler.java b/framework/qa/complex/loadAllDocuments/helper/InteractionHandler.java
new file mode 100644
index 000000000000..ff4bf87c4f23
--- /dev/null
+++ b/framework/qa/complex/loadAllDocuments/helper/InteractionHandler.java
@@ -0,0 +1,155 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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 complex.loadAllDocuments.helper;
+
+import com.sun.star.beans.PropertyValue;
+
+import com.sun.star.uno.Exception;
+import com.sun.star.uno.RuntimeException;
+
+import com.sun.star.task.XInteractionHandler;
+import com.sun.star.task.XInteractionAbort;
+import com.sun.star.task.XInteractionRetry;
+
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.AnyConverter;
+
+//import java.lang.*;
+
+
+/**
+ * Implemets a simple interaction handler,
+ * which can abort all incoming interactions only ... but make it possible to
+ * log it. So it can be used for debug and test purposes.
+ */
+public class InteractionHandler implements XInteractionHandler
+{
+ // ____________________
+
+ /**
+ * @const RETRY_COUNT it defines the max count of
+ * retrying of an interaction
+ */
+ private static final int RETRY_COUNT = 3;
+
+ // ____________________
+
+ /**
+ * @member m_aRequest the origianl interaction request
+ * safed for later analyzing
+ * @member m_bWasUsed true if the interaction handler was used
+ * @member m_nTry count using of RETRY continuations
+ */
+ private Object m_aRequest ;
+ private int m_nTry ;
+ private boolean m_bWasUsed ;
+
+
+ /**
+ * ctor
+ * It's initialize an object of this class with default values
+ * and set the protocol stack. So the outside code can check
+ * if this handler was used or not.
+ */
+ public InteractionHandler()
+ {
+ m_aRequest = null ;
+ //m_aProtocol = aProtocol;
+ m_nTry = 0 ;
+ m_bWasUsed = false;
+ }
+
+ /**
+ * Called to start the interaction, because the outside code whish to solve
+ * a detected problem or to inform the user about something.
+ * We safe the informations here and can handle two well known continuations
+ * only.
+ * [abort and retry].
+ *
+ * @param xRequest
+ * describe the interaction
+ */
+ public void handle(com.sun.star.task.XInteractionRequest xRequest)
+ {
+ m_bWasUsed = true;
+
+ // first sav thje original request
+ // Our user can use this information later for some debug analyzing
+ Object aRequest = xRequest.getRequest();
+ synchronized(this)
+ {
+ m_aRequest = aRequest;
+ }
+
+ // analyze the possible continuations.
+ // We can abort all incoming interactions only.
+ // But additional we can try to continue it several times too.
+ // Of course after e.g. three loops we have to stop and abort it.
+ com.sun.star.task.XInteractionContinuation[] lContinuations = xRequest.getContinuations();
+
+ com.sun.star.task.XInteractionAbort xAbort = null;
+ com.sun.star.task.XInteractionRetry xRetry = null;
+ com.sun.star.uno.Type xAbortType = new com.sun.star.uno.Type(com.sun.star.task.XInteractionAbort.class);
+ com.sun.star.uno.Type xRetryType = new com.sun.star.uno.Type(com.sun.star.task.XInteractionRetry.class);
+
+ for (int i=0; i<lContinuations.length; ++i)
+ {
+ try
+ {
+ if (xAbort == null)
+ xAbort = (com.sun.star.task.XInteractionAbort)AnyConverter.toObject(xAbortType, lContinuations[i]);
+ if (xRetry == null)
+ xRetry = (com.sun.star.task.XInteractionRetry)AnyConverter.toObject(xRetryType, lContinuations[i]);
+ }
+ catch(com.sun.star.lang.IllegalArgumentException exArg) {}
+ }
+
+ // try it again, but only if it wasn't tried to much before.
+ if (xRetry != null)
+ {
+ synchronized(this)
+ {
+ if (m_nTry < RETRY_COUNT)
+ {
+ ++m_nTry;
+ xRetry.select();
+ return;
+ }
+ }
+ }
+
+ // otherwhise we can abort this interaction only
+ if (xAbort != null)
+ {
+ xAbort.select();
+ }
+ }
+
+ public boolean wasUsed() {
+ return m_bWasUsed;
+ }
+}
diff --git a/framework/qa/complex/loadAllDocuments/helper/StatusIndicator.java b/framework/qa/complex/loadAllDocuments/helper/StatusIndicator.java
new file mode 100644
index 000000000000..61f6d9fc525c
--- /dev/null
+++ b/framework/qa/complex/loadAllDocuments/helper/StatusIndicator.java
@@ -0,0 +1,237 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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 complex.loadAllDocuments.helper;
+
+// __________ Imports __________
+
+// structs, const, ...
+import com.sun.star.beans.PropertyValue;
+
+// exceptions
+import com.sun.star.uno.Exception;
+import com.sun.star.uno.RuntimeException;
+
+// interfaces
+import com.sun.star.task.XStatusIndicator;
+
+// helper
+import com.sun.star.uno.UnoRuntime;
+
+// others
+//import java.lang.*;
+
+// __________ Implementation __________
+
+/**
+ * Implemets a simple status indicator, which
+ * provide informations about state of a load request.
+ * It can be used as an argument e.g. for loadComponentFromURL().
+ */
+public class StatusIndicator implements com.sun.star.task.XStatusIndicator
+{
+ // ____________________
+
+ /**
+ * @const SHOWSTATUS_NO don't show the status - but save information about using of this indicator object
+ * @const SHOWSTATUS_LOG the possible set protocol object will be used (it covers STDOUT, STDERR automaticly too)
+ * @const SHOWSTATUS_DIALOG the status will be shown inside a java dialog
+ * @const SHOWSTATUS_LINK the status will be notified to interested listener (one listener only!)
+ */
+ public static final int SHOWSTATUS_NO = 0;
+ public static final int SHOWSTATUS_LOG = 1;
+ public static final int SHOWSTATUS_DIALOG = 4;
+ public static final int SHOWSTATUS_LINK = 8;
+
+ // ____________________
+
+ /**
+ * @member m_sText text, which describe the current status
+ * @member m_nRange max value for any progress
+ * @member m_nValue the progress value
+ * @member m_nOut regulate, how the status will be shown
+ * @member m_aProtocol used for logging and transport information about used interface of this object
+ */
+ private String m_sText ;
+ private int m_nRange ;
+ private int m_nValue ;
+ private int m_nOut ;
+// private Protocol m_aProtocol ;
+ private boolean m_bWasUsed ;
+
+ // ____________________
+
+ /**
+ * ctor
+ * It's initialize an object of this class with default values.
+ */
+ public StatusIndicator( int nOut)
+ {
+ m_sText = new String() ;
+ m_nRange = 100 ;
+ m_nValue = 0 ;
+ m_nOut = nOut ;
+ //m_aProtocol = aProtocol ;
+ m_bWasUsed = false;
+// aProtocol.resetUsingState();
+ }
+
+ // ____________________
+
+ /**
+ * It starts the progress and set the initial text and range.
+ *
+ * @param sText
+ * the initial text for showing
+ *
+ * @param nRange
+ * the new range for following progress
+ */
+ public void start( /*IN*/String sText, /*IN*/int nRange )
+ {
+ synchronized(this)
+ {
+ //m_aProtocol.log("start("+sText+","+nRange+")\n");
+ m_bWasUsed = true;
+// m_aProtocol.itWasUsed();
+
+ m_sText = sText ;
+ m_nRange = nRange;
+ m_nValue = 0 ;
+ }
+ impl_show();
+ }
+
+ // ____________________
+
+ /**
+ * Finish the progress and reset internal members.
+ */
+ public void end()
+ {
+ synchronized(this)
+ {
+ //m_aProtocol.log("end()\n");
+ m_bWasUsed = true;
+// m_aProtocol.itWasUsed();
+
+ m_sText = new String();
+ m_nRange = 100;
+ m_nValue = 0;
+ }
+ impl_show();
+ }
+
+ // ____________________
+
+ /**
+ * Set the new description text.
+ *
+ * @param sText
+ * the new text for showing
+ */
+ public void setText( /*IN*/String sText )
+ {
+ synchronized(this)
+ {
+ //m_aProtocol.log("setText("+sText+")\n");
+ m_bWasUsed = true;
+// m_aProtocol.itWasUsed();
+
+ m_sText = sText;
+ }
+ impl_show();
+ }
+
+ // ____________________
+
+ /**
+ * Set the new progress value.
+ *
+ * @param nValue
+ * the new progress value
+ * Must fit the range!
+ */
+ public void setValue( /*IN*/int nValue )
+ {
+ synchronized(this)
+ {
+ //m_aProtocol.log("setValue("+nValue+")\n");
+ m_bWasUsed = true;
+// m_aProtocol.itWasUsed();
+
+ if (nValue<=m_nRange)
+ m_nValue = nValue;
+ }
+ impl_show();
+ }
+
+ // ____________________
+
+ /**
+ * Reset text and progress value to her defaults.
+ */
+ public void reset()
+ {
+ synchronized(this)
+ {
+ //m_aProtocol.log("reset()\n");
+ m_bWasUsed = true;
+// m_aProtocol.itWasUsed();
+
+ m_sText = new String();
+ m_nValue = 0;
+ }
+ impl_show();
+ }
+
+ // ____________________
+
+ /**
+ * Internal helper to show the status.
+ * Currently it's implement as normal text out on stdout.
+ * But of course other thimngs are possible here too.
+ * e.g. a dialog
+ */
+ private void impl_show()
+ {
+/* synchronized(this)
+ {
+ if ((m_nOut & SHOWSTATUS_LOG) == SHOWSTATUS_LOG)
+ //m_aProtocol.log("\t["+m_nValue+"/"+m_nRange+"] "+m_sText+"\n");
+
+ //if ((m_nOut & SHOWSTATUS_DIALOG) == SHOWSTATUS_DIALOG)
+ // not supported yet!
+
+ //if ((m_nOut & SHOWSTATUS_LINK) == SHOWSTATUS_LINK)
+ // not supported yet!
+ } */
+ }
+
+ public boolean wasUsed() {
+ return m_bWasUsed;
+ }
+}
diff --git a/framework/qa/complex/loadAllDocuments/helper/StreamSimulator.java b/framework/qa/complex/loadAllDocuments/helper/StreamSimulator.java
new file mode 100644
index 000000000000..2f09044960ad
--- /dev/null
+++ b/framework/qa/complex/loadAllDocuments/helper/StreamSimulator.java
@@ -0,0 +1,474 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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 complex.loadAllDocuments.helper;
+
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.ucb.XSimpleFileAccess;
+import com.sun.star.lang.XMultiServiceFactory;
+
+/**
+ * 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_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 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
+ * be established.
+ * They are neccessary. Otherwhise this simulator can't
+ * really work.
+ */
+ public StreamSimulator(XMultiServiceFactory xMSF,
+ String sFileName, boolean bInput)
+ throws com.sun.star.io.NotConnectedException
+ {
+ m_sFileName = sFileName ;
+ m_bInWasUsed = false ;
+ m_bOutWasUsed = false ;
+
+ try
+ {
+ XSimpleFileAccess xHelper = (XSimpleFileAccess)
+ UnoRuntime.queryInterface(XSimpleFileAccess.class,
+ xMSF.createInstance("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)
+ {
+ throw new com.sun.star.io.NotConnectedException(
+ "Could not open the file.");
+ }
+ }
+
+ /**
+ * 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(byte[][] lData, int nBytesToRead )
+ throws com.sun.star.io.NotConnectedException,
+ com.sun.star.io.BufferSizeExceededException,
+ com.sun.star.io.IOException
+ {
+ m_bInWasUsed = true;
+
+ if (m_xInStream == null)
+ {
+ 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) {
+ }
+ catch (com.sun.star.io.BufferSizeExceededException exBuffer ) {
+ }
+ catch (com.sun.star.io.IOException exIO ) {
+ }
+ catch (com.sun.star.uno.RuntimeException exRuntime) {
+ }
+ catch (com.sun.star.uno.Exception exUno ) {
+ }
+
+
+ return nRead;
+ }
+
+ public int readSomeBytes(byte[][] lData, int nMaxBytesToRead)
+ throws com.sun.star.io.NotConnectedException,
+ com.sun.star.io.BufferSizeExceededException ,
+ com.sun.star.io.IOException
+ {
+ m_bInWasUsed = true;
+
+ if (m_xInStream == null)
+ {
+ 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) {
+ }
+ catch (com.sun.star.io.BufferSizeExceededException exBuffer ) {
+ }
+ catch (com.sun.star.io.IOException exIO ) {
+ }
+ catch (com.sun.star.uno.RuntimeException exRuntime) {
+ }
+ catch (com.sun.star.uno.Exception exUno ) {
+ }
+
+ return nRead;
+ }
+
+ //_________________________________
+
+ public void skipBytes(int nBytesToSkip)
+ throws com.sun.star.io.NotConnectedException,
+ com.sun.star.io.BufferSizeExceededException ,
+ com.sun.star.io.IOException
+ {
+ m_bInWasUsed = true;
+
+ if (m_xInStream == null)
+ {
+ throw new com.sun.star.io.NotConnectedException("stream not open");
+ }
+
+ try
+ {
+ m_xInStream.skipBytes(nBytesToSkip);
+ }
+ catch (com.sun.star.io.NotConnectedException exConnect) {
+ }
+ catch (com.sun.star.io.BufferSizeExceededException exBuffer ) {
+ }
+ catch (com.sun.star.io.IOException exIO ) {
+ }
+ catch (com.sun.star.uno.RuntimeException exRuntime) {
+ }
+ catch (com.sun.star.uno.Exception exUno ) {
+ }
+
+ }
+
+ public int available() throws com.sun.star.io.NotConnectedException,
+ com.sun.star.io.IOException
+ {
+ m_bInWasUsed = true;
+
+ if (m_xInStream == null)
+ {
+ 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) {
+ }
+ catch (com.sun.star.io.IOException exIO ) {
+ }
+ catch (com.sun.star.uno.RuntimeException exRuntime) {
+ }
+ catch (com.sun.star.uno.Exception exUno ) {
+ }
+
+ return nAvailable;
+ }
+
+ //_________________________________
+
+ public void closeInput() throws com.sun.star.io.NotConnectedException,
+ com.sun.star.io.IOException
+ {
+ m_bInWasUsed = true;
+
+ if (m_xInStream == null)
+ {
+ throw new com.sun.star.io.NotConnectedException("stream not open");
+ }
+
+ try
+ {
+ m_xInStream.closeInput();
+ }
+ catch (com.sun.star.io.NotConnectedException exConnect) {
+ }
+ catch (com.sun.star.io.IOException exIO ) {
+ }
+ catch (com.sun.star.uno.RuntimeException exRuntime) {
+ }
+ catch (com.sun.star.uno.Exception exUno ) {
+ }
+
+ }
+
+ /**
+ * 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(byte[] lData)
+ throws com.sun.star.io.NotConnectedException,
+ com.sun.star.io.BufferSizeExceededException ,
+ com.sun.star.io.IOException
+ {
+ m_bOutWasUsed = true;
+
+ if (m_xOutStream == null)
+ {
+ throw new com.sun.star.io.NotConnectedException("stream not open");
+ }
+
+ try
+ {
+ m_xOutStream.writeBytes(lData);
+ }
+ catch (com.sun.star.io.NotConnectedException exConnect) {
+ }
+ catch (com.sun.star.io.BufferSizeExceededException exBuffer ) {
+ }
+ catch (com.sun.star.io.IOException exIO ) {
+ }
+ catch (com.sun.star.uno.RuntimeException exRuntime) {
+ }
+ catch (com.sun.star.uno.Exception exUno ) {
+ }
+
+ }
+
+ //_________________________________
+
+ public void flush() throws com.sun.star.io.NotConnectedException ,
+ com.sun.star.io.BufferSizeExceededException ,
+ com.sun.star.io.IOException
+ {
+ m_bOutWasUsed = true;
+
+ if (m_xOutStream == null)
+ {
+ throw new com.sun.star.io.NotConnectedException("stream not open");
+ }
+
+ try
+ {
+ m_xOutStream.flush();
+ }
+ catch (com.sun.star.io.NotConnectedException exConnect) {
+ }
+ catch (com.sun.star.io.BufferSizeExceededException exBuffer ) {
+ }
+ catch (com.sun.star.io.IOException exIO ) {
+ }
+ catch (com.sun.star.uno.RuntimeException exRuntime) {
+ }
+ catch (com.sun.star.uno.Exception exUno ) {
+ }
+ }
+
+ //_________________________________
+
+ public void closeOutput() throws com.sun.star.io.NotConnectedException ,
+ com.sun.star.io.BufferSizeExceededException,
+ com.sun.star.io.IOException
+ {
+ m_bOutWasUsed = true;
+
+ if (m_xOutStream == null)
+ {
+ throw new com.sun.star.io.NotConnectedException("stream not open");
+ }
+
+ try
+ {
+ m_xOutStream.closeOutput();
+ }
+ catch (com.sun.star.io.NotConnectedException exConnect) {
+ }
+ catch (com.sun.star.io.BufferSizeExceededException exBuffer ) {
+ }
+ catch (com.sun.star.io.IOException exIO ) {
+ }
+ catch (com.sun.star.uno.RuntimeException exRuntime) {
+ }
+ catch (com.sun.star.uno.Exception exUno ) {
+ }
+
+ }
+
+ /**
+ * 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(long nLocation )
+ throws com.sun.star.lang.IllegalArgumentException,
+ com.sun.star.io.IOException
+ {
+ 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)
+ {
+ throw new com.sun.star.io.IOException("stream not seekable");
+ }
+
+ try
+ {
+ m_xSeek.seek(nLocation);
+ }
+ catch (com.sun.star.lang.IllegalArgumentException exArg ) {
+ }
+ catch (com.sun.star.io.IOException exIO ) {
+ }
+ catch (com.sun.star.uno.RuntimeException exRuntime) {
+ }
+ catch (com.sun.star.uno.Exception exUno ) {
+ }
+
+ }
+
+ public long getPosition() throws com.sun.star.io.IOException
+ {
+
+ 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)
+ {
+ 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 ) {
+ }
+ catch (com.sun.star.uno.RuntimeException exRuntime) {
+ }
+ catch (com.sun.star.uno.Exception exUno ) {
+ }
+
+ return nPos;
+ }
+
+ //_________________________________
+
+ public long getLength() throws com.sun.star.io.IOException
+ {
+
+ 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)
+ {
+ 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 ) {
+ }
+ catch (com.sun.star.uno.RuntimeException exRuntime) {
+ }
+ catch (com.sun.star.uno.Exception exUno ) {
+ }
+
+ return nLen;
+ }
+}
diff --git a/framework/qa/complex/loadAllDocuments/helper/makefile.mk b/framework/qa/complex/loadAllDocuments/helper/makefile.mk
new file mode 100644
index 000000000000..98c414c2c1f7
--- /dev/null
+++ b/framework/qa/complex/loadAllDocuments/helper/makefile.mk
@@ -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.
+#
+#*************************************************************************
+PRJ = ..$/..$/..$/..
+TARGET = CheckXComponentLoader
+PRJNAME = framework
+PACKAGE = complex$/loadAllDocuments$/helper
+
+# --- Settings -----------------------------------------------------
+.INCLUDE: settings.mk
+
+
+#----- compile .java files -----------------------------------------
+
+JARFILES = mysql.jar ridl.jar unoil.jar jurt.jar juh.jar java_uno.jar \
+ Generator.jar
+JAVAFILES = InteractionHandler.java StatusIndicator.java StreamSimulator.java
+JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class)
+
+MAXLINELENGTH = 100000
+
+.INCLUDE : target.mk
+
+
+
diff --git a/framework/qa/complex/loadAllDocuments/makefile.mk b/framework/qa/complex/loadAllDocuments/makefile.mk
new file mode 100644
index 000000000000..02aacd36d20d
--- /dev/null
+++ b/framework/qa/complex/loadAllDocuments/makefile.mk
@@ -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.
+#
+#*************************************************************************
+PRJ = ..$/..$/..
+TARGET = CheckXComponentLoader
+PRJNAME = framework
+PACKAGE = complex$/loadAllDocuments
+
+# --- Settings -----------------------------------------------------
+.INCLUDE: settings.mk
+
+
+#----- compile .java files -----------------------------------------
+
+JARFILES = mysql.jar ridl.jar unoil.jar jurt.jar juh.jar java_uno.jar \
+ OOoRunner.jar mysql.jar
+JAVAFILES = CheckXComponentLoader.java
+JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class)
+
+SUBDIRS = helper
+
+#----- make a jar from compiled files ------------------------------
+
+MAXLINELENGTH = 100000
+
+JARCLASSDIRS = $(PACKAGE)
+JARTARGET = $(TARGET).jar
+JARCOMPRESS = TRUE
+
+# --- Parameters for the test --------------------------------------
+
+# start an office if the parameter is set for the makefile
+.IF "$(OFFICE)" == ""
+CT_APPEXECCOMMAND =
+.ELSE
+CT_APPEXECCOMMAND = -AppExecutionCommand "$(OFFICE)$/soffice -accept=socket,host=localhost,port=8100;urp;"
+.ENDIF
+
+# test base is java complex
+CT_TESTBASE = -TestBase java_complex
+
+# test looks something like the.full.package.TestName
+CT_TEST = -o $(PACKAGE:s\$/\.\).$(JAVAFILES:b)
+
+# start the runner application
+CT_APP = org.openoffice.Runner
+
+# --- Targets ------------------------------------------------------
+
+.IF "$(depend)" == ""
+$(CLASSDIR)$/$(PACKAGE)$/$(JAVAFILES:b).props : ALLTAR
+.ELSE
+$(CLASSDIR)$/$(PACKAGE)$/$(JAVAFILES:b).props : ALLDEP
+.ENDIF
+
+.INCLUDE : target.mk
+
+$(CLASSDIR)$/$(PACKAGE)$/$(JAVAFILES:b).props : $(JAVAFILES:b).props
+ cp $(JAVAFILES:b).props $(CLASSDIR)$/$(PACKAGE)$/$(JAVAFILES:b).props
+ jar uf $(CLASSDIR)$/$(JARTARGET) -C $(CLASSDIR) $(PACKAGE)$/$(JAVAFILES:b).props
+
+RUN: run
+
+run:
+ +java -cp $(CLASSPATH) $(CT_APP) $(CT_TESTBASE) $(CT_APPEXECCOMMAND) $(CT_TEST) -tdoc $(PWD)$/testdocuments
+
+
+
diff --git a/framework/qa/complex/loadAllDocuments/password_check.sxw b/framework/qa/complex/loadAllDocuments/password_check.sxw
new file mode 100644
index 000000000000..ec545b99e22a
--- /dev/null
+++ b/framework/qa/complex/loadAllDocuments/password_check.sxw
Binary files differ
diff --git a/framework/qa/complex/loadAllDocuments/testdocuments/Calc_6.sxc b/framework/qa/complex/loadAllDocuments/testdocuments/Calc_6.sxc
new file mode 100644
index 000000000000..4b2b572085dc
--- /dev/null
+++ b/framework/qa/complex/loadAllDocuments/testdocuments/Calc_6.sxc
Binary files differ
diff --git a/framework/qa/complex/loadAllDocuments/testdocuments/Writer6.sxw b/framework/qa/complex/loadAllDocuments/testdocuments/Writer6.sxw
new file mode 100644
index 000000000000..1b2c2cb2dab6
--- /dev/null
+++ b/framework/qa/complex/loadAllDocuments/testdocuments/Writer6.sxw
Binary files differ
diff --git a/framework/qa/complex/loadAllDocuments/testdocuments/draw1.sxd b/framework/qa/complex/loadAllDocuments/testdocuments/draw1.sxd
new file mode 100644
index 000000000000..58c8772cb04b
--- /dev/null
+++ b/framework/qa/complex/loadAllDocuments/testdocuments/draw1.sxd
Binary files differ
diff --git a/framework/qa/complex/loadAllDocuments/testdocuments/imp1.sxi b/framework/qa/complex/loadAllDocuments/testdocuments/imp1.sxi
new file mode 100644
index 000000000000..efcdf9b6a25e
--- /dev/null
+++ b/framework/qa/complex/loadAllDocuments/testdocuments/imp1.sxi
Binary files differ
diff --git a/framework/qa/complex/loadAllDocuments/testdocuments/pic.gif b/framework/qa/complex/loadAllDocuments/testdocuments/pic.gif
new file mode 100644
index 000000000000..abbbc65f6340
--- /dev/null
+++ b/framework/qa/complex/loadAllDocuments/testdocuments/pic.gif
Binary files differ
diff --git a/framework/qa/complex/loadAllDocuments/testdocuments/pic.jpg b/framework/qa/complex/loadAllDocuments/testdocuments/pic.jpg
new file mode 100644
index 000000000000..6b4b744f8ea1
--- /dev/null
+++ b/framework/qa/complex/loadAllDocuments/testdocuments/pic.jpg
Binary files differ
diff --git a/framework/qa/complex/path_settings/PathSettingsTest.java b/framework/qa/complex/path_settings/PathSettingsTest.java
new file mode 100755
index 000000000000..cc896a74ea16
--- /dev/null
+++ b/framework/qa/complex/path_settings/PathSettingsTest.java
@@ -0,0 +1,458 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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 complex.path_settings;
+
+import com.sun.star.beans.Property;
+import com.sun.star.beans.XFastPropertySet;
+import com.sun.star.beans.XMultiPropertySet;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.beans.XPropertiesChangeListener;
+import com.sun.star.beans.XPropertyChangeListener;
+import com.sun.star.beans.XVetoableChangeListener;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.AnyConverter;
+import complexlib.ComplexTestCase;
+
+public class PathSettingsTest extends ComplexTestCase {
+
+ private static XMultiServiceFactory xMSF;
+
+ // the test object: an instance of the tested service
+ private static Object oObj = null;
+ // the properties of the service
+ private static Property[] props = null;
+ private static String[] propNames = null;
+ private static String[] availablePropNames = new String[]{
+ "Addin",
+ "AutoCorrect",
+ "Autotext",
+ "Backup",
+ "Basic",
+ "Bitmap",
+ "Config",
+ "Dictionary",
+ "Favorite",
+ "Filter",
+ "Gallery",
+ "Help",
+ "Linguistic",
+ "Module",
+ "Palette",
+ "Plugin",
+ "Temp",
+ "Template",
+ "UIConfig",
+ "UserConfig",
+ "UserDictionary",
+ "Work",
+};
+ private static String[] propVals = null;
+
+ /**
+ * A function to tell the framework, which test functions are available.
+ * Right now, it's only 'checkComplexTemplateState'.
+ * @return All test methods.
+ */
+ public String[] getTestMethodNames() {
+ return new String[]{"checkXFastPropertySet",
+ "checkXMultiPropertySet",
+ "checkXPropertySet"
+ };
+ }
+
+ /**
+ * Initialize before the tests start: this has to be done only once.
+ * This methods sets the 'oObj' and 'props' variables.
+ */
+ public void before() {
+ try {
+ xMSF = (XMultiServiceFactory)param.getMSF();
+// oObj = xMSF.createInstance("com.sun.star.util.PathSettings");
+ oObj = xMSF.createInstance("com.sun.star.comp.framework.PathSettings");
+ System.out.println("Implementation: " + util.utils.getImplName(oObj));
+ System.out.println("Service: ");
+ util.dbg.getSuppServices(oObj);
+ if (oObj == null) throw new com.sun.star.uno.Exception();
+ XPropertySet xProp = (XPropertySet)
+ UnoRuntime.queryInterface(XPropertySet.class, oObj);
+
+ props = xProp.getPropertySetInfo().getProperties();
+ propNames = new String[props.length];
+ propVals = new String[props.length];
+
+ // get intitial values and create new ones
+ log.println("\n---- All properties ----");
+ for (int i = 1; i < props.length; i++) {
+ propNames[i] = props[i].Name;
+ Object o = xProp.getPropertyValue(propNames[i]);
+ System.out.println("#### Object: " + o.getClass().getName() + " - " + o.toString());
+ propVals[i] = AnyConverter.toString(o);
+ System.out.println("#### String " + propVals[i]);
+ log.println("Property Name: " + propNames[i]);
+ log.println("Property Value: " + propVals[i]);
+ }
+ log.println("---- Finish showing properties ----\n");
+ }
+ catch(com.sun.star.uno.Exception e) {
+ e.printStackTrace();
+ log.println(e.getClass().getName());
+ log.println("Message: " + e.getMessage());
+ failed("Could not create an instance of the test object.");
+ }
+ catch(Exception e) {
+ e.printStackTrace();
+ failed("What exception?");
+ }
+ }
+
+ /**
+ * This tests the XFastPropertySet interface implementation.
+ */
+ public void checkXFastPropertySet()
+ {
+ log.println("---- Testing the XFastPropertySet interface ----");
+
+ // creating instances
+ XFastPropertySet xFPS = (XFastPropertySet)
+ UnoRuntime.queryInterface(XFastPropertySet.class, oObj);
+
+ String name = null;
+ // do for all properties
+ for (int i = 0; i < props.length; i++) {
+ try {
+ Property property = props[i];
+ name = property.Name;
+ int handle = property.Handle;
+
+ // get property name and initial value
+ log.println("Test property with name: " + name);
+ String val = (String)xFPS.getFastPropertyValue(handle);
+ log.println("Property has initial value: '" + val + "'");
+
+ // set to a new correct value
+ String newVal = changeToCorrectValue(val);
+ log.println("Try to change to correct value '" + newVal + "'");
+ xFPS.setFastPropertyValue(handle, newVal);
+
+ // check the change
+ String checkVal = (String)xFPS.getFastPropertyValue(handle);
+ assure("Did not change value on property " + name + ".", checkVal.equals(newVal));
+
+ newVal = changeToIncorrectValue(val);
+ log.println("Try to change to incorrect value '" + newVal + "'");
+ try {
+ xFPS.setFastPropertyValue(handle, newVal);
+ }
+ catch(com.sun.star.lang.IllegalArgumentException e) {
+ log.println("Correctly thrown Exception caught.");
+ }
+
+ // check if changed
+ checkVal = (String)xFPS.getFastPropertyValue(handle);
+ assure("Value did change on property " + name + " though it should not have.",
+ !checkVal.equals(newVal));
+
+ // set back to initial setting
+ xFPS.setFastPropertyValue(handle, val);
+
+ // check if changed
+ checkVal = (String)xFPS.getFastPropertyValue(handle);
+ assure("Did not change value back to original on property "
+ + name, checkVal.equals(val));
+ log.println("Test of property " + name + " finished\n");
+ }
+ catch(com.sun.star.uno.Exception e) {
+// e.printStackTrace();
+ log.println(e.getClass().getName());
+ log.println("Message: " + e.getMessage());
+ failed("Unexpected exception on property " + name + ".");
+ continue;
+ }
+ }
+ log.println("---- Test of XFastPropertySet finished ----\n");
+ }
+
+
+ // ____________________
+ /**
+ * This tests the XMultiPropertySet interface implementation.
+ */
+ public void checkXMultiPropertySet()
+ {
+ log.println("---- Testing the XMultiPropertySet interface ----");
+ XMultiPropertySet xMPS = (XMultiPropertySet)
+ UnoRuntime.queryInterface(XMultiPropertySet.class, oObj);
+
+ String[] correctVals = new String[props.length];
+ String[] incorrectVals = new String[props.length];
+
+ // get intitial values and create new ones
+ for (int i = 0; i < props.length; i++) {
+ correctVals[i] = changeToCorrectValue(propVals[i]);
+ incorrectVals[i] = changeToIncorrectValue(propVals[i]);
+ }
+
+ try {
+ // add a change listener
+ MyChangeListener mListener = new MyChangeListener();
+ xMPS.addPropertiesChangeListener(propNames, mListener);
+
+ // first change props to correct values
+ log.println("Change to correct values.");
+ xMPS.setPropertyValues(propNames, correctVals);
+ assure("Could not change to correct values with XMultiPropoertySet.",
+ verifyPropertySet(xMPS,propNames,correctVals)>0);
+
+ // second, change to incorrect values: expect an exception
+ log.println("Try to change to incorrect values.");
+ try {
+ xMPS.setPropertyValues(propNames, incorrectVals);
+ }
+ catch(com.sun.star.lang.IllegalArgumentException r) {
+ log.println("Correctly thrown Exception caught.");
+ }
+ assure("Did change to incorrect values with XMultiPropertySet," +
+ " but should not have.",
+ verifyPropertySet(xMPS,propNames,correctVals)>0);
+
+ // third, change back to initial values
+ log.println("Change back to initial values.");
+ xMPS.setPropertyValues(propNames, propVals);
+ assure("Could not change back to initial values with" +
+ " XMultiPropertySet.",
+ verifyPropertySet(xMPS,propNames,propVals)>0);
+
+ // fire the event for the listener
+ log.println("Fire event.");
+ xMPS.firePropertiesChangeEvent(propNames, mListener);
+ assure("Event was not fired on XMultiPropertySet.",
+ mListener.changePropertiesEventFired());
+ }
+ catch(com.sun.star.uno.Exception e) {
+// e.printStackTrace();
+ log.println(e.getClass().getName());
+ log.println("Message: " + e.getMessage());
+ failed("Unexpected exception on XMultiPropertySet.");
+ }
+
+ // test finished
+ log.println("---- Test of XMultiPropertySet finished ----\n");
+ }
+
+ /**
+ * Verify if the values of xProp are the same as vals.
+ * @param xProp A XMultiPropertySet.
+ * @param propNames An array with property names.
+ * @param vals An array with values of the properties
+ * @return -1 if none are equal, 1 if all are equal, 0 if some were equal
+ * and some not.
+ * @throws com.sun.star.lang.IllegalArgumentException
+ */
+ private int verifyPropertySet(XMultiPropertySet xProp,
+ String[] propNames, String[] vals)
+ {
+ int ret=0;
+ if (vals.length != propNames.length) {
+ log.println("Length of array parameters must be equal.");
+ return ret;
+ }
+ for (int i = 0; i < vals.length; i++) {
+ Object[] objs = xProp.getPropertyValues(new String[]{propNames[i]});
+ String retVal = (String)objs[0];
+ boolean nCheck = retVal.equals(vals[i]);
+ if (!nCheck) {
+ log.println("Property '" + propNames[i] +
+ "' was supposed to have value:");
+ log.println(vals[i]);
+ log.println("but has value:");
+ log.println(retVal);
+ }
+ // initialize
+ if (i==0) {
+ ret = nCheck?1:-1;
+ continue;
+ }
+ // return 0 if equal state changes compared to initial value
+ if ((nCheck && ret<0) || (!nCheck && ret>0)) {
+ ret = 0;
+ }
+ }
+ return ret;
+ }
+
+
+ // ____________________
+ /**
+ * This tests the XPropertySet interface implementation.
+ */
+ public void checkXPropertySet()
+ {
+ log.println("---- Testing the XPropertySet interface ----");
+
+ XPropertySet xPS = (XPropertySet)
+ UnoRuntime.queryInterface(XPropertySet.class, oObj);
+
+ MyChangeListener mListener1 = new MyChangeListener();
+ MyChangeListener mListener2 = new MyChangeListener();
+
+ for (int i=0; i<props.length; i++) {
+ // adding listeners
+ String name = propNames[i];
+ log.println("Testing property '" + name + "'");
+ try {
+ log.println("Add 2 Listeners.");
+ xPS.addPropertyChangeListener(name, mListener1);
+ xPS.addVetoableChangeListener(name, mListener1);
+ xPS.addPropertyChangeListener(name, mListener2);
+ xPS.addVetoableChangeListener(name, mListener2);
+
+ // change the property
+ log.println("Change value.");
+ String changeVal = changeToCorrectValue(propVals[i]);
+ xPS.setPropertyValue(name, changeVal);
+ String newVal = (String)xPS.getPropertyValue(name);
+
+ assure("Value did not change on property " + name + ".",
+ newVal.equals(changeVal));
+
+ assure("Listener 1 was not called.", checkListener(mListener1), true);
+ assure("Listener 2 was not called.", checkListener(mListener2), true);
+
+ mListener1.resetListener();
+ mListener2.resetListener();
+
+ log.println("Remove Listener 1.");
+
+ xPS.removePropertyChangeListener(name, mListener1);
+ xPS.removeVetoableChangeListener(name, mListener1);
+
+ // change the property
+ log.println("Change value back.");
+ xPS.setPropertyValue(name, propVals[i]);
+ newVal = (String)xPS.getPropertyValue(name);
+ assure("Value did not change on property " + name,
+ newVal.equals(propVals[i]));
+
+ assure("Listener was called, although it was removed on" +
+ " property " + name + ".", !checkListener(mListener1), true);
+ assure("Listener 2 was not called on property " + name + ".",
+ checkListener(mListener2), true);
+ }
+ catch(com.sun.star.uno.Exception e) {
+ e.printStackTrace();
+ log.println(e.getClass().getName());
+ log.println("Message: " + e.getMessage());
+ failed("Unexpcted exception on property " + name);
+ continue;
+ }
+ log.println("Finish testing property '" + propNames[i] + "'\n");
+ }
+ log.println("---- Test of XPropertySet finished ----\n");
+
+ }
+
+ private boolean checkListener(MyChangeListener ml) {
+ return ml.changePropertyEventFired() ||
+ ml.changePropertiesEventFired() ||
+ ml.vetoableChangeEventFired();
+ }
+
+ // ____________________
+ /**
+ * Change the given String to a correct path URL.
+ * @return The changed path URL.
+ */
+ private String changeToCorrectValue(String path) {
+ // the simplest possiblity
+ if ( path == null || path.equals("") ) {
+ return "file:///tmp";
+ }
+ return path + "/tmp";
+ }
+
+
+ /**
+ * Change the given String to an incorrect path URL.
+ * @return The changed path URL.
+ */
+ private String changeToIncorrectValue(String path) {
+ // the simplest possiblity
+ return "fileblablabla";
+ }
+
+
+ /**
+ * Listener implementation which sets a flag when
+ * listener was called.
+ */
+ public class MyChangeListener implements XPropertiesChangeListener,
+ XPropertyChangeListener,
+ XVetoableChangeListener {
+
+ private boolean propChanged = false;
+ private boolean propertiesChanged = false;
+ private boolean disposeCalled = false;
+ private boolean vetoableChanged = false;
+
+ public void propertiesChange(
+ com.sun.star.beans.PropertyChangeEvent[] e) {
+ propertiesChanged = true;
+ }
+
+ public void vetoableChange(com.sun.star.beans.PropertyChangeEvent pE)
+ throws com.sun.star.beans.PropertyVetoException {
+ vetoableChanged = true;
+ }
+
+ public void propertyChange(com.sun.star.beans.PropertyChangeEvent pE) {
+ propChanged = true;
+ }
+
+ public void disposing(com.sun.star.lang.EventObject eventObject) {
+ disposeCalled = true;
+ }
+
+ public void resetListener() {
+ propChanged = false;
+ propertiesChanged = false;
+ disposeCalled = false;
+ vetoableChanged = false;
+ }
+
+ public boolean changePropertyEventFired() {
+ return propChanged;
+ }
+ public boolean changePropertiesEventFired() {
+ return propertiesChanged;
+ }
+ public boolean vetoableChangeEventFired() {
+ return vetoableChanged;
+ }
+
+ };
+}
diff --git a/framework/qa/complex/path_settings/makefile.mk b/framework/qa/complex/path_settings/makefile.mk
new file mode 100755
index 000000000000..70af7817aca3
--- /dev/null
+++ b/framework/qa/complex/path_settings/makefile.mk
@@ -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.
+#
+#*************************************************************************
+
+PRJ = ..$/..$/..
+TARGET = PathSettings
+PRJNAME = $(TARGET)
+PACKAGE = complex$/path_settings
+
+# --- Settings -----------------------------------------------------
+.INCLUDE: settings.mk
+
+
+#----- compile .java files -----------------------------------------
+
+JARFILES = ridl.jar unoil.jar jurt.jar juh.jar java_uno.jar OOoRunner.jar mysql.jar
+JAVAFILES = PathSettingsTest.java
+JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class)
+
+#----- make a jar from compiled files ------------------------------
+
+MAXLINELENGTH = 100000
+
+JARCLASSDIRS = $(PACKAGE)
+JARTARGET = $(TARGET).jar
+JARCOMPRESS = TRUE
+
+# --- Parameters for the test --------------------------------------
+
+# start an office if the parameter is set for the makefile
+.IF "$(OFFICE)" == ""
+CT_APPEXECCOMMAND =
+.ELSE
+CT_APPEXECCOMMAND = -AppExecutionCommand "$(OFFICE)$/soffice -accept=socket,host=localhost,port=8100;urp;"
+.ENDIF
+
+# test base is java complex
+CT_TESTBASE = -TestBase java_complex
+
+# test looks something like the.full.package.TestName
+CT_TEST = -o $(PACKAGE:s\$/\.\).$(JAVAFILES:b)
+
+# start the runner application
+CT_APP = org.openoffice.Runner
+
+# --- Targets ------------------------------------------------------
+
+.IF "$(depend)" == ""
+ALL : ALLTAR
+.ELSE
+ALL: ALLDEP
+.ENDIF
+
+.INCLUDE : target.mk
+
+RUN: run
+
+run:
+ +java -version
+ +java -cp $(CLASSPATH) $(CT_APP) $(CT_APPEXECCOMMAND) $(CT_TESTBASE) $(CT_TEST)
+
diff --git a/framework/qa/complex/path_substitution/PathSubstitutionTest.java b/framework/qa/complex/path_substitution/PathSubstitutionTest.java
new file mode 100755
index 000000000000..27fe6410eca0
--- /dev/null
+++ b/framework/qa/complex/path_substitution/PathSubstitutionTest.java
@@ -0,0 +1,246 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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 complex.path_substitution;
+
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.util.XStringSubstitution;
+import complexlib.ComplexTestCase;
+import java.util.Vector;
+
+/**
+ *
+ */
+public class PathSubstitutionTest extends ComplexTestCase {
+
+ private static XMultiServiceFactory xMSF;
+
+ // all substitution variables
+ private VariableContainer substVars = null;
+
+ /**
+ * A function to tell the framework, which test functions are available.
+ * Right now, it's only 'checkXStringSubstitution'.
+ * @return All test methods.
+ */
+ public String[] getTestMethodNames() {
+ return new String[]{"checkXStringSubstitution"};
+ }
+
+ /**
+ * Create an array with all substitution variables
+ */
+ private void initialize() {
+ substVars = new VariableContainer();
+ substVars.add("$(prog)", false, true);
+ substVars.add("$(inst)", false, true);
+ substVars.add("$(user)", false, true);
+ substVars.add("$(work)", false, true);
+ substVars.add("$(home)", false, true);
+ substVars.add("$(temp)", false, true);
+ substVars.add("$(lang)", false, false);
+ substVars.add("$(langid)", false, false);
+ substVars.add("$(vlang)", false,false);
+ // path won't resubstitute
+ substVars.add("$(path)", false,false);
+ }
+
+ /**
+ * One actual test: as the method 'getTestMethodNames()' tells.
+ */
+ public void checkXStringSubstitution()
+ {
+ xMSF = (XMultiServiceFactory)param.getMSF();
+ log.println("---- Testing the XStringSubstitution interface ----");
+ log.println("Create intance of test object.\n");
+ XStringSubstitution oObj = null;
+ try {
+ Object x = xMSF.createInstance(
+ "com.sun.star.util.PathSubstitution");
+ oObj = (XStringSubstitution)
+ UnoRuntime.queryInterface(XStringSubstitution.class, x);
+ if (oObj == null) throw new com.sun.star.uno.Exception();
+ }
+ catch(com.sun.star.uno.Exception e) {
+ log.println(e.getClass().getName());
+ log.println("Message: " + e.getMessage());
+ failed("Could not create an instance of the test object.");
+ return;
+ }
+
+ initialize();
+
+ for (int i=0; i<substVars.size(); i++) {
+ String var = substVars.getVariable(i);
+ log.println("Testing var '" + var + "'");
+ try {
+ String substVal = oObj.getSubstituteVariableValue(var);
+ log.println("\tvalue '" + substVal + "'");
+ substVars.putValue(i,substVal);
+
+ // simple check: let path in a string replace
+ String substString = var + "/additional/path";
+
+ log.println("Substitute '"+substString+"'");
+ String newValue = oObj.substituteVariables(substString, true);
+ log.println("Return value '"+newValue+"'");
+ // 2do: better check for correct substitution
+ assure("Did not substitute '"
+ + substString+"' to '" + newValue
+ + "' correctly:", newValue.startsWith(substVal));
+
+ // simple check part two:
+ //make substitution backwards if possible
+ if (substVars.canReSubstitute(i)) {
+ substString = substVal + "/additional/path";
+
+ log.println("Substitute backwards '"+substString+"'");
+ newValue = oObj.reSubstituteVariables(substString);
+ log.println("Return value '"+newValue+"'");
+ // 2do: better check for correct substitution
+ assure("Did not reSubstitute '"
+ + substString + "' to '" + newValue
+ + "' correctly:", checkResubstitute(newValue, var));
+ }
+
+ // simple check part three: look if replace
+ //in middle of text works
+ substString = "file:///starting/" + var + "/path";
+
+ log.println("Substitute '"+substString+"'");
+ newValue = oObj.substituteVariables(substString, false);
+ log.println("Return value '"+newValue+"'");
+ boolean erg = true;
+ if(substVars.onlySubstituteAtBegin(i))
+ // in this case it should not have worked
+ erg = newValue.indexOf(substVal)==-1;
+ else
+ erg = newValue.indexOf(substVal)!=-1;
+
+ assure("Did not substitute '"
+ + substString + "' to '" + newValue
+ + "' correctly:", erg);
+
+ }
+ catch(com.sun.star.uno.Exception e) {
+ log.println(e.getClass().getName());
+ log.println("Message: " + e.getMessage());
+ failed("Could not create an instance of the test object.");
+ return;
+ }
+ log.println("Finish testing '" + var + "'\n");
+ }
+
+ // check of greedy resubstitution
+ String prog = "$(prog)";
+ String inst = "$(inst)";
+ String instPth = substVars.getValue(inst);
+ String progPth = substVars.getValue(prog);
+
+ if (progPth.startsWith(instPth) && instPth.startsWith(progPth)) {
+ log.println("Greedy ReSubstitute");
+ String substString = progPth + "/additional/path";
+ String newVal = oObj.reSubstituteVariables(substString);
+ log.println("String '" + substString +
+ "' should be resubstituted with");
+ log.println("Variable '" + prog + "' instead of Variable '" +
+ inst + "'");
+ assure("Did not reSubstitute '" + substString
+ + "' to '" + newVal + "' correctly:",
+ newVal.startsWith(prog));
+ }
+
+ log.println(
+ "---- Finish testing the XStringSubstitution interface ----");
+ }
+
+ /**
+ * test the resubstitution
+ * @return true, if resubstitution is correct.
+ */
+ private boolean checkResubstitute(String subst, String original) {
+ // simple: subst starts with original
+ if ( subst.startsWith(original) ) {
+ return true;
+ }
+ else { // hard: been resubstituted with a differernt variable.
+ for (int i=0; i<substVars.size(); i++) {
+ String var = substVars.getVariable(i);
+ if ( subst.startsWith(var) && original.startsWith(original)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+ /**
+ * Class for containing the substitution variables with their
+ * values and some information.
+ */
+ private class VariableContainer {
+ public Vector varName;
+ public Vector varValue;
+ public Vector substAtBegin;
+ public Vector resubst;
+
+ public VariableContainer() {
+ varName = new Vector();
+ varValue = new Vector();
+ substAtBegin = new Vector();
+ resubst = new Vector();
+ }
+
+ public void add(String var) {
+ varName.add(var);
+ substAtBegin.add(Boolean.TRUE);
+ resubst.add(Boolean.TRUE);
+ }
+ public void add(String var, boolean onlySubstAtBegin,
+ boolean canResubst) {
+ varName.add(var);
+ this.substAtBegin.add(new Boolean(onlySubstAtBegin));
+ this.resubst.add(new Boolean(canResubst));
+ }
+
+ public void putValue(int i, String val) {
+ varValue.add(i, val);
+ }
+
+ public int size() { return varName.size(); }
+ public String getVariable(int i) { return (String)varName.get(i); }
+ public String getValue(int i) { return (String)varName.get(i); }
+ public String getValue(String var) {
+ return (String)varValue.get(varName.indexOf(var));
+ }
+ public boolean onlySubstituteAtBegin(int i) {
+ return ((Boolean)substAtBegin.get(i)).booleanValue();
+ }
+ public boolean canReSubstitute(int i) {
+ return ((Boolean)resubst.get(i)).booleanValue();
+ }
+ }
+}
diff --git a/framework/qa/complex/path_substitution/makefile.mk b/framework/qa/complex/path_substitution/makefile.mk
new file mode 100755
index 000000000000..a266d3fa4123
--- /dev/null
+++ b/framework/qa/complex/path_substitution/makefile.mk
@@ -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.
+#
+#*************************************************************************
+
+PRJ = ..$/..$/..
+TARGET = PathSubstitution
+PRJNAME = $(TARGET)
+PACKAGE = complex$/path_substitution
+
+# --- Settings -----------------------------------------------------
+.INCLUDE: settings.mk
+
+
+#----- compile .java files -----------------------------------------
+
+JARFILES = ridl.jar unoil.jar jurt.jar juh.jar java_uno.jar OOoRunner.jar mysql.jar
+JAVAFILES = PathSubstitutionTest.java
+JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class)
+
+#----- make a jar from compiled files ------------------------------
+
+MAXLINELENGTH = 100000
+
+JARCLASSDIRS = $(PACKAGE)
+JARTARGET = $(TARGET).jar
+JARCOMPRESS = TRUE
+
+# --- Parameters for the test --------------------------------------
+
+# start an office if the parameter is set for the makefile
+.IF "$(OFFICE)" == ""
+CT_APPEXECCOMMAND =
+.ELSE
+CT_APPEXECCOMMAND = -AppExecutionCommand "$(OFFICE)$/soffice -accept=socket,host=localhost,port=8100;urp;"
+.ENDIF
+
+# test base is java complex
+CT_TESTBASE = -TestBase java_complex
+
+# test looks something like the.full.package.TestName
+CT_TEST = -o $(PACKAGE:s\$/\.\).$(JAVAFILES:b)
+
+# start the runner application
+CT_APP = org.openoffice.Runner
+
+# --- Targets ------------------------------------------------------
+
+.IF "$(depend)" == ""
+ALL : ALLTAR
+.ELSE
+ALL: ALLDEP
+.ENDIF
+
+.INCLUDE : target.mk
+
+RUN: run
+
+run:
+ +java -cp $(CLASSPATH) $(CT_APP) $(CT_APPEXECCOMMAND) $(CT_TESTBASE) $(CT_TEST)
+
diff --git a/framework/qa/complex/sequence/CheckSequenceOfEnum.java b/framework/qa/complex/sequence/CheckSequenceOfEnum.java
new file mode 100755
index 000000000000..a09703398f8c
--- /dev/null
+++ b/framework/qa/complex/sequence/CheckSequenceOfEnum.java
@@ -0,0 +1,95 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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 complex.sequence;
+
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.enumexample.XEnumSequence;
+import com.sun.star.beans.PropertyState;
+import com.sun.star.uno.UnoRuntime;
+import complexlib.ComplexTestCase;
+
+/**
+ * The test is for bug 111128. The mapping of sequence<enumeration> between
+ * Java and C++ from the IDL definition was erroneous. This test checks, if
+ * the mapping works.
+ */
+public class CheckSequenceOfEnum extends ComplexTestCase {
+
+ /**
+ * Return all test methods.
+ * @return The test methods.
+ */
+ public String[] getTestMethodNames() {
+ return new String[]{"checkSequence"};
+ }
+
+ /**
+ * Check the sequence<enumeration> mapping between Java and C++.
+ * Since the Office does
+ * not use such a construct itself, a C++ component with an own defined
+ * interface is used for testing.
+ */
+ public void checkSequence() {
+ try {
+ XMultiServiceFactory xMSF = (XMultiServiceFactory) param.getMSF();
+ Object oObj = xMSF.createInstance("com.sun.star.enumexample.ChangeSequenceOrder");
+ assure("Build the shared library 'changeSequenceOrder' in directory 'enumexample' and\n"
+ + "register the created zip 'EnumSequenceComponent' before executing this test.", oObj != null);
+ // build a first sequence
+ PropertyState[] aOriginalSequence = new PropertyState[] {
+ PropertyState.DIRECT_VALUE,
+ PropertyState.DEFAULT_VALUE,
+ PropertyState.AMBIGUOUS_VALUE
+ };
+ XEnumSequence xSequence = (XEnumSequence)UnoRuntime.queryInterface(XEnumSequence.class, oObj);
+ PropertyState[] aChangedSequence = xSequence.getSequenceInChangedOrder(aOriginalSequence);
+ assure("Did not return a correct sequence.", checkSequence(aOriginalSequence, aChangedSequence));
+ }
+ catch(Exception e) {
+ e.printStackTrace();
+ failed("Exception!");
+ }
+ }
+
+ private boolean checkSequence(PropertyState[] aOriginalSequence, PropertyState[] aChangedSequence) {
+ boolean erg = true;
+ int length = aOriginalSequence.length;
+ for ( int i=0; i<length; i++ ) {
+ if ( aOriginalSequence[i] != aChangedSequence[length -1 - i]) {
+ log.println("Checking '" + aOriginalSequence[i] + "' == '" + aChangedSequence[length - 1 - i] + "'");
+ erg = false;
+ }
+ if ( aChangedSequence[length - 1 - i].getValue() != PropertyState.fromInt(i).getValue() ) {
+ log.println("Checking '" + aChangedSequence[length - 1 - i].getValue() + "' == '" + PropertyState.fromInt(i).getValue() + "'");
+ erg = false;
+ }
+ }
+ return erg;
+ }
+}
+
+
diff --git a/framework/qa/complex/sequence/makefile.mk b/framework/qa/complex/sequence/makefile.mk
new file mode 100755
index 000000000000..ba18b278d79a
--- /dev/null
+++ b/framework/qa/complex/sequence/makefile.mk
@@ -0,0 +1,98 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General 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 = ..$/..$/..
+TARGET = CheckSequenceOfEnum
+PRJNAME = $(TARGET)
+PACKAGE = complex$/sequence
+
+# --- Settings -----------------------------------------------------
+.INCLUDE: settings.mk
+
+
+#----- compile .java files -----------------------------------------
+
+JARFILES = mysql.jar ridl.jar unoil.jar jurt.jar juh.jar java_uno.jar OOoRunner.jar CheckSequenceOfEnum.jar
+JAVAFILES = CheckSequenceOfEnum.java
+
+ENUMSEQUENCEIDL = com.sun.star.enumexample.XEnumSequence
+
+#----- make a jar from compiled files ------------------------------
+
+MAXLINELENGTH = 100000
+
+JARCLASSDIRS = $(PACKAGE) com
+JARTARGET = $(TARGET).jar
+JARCOMPRESS = TRUE
+
+# --- Parameters for the test --------------------------------------
+
+# start an office if the parameter is set for the makefile
+.IF "$(OFFICE)" == ""
+CT_APPEXECCOMMAND =
+.ELSE
+CT_APPEXECCOMMAND = -AppExecutionCommand "$(OFFICE)$/soffice -accept=socket,host=localhost,port=8100;urp;"
+.ENDIF
+
+# test base is java complex
+CT_TESTBASE = -TestBase java_complex
+
+# test looks something like the.full.package.TestName
+CT_TEST = -o $(PACKAGE:s\$/\.\).CheckSequenceOfEnum
+
+# start the runner application
+CT_APP = org.openoffice.Runner
+
+RDB = $(BIN)$/myudkapi.rdb
+JAVADIR = $(OUT)$/misc$/java
+
+# --- Targets ------------------------------------------------------
+
+.IF "$(depend)" == ""
+ALL: GENJAVAFILES ALLTAR
+.ELSE
+ALL: ALLDEP
+.ENDIF
+
+
+.INCLUDE : target.mk
+
+$(RDB) :
+ +idlc -I$(IDL) -I$(SOLARIDLDIR) -O$(BIN) $?
+ +regmerge $@ /UCR $(BIN)$/{$(?:f:s/.idl/.urd/)}
+ +regmerge $@ / $(SOLARBINDIR)$/udkapi.rdb
+ touch $@
+
+GENJAVAFILES :
+ -+$(MKDIR) $(CLASSDIR) >& $(NULLDEV)
+ -+$(MKDIR) $(JAVADIR) >& $(NULLDEV)
+ +javamaker -BUCR -nD -O$(CLASSDIR) $(RDB) -T$(ENUMSEQUENCEIDL)
+
+RUN:
+ +java -cp $(CLASSPATH) $(CT_APP) $(CT_APPEXECCOMMAND) $(CT_TESTBASE) $(CT_TEST)
+
+run: RUN