summaryrefslogtreecommitdiff
path: root/framework/qa
diff options
context:
space:
mode:
Diffstat (limited to 'framework/qa')
-rw-r--r--framework/qa/complex/ModuleManager/CheckXModuleManager.java358
-rw-r--r--framework/qa/complex/ModuleManager/makefile.mk60
-rw-r--r--framework/qa/complex/XUserInputInterception/EventTest.java627
-rw-r--r--framework/qa/complex/XUserInputInterception/makefile.mk133
-rw-r--r--framework/qa/complex/accelerators/AcceleratorsConfigurationTest.java859
-rw-r--r--framework/qa/complex/accelerators/KeyMapping.java168
-rw-r--r--framework/qa/complex/accelerators/helper/makefile.mk46
-rw-r--r--framework/qa/complex/accelerators/makefile.mk67
-rwxr-xr-xframework/qa/complex/api_internal/CheckAPI.java249
-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.mk63
-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.java136
-rw-r--r--framework/qa/complex/broken_document/TestDocument.java41
-rwxr-xr-xframework/qa/complex/broken_document/makefile.mk65
-rwxr-xr-xframework/qa/complex/broken_document/test_documents/dbf.dbf.emf1
-rw-r--r--framework/qa/complex/contextMenuInterceptor/CheckContextMenuInterceptor.java352
-rw-r--r--framework/qa/complex/contextMenuInterceptor/ContextMenuInterceptor.java114
-rw-r--r--framework/qa/complex/contextMenuInterceptor/makefile.mk63
-rw-r--r--framework/qa/complex/contextMenuInterceptor/space-metal.jpgbin0 -> 4313 bytes
-rwxr-xr-xframework/qa/complex/desktop/DesktopTerminate.java195
-rwxr-xr-xframework/qa/complex/desktop/makefile.mk62
-rw-r--r--framework/qa/complex/dispatches/Interceptor.java345
-rw-r--r--framework/qa/complex/dispatches/checkdispatchapi.java498
-rw-r--r--framework/qa/complex/dispatches/helper/makefile.mk47
-rw-r--r--framework/qa/complex/dispatches/makefile.mk131
-rwxr-xr-xframework/qa/complex/disposing/GetServiceWhileDisposingOffice.java118
-rwxr-xr-xframework/qa/complex/disposing/makefile.mk61
-rw-r--r--framework/qa/complex/framework/autosave/AutoSave.java489
-rw-r--r--framework/qa/complex/framework/autosave/ConfigHelper.java115
-rw-r--r--framework/qa/complex/framework/autosave/Protocol.java999
-rw-r--r--framework/qa/complex/framework/autosave/makefile.mk127
-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.java1022
-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.java223
-rwxr-xr-xframework/qa/complex/imageManager/_XComponent.java187
-rwxr-xr-xframework/qa/complex/imageManager/_XImageManager.java117
-rwxr-xr-xframework/qa/complex/imageManager/_XInitialization.java94
-rwxr-xr-xframework/qa/complex/imageManager/_XTypeProvider.java102
-rwxr-xr-xframework/qa/complex/imageManager/_XUIConfiguration.java82
-rwxr-xr-xframework/qa/complex/imageManager/_XUIConfigurationPersistence.java93
-rwxr-xr-xframework/qa/complex/imageManager/interfaces/makefile.mk63
-rwxr-xr-xframework/qa/complex/imageManager/makefile.mk123
-rw-r--r--framework/qa/complex/loadAllDocuments/CheckXComponentLoader.java750
-rw-r--r--framework/qa/complex/loadAllDocuments/CheckXComponentLoader.props3
-rw-r--r--framework/qa/complex/loadAllDocuments/InteractionHandler.java155
-rw-r--r--framework/qa/complex/loadAllDocuments/StatusIndicator.java237
-rw-r--r--framework/qa/complex/loadAllDocuments/StreamSimulator.java474
-rw-r--r--framework/qa/complex/loadAllDocuments/TestDocument.java41
-rw-r--r--framework/qa/complex/loadAllDocuments/helper/makefile.mk47
-rw-r--r--framework/qa/complex/loadAllDocuments/makefile.mk134
-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/password_check.sxwbin0 -> 5128 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.java1018
-rwxr-xr-xframework/qa/complex/path_settings/makefile.mk62
-rwxr-xr-xframework/qa/complex/path_substitution/PathSubstitutionTest.java321
-rwxr-xr-xframework/qa/complex/path_substitution/makefile.mk122
-rw-r--r--framework/qa/unoapi/Test.java51
-rwxr-xr-xframework/qa/unoapi/framework.sce35
-rwxr-xr-xframework/qa/unoapi/knownissues.xcl59
-rwxr-xr-xframework/qa/unoapi/makefile.mk48
-rw-r--r--framework/qa/unoapi/testdocuments/Calc_Link.sxcbin0 -> 5410 bytes
-rw-r--r--framework/qa/unoapi/testdocuments/Writer_link.sxwbin0 -> 5188 bytes
-rw-r--r--framework/qa/unoapi/testdocuments/XTypeDetection.sxwbin0 -> 4995 bytes
-rwxr-xr-xframework/qa/unoapi/testdocuments/delete.cfgbin0 -> 2799 bytes
76 files changed, 13270 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..22e3003d86e3
--- /dev/null
+++ b/framework/qa/complex/ModuleManager/CheckXModuleManager.java
@@ -0,0 +1,358 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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.AnyConverter;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.util.*;
+import com.sun.star.container.*;
+
+
+
+// ---------- junit imports -----------------
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.openoffice.test.OfficeConnection;
+import static org.junit.Assert.*;
+// ------------------------------------------
+
+//-----------------------------------------------
+/** @short todo document me
+ */
+public class CheckXModuleManager
+{
+ //-------------------------------------------
+ // 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
+ */
+ @Before public void before()
+ throws java.lang.Exception
+ {
+ // get uno service manager from global test environment
+ m_xSmgr = getMSF();
+
+ // create module manager
+ m_xMM = 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 = UnoRuntime.queryInterface(XFrame.class, m_xSmgr.createInstance("com.sun.star.frame.Desktop"));
+
+ m_xLoader = UnoRuntime.queryInterface(XComponentLoader.class, xDesktop.findFrame("_blank", 0));
+ }
+
+ //-------------------------------------------
+ /** @short close the environment.
+ */
+ @After public void after()
+ throws java.lang.Exception
+ {
+ XCloseable xClose = UnoRuntime.queryInterface(XCloseable.class, m_xLoader);
+ xClose.close(false);
+
+ m_xLoader = null;
+ m_xMM = null;
+ m_xSmgr = null;
+ }
+
+ //-------------------------------------------
+ /** @todo document me
+ */
+ @Test 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" );
+ // TODO: fails
+ // impl_identifyModulesBasedOnDocs("com.sun.star.chart.ChartDocument" );
+ }
+
+ //-------------------------------------------
+ /** @todo document me
+ */
+ @Test public void checkModuleConfigurationReadable()
+ throws java.lang.Exception
+ {
+ }
+
+ //-------------------------------------------
+ /** @todo document me
+ */
+ @Test 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
+ */
+ @Test 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
+ {
+ System.out.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 = 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)
+ {
+ fail("Miss module identifier in result set. Returned data are incomplete.");
+ }
+
+ if ( ! sFoundDocService.equals(sDocumentService))
+ {
+ fail("Query returned wrong module '" + sFoundModule + "' with DocumentService='" + sFoundDocService + "'.");
+ }
+
+ System.out.println("Found module '"+sFoundModule+"'.");
+ }
+ }
+
+ //-------------------------------------------
+ /** @todo document me
+ */
+ private void impl_identifyModulesBasedOnDocs(String sModule)
+ throws java.lang.Exception
+ {
+ System.out.println("check identification of module '"+sModule+"' ...");
+
+ XNameAccess xMM = 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 = 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))
+ {
+ fail("Identification of module '" + sModule + "' failed if frame was used as entry point.");
+ }
+ if ( ! sModuleController.equals(sModule))
+ {
+ fail("Identification of module '" + sModule + "' failed if controller was used as entry point.");
+ }
+ if ( ! sModuleModel.equals(sModule))
+ {
+ fail("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 = 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 !
+ System.out.println("check readonly state of module '"+sModule+"' for property '"+sPropName+"' ...");
+ try
+ {
+ xMM.replaceByName(sModule, lChanges);
+ fail("Was able to write READONLY property '"+sPropName+"' of module '"+sModule+"' configuration.");
+ }
+ catch(Throwable ex)
+ {}
+ }
+
+
+
+ private XMultiServiceFactory getMSF()
+ {
+ final XMultiServiceFactory xMSF1 = UnoRuntime.queryInterface(XMultiServiceFactory.class, connection.getComponentContext().getServiceManager());
+ return xMSF1;
+ }
+
+ // setup and close connections
+ @BeforeClass public static void setUpConnection() throws Exception {
+ System.out.println("setUpConnection()");
+ connection.setUp();
+ }
+
+ @AfterClass public static void tearDownConnection()
+ throws InterruptedException, com.sun.star.uno.Exception
+ {
+ System.out.println("tearDownConnection()");
+ connection.tearDown();
+ }
+
+ private static final OfficeConnection connection = new OfficeConnection();
+
+}
diff --git a/framework/qa/complex/ModuleManager/makefile.mk b/framework/qa/complex/ModuleManager/makefile.mk
new file mode 100644
index 000000000000..4ad6d8929030
--- /dev/null
+++ b/framework/qa/complex/ModuleManager/makefile.mk
@@ -0,0 +1,60 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+.IF "$(OOO_SUBSEQUENT_TESTS)" == ""
+nothing .PHONY:
+.ELSE
+
+PRJ = ../../..
+PRJNAME = framework
+TARGET = qa_complex_ModuleManager
+
+.IF "$(OOO_JUNIT_JAR)" != ""
+PACKAGE = complex/ModuleManager
+
+# here store only Files which contain a @Test
+JAVATESTFILES = \
+ CheckXModuleManager.java
+
+# put here all other files
+JAVAFILES = $(JAVATESTFILES)
+
+JARFILES = OOoRunner.jar ridl.jar test.jar unoil.jar
+EXTRAJARFILES = $(OOO_JUNIT_JAR)
+
+# Sample how to debug
+# JAVAIFLAGS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=9003,suspend=y
+
+.END
+
+.INCLUDE: settings.mk
+.INCLUDE: target.mk
+.INCLUDE: installationtest.mk
+
+ALLTAR : javatest
+
+.END
+
diff --git a/framework/qa/complex/XUserInputInterception/EventTest.java b/framework/qa/complex/XUserInputInterception/EventTest.java
new file mode 100644
index 000000000000..6f7b8952a0b1
--- /dev/null
+++ b/framework/qa/complex/XUserInputInterception/EventTest.java
@@ -0,0 +1,627 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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.uno.UnoRuntime;
+import com.sun.star.uno.XInterface;
+import com.sun.star.util.*;
+import java.awt.Robot;
+import java.awt.event.InputEvent;
+
+import util.AccessibilityTools;
+import util.SOfficeFactory;
+
+// ---------- junit imports -----------------
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.openoffice.test.OfficeConnection;
+import static org.junit.Assert.*;
+// ------------------------------------------
+//-----------------------------------------------
+/**
+ * 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 {
+ //-------------------------------------------
+ // 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.
+ */
+@Before public void before() {
+ // get uno service manager from global test environment
+ m_xMSF = getMSF();
+
+ // create frame instance
+ try {
+ // get a soffice factory object
+ m_SOF = SOfficeFactory.getFactory(getMSF());
+
+ } catch(java.lang.Throwable ex) {
+ fail("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 = UnoRuntime.queryInterface(XCloseable.class, xDoc);
+ try {
+ xClose.close(false);
+ } catch(com.sun.star.util.CloseVetoException exVeto) {
+ System.out.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
+ */
+ @Test public void checkTextDocument(){
+
+ XTextDocument xDoc = null;
+
+ try{
+ xDoc = m_SOF.createTextDoc("WriterTest");
+ } catch (com.sun.star.uno.Exception e){
+ fail("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
+ */
+ @Test public void checkImpressDocument(){
+
+ XComponent xDoc = null;
+
+ try{
+ xDoc = m_SOF.createImpressDoc("ImpressTest");
+ } catch (com.sun.star.uno.Exception e){
+ fail("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
+ */
+// TODO!
+// @Test public void checkChartDocument(){
+//
+// XChartDocument xDoc = null;
+//
+// try{
+// xDoc = m_SOF.createChartDoc("ChartTest");
+// } catch (com.sun.star.uno.Exception e){
+// fail("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
+ */
+ @Test public void checkMathDocument(){
+
+ XComponent xDoc = null;
+
+ try{
+ xDoc = m_SOF.createMathDoc("MathTest");
+ } catch (com.sun.star.uno.Exception e){
+ fail("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
+ */
+ @Test public void checkDrawDocument(){
+
+ XComponent xDoc = null;
+
+ try{
+ xDoc = m_SOF.createDrawDoc("DrawTest");
+ } catch (com.sun.star.uno.Exception e){
+ fail("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
+ */
+ @Test public void checkCalcDocument(){
+
+ XSpreadsheetDocument xDoc = null;
+
+ try{
+ xDoc = m_SOF.createCalcDoc("CalcTest");
+ } catch (com.sun.star.uno.Exception e){
+ fail("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 = 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);
+
+ System.out.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);
+ System.out.println("key listener thread should be finished.");
+
+ assertTrue("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);
+
+ System.out.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);
+ System.out.println("mouse listener thread should be finished.");
+
+ assertTrue("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 = UnoRuntime.queryInterface(XUserInputInterception.class, xController);
+ if (xUII == null) {
+ fail("could not get XUserInputInterception from XContoller");
+ }
+ 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 ){
+ System.out.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 ){
+ System.out.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 ){
+ System.out.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 ){
+ System.out.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 ){
+ System.out.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 ){
+ System.out.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(
+ getMSF(),
+ xModel);
+
+ XAccessible xRoot = at.getAccessibleObject(xWindow);
+
+
+
+ XAccessibleContext xPanel = at.getAccessibleObjectForRole(xRoot, AccessibleRole.PANEL);
+ XAccessibleComponent xPanelCont = 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);
+ System.out.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) {
+ System.out.println("couldn't press mouse button");
+ }
+ } catch (java.lang.Exception e){
+ System.out.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();
+ System.out.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) {
+ System.out.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;
+ }
+
+
+
+
+ private XMultiServiceFactory getMSF()
+ {
+ final XMultiServiceFactory xMSF1 = UnoRuntime.queryInterface(XMultiServiceFactory.class, connection.getComponentContext().getServiceManager());
+ return xMSF1;
+ }
+
+ // setup and close connections
+ @BeforeClass public static void setUpConnection() throws Exception {
+ System.out.println("setUpConnection()");
+ connection.setUp();
+ }
+
+ @AfterClass public static void tearDownConnection()
+ throws InterruptedException, com.sun.star.uno.Exception
+ {
+ System.out.println("tearDownConnection()");
+ connection.tearDown();
+ }
+
+ private static final OfficeConnection connection = new OfficeConnection();
+
+} \ 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..8b08bec171ee
--- /dev/null
+++ b/framework/qa/complex/XUserInputInterception/makefile.mk
@@ -0,0 +1,133 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+.IF "$(OOO_SUBSEQUENT_TESTS)" == ""
+nothing .PHONY:
+.ELSE
+
+# we don't want something like this.
+# .IF "$(OS)"=="LINUX"
+# nothing .PHONY:
+# @echo "Test marked as failed on this platform"
+# .END
+
+PRJ = ../../..
+PRJNAME = framework
+TARGET = qa_complex_xuserinputinterception
+
+.IF "$(OOO_JUNIT_JAR)" != ""
+PACKAGE = complex/XUserInputInterception
+
+# here store only Files which contain a @Test
+JAVATESTFILES = \
+ EventTest.java
+
+# put here all other files
+JAVAFILES = $(JAVATESTFILES)
+
+JARFILES = OOoRunner.jar ridl.jar test.jar unoil.jar
+EXTRAJARFILES = $(OOO_JUNIT_JAR)
+
+# Sample how to debug
+# JAVAIFLAGS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=9003,suspend=y
+
+.END
+
+.INCLUDE: settings.mk
+.INCLUDE: target.mk
+.INCLUDE: installationtest.mk
+
+ALLTAR : javatest
+
+.END
+
+#
+#
+#
+# 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..b0d89ad81858
--- /dev/null
+++ b/framework/qa/complex/accelerators/AcceleratorsConfigurationTest.java
@@ -0,0 +1,859 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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.KeyEvent;
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.container.XNameAccess;
+import com.sun.star.container.XNameContainer;
+import com.sun.star.embed.XStorage;
+import com.sun.star.embed.XTransactedObject;
+import com.sun.star.lang.XInitialization;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.lang.XSingleServiceFactory;
+import com.sun.star.ui.XAcceleratorConfiguration;
+import com.sun.star.ui.XUIConfigurationManager;
+import com.sun.star.ui.XUIConfigurationPersistence;
+import com.sun.star.ui.XUIConfigurationStorage;
+import com.sun.star.uno.AnyConverter;
+import com.sun.star.uno.XInterface;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.util.XChangesBatch;
+
+// import complex.accelerators.KeyMapping;
+
+
+// ---------- junit imports -----------------
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.openoffice.test.FileHelper;
+import org.openoffice.test.OfficeConnection;
+import static org.junit.Assert.*;
+// ------------------------------------------
+//-----------------------------------------------
+
+/** @short todo document me
+ */
+public class AcceleratorsConfigurationTest
+{
+
+ /** 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.
+ */
+ @Before
+ public void before()
+ throws java.lang.Exception
+ {
+ // get uno service manager from global test environment
+ m_xSmgr = getMSF();
+
+ m_xGlobalAccelCfg = UnoRuntime.queryInterface(XAcceleratorConfiguration.class, m_xSmgr.createInstance("com.sun.star.ui.GlobalAcceleratorConfiguration"));
+ m_xModuleAccelCfg = UnoRuntime.queryInterface(XAcceleratorConfiguration.class, m_xSmgr.createInstance("com.sun.star.ui.ModuleAcceleratorConfiguration"));
+ m_xDocumentAccelCfg = UnoRuntime.queryInterface(XAcceleratorConfiguration.class, m_xSmgr.createInstance("com.sun.star.ui.DocumentAcceleratorConfiguration"));
+
+ String sConfigPath = "org.openoffice.Office.Accelerators";
+ boolean bReadOnly = false;
+ XNameAccess m_xConfig2 = openConfig(m_xSmgr, sConfigPath, bReadOnly);
+ if (m_xConfig2 != null)
+ {
+ m_xPrimaryKeys = UnoRuntime.queryInterface(XNameAccess.class, m_xConfig2.getByName("PrimaryKeys"));
+ m_xSecondaryKeys = UnoRuntime.queryInterface(XNameAccess.class, m_xConfig2.getByName("SecondaryKeys"));
+ }
+ }
+
+ //-------------------------------------------
+ /** @short close the environment.
+ */
+ @After
+ 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.
+ */
+ @Test
+ public void checkGlobalAccelCfg()
+ throws java.lang.Exception
+ {
+ System.out.println("\n---- check Global accelerator configuration: ----");
+
+ String[] sKeys;
+ XNameAccess xPrimaryAccess = UnoRuntime.queryInterface(XNameAccess.class, m_xPrimaryKeys.getByName("Global"));
+ XNameAccess xSecondaryAccess = 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.
+ */
+ @Test
+ 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)
+ {
+ System.out.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 = UnoRuntime.queryInterface(XInitialization.class, m_xModuleAccelCfg);
+ xInit.initialize(aProp); // to fill cache
+
+ XNameAccess xPrimaryModules = UnoRuntime.queryInterface(XNameAccess.class, m_xPrimaryKeys.getByName("Modules"));
+ XNameAccess xSecondaryModules = UnoRuntime.queryInterface(XNameAccess.class, m_xSecondaryKeys.getByName("Modules"));
+
+ String[] sKeys;
+ XNameAccess xPrimaryAccess = UnoRuntime.queryInterface(XNameAccess.class, xPrimaryModules.getByName(sModules[i]));
+ XNameAccess xSecondaryAccess = 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.
+ */
+ @Test
+ public void checkDocumentAccelCfg()
+ throws java.lang.Exception
+ {
+ System.out.println("\n---- check Document accelerator configuration: ----");
+
+ String sDocCfgName;
+
+ String tempDirURL = util.utils.getOfficeTemp/*Dir*/(getMSF());
+ sDocCfgName = FileHelper.appendPath(tempDirURL, "test.cfg");
+ // 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
+ {
+ System.out.println("check getKeyCommands...");
+
+ for (int i = 0; i < sKeys.length; ++i)
+ {
+ if (xAccess.hasByName(sKeys[i]) && getCommandFromConfiguration(xAccess, sKeys[i]).length() > 0)
+ {
+ System.out.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]));
+ System.out.println(sKeys[i] + "-->" + sCmdFromCache + ", by XAcceleratorConfiguration API");
+
+ // GET shortcuts/commands using configuration API
+ sCmdFromConfiguration = getCommandFromConfiguration(xAccess, sKeys[i]);
+ System.out.println(sKeys[i] + "-->" + sCmdFromConfiguration + ", by configuration API");
+
+ assertTrue("values are different by XAcceleratorConfiguration API and configuration API!", sCmdFromCache.equals(sCmdFromConfiguration));
+
+ String sLocale = "es";
+ setOfficeLocale(sLocale);
+ sCmdFromConfiguration = getCommandFromConfiguration(xAccess, sKeys[i]);
+ System.out.println(sKeys[i] + "-->" + sCmdFromConfiguration + ", by configuration API" + " for locale:" + getOfficeLocale());
+
+ sLocale = "en-US";
+ setOfficeLocale(sLocale); //reset to default locale
+ }
+ else
+ {
+ System.out.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
+ {
+ System.out.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]))
+ {
+ System.out.println("add " + sKeys[i] + " successfully!");
+ }
+ else
+ {
+ System.out.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))
+ {
+ System.out.println("change " + sKeys[i] + " successfully!");
+ }
+ else
+ {
+ System.out.println("change " + sKeys[i] + " failed!");
+ }
+ }
+ else
+ {
+ System.out.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))
+ {
+ System.out.println("change " + sKeys[i] + " successfully!");
+ }
+ else
+ {
+ System.out.println("change " + sKeys[i] + " failed!");
+ }
+ }
+ else
+ {
+ System.out.println(sKeys[i] + " already exist!");
+ }
+ }
+ }
+ }
+
+ //-------------------------------------------
+ /** @todo document me.
+ */
+ private void impl_checkRemoveKeyCommands(XAcceleratorConfiguration xAccelCfg, XNameAccess xPrimaryAccess, XNameAccess xSecondaryAccess, String[] sKeys)
+ throws java.lang.Exception
+ {
+ System.out.println("check removeKeyCommands...");
+
+ for (int i = 0; i < sKeys.length; i++)
+ {
+ if (!xPrimaryAccess.hasByName(sKeys[i]) && !xSecondaryAccess.hasByName(sKeys[i]))
+ {
+ System.out.println(sKeys[i] + " doesn't exist!");
+ }
+ else if (xPrimaryAccess.hasByName(sKeys[i]))
+ {
+ xAccelCfg.removeKeyEvent(convertShortcut2AWTKey(sKeys[i]));
+ xAccelCfg.store();
+ if (!xPrimaryAccess.hasByName(sKeys[i]))
+ {
+ System.out.println("Remove " + sKeys[i] + " successfully!");
+ }
+ else
+ {
+ System.out.println("Remove " + sKeys[i] + " failed!");
+ }
+ }
+ else if (xSecondaryAccess.hasByName(sKeys[i]))
+ {
+ xAccelCfg.removeKeyEvent(convertShortcut2AWTKey(sKeys[i]));
+ xAccelCfg.store();
+ if (!xSecondaryAccess.hasByName(sKeys[i]))
+ {
+ System.out.println("Remove " + sKeys[i] + " successfully!");
+ }
+ else
+ {
+ System.out.println("Remove " + sKeys[i] + " failed!");
+ }
+ }
+ }
+ }
+
+ //-------------------------------------------
+ /** @todo document me.
+ */
+ private void impl_checkGetPreferredKeyEventsForCommandList(XAcceleratorConfiguration xAccelCfg, XNameAccess xPrimaryAccess, String[] sCommandList)
+ throws java.lang.Exception
+ {
+ System.out.println("check getPreferredKeyEventsForCommandList...");
+
+ Object[] oKeyEvents = xAccelCfg.getPreferredKeyEventsForCommandList(sCommandList);
+ for (int i = 0; i < oKeyEvents.length; i++)
+ {
+ System.out.println("get preferred key for command " + sCommandList[i] + ":");
+
+ KeyEvent aKeyEvent = (KeyEvent) AnyConverter.toObject(KeyEvent.class, oKeyEvents[i]);
+ String sKeyEvent = convertAWTKey2Shortcut(aKeyEvent);
+ System.out.println(sKeyEvent);
+
+ String sCmdFromConfiguration = getCommandFromConfiguration(xPrimaryAccess, sKeyEvent);
+ System.out.println(sCmdFromConfiguration);
+ if (sCommandList[i].equals(sCmdFromConfiguration))
+ {
+ System.out.println("get preferred key correctly!");
+ }
+ else
+ {
+ System.out.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 = UnoRuntime.queryInterface(XNameAccess.class, xAccess.getByName(sKey));
+ XNameAccess xCommand = UnoRuntime.queryInterface(XNameAccess.class, xKey.getByName("Command"));
+
+ String sLocale = getOfficeLocale();
+ if (xCommand.hasByName(sLocale))
+ {
+ sCommand = 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 = UnoRuntime.queryInterface(XNameContainer.class, xAccess);
+ if (!xContainer.hasByName(sKey))
+ {
+ XSingleServiceFactory xFac = UnoRuntime.queryInterface(XSingleServiceFactory.class, xContainer);
+ XInterface xInst = UnoRuntime.queryInterface(XInterface.class, xFac.createInstance());
+ xContainer.insertByName(sKey, xInst);
+ }
+
+ XNameAccess xKey = UnoRuntime.queryInterface(XNameAccess.class, xContainer.getByName(sKey));
+ XNameContainer xCommand = 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 = 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 = 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 = 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 = UnoRuntime.queryInterface(XInitialization.class, m_xDocumentAccelCfg);
+ xInit.initialize(lArgs);
+
+ // TODO: throws css::container::NoSuchElementException
+ try
+ {
+ String test = m_xDocumentAccelCfg.getCommandByKeyEvent(convertShortcut2AWTKey("F2"));
+ System.out.println(test);
+ }
+ catch(com.sun.star.container.NoSuchElementException e)
+ {
+ System.out.println("NoSuchElementException caught: " + e.getMessage());
+ }
+ }
+
+ //-------------------------------------------
+ /** @todo document me.
+ */
+ private void SaveDocumentAcceleratorConfiguration(String sDocCfgName)
+ throws java.lang.Exception
+ {
+ XSingleServiceFactory xStorageFactory = 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 = UnoRuntime.queryInterface(XStorage.class, xStorageFactory.createInstanceWithArguments(aArgs));
+
+ XStorage xUIConfig = xRootStorage.openStorageElement("Configurations2", com.sun.star.embed.ElementModes.WRITE);
+
+ XUIConfigurationManager xCfgMgr = UnoRuntime.queryInterface(XUIConfigurationManager.class, m_xSmgr.createInstance("com.sun.star.ui.UIConfigurationManager"));
+
+ XUIConfigurationStorage xUICfgStore = UnoRuntime.queryInterface(XUIConfigurationStorage.class, xCfgMgr);
+ xUICfgStore.setStorage(xUIConfig);
+
+ XPropertySet xUIConfigProps = UnoRuntime.queryInterface(XPropertySet.class, xUIConfig);
+ xUIConfigProps.setPropertyValue("MediaType", "application/vnd.sun.xml.ui.configuration");
+
+ if (xCfgMgr != null)
+ {
+ XAcceleratorConfiguration xTargetAccMgr = UnoRuntime.queryInterface(XAcceleratorConfiguration.class, xCfgMgr.getShortCutManager());
+ XUIConfigurationPersistence xCommit1 = UnoRuntime.queryInterface(XUIConfigurationPersistence.class, xTargetAccMgr);
+ XUIConfigurationPersistence xCommit2 = UnoRuntime.queryInterface(XUIConfigurationPersistence.class, xCfgMgr);
+ xCommit1.store();
+ xCommit2.store();
+
+ XTransactedObject xCommit3 = 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 = UnoRuntime.queryInterface(XNameAccess.class, xRootConfig.getByName("L10N"));
+ XPropertySet xSet = 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 = UnoRuntime.queryInterface(XNameAccess.class, xRootConfig.getByName("L10N"));
+ XPropertySet xSet = UnoRuntime.queryInterface(XPropertySet.class, xLocale);
+ xSet.setPropertyValue("ooLocale", sLocale);
+ XChangesBatch xBatch = 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 = 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 = UnoRuntime.queryInterface(XNameAccess.class, aConfig);
+
+ if (xConfig == null)
+ {
+ throw new com.sun.star.uno.Exception("Could not open configuration \"" + sConfigPath + "\"");
+ }
+
+ return xConfig;
+ }
+
+ private XMultiServiceFactory getMSF()
+ {
+ final XMultiServiceFactory xMSF1 = UnoRuntime.queryInterface(XMultiServiceFactory.class, connection.getComponentContext().getServiceManager());
+ return xMSF1;
+ }
+
+ // setup and close connections
+ @BeforeClass
+ public static void setUpConnection() throws Exception
+ {
+ System.out.println("setUpConnection()");
+ connection.setUp();
+ }
+
+ @AfterClass
+ public static void tearDownConnection()
+ throws InterruptedException, com.sun.star.uno.Exception
+ {
+ System.out.println("tearDownConnection()");
+ connection.tearDown();
+ }
+ private static final OfficeConnection connection = new OfficeConnection();
+}
diff --git a/framework/qa/complex/accelerators/KeyMapping.java b/framework/qa/complex/accelerators/KeyMapping.java
new file mode 100644
index 000000000000..d09a51162e7c
--- /dev/null
+++ b/framework/qa/complex/accelerators/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;
+
+ public 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..189a5fddba77
--- /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..7d5460324849
--- /dev/null
+++ b/framework/qa/complex/accelerators/makefile.mk
@@ -0,0 +1,67 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+.IF "$(OOO_SUBSEQUENT_TESTS)" == ""
+nothing .PHONY:
+.ELSE
+
+PRJ = ../../..
+PRJNAME = framework
+TARGET = qa_complex_accelerators
+
+.IF "$(OOO_JUNIT_JAR)" != ""
+PACKAGE = complex/accelerators
+
+# here store only Files which contain a @Test
+JAVATESTFILES = \
+ AcceleratorsConfigurationTest.java
+
+# put here all other files
+JAVAFILES = $(JAVATESTFILES) \
+ KeyMapping.java
+
+JARFILES = OOoRunner.jar ridl.jar test.jar unoil.jar
+#JARFILES = ridl.jar unoil.jar jurt.jar juh.jar jut.jar java_uno.jar \
+# OOoRunner.jar
+EXTRAJARFILES = $(OOO_JUNIT_JAR)
+
+# Sample how to debug
+# JAVAIFLAGS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=9003,suspend=y
+
+.END
+
+.INCLUDE: settings.mk
+.INCLUDE: target.mk
+.INCLUDE: installationtest.mk
+
+ALLTAR : javatest
+
+.END
+
+
+
+
+
diff --git a/framework/qa/complex/api_internal/CheckAPI.java b/framework/qa/complex/api_internal/CheckAPI.java
new file mode 100755
index 000000000000..be979e9234ac
--- /dev/null
+++ b/framework/qa/complex/api_internal/CheckAPI.java
@@ -0,0 +1,249 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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 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.util.Vector;
+import java.util.StringTokenizer;
+
+
+// ---------- junit imports -----------------
+import lib.TestParameters;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.openoffice.test.OfficeConnection;
+import static org.junit.Assert.*;
+// ------------------------------------------
+
+/**
+ * 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 {
+
+ // 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"};
+// }
+
+ /**
+ * The test parameters
+ */
+ private static TestParameters param = null;
+
+ /**
+ *
+ */
+ @Before public void before()
+ {
+ param = new TestParameters();
+ }
+ /**
+ * 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.
+ */
+ @Test public void checkAPI() {
+ System.out.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 = getMSF();
+ Object oObj = null;
+ try {
+ oObj = xMSF.createInstance("org.openoffice.RunnerService");
+ }
+ catch(com.sun.star.uno.Exception e) {
+ fail("Could not create Instance of 'org.openoffice.RunnerService'");
+ }
+ assertNotNull("Cannot create 'org.openoffice.RunnerService'", oObj);
+
+ // 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);
+ System.out.println("Name: "+internalParams[i].Name);
+ System.out.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;
+ }
+
+ System.out.println("Props length: "+ props.length);
+ for (int i=0; i<props.length; i++) {
+ XJob xJob = UnoRuntime.queryInterface(XJob.class, oObj);
+ internalParams[length-1] = new NamedValue();
+ internalParams[length-1].Name = "-o";
+ internalParams[length-1].Value = props[i].Value;
+ System.out.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();
+ fail("Test run '" + (String)props[i].Value +"' could not be executed: Office crashed and is killed!");
+ 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) {
+ fail("Could not create Instance of 'org.openoffice.RunnerService'");
+ }
+ }
+ System.out.println(erg);
+ String processedErg = parseResult(erg);
+ assertTrue("Run '" + (String)props[i].Value + "' has result '" + processedErg + "'", processedErg == null);
+ }
+ }
+
+ 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;
+ }
+
+
+
+
+ private XMultiServiceFactory getMSF()
+ {
+ final XMultiServiceFactory xMSF1 = UnoRuntime.queryInterface(XMultiServiceFactory.class, connection.getComponentContext().getServiceManager());
+ return xMSF1;
+ }
+
+ // setup and close connections
+ @BeforeClass public static void setUpConnection() throws Exception {
+ System.out.println("setUpConnection()");
+ connection.setUp();
+ }
+
+ @AfterClass public static void tearDownConnection()
+ throws InterruptedException, com.sun.star.uno.Exception
+ {
+ System.out.println("tearDownConnection()");
+ connection.tearDown();
+ }
+
+ private static final OfficeConnection connection = new OfficeConnection();
+
+}
+
+
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..f1a22011a8e7
--- /dev/null
+++ b/framework/qa/complex/api_internal/makefile.mk
@@ -0,0 +1,63 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+.IF "$(OOO_SUBSEQUENT_TESTS)" == ""
+nothing .PHONY:
+.ELSE
+
+PRJ = ../../..
+PRJNAME = framework
+TARGET = qa_complex_api_internal
+
+.IF "$(OOO_JUNIT_JAR)" != ""
+PACKAGE = complex/api_internal
+
+# here store only Files which contain a @Test
+JAVATESTFILES = \
+ CheckAPI.java
+
+# put here all other files
+JAVAFILES = $(JAVATESTFILES)
+
+JARFILES = OOoRunner.jar ridl.jar test.jar unoil.jar
+#JARFILES = ridl.jar unoil.jar jurt.jar juh.jar jut.jar java_uno.jar \
+# OOoRunner.jar
+EXTRAJARFILES = $(OOO_JUNIT_JAR)
+
+# Sample how to debug
+# JAVAIFLAGS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=9003,suspend=y
+
+.END
+
+.INCLUDE: settings.mk
+.INCLUDE: target.mk
+.INCLUDE: installationtest.mk
+
+ALLTAR : javatest
+
+.END
+
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..f5d41c1e02b1
--- /dev/null
+++ b/framework/qa/complex/broken_document/LoadDocument.java
@@ -0,0 +1,136 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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;
+
+
+// ---------- junit imports -----------------
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.openoffice.test.OfficeConnection;
+import static org.junit.Assert.*;
+// ------------------------------------------
+
+/**
+ * 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 {
+
+ /** 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.
+ */
+ @Test public void checkHeadlessState()
+ {
+ XMultiServiceFactory xMSF = getMSF();
+ XFrame xDesktop = null;
+
+ try {
+ xDesktop = UnoRuntime.queryInterface(XFrame.class, xMSF.createInstance("com.sun.star.frame.Desktop"));
+ }
+ catch(com.sun.star.uno.Exception e) {
+ fail("Could not create a desktop instance.");
+ }
+
+ XComponentLoader xDesktopLoader = 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 = complex.broken_document.TestDocument.getUrl("dbf.dbf.emf");
+ System.out.println("File Url: " + fileUrl);
+
+ try {
+ xDesktopLoader.loadComponentFromURL(fileUrl, "_blank", 0, val);
+ }
+ catch(com.sun.star.io.IOException e) {
+ fail("Could not load document");
+ }
+ catch(com.sun.star.lang.IllegalArgumentException e) {
+ fail("Could not load document");
+ }
+
+ // try again: headless mode defect now?
+ try {
+ xDesktopLoader.loadComponentFromURL(fileUrl, "_blank", 0, val);
+ }
+ catch(com.sun.star.io.IOException e) {
+ fail("Could not load document");
+ }
+ catch(com.sun.star.lang.IllegalArgumentException e) {
+ fail("Could not load document");
+ }
+
+ }
+
+
+
+ private XMultiServiceFactory getMSF()
+ {
+ final XMultiServiceFactory xMSF1 = UnoRuntime.queryInterface(XMultiServiceFactory.class, connection.getComponentContext().getServiceManager());
+ return xMSF1;
+ }
+
+ // setup and close connections
+ @BeforeClass public static void setUpConnection() throws Exception {
+ System.out.println("setUpConnection()");
+ connection.setUp();
+ }
+
+ @AfterClass public static void tearDownConnection()
+ throws InterruptedException, com.sun.star.uno.Exception
+ {
+ System.out.println("tearDownConnection()");
+ connection.tearDown();
+ }
+
+ private static final OfficeConnection connection = new OfficeConnection();
+
+}
diff --git a/framework/qa/complex/broken_document/TestDocument.java b/framework/qa/complex/broken_document/TestDocument.java
new file mode 100644
index 000000000000..c282790211e3
--- /dev/null
+++ b/framework/qa/complex/broken_document/TestDocument.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.broken_document;
+
+import java.io.File;
+import org.openoffice.test.OfficeFileUrl;
+
+final class TestDocument
+{
+ public static String getUrl(String name)
+ {
+ return OfficeFileUrl.getAbsolute(new File("test_documents", name));
+ }
+
+ private TestDocument() {}
+}
diff --git a/framework/qa/complex/broken_document/makefile.mk b/framework/qa/complex/broken_document/makefile.mk
new file mode 100755
index 000000000000..8b1cf2ac3bfd
--- /dev/null
+++ b/framework/qa/complex/broken_document/makefile.mk
@@ -0,0 +1,65 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+
+.IF "$(OOO_SUBSEQUENT_TESTS)" == ""
+nothing .PHONY:
+.ELSE
+
+PRJ = ../../..
+PRJNAME = framework
+TARGET = qa_complex_broken_document
+
+.IF "$(OOO_JUNIT_JAR)" != ""
+PACKAGE = complex/broken_document
+
+# here store only Files which contain a @Test
+JAVATESTFILES = \
+ LoadDocument.java
+
+# put here all other files
+JAVAFILES = $(JAVATESTFILES) \
+ TestDocument.java
+
+JARFILES = OOoRunner.jar ridl.jar test.jar unoil.jar
+#JARFILES = ridl.jar unoil.jar jurt.jar juh.jar jut.jar java_uno.jar \
+# OOoRunner.jar
+EXTRAJARFILES = $(OOO_JUNIT_JAR)
+
+# Sample how to debug
+# JAVAIFLAGS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=9003,suspend=y
+
+.END
+
+.INCLUDE: settings.mk
+.INCLUDE: target.mk
+.INCLUDE: installationtest.mk
+
+ALLTAR : javatest
+
+.END
+
diff --git a/framework/qa/complex/broken_document/test_documents/dbf.dbf.emf b/framework/qa/complex/broken_document/test_documents/dbf.dbf.emf
new file mode 100755
index 000000000000..11e45e9df5d1
--- /dev/null
+++ b/framework/qa/complex/broken_document/test_documents/dbf.dbf.emf
@@ -0,0 +1 @@
+ \ No newline at end of file
diff --git a/framework/qa/complex/contextMenuInterceptor/CheckContextMenuInterceptor.java b/framework/qa/complex/contextMenuInterceptor/CheckContextMenuInterceptor.java
new file mode 100644
index 000000000000..471f5246b787
--- /dev/null
+++ b/framework/qa/complex/contextMenuInterceptor/CheckContextMenuInterceptor.java
@@ -0,0 +1,352 @@
+package complex.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.XPropertySet;
+import com.sun.star.drawing.XShape;
+import com.sun.star.frame.XFrame;
+import com.sun.star.frame.XModel;
+import com.sun.star.lang.IndexOutOfBoundsException;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.ui.XContextMenuInterception;
+import com.sun.star.ui.XContextMenuInterceptor;
+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.util.XCloseable;
+import java.awt.Robot;
+import java.awt.event.InputEvent;
+import java.io.File;
+import util.AccessibilityTools;
+import util.DesktopTools;
+import util.DrawTools;
+import util.SOfficeFactory;
+import util.utils;
+import org.openoffice.test.OfficeFileUrl;
+
+// ---------- junit imports -----------------
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.openoffice.test.OfficeConnection;
+import static org.junit.Assert.*;
+// ------------------------------------------
+
+/**
+ *
+ */
+public class CheckContextMenuInterceptor
+{
+
+ XMultiServiceFactory xMSF = null;
+ XFrame xFrame = null;
+ Point point = null;
+ XWindow xWindow = null;
+ com.sun.star.lang.XComponent xDrawDoc;
+
+ @Before
+ public void before()
+ {
+ xMSF = getMSF();
+ }
+
+ @After
+ public void after()
+ {
+ System.out.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)
+ {
+ System.out.println("couldn't press mouse button");
+ }
+
+ XCloseable xClose = UnoRuntime.queryInterface(XCloseable.class, xFrame);
+
+ try
+ {
+ xClose.close(true);
+ }
+ catch (com.sun.star.util.CloseVetoException exVeto)
+ {
+ fail("Test frame couldn't be closed successfully.");
+ }
+
+ xFrame = null;
+
+// xClose = UnoRuntime.queryInterface(XCloseable.class, xDrawDoc);
+// try
+// {
+// xClose.close(true);
+// }
+// catch (com.sun.star.util.CloseVetoException exVeto)
+// {
+// fail("Test DrawDoc couldn't be closed successfully.");
+// }
+
+ }
+
+// public String[] getTestMethodNames() {
+// return new String[]{"checkContextMenuInterceptor"};
+// }
+ @Test
+ public void checkContextMenuInterceptor()
+ {
+ System.out.println(" **** Context Menu Interceptor *** ");
+
+ try
+ {
+ // intialize the test document
+ 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 =
+ 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 = UnoRuntime.queryInterface(XPropertySet.class, oShape);
+ System.out.println("Inserting a shape into the document");
+
+ try
+ {
+ String sFile = OfficeFileUrl.getAbsolute(new File("space-metal.jpg"));
+ // String sFile = util.utils.getFullTestURL("space-metal.jpg");
+ oShapeProps.setPropertyValue("GraphicURL", sFile);
+ Object oProp = oShapeProps.getPropertyValue("GraphicObjectFillBitmap");
+ xBitmap = (XBitmap) AnyConverter.toObject(new Type(XBitmap.class), oProp);
+ }
+ 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();
+ XContextMenuInterception xContextMenuInterception = null;
+ XContextMenuInterceptor xContextMenuInterceptor = null;
+
+ if (xController != null)
+ {
+ System.out.println("Creating context menu interceptor");
+
+ // add our context menu interceptor
+ xContextMenuInterception =
+ UnoRuntime.queryInterface(XContextMenuInterception.class, xController);
+
+ if (xContextMenuInterception != null)
+ {
+ ContextMenuInterceptor aContextMenuInterceptor = new ContextMenuInterceptor(xBitmap);
+ xContextMenuInterceptor =
+ UnoRuntime.queryInterface(XContextMenuInterceptor.class, aContextMenuInterceptor);
+
+ System.out.println("Register context menu interceptor");
+ xContextMenuInterception.registerContextMenuInterceptor(xContextMenuInterceptor);
+ }
+ }
+
+ // utils.shortWait(10000);
+
+ openContextMenu(UnoRuntime.queryInterface(XModel.class, xDrawDoc));
+
+ checkHelpEntry();
+
+ // remove our context menu interceptor
+ if (xContextMenuInterception != null
+ && xContextMenuInterceptor != null)
+ {
+ System.out.println("Release context menu interceptor");
+ xContextMenuInterception.releaseContextMenuInterceptor(
+ xContextMenuInterceptor);
+ }
+ }
+ catch (com.sun.star.uno.RuntimeException ex)
+ {
+ // ex.printStackTrace();
+ fail("Runtime exception caught!" + ex.getMessage());
+ }
+ catch (java.lang.Exception ex)
+ {
+ // ex.printStackTrace();
+ fail("Java lang exception caught!" + ex.getMessage());
+ }
+ }
+
+ private void checkHelpEntry()
+ {
+ XInterface toolkit = null;
+
+ System.out.println("get accesibility...");
+ try
+ {
+ toolkit = (XInterface) xMSF.createInstance("com.sun.star.awt.Toolkit");
+ }
+ catch (com.sun.star.uno.Exception e)
+ {
+ System.out.println("could not get Toolkit " + e.toString());
+ }
+ XExtendedToolkit tk = UnoRuntime.queryInterface(XExtendedToolkit.class, toolkit);
+
+ XAccessible xRoot = null;
+
+ AccessibilityTools at = new AccessibilityTools();
+
+ try
+ {
+ 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(System.out, xRoot, true);
+ }
+ catch (com.sun.star.lang.IndexOutOfBoundsException e)
+ {
+ System.out.println("Couldn't get Window");
+ }
+
+ XAccessibleContext oPopMenu = at.getAccessibleObjectForRole(xRoot, AccessibleRole.POPUP_MENU);
+
+ System.out.println("ImplementationName: " + util.utils.getImplName(oPopMenu));
+
+ XAccessible xHelp = null;
+ try
+ {
+ System.out.println("Try to get first entry of context menu...");
+ xHelp = oPopMenu.getAccessibleChild(0);
+
+ }
+ catch (IndexOutOfBoundsException e)
+ {
+ fail("Not possible to get first entry of context menu");
+ }
+
+ if (xHelp == null)
+ {
+ fail("first entry of context menu is NULL");
+ }
+
+ XAccessibleContext xHelpCont = xHelp.getAccessibleContext();
+
+ if (xHelpCont == null)
+ {
+ fail("No able to retrieve accessible context from first entry of context menu");
+ }
+
+ String aAccessibleName = xHelpCont.getAccessibleName();
+ if (!aAccessibleName.equals("Help"))
+ {
+ System.out.println("Accessible name found = " + aAccessibleName);
+ fail("First entry of context menu is not from context menu interceptor");
+ }
+
+ try
+ {
+ System.out.println("try to get first children of Help context...");
+ XAccessible xHelpChild = xHelpCont.getAccessibleChild(0);
+
+ }
+ catch (IndexOutOfBoundsException e)
+ {
+ fail("not possible to get first children of Help context");
+ }
+
+ }
+
+ private void openContextMenu(XModel aModel)
+ {
+
+ System.out.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 = UnoRuntime.queryInterface(XAccessibleComponent.class, oObj);
+
+ point = window.getLocationOnScreen();
+ Rectangle rect = window.getBounds();
+
+ System.out.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)
+ {
+ System.out.println("couldn't press mouse button");
+ }
+
+ utils.shortWait(3000);
+
+ }
+
+ private XMultiServiceFactory getMSF()
+ {
+ final XMultiServiceFactory xMSF1 = UnoRuntime.queryInterface(XMultiServiceFactory.class, connection.getComponentContext().getServiceManager());
+ return xMSF1;
+ }
+
+ // setup and close connections
+ @BeforeClass
+ public static void setUpConnection() throws Exception
+ {
+ System.out.println("setUpConnection()");
+ connection.setUp();
+ }
+
+ @AfterClass
+ public static void tearDownConnection()
+ throws InterruptedException, com.sun.star.uno.Exception
+ {
+ System.out.println("tearDownConnection()");
+ connection.tearDown();
+ }
+ private static final OfficeConnection connection = new OfficeConnection();
+}
diff --git a/framework/qa/complex/contextMenuInterceptor/ContextMenuInterceptor.java b/framework/qa/complex/contextMenuInterceptor/ContextMenuInterceptor.java
new file mode 100644
index 000000000000..6455807f5630
--- /dev/null
+++ b/framework/qa/complex/contextMenuInterceptor/ContextMenuInterceptor.java
@@ -0,0 +1,114 @@
+package complex.contextMenuInterceptor;
+
+import com.sun.star.ui.*;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.uno.UnoRuntime;
+
+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 =
+ 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 =
+ 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 =
+ 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 =
+ UnoRuntime.queryInterface(com.sun.star.container.XIndexContainer.class, xMenuElementFactory.createInstance("com.sun.star.ui.ActionTriggerContainer"));
+
+ // intialize root menu entry "Help"
+ xRootMenuEntry.setPropertyValue("Text", ("Help"));
+ xRootMenuEntry.setPropertyValue("CommandURL", ("slot:5410"));
+ xRootMenuEntry.setPropertyValue("HelpURL", ("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 = UnoRuntime.queryInterface(XPropertySet.class, xMenuElementFactory.createInstance("com.sun.star.ui.ActionTrigger"));
+ xMenuEntry.setPropertyValue("Text", ("Content"));
+ xMenuEntry.setPropertyValue("CommandURL", ("slot:5401"));
+ xMenuEntry.setPropertyValue("HelpURL", ("5401"));
+
+ // insert menu entry to sub menu
+ xSubMenuContainer.insertByIndex(0, (Object) xMenuEntry);
+
+ // intialize help/help agent
+ // entry "Help Agent"
+ xMenuEntry = UnoRuntime.queryInterface(com.sun.star.beans.XPropertySet.class, xMenuElementFactory.createInstance("com.sun.star.ui.ActionTrigger"));
+ xMenuEntry.setPropertyValue("Text", ("Help Agent"));
+ xMenuEntry.setPropertyValue("CommandURL", ("slot:5962"));
+ xMenuEntry.setPropertyValue("HelpURL", ("5962"));
+
+ // insert menu entry to sub menu
+ xSubMenuContainer.insertByIndex(1, (Object) xMenuEntry);
+ // intialize help/tips
+ // entry "Tips"
+ xMenuEntry = UnoRuntime.queryInterface(com.sun.star.beans.XPropertySet.class, xMenuElementFactory.createInstance("com.sun.star.ui.ActionTrigger"));
+ xMenuEntry.setPropertyValue("Text", ("Tips"));
+ xMenuEntry.setPropertyValue("CommandURL", ("slot:5404"));
+ xMenuEntry.setPropertyValue("HelpURL", ("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..574d98641468
--- /dev/null
+++ b/framework/qa/complex/contextMenuInterceptor/makefile.mk
@@ -0,0 +1,63 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+.IF "$(OOO_SUBSEQUENT_TESTS)" == ""
+nothing .PHONY:
+.ELSE
+
+PRJ = ../../..
+PRJNAME = framework
+TARGET = qa_complex_contextMenuInterceptor
+
+.IF "$(OOO_JUNIT_JAR)" != ""
+PACKAGE = complex/contextMenuInterceptor
+
+# here store only Files which contain a @Test
+JAVATESTFILES = \
+ CheckContextMenuInterceptor.java
+
+# put here all other files
+JAVAFILES = $(JAVATESTFILES) \
+ ContextMenuInterceptor.java
+
+JARFILES = OOoRunner.jar ridl.jar test.jar unoil.jar
+#JARFILES = ridl.jar unoil.jar jurt.jar juh.jar jut.jar java_uno.jar \
+# OOoRunner.jar
+EXTRAJARFILES = $(OOO_JUNIT_JAR)
+
+# Sample how to debug
+# JAVAIFLAGS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=9003,suspend=y
+
+.END
+
+.INCLUDE: settings.mk
+.INCLUDE: target.mk
+.INCLUDE: installationtest.mk
+
+ALLTAR : javatest
+
+.END
diff --git a/framework/qa/complex/contextMenuInterceptor/space-metal.jpg b/framework/qa/complex/contextMenuInterceptor/space-metal.jpg
new file mode 100644
index 000000000000..d23344389073
--- /dev/null
+++ b/framework/qa/complex/contextMenuInterceptor/space-metal.jpg
Binary files differ
diff --git a/framework/qa/complex/desktop/DesktopTerminate.java b/framework/qa/complex/desktop/DesktopTerminate.java
new file mode 100755
index 000000000000..0f385edf0cb0
--- /dev/null
+++ b/framework/qa/complex/desktop/DesktopTerminate.java
@@ -0,0 +1,195 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package complex.desktop;
+
+
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.frame.XDesktop;
+import com.sun.star.uno.UnoRuntime;
+import helper.OfficeProvider;
+//import complex.persistent_window_states.helper.DocumentHandle;
+
+// ---------- junit imports -----------------
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.openoffice.test.OfficeConnection;
+import static org.junit.Assert.*;
+// ------------------------------------------
+
+/**
+ * Parameters:
+ * <ul>
+ * <li>NoOffice=yes - StarOffice is not started initially.</li>
+ * </ul>
+ */
+public class DesktopTerminate
+{
+
+ private XMultiServiceFactory xMSF;
+ private int iOfficeCloseTime = 1000;
+
+ /**
+ * 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
+ */
+ @Test public void checkPersistentWindowState()
+ {
+ try
+ {
+
+ System.out.println("Connect the first time.");
+// System.out.println("AppExecCommand: " + (String) param.get("AppExecutionCommand"));
+// System.out.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 = getMSF();
+ try
+ {
+ Thread.sleep(10000);
+ }
+ catch (java.lang.InterruptedException e)
+ {
+ }
+ }
+ catch (java.lang.Exception e)
+ {
+ System.out.println(e.getClass().getName());
+ System.out.println("Message: " + e.getMessage());
+ fail("Cannot connect the Office.");
+ return false;
+ }
+ return true;
+ }
+
+ private boolean disconnect()
+ {
+ try
+ {
+ XDesktop desk = null;
+ desk = UnoRuntime.queryInterface(XDesktop.class, xMSF.createInstance("com.sun.star.frame.Desktop"));
+ desk.terminate();
+ System.out.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();
+ fail("Cannot dispose the Office.");
+ return false;
+ }
+ return true;
+ }
+
+
+ private XMultiServiceFactory getMSF()
+ {
+ final XMultiServiceFactory xMSF1 = UnoRuntime.queryInterface(XMultiServiceFactory.class, connection.getComponentContext().getServiceManager());
+ return xMSF1;
+ }
+
+ // setup and close connections
+ @BeforeClass public static void setUpConnection() throws Exception {
+ System.out.println("setUpConnection()");
+ connection.setUp();
+ }
+
+ @AfterClass public static void tearDownConnection()
+ throws InterruptedException, com.sun.star.uno.Exception
+ {
+ System.out.println("tearDownConnection()");
+ // don't do a tearDown here, desktop is already terminated.
+ // connection.tearDown();
+ }
+
+ private static final OfficeConnection connection = new OfficeConnection();
+
+}
diff --git a/framework/qa/complex/desktop/makefile.mk b/framework/qa/complex/desktop/makefile.mk
new file mode 100755
index 000000000000..74db8d34e160
--- /dev/null
+++ b/framework/qa/complex/desktop/makefile.mk
@@ -0,0 +1,62 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+.IF "$(OOO_SUBSEQUENT_TESTS)" == ""
+nothing .PHONY:
+.ELSE
+
+PRJ = ../../..
+PRJNAME = framework
+TARGET = qa_complex_desktop
+
+.IF "$(OOO_JUNIT_JAR)" != ""
+PACKAGE = complex/desktop
+
+# here store only Files which contain a @Test
+JAVATESTFILES = \
+ DesktopTerminate.java
+
+# put here all other files
+JAVAFILES = $(JAVATESTFILES)
+
+JARFILES = OOoRunner.jar ridl.jar test.jar unoil.jar
+#JARFILES = ridl.jar unoil.jar jurt.jar juh.jar jut.jar java_uno.jar \
+# OOoRunner.jar
+EXTRAJARFILES = $(OOO_JUNIT_JAR)
+
+# Sample how to debug
+# JAVAIFLAGS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=9003,suspend=y
+
+.END
+
+.INCLUDE: settings.mk
+.INCLUDE: target.mk
+.INCLUDE: installationtest.mk
+
+ALLTAR : javatest
+
+.END
diff --git a/framework/qa/complex/dispatches/Interceptor.java b/framework/qa/complex/dispatches/Interceptor.java
new file mode 100644
index 000000000000..fc5b57b1215e
--- /dev/null
+++ b/framework/qa/complex/dispatches/Interceptor.java
@@ -0,0 +1,345 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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.frame.DispatchDescriptor;
+import com.sun.star.frame.XDispatch;
+import com.sun.star.frame.XDispatchProvider;
+import com.sun.star.frame.XDispatchProviderInterceptor;
+import com.sun.star.frame.XInterceptorInfo;
+import com.sun.star.frame.XStatusListener;
+
+// interfaces
+
+
+// helper
+import com.sun.star.util.URL;
+
+// others
+//import java.lang.*;
+
+// __________ Implementation __________
+
+/**
+ * implements a configurable interceptor for dispatch events.
+ */
+public class Interceptor implements XDispatchProvider,
+ XDispatch,
+ XDispatchProviderInterceptor,
+ 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 XDispatchProvider m_xSlave = null;
+ private 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;
+
+
+ // ____________________
+
+ /** ctor
+ * It's initialize an object of this class with default values.
+ */
+ public Interceptor()
+ {
+ }
+
+ // ____________________
+
+ /** XInterceptorInfo */
+ public synchronized String[] getInterceptedURLs()
+ {
+ return impl_getURLs4InterceptionInfo();
+ }
+
+ // ____________________
+
+ /** XDispatchProviderInterceptor */
+ public synchronized XDispatchProvider getSlaveDispatchProvider()
+ {
+ System.out.println("Interceptor.getSlaveDispatchProvider() called");
+ return m_xSlave;
+ }
+
+ // ____________________
+
+ /** XDispatchProviderInterceptor */
+ public synchronized XDispatchProvider getMasterDispatchProvider()
+ {
+ System.out.println("Interceptor.getMasterDispatchProvider() called");
+ return m_xMaster;
+ }
+
+ // ____________________
+
+ /** XDispatchProviderInterceptor */
+ public synchronized void setSlaveDispatchProvider(XDispatchProvider xSlave)
+ {
+ System.out.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(XDispatchProvider xMaster)
+ {
+ System.out.println("Interceptor.setMasterDispatchProvider("+xMaster+") called");
+ m_xMaster = xMaster;
+ }
+
+ // ____________________
+
+ /** XDispatchProvider
+ */
+ public synchronized XDispatch queryDispatch(URL aURL ,
+ String sTargetFrameName,
+ int nSearchFlags )
+ {
+ System.out.println("Interceptor.queryDispatch('"+aURL.Complete+"', '"+sTargetFrameName+"', "+nSearchFlags+") called");
+
+ if (impl_isBlockedURL(aURL.Complete))
+ {
+ System.out.println("Interceptor.queryDispatch(): URL blocked => returns NULL");
+ return null;
+ }
+
+ if (m_xSlave != null)
+ {
+ System.out.println("Interceptor.queryDispatch(): ask slave ...");
+ return m_xSlave.queryDispatch(aURL, sTargetFrameName, nSearchFlags);
+ }
+
+ System.out.println("Interceptor.queryDispatch(): no idea => returns this");
+ return this;
+ }
+
+ // ____________________
+
+ /** XDispatchProvider
+ */
+ public XDispatch[] queryDispatches(DispatchDescriptor[] lRequests)
+ {
+ int i = 0;
+ int c = lRequests.length;
+
+ XDispatch[] lResults = new 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(URL aURL ,
+ PropertyValue[] lArguments)
+ {
+ System.out.println("Interceptor.dispatch('"+aURL.Complete+"') called");
+ }
+
+ // ____________________
+
+ /** XDispatch
+ */
+ public synchronized void addStatusListener(XStatusListener xListener,
+ com.sun.star.util.URL aURL )
+ {
+ System.out.println("Interceptor.addStatusListener(..., '"+aURL.Complete+"') called");
+ }
+
+ // ____________________
+
+ /** XDispatch
+ */
+ public synchronized void removeStatusListener(XStatusListener xListener,
+ com.sun.star.util.URL aURL )
+ {
+ System.out.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/checkdispatchapi.java b/framework/qa/complex/dispatches/checkdispatchapi.java
new file mode 100644
index 000000000000..b0ba4b55da75
--- /dev/null
+++ b/framework/qa/complex/dispatches/checkdispatchapi.java
@@ -0,0 +1,498 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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.beans.PropertyValue;
+import com.sun.star.frame.DispatchInformation;
+import com.sun.star.frame.XComponentLoader;
+import com.sun.star.frame.XDispatchInformationProvider;
+import com.sun.star.frame.XDispatchProviderInterception;
+import com.sun.star.frame.XDispatchProviderInterceptor;
+import com.sun.star.frame.XFrame;
+import com.sun.star.lang.XComponent;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.util.XCloseable;
+import complex.dispatches.Interceptor;
+import java.util.HashMap;
+
+
+
+
+
+// ---------- junit imports -----------------
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.openoffice.test.OfficeConnection;
+import static org.junit.Assert.*;
+// ------------------------------------------
+
+//-----------------------------------------------
+/** @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
+{
+ //-------------------------------------------
+ // 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.
+ */
+ @Before public void before()
+ {
+ try
+ {
+ // get uno service manager from global test environment
+ m_xMSF = getMSF();
+
+ db = new connectivity.tools.HsqlDatabase(m_xMSF);
+
+ // create desktop
+ m_xDesktop = UnoRuntime.queryInterface(XFrame.class, m_xMSF.createInstance("com.sun.star.frame.Desktop"));
+
+ m_xFrame = impl_createNewFrame();
+ }
+ catch (java.lang.Throwable ex)
+ {
+ fail("Cant initialize test environment.");
+ }
+ }
+
+ //-------------------------------------------
+ /** @short close the environment.
+ */
+ @After public void after()
+ {
+ db.close();
+ impl_closeFrame(m_xFrame);
+ m_xFrame = null;
+ }
+
+ //-------------------------------------------
+ @Test public void checkDispatchInfoOfWriter()
+ {
+ impl_checkDispatchInfoOfXXX("private:factory/swriter");
+ }
+
+ //-------------------------------------------
+ @Test public void checkDispatchInfoOfCalc()
+ {
+ impl_checkDispatchInfoOfXXX("private:factory/scalc");
+ }
+
+ //-------------------------------------------
+ @Test public void checkDispatchInfoOfDraw()
+ {
+ impl_checkDispatchInfoOfXXX("private:factory/sdraw");
+ }
+
+ //-------------------------------------------
+ @Test public void checkDispatchInfoOfImpress()
+ {
+ impl_checkDispatchInfoOfXXX("private:factory/simpress");
+ }
+
+ //-------------------------------------------
+ @Test public void checkDispatchInfoOfChart()
+ {
+ impl_checkDispatchInfoOfXXX("private:factory/schart");
+ }
+
+ //-------------------------------------------
+ @Test public void checkDispatchInfoOfMath()
+ {
+ impl_checkDispatchInfoOfXXX("private:factory/smath");
+ }
+
+ //-------------------------------------------
+ @Test public void checkDispatchInfoOfDataBase()
+ {
+ impl_checkDispatchInfoOfXXX("private:factory/sdatabase");
+ }
+
+ //-------------------------------------------
+ @Test public void checkDispatchInfoOfBibliography()
+ {
+ impl_checkDispatchInfoOfXXX(".component:Bibliography/View1");
+ }
+
+ //-------------------------------------------
+ @Test public void checkDispatchInfoOfQueryDesign()
+ {
+ callDatabaseDispatch(".component:DB/QueryDesign");
+ }
+
+ //-------------------------------------------
+ @Test public void checkDispatchInfoOfTableDesign()
+ {
+ callDatabaseDispatch(".component:DB/TableDesign");
+ }
+
+ //-------------------------------------------
+ @Test public void checkDispatchInfoOfFormGridView()
+ {
+ impl_checkDispatchInfoOfXXX(".component:DB/FormGridView");
+ }
+
+ //-------------------------------------------
+ @Test public void checkDispatchInfoOfDataSourceBrowser()
+ {
+ impl_checkDispatchInfoOfXXX(".component:DB/DataSourceBrowser");
+ }
+
+ //-------------------------------------------
+ @Test 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)
+ {
+ }
+ }
+
+ //-------------------------------------------
+ @Test public void checkDispatchInfoOfBasic()
+ {
+ Object aComponent = impl_createUNOComponent("com.sun.star.script.BasicIDE");
+ impl_checkDispatchInfo(aComponent);
+ }
+
+ //-------------------------------------------
+ @Test 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();
+ XDispatchProviderInterceptor xInterceptor = UnoRuntime.queryInterface(XDispatchProviderInterceptor.class, aInterceptor);
+
+ XFrame xFrame = impl_createNewFrame();
+ XDispatchProviderInterception xInterception = UnoRuntime.queryInterface(XDispatchProviderInterception.class, xFrame);
+
+ xInterception.registerDispatchProviderInterceptor(xInterceptor);
+ impl_closeFrame(xFrame);
+
+ int nRegCount = aInterceptor.getRegistrationCount();
+ boolean bIsRegistered = aInterceptor.isRegistered();
+
+ System.out.println("registration count = " + nRegCount);
+ System.out.println("is registered ? = " + bIsRegistered);
+
+ if (nRegCount < 1)
+ {
+ fail("Interceptor was never registered.");
+ }
+
+ if (bIsRegistered)
+ {
+ fail("Interceptor was not deregistered automaticly on closing the corresponding frame.");
+ }
+
+ System.out.println("Destruction of interception chain works as designed .-)");
+ }
+
+ //-------------------------------------------
+ public void checkInterception()
+ {
+ String[] lDisabledURLs = new String[1];
+ lDisabledURLs[0] = ".uno:Open";
+
+ System.out.println("create and initialize interceptor ...");
+ Interceptor aInterceptor = new Interceptor();
+ aInterceptor.setURLs4URLs4Blocking(lDisabledURLs);
+
+ XDispatchProviderInterceptor xInterceptor = UnoRuntime.queryInterface(XDispatchProviderInterceptor.class, aInterceptor);
+
+ System.out.println("create and initialize frame ...");
+ XFrame xFrame = impl_createNewFrame();
+ impl_loadIntoFrame(xFrame, "private:factory/swriter", null);
+
+ XDispatchProviderInterception xInterception = UnoRuntime.queryInterface(XDispatchProviderInterception.class, xFrame);
+
+ System.out.println("register interceptor ...");
+ xInterception.registerDispatchProviderInterceptor(xInterceptor);
+
+ System.out.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 = UnoRuntime.queryInterface(XComponentLoader.class, xFrame);
+ if (xLoader == null)
+ {
+ fail("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)
+ {
+ fail("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)
+ {
+ fail("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 = UnoRuntime.queryInterface(XDispatchInformationProvider.class, aComponent);
+ if (xInfoProvider == null)
+ {
+ // Warning
+ System.out.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)
+ {
+ System.out.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
+ fail("At least one DispatchInformation item does not match the requested group.\n\trequested group=[" + nGroup
+ + "] returned groupd=[" + aInfo.GroupId + "] command=\"" + aInfo.Command + "\""); // true => dont break this test
+ continue;
+ }
+
+ if (aCheckMap.containsKey(aInfo.Command))
+ {
+ // Error
+ fail("Found a duplicate item: group=[" + aInfo.GroupId + "] command=\"" + aInfo.Command + "\""); // true => dont break this test
+ continue;
+ }
+
+ aCheckMap.put(aInfo.Command, aInfo.Command);
+ System.out.println("\t[" + aInfo.GroupId + "] \"" + aInfo.Command + "\"");
+ }
+ }
+ }
+ catch (java.lang.Throwable ex)
+ {
+ fail("Exception caught during using XDispatchInformationProvider.");
+ // ex.printStackTrace();
+ }
+ }
+
+ //-------------------------------------------
+ private synchronized XFrame impl_createNewFrame()
+ {
+ XFrame xFrame = null;
+
+ try
+ {
+ xFrame = m_xDesktop.findFrame("_blank", 0);
+ xFrame.getContainerWindow().setVisible(true);
+ }
+ catch (java.lang.Throwable ex)
+ {
+ fail("Could not create the frame instance.");
+ }
+
+ return xFrame;
+ }
+
+ //-------------------------------------------
+ private synchronized void impl_closeFrame(XFrame xFrame)
+ {
+ XCloseable xClose = UnoRuntime.queryInterface(XCloseable.class, xFrame);
+ try
+ {
+ xClose.close(false);
+ }
+ catch (com.sun.star.util.CloseVetoException exVeto)
+ {
+ fail("Test frame couldn't be closed successfully.");
+ }
+ }
+
+ private XMultiServiceFactory getMSF()
+ {
+ final XMultiServiceFactory xMSF1 = UnoRuntime.queryInterface(XMultiServiceFactory.class, connection.getComponentContext().getServiceManager());
+ return xMSF1;
+ }
+
+ // setup and close connections
+ @BeforeClass
+ public static void setUpConnection() throws Exception
+ {
+ System.out.println("setUpConnection()");
+ connection.setUp();
+ }
+
+ @AfterClass
+ public static void tearDownConnection()
+ throws InterruptedException, com.sun.star.uno.Exception
+ {
+ System.out.println("tearDownConnection()");
+ connection.tearDown();
+ }
+ private static final OfficeConnection connection = new OfficeConnection();
+}
diff --git a/framework/qa/complex/dispatches/helper/makefile.mk b/framework/qa/complex/dispatches/helper/makefile.mk
new file mode 100644
index 000000000000..2b2ccab5ebef
--- /dev/null
+++ b/framework/qa/complex/dispatches/helper/makefile.mk
@@ -0,0 +1,47 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+PRJ = ../../../..
+TARGET = checkdispatchapi
+PRJNAME = framework
+PACKAGE = complex/dispatches/helper
+
+# --- Settings -----------------------------------------------------
+.INCLUDE: settings.mk
+
+
+#----- compile .java files -----------------------------------------
+
+JARFILES = ridl.jar unoil.jar jurt.jar juh.jar java_uno.jar Generator.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..6a5ff79dd793
--- /dev/null
+++ b/framework/qa/complex/dispatches/makefile.mk
@@ -0,0 +1,131 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+.IF "$(OOO_SUBSEQUENT_TESTS)" == ""
+nothing .PHONY:
+.ELSE
+
+PRJ = ../../..
+PRJNAME = framework
+TARGET = qa_complex_dispatches
+
+.IF "$(OOO_JUNIT_JAR)" != ""
+PACKAGE = complex/dispatches
+
+# here store only Files which contain a @Test
+JAVATESTFILES = \
+ checkdispatchapi.java
+
+# put here all other files
+JAVAFILES = $(JAVATESTFILES) \
+ Interceptor.java
+
+JARFILES = OOoRunner.jar ridl.jar test.jar unoil.jar ConnectivityTools.jar
+EXTRAJARFILES = $(OOO_JUNIT_JAR)
+
+# Sample how to debug
+# JAVAIFLAGS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=9003,suspend=y
+
+.END
+
+.INCLUDE: settings.mk
+.INCLUDE: target.mk
+.INCLUDE: installationtest.mk
+
+ALLTAR : javatest
+
+.END
+
+
+
+
+# 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..a3365cbda75d
--- /dev/null
+++ b/framework/qa/complex/disposing/GetServiceWhileDisposingOffice.java
@@ -0,0 +1,118 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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 com.sun.star.frame.XDesktop;
+
+// ---------- junit imports -----------------
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.openoffice.test.OfficeConnection;
+import static org.junit.Assert.*;
+// ------------------------------------------
+
+/**
+ * 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
+{
+
+// public String[] getTestMethodNames()
+// {
+// return new String[]
+// {
+// "checkServiceWhileDisposing"
+// };
+// }
+
+ @Test public void checkServiceWhileDisposing()
+ {
+ XMultiServiceFactory xMSF = getMSF();
+ XDesktop xDesktop = null;
+
+ try
+ {
+ xDesktop = UnoRuntime.queryInterface(XDesktop.class, xMSF.createInstance("com.sun.star.frame.Desktop"));
+ }
+ catch (com.sun.star.uno.Exception e)
+ {
+ fail("Could not create a desktop instance.");
+ }
+ int step = 0;
+ try
+ {
+ System.out.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)
+ {
+ System.out.println("DisposedException in step: " + step);
+ }
+ catch (Exception e)
+ {
+ fail(e.getMessage());
+ }
+
+ }
+
+
+ private XMultiServiceFactory getMSF()
+ {
+ final XMultiServiceFactory xMSF1 = UnoRuntime.queryInterface(XMultiServiceFactory.class, connection.getComponentContext().getServiceManager());
+ return xMSF1;
+ }
+
+ // setup and close connections
+ @BeforeClass
+ public static void setUpConnection() throws Exception
+ {
+ System.out.println("setUpConnection()");
+ connection.setUp();
+ }
+
+ @AfterClass
+ public static void tearDownConnection()
+ throws InterruptedException, com.sun.star.uno.Exception
+ {
+ System.out.println("tearDownConnection()");
+ // Office is already terminated.
+ // connection.tearDown();
+ }
+ private static final OfficeConnection connection = new OfficeConnection();
+
+}
diff --git a/framework/qa/complex/disposing/makefile.mk b/framework/qa/complex/disposing/makefile.mk
new file mode 100755
index 000000000000..f24960421f21
--- /dev/null
+++ b/framework/qa/complex/disposing/makefile.mk
@@ -0,0 +1,61 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+.IF "$(OOO_SUBSEQUENT_TESTS)" == ""
+nothing .PHONY:
+.ELSE
+
+PRJ = ../../..
+PRJNAME = framework
+TARGET = qa_complex_disposing
+
+.IF "$(OOO_JUNIT_JAR)" != ""
+PACKAGE = complex/disposing
+
+# here store only Files which contain a @Test
+JAVATESTFILES = \
+ GetServiceWhileDisposingOffice.java
+
+# put here all other files
+JAVAFILES = $(JAVATESTFILES)
+
+JARFILES = OOoRunner.jar ridl.jar test.jar unoil.jar
+EXTRAJARFILES = $(OOO_JUNIT_JAR)
+
+# Sample how to debug
+# JAVAIFLAGS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=9003,suspend=y
+
+.END
+
+.INCLUDE: settings.mk
+.INCLUDE: target.mk
+.INCLUDE: installationtest.mk
+
+ALLTAR : javatest
+
+.END
+
diff --git a/framework/qa/complex/framework/autosave/AutoSave.java b/framework/qa/complex/framework/autosave/AutoSave.java
new file mode 100644
index 000000000000..178f9c0af987
--- /dev/null
+++ b/framework/qa/complex/framework/autosave/AutoSave.java
@@ -0,0 +1,489 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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.beans.PropertyValue;
+import com.sun.star.frame.FeatureStateEvent;
+import com.sun.star.frame.XDispatch;
+import com.sun.star.frame.XDispatchProvider;
+import com.sun.star.frame.XModel;
+import com.sun.star.frame.XStatusListener;
+import com.sun.star.frame.XStorable;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.sheet.FillDirection;
+import com.sun.star.sheet.XCellSeries;
+import com.sun.star.table.XCellRange;
+import com.sun.star.util.XCloseable;
+import com.sun.star.sheet.XSpreadsheet;
+import com.sun.star.sheet.XSpreadsheetDocument;
+import com.sun.star.sheet.XSpreadsheets;
+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.util.URL;
+import com.sun.star.util.XURLTransformer;
+import java.util.*;
+import util.utils;
+
+
+// ---------- junit imports -----------------
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.openoffice.test.OfficeConnection;
+import util.SOfficeFactory;
+import static org.junit.Assert.*;
+// ------------------------------------------
+
+//-----------------------------------------------
+/** @short Check some use cases of the AutoSave feature
+ */
+public class AutoSave
+{
+ //-------------------------------------------
+ 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 = 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.
+ */
+ @Before 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 = getMSF();
+
+ // get another helper to e.g. create test documents
+ m_aSOF = SOfficeFactory.getFactory(m_xSMGR);
+
+ // create AutoSave instance
+ m_xAutoSave = 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 = UnoRuntime.queryInterface(XURLTransformer.class, m_xSMGR.createInstance("com.sun.star.util.URLTransformer"));
+
+ }
+ catch(java.lang.Throwable ex)
+ {
+ m_aLog.log(ex);
+ fail("Couldn't create test environment");
+ }
+ }
+
+ //-------------------------------------------
+ /** @short close the environment.
+ */
+ @After 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 = 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 = UnoRuntime.queryInterface(XModel.class, xDoc);
+ XDispatchProvider xProvider = 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 = 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.
+ */
+ @Test 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);
+ }
+ }
+
+ private XMultiServiceFactory getMSF()
+ {
+ final XMultiServiceFactory xMSF1 = UnoRuntime.queryInterface(XMultiServiceFactory.class, connection.getComponentContext().getServiceManager());
+ return xMSF1;
+ }
+
+ // setup and close connections
+ @BeforeClass
+ public static void setUpConnection() throws Exception
+ {
+ System.out.println("setUpConnection()");
+ connection.setUp();
+ }
+
+ @AfterClass
+ public static void tearDownConnection()
+ throws InterruptedException, com.sun.star.uno.Exception
+ {
+ System.out.println("tearDownConnection()");
+ connection.tearDown();
+ }
+ private static final OfficeConnection connection = new OfficeConnection();
+}
diff --git a/framework/qa/complex/framework/autosave/ConfigHelper.java b/framework/qa/complex/framework/autosave/ConfigHelper.java
new file mode 100644
index 000000000000..a7f5df8cc72d
--- /dev/null
+++ b/framework/qa/complex/framework/autosave/ConfigHelper.java
@@ -0,0 +1,115 @@
+package complex.framework.autosave;
+
+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 = 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 = 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 = 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 = 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 = 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..2e8e3dca1f76
--- /dev/null
+++ b/framework/qa/complex/framework/autosave/makefile.mk
@@ -0,0 +1,127 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+.IF "$(OOO_SUBSEQUENT_TESTS)" == ""
+nothing .PHONY:
+.ELSE
+
+PRJ = ../../../..
+PRJNAME = framework
+TARGET = qa_complex_framework_autosave
+
+.IF "$(OOO_JUNIT_JAR)" != ""
+PACKAGE = complex/framework/autosave
+
+# here store only Files which contain a @Test
+JAVATESTFILES = \
+ AutoSave.java
+
+# put here all other files
+JAVAFILES = $(JAVATESTFILES) \
+ ConfigHelper.java \
+ Protocol.java
+
+JARFILES = OOoRunner.jar ridl.jar test.jar unoil.jar
+EXTRAJARFILES = $(OOO_JUNIT_JAR)
+
+# Sample how to debug
+# JAVAIFLAGS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=9003,suspend=y
+
+.END
+
+.INCLUDE: settings.mk
+.INCLUDE: target.mk
+.INCLUDE: installationtest.mk
+
+ALLTAR : javatest
+
+.END
+
+#
+# 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..10fc433e7cd1
--- /dev/null
+++ b/framework/qa/complex/framework/recovery/RecoveryTest.java
@@ -0,0 +1,1022 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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;
+
+// ---------- junit imports -----------------
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.openoffice.test.OfficeConnection;
+import static org.junit.Assert.*;
+// ------------------------------------------
+
+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..7db880958ab5
--- /dev/null
+++ b/framework/qa/complex/imageManager/CheckImageManager.java
@@ -0,0 +1,223 @@
+package complex.imageManager;
+
+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 com.sun.star.ui.XModuleUIConfigurationManagerSupplier;
+import com.sun.star.ui.XUIConfiguration;
+import com.sun.star.ui.XUIConfigurationManager;
+import com.sun.star.ui.XUIConfigurationPersistence;
+
+
+// ---------- junit imports -----------------
+import lib.TestParameters;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.openoffice.test.OfficeConnection;
+import static org.junit.Assert.*;
+// ------------------------------------------
+
+/**
+ *
+ */
+public class CheckImageManager {
+ boolean checkUIConfigManager = false;
+ XMultiServiceFactory xMSF = null;
+ /**
+ * The test parameters
+ */
+ private static TestParameters param = null;
+
+ @Before public void before()
+ {
+ xMSF = getMSF();
+ param = new TestParameters();
+ param.put("ServiceFactory", xMSF); // some qadevOOo functions need the ServiceFactory
+ }
+
+// public String[] getTestMethodNames() {
+// return new String[]{"checkImageManagerFromModule"};//, "checkImageManager"};
+// }
+
+ @Test public void checkImageManagerFromModule()
+ {
+ System.out.println(" **** ImageManager from ModuleUIConfigurationManager *** ");
+ XUIConfigurationManager xManager = null;
+ try {
+ Object o = (XInterface)xMSF.createInstance(
+ "com.sun.star.ui.ModuleUIConfigurationManagerSupplier");
+ XModuleUIConfigurationManagerSupplier xMUICMS =
+ UnoRuntime.queryInterface(XModuleUIConfigurationManagerSupplier.class, o);
+ xManager = xMUICMS.getUIConfigurationManager(
+ "com.sun.star.text.TextDocument");
+ }
+ catch(com.sun.star.uno.Exception e) {
+ fail("Exception. " + e.getMessage());
+ }
+ XImageManager xImageManager = UnoRuntime.queryInterface(XImageManager.class, xManager.getImageManager());
+ performChecks(xImageManager, "ModuleUIConfig", xManager);
+ }
+
+ public void checkImageManager() {
+ System.out.println(" **** ImageManager from UIConfigurationManager *** ");
+ XUIConfigurationManager xManager = null;
+ try {
+ xManager = UnoRuntime.queryInterface(XUIConfigurationManager.class, xMSF.createInstance("com.sun.star.comp.framework.UIConfigurationManager"));
+ }
+ catch(com.sun.star.uno.Exception e) {
+ fail("Exception. " + e.getMessage());
+ }
+
+ 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(xManager, xMSF);
+ param.put("XUIConfiguration.XUIConfigurationListenerImpl", configListener);
+
+ XInitialization xInit = UnoRuntime.queryInterface(XInitialization.class, xImageManager);
+ _XInitialization _xInit = new _XInitialization(param, xInit);
+ assertTrue(testObjectName + "::XInitialization.initialize", _xInit._initialize());
+
+ // xImageManager is already there, just write a test ;-)
+ _XImageManager _xImage = new _XImageManager(param, xImageManager);
+ assertTrue(testObjectName + "::XImageManager.getAllImageNames", _xImage._getAllImageNames());
+ assertTrue(testObjectName + "::XImageManager.getImages", _xImage._getImages());
+ assertTrue(testObjectName + "::XImageManager.hasImage", _xImage._hasImage());
+ assertTrue(testObjectName + "::XImageManager.insertImages", _xImage._insertImages());
+ assertTrue(testObjectName + "::XImageManager.removeImages", _xImage._removeImages());
+ assertTrue(testObjectName + "::XImageManager.replaceImages", _xImage._replaceImages());
+ assertTrue(testObjectName + "::XImageManager.reset", _xImage._reset());
+
+ XTypeProvider xType = UnoRuntime.queryInterface(XTypeProvider.class, xImageManager);
+ _XTypeProvider _xType = new _XTypeProvider(param, xType);
+ assertTrue(testObjectName + "::XTypeProvider.getImplementationId", _xType._getImplementationId());
+ assertTrue(testObjectName + "::XTypeProvider.getTypes", _xType._getTypes());
+
+ XUIConfiguration xUIConfig = UnoRuntime.queryInterface(XUIConfiguration.class, xImageManager);
+ _XUIConfiguration _xUIConfig = new _XUIConfiguration(param, xUIConfig);
+ _xUIConfig.before();
+ assertTrue(testObjectName + "::XUIConfig.addConfigurationListener", _xUIConfig._addConfigurationListener());
+ assertTrue(testObjectName + "::XUIConfig.removeConfigurationListener", _xUIConfig._removeConfigurationListener());
+
+ XUIConfigurationPersistence xUIConfigPersistence = (XUIConfigurationPersistence)UnoRuntime.queryInterface(XUIConfiguration.class, xImageManager);
+ _XUIConfigurationPersistence _xUIConfigPersistence = new _XUIConfigurationPersistence(param, xUIConfigPersistence);
+ _xUIConfigPersistence.before();
+ assertTrue(testObjectName + "::XUIConfigPersistence.isModified", _xUIConfigPersistence._isModified());
+ // System.out.println(testObjectName + "::XUIConfigPersistence.isReadOnly "+ _xUIConfigPersistence._isReadOnly());
+ assertTrue(testObjectName + "::XUIConfigPersistence.isReadOnly", _xUIConfigPersistence._isReadOnly());
+ assertTrue(testObjectName + "::XUIConfigPersistence.reload", _xUIConfigPersistence._reload());
+ assertTrue(testObjectName + "::XUIConfigPersistence.store", _xUIConfigPersistence._store());
+ assertTrue(testObjectName + "::XUIConfigPersistence.storeToStorage", _xUIConfigPersistence._storeToStorage());
+
+ XComponent xComp = UnoRuntime.queryInterface(XComponent.class, xImageManager);
+ _XComponent _xComp = new _XComponent(param, xComp);
+ _xComp.before();
+ assertTrue(testObjectName + "::XComponent.addEventListener", _xComp._addEventListener());
+ assertTrue(testObjectName + "::XComponent.removeEventListener", _xComp._removeEventListener());
+ assertTrue(testObjectName + "::XComponent.dispose", _xComp._dispose());
+ }
+
+
+ class OXUIConfigurationListenerImpl implements _XUIConfiguration.XUIConfigurationListenerImpl {
+ private boolean triggered = false;
+ private XUIConfigurationManager xUIManager = null;
+ private XMultiServiceFactory xMSF = null;
+
+ public OXUIConfigurationListenerImpl(XUIConfigurationManager xUIManager, XMultiServiceFactory xMSF) {
+
+ 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) {
+ System.out.println("_XUIConfiguration.XUIConfigurationListenerImpl: Exception.");
+ e.printStackTrace((java.io.PrintWriter)log);
+ }
+ catch(com.sun.star.lang.IllegalArgumentException e) {
+ System.out.println("_XUIConfiguration.XUIConfigurationListenerImpl: Exception.");
+ e.printStackTrace((java.io.PrintWriter)log);
+ }
+ catch(com.sun.star.lang.IllegalAccessException e) {
+ System.out.println("_XUIConfiguration.XUIConfigurationListenerImpl: Exception.");
+ e.printStackTrace((java.io.PrintWriter)log);
+ }
+ catch(com.sun.star.lang.IndexOutOfBoundsException e) {
+ System.out.println("_XUIConfiguration.XUIConfigurationListenerImpl: Exception.");
+ e.printStackTrace((java.io.PrintWriter)log);
+ }
+ catch(com.sun.star.lang.WrappedTargetException e) {
+ System.out.println("_XUIConfiguration.XUIConfigurationListenerImpl: Exception.");
+ e.printStackTrace((java.io.PrintWriter)log);
+ } */
+ }
+
+ public void reset() {
+ // remove comment for real function
+ //triggered = false;
+ }
+
+ }
+
+ private XMultiServiceFactory getMSF()
+ {
+ final XMultiServiceFactory xMSF1 = UnoRuntime.queryInterface(XMultiServiceFactory.class, connection.getComponentContext().getServiceManager());
+ return xMSF1;
+ }
+
+ // setup and close connections
+ @BeforeClass
+ public static void setUpConnection() throws Exception
+ {
+ System.out.println("setUpConnection()");
+ connection.setUp();
+ }
+
+ @AfterClass
+ public static void tearDownConnection()
+ throws InterruptedException, com.sun.star.uno.Exception
+ {
+ System.out.println("tearDownConnection()");
+ connection.tearDown();
+ }
+ private static final OfficeConnection connection = new OfficeConnection();
+
+}
diff --git a/framework/qa/complex/imageManager/_XComponent.java b/framework/qa/complex/imageManager/_XComponent.java
new file mode 100755
index 000000000000..9affbb9499b5
--- /dev/null
+++ b/framework/qa/complex/imageManager/_XComponent.java
@@ -0,0 +1,187 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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.imageManager;
+
+import com.sun.star.container.XNameContainer;
+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;
+ 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(TestParameters tEnv, XComponent oObj) {
+ 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)
+ {
+ System.out.println("Hint: already disposed.");
+ return false;
+ }
+ // the second listener should not be called
+ oObj.removeEventListener( listener2 );
+ System.out.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;
+
+ System.out.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){
+ System.out.println(Loutput[0]);
+ }
+ if (Loutput[1]!=null) {
+ System.out.println(Loutput[1]);
+ }
+ System.out.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/_XImageManager.java b/framework/qa/complex/imageManager/_XImageManager.java
new file mode 100755
index 000000000000..5887fd8fa0d8
--- /dev/null
+++ b/framework/qa/complex/imageManager/_XImageManager.java
@@ -0,0 +1,117 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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.imageManager;
+
+import com.sun.star.graphic.XGraphic;
+import com.sun.star.ui.ImageType;
+import com.sun.star.ui.XImageManager;
+import lib.TestParameters;
+
+
+/**
+ *
+ */
+public class _XImageManager {
+
+ TestParameters tEnv = null;
+ String[]imageNames = null;
+ XGraphic[] xGraphicArray = null;
+ public XImageManager oObj;
+
+ public _XImageManager( TestParameters tEnv, XImageManager oObj) {
+
+ 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) {
+ 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/_XInitialization.java b/framework/qa/complex/imageManager/_XInitialization.java
new file mode 100755
index 000000000000..fcfaf5f981d3
--- /dev/null
+++ b/framework/qa/complex/imageManager/_XInitialization.java
@@ -0,0 +1,94 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package complex.imageManager;
+
+
+
+
+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 {
+
+
+ TestParameters tEnv = null;
+ public static XInitialization oObj = null;
+
+ public _XInitialization(TestParameters tEnv, XInitialization oObj) {
+
+ 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) {
+ System.out.println("Exception occured while method calling.") ;
+ result = false ;
+ }
+
+ return result ;
+ } // finished _initialize()
+
+ /**
+ * Disposes object environment.
+ */
+ public void after() {
+// disposeEnvironment() ;
+ }
+
+} // finished class _XInitialization
+
+
diff --git a/framework/qa/complex/imageManager/_XTypeProvider.java b/framework/qa/complex/imageManager/_XTypeProvider.java
new file mode 100755
index 000000000000..08b810198d9b
--- /dev/null
+++ b/framework/qa/complex/imageManager/_XTypeProvider.java
@@ -0,0 +1,102 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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.imageManager;
+
+
+
+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 {
+
+
+ TestParameters tEnv = null;
+ public static XTypeProvider oObj = null;
+ public static Type[] types = null;
+
+ public _XTypeProvider(TestParameters tEnv, XTypeProvider oObj) {
+
+ 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;
+ System.out.println("testing getImplementationId() ... ");
+
+ System.out.println("The ImplementationId is "+oObj.getImplementationId());
+ result = true;
+
+ return result;
+
+ } // end getImplementationId()
+
+
+ /**
+ * Calls 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;
+ System.out.println("getting Types...");
+ types = oObj.getTypes();
+ for (int i=0;i<types.length;i++) {
+ int k = i+1;
+ System.out.println(k+". Type is "+types[i].toString());
+ if (types[i].toString().equals
+ ("Type[com.sun.star.lang.XTypeProvider]")) {
+ result = true;
+ }
+ }
+ if (!result) {
+ System.out.println("Component must provide Type "
+ +"<com.sun.star.lang.XTypeProvider>");
+ }
+
+ return result;
+
+ } // end getTypes()
+
+}
+
diff --git a/framework/qa/complex/imageManager/_XUIConfiguration.java b/framework/qa/complex/imageManager/_XUIConfiguration.java
new file mode 100755
index 000000000000..ec9d5f3fc634
--- /dev/null
+++ b/framework/qa/complex/imageManager/_XUIConfiguration.java
@@ -0,0 +1,82 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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.imageManager;
+
+
+import com.sun.star.ui.XUIConfiguration;
+import com.sun.star.ui.XUIConfigurationListener;
+import lib.TestParameters;
+
+
+
+public class _XUIConfiguration {
+
+
+ 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(TestParameters tEnv, XUIConfiguration oObj) {
+ 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/_XUIConfigurationPersistence.java b/framework/qa/complex/imageManager/_XUIConfigurationPersistence.java
new file mode 100755
index 000000000000..1dec01ad0660
--- /dev/null
+++ b/framework/qa/complex/imageManager/_XUIConfigurationPersistence.java
@@ -0,0 +1,93 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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.imageManager;
+
+import com.sun.star.embed.XStorage;
+import com.sun.star.ui.XUIConfigurationPersistence;
+import lib.TestParameters;
+
+
+
+public class _XUIConfigurationPersistence {
+
+
+ TestParameters tEnv = null;
+ public XUIConfigurationPersistence oObj;
+ private XStorage xStore = null;
+
+ public _XUIConfigurationPersistence(TestParameters tEnv, XUIConfigurationPersistence oObj) {
+
+ 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) {
+
+ }
+ return true;
+ }
+
+ public boolean _store() {
+ try {
+ oObj.store();
+ }
+ catch(com.sun.star.uno.Exception e) {
+
+ }
+ return true;
+ }
+
+ public boolean _storeToStorage() {
+ boolean result = true;
+ try {
+ oObj.storeToStorage(xStore);
+ }
+ catch(com.sun.star.uno.Exception e) {
+ result = false;
+
+ }
+ 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..f7b6f5ebf035
--- /dev/null
+++ b/framework/qa/complex/imageManager/interfaces/makefile.mk
@@ -0,0 +1,63 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ = ../../../..
+TARGET = ImageManager
+PRJNAME = framework
+PACKAGE = complex/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..133e522b13b4
--- /dev/null
+++ b/framework/qa/complex/imageManager/makefile.mk
@@ -0,0 +1,123 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+.IF "$(OOO_SUBSEQUENT_TESTS)" == ""
+nothing .PHONY:
+.ELSE
+
+PRJ = ../../..
+PRJNAME = framework
+TARGET = qa_complex_imageManager
+
+.IF "$(OOO_JUNIT_JAR)" != ""
+PACKAGE = complex/imageManager
+
+# here store only Files which contain a @Test
+JAVATESTFILES = \
+ CheckImageManager.java
+
+# put here all other files
+JAVAFILES = $(JAVATESTFILES) \
+ _XComponent.java \
+ _XImageManager.java \
+ _XInitialization.java \
+ _XTypeProvider.java \
+ _XUIConfiguration.java \
+ _XUIConfigurationPersistence.java
+
+JARFILES = OOoRunner.jar ridl.jar test.jar unoil.jar
+EXTRAJARFILES = $(OOO_JUNIT_JAR)
+
+# Sample how to debug
+# JAVAIFLAGS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=9003,suspend=y
+
+.END
+
+.INCLUDE: settings.mk
+.INCLUDE: target.mk
+.INCLUDE: installationtest.mk
+
+ALLTAR : javatest
+
+.END
+
+
+
+#
+#
+# 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..1c67271fd6bb
--- /dev/null
+++ b/framework/qa/complex/loadAllDocuments/CheckXComponentLoader.java
@@ -0,0 +1,750 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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.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.XMultiServiceFactory;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.util.XCloseable;
+import com.sun.star.ucb.XSimpleFileAccess;
+
+
+import helper.URLHelper;
+
+import java.io.File;
+import java.io.InputStreamReader;
+
+import java.util.Enumeration;
+import java.util.Vector;
+
+// ---------- junit imports -----------------
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.openoffice.test.OfficeConnection;
+import org.openoffice.test.OfficeFileUrl;
+import static org.junit.Assert.*;
+// ------------------------------------------
+
+//-----------------------------------------------
+/** @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
+{
+ //-------------------------------------------
+ // 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
+ */
+ @Before public void before()
+ {
+ // get uno service manager from global test environment
+ m_xMSF = getMSF();
+
+ // create stream provider
+ try
+ {
+ m_xStreamProvider = UnoRuntime.queryInterface(XSimpleFileAccess.class, m_xMSF.createInstance("com.sun.star.ucb.SimpleFileAccess"));
+ }
+ catch(java.lang.Throwable ex)
+ {
+ fail("Could not create a stream provider instance.");
+ }
+
+ // create desktop instance
+ try
+ {
+ m_xDesktop = UnoRuntime.queryInterface(XFrame.class, m_xMSF.createInstance("com.sun.star.frame.Desktop"));
+ }
+ catch(java.lang.Throwable ex)
+ {
+ fail("Could not create the desktop instance.");
+ }
+
+ // create frame instance
+ m_xFrame = m_xDesktop.findFrame("testFrame_componentLoader",
+ FrameSearchFlag.TASKS | FrameSearchFlag.CREATE);
+ assertNotNull("Couldn't create test frame.", m_xFrame);
+
+ // define default loader for testing
+ // TODO think about using of bot loader instances!
+ m_xLoader = UnoRuntime.queryInterface(XComponentLoader.class, m_xDesktop);
+ assertNotNull("Desktop service doesnt support needed component loader interface.", m_xLoader);
+
+ // get temp path for this environment
+ final String tempDirURL = util.utils.getOfficeTemp/*Dir*/(getMSF());
+ m_sTempPath = graphical.FileHelper.getSystemPathFromFileURL(tempDirURL);
+ // m_sTempPath = "."+fs_sys;
+
+ // get all files from the given directory
+ // TODO URLHelper should ignore directories!
+ m_lTestFiles = new Vector();
+ final String sTestDocURL = OfficeFileUrl.getAbsolute(new File("testdocuments"));
+ m_sTestDocPath = graphical.FileHelper.getSystemPathFromFileURL(sTestDocURL);
+ 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);
+
+ // 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)
+ {
+ fail("Couldn't find test documents.");
+ }
+ }
+
+ //-------------------------------------------
+ /** @short close the environment.
+ */
+ @After public void after()
+ {
+ XCloseable xClose = UnoRuntime.queryInterface(XCloseable.class, m_xFrame);
+ try
+ {
+ xClose.close(false);
+ }
+ catch(com.sun.star.util.CloseVetoException exVeto)
+ { fail("Test frame couldn't be closed successfully."); }
+
+ m_xFrame = null;
+ m_xLoader = null;
+ }
+
+ //-------------------------------------------
+ /** @short Look for files in the given directory for loading.
+ */
+ @Test 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, (String)aSnapshot.nextElement());
+ String sURL = URLHelper.getFileURLFromSystemPath(aSysFile);
+
+ if (/*! (sURL.endsWith(".jpg") ||
+ sURL.endsWith(".gif"))*/
+ true
+ )
+ {
+ loadURL(m_xLoader, RESULT_VALID_DOC, sURL, "_blank", 0, lProps);
+ // Its not needed to reset this using states!
+ // Its done internaly ...
+ if (!xIndicator.wasUsed())
+ {
+ System.out.println("External progress was not used for loading.");
+ }
+ if (xHandler.wasUsed())
+ {
+ System.out.println("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);
+ aDir.mkdirs();
+// if (!aDir.exists())
+// {
+// fail("Could not access temp directory \"" + sTempPath + "\".");
+// }
+
+ // TODO: create a temp file which not exist!
+ for (int i=0; i<999999; ++i)
+ {
+ File aTempFile = new File(aDir, sSuffix+i+sPrefix);
+ if (!aTempFile.exists())
+ {
+ return aTempFile.getAbsolutePath();
+ }
+ }
+
+ fail("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);
+ assertNotNull("Could create office document, which should be saved as temp one.", xDoc);
+
+ // save it as temp file
+ XStorable xStore = UnoRuntime.queryInterface(XStorable.class, xDoc);
+ xStore.storeAsURL(sTargetURL, lSaveProps);
+
+ // Dont forget to close this file. Otherwise the temp file is locked!
+ XCloseable xClose = UnoRuntime.queryInterface(XCloseable.class, xDoc);
+ xClose.close(false);
+ }
+ catch(java.lang.Throwable ex)
+ {
+ fail("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.
+ */
+ @Test 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);
+// TODO: wrong? 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.
+ */
+ @Test 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();
+
+ System.out.println("This system's encoding: " + sSystemEncoding);
+
+ assertNotNull("Found an empty directory. There are no files for testing.", m_lTestFiles);
+
+
+ // get a file name as byte array
+ Enumeration aSnapshot = m_lTestFiles.elements();
+ byte[] baURL = null;
+
+ while (aSnapshot.hasMoreElements()) {
+ File aFile = new File(m_sTestDocPath, (String)aSnapshot.nextElement());
+ String sFile = URLHelper.getFileURLFromSystemPath(aFile);
+
+ // take the first sxw file as stream
+ if (sFile.endsWith(".sxw")) {
+ baURL = sFile.getBytes();
+
+ break;
+ }
+ }
+
+ assertNotNull("Found no file to load. Cannot test.", baURL);
+
+ //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]);
+ System.out.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) {
+ fail("Unsopported Encoding: " + sEncoding[i] +
+ "\n Not able to test encoding on this platform.");
+ }
+ }
+ }
+
+ /**
+ * 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;
+//
+// System.out.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);
+//
+// System.out.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);
+//
+// System.out.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);
+//
+// System.out.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);
+// }
+// }
+//
+// System.out.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
+ */
+ @Test 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, (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)
+ {
+ fail("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);
+ // 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) {
+ nResult = RESULT_RUNTIMEEXCEPTION;
+ } catch (Exception e) {
+ nResult = RESULT_EXCEPTION;
+ }
+
+ try {
+ if (xDoc != null) {
+ xDoc.dispose();
+ xDoc = null;
+ }
+ } catch (com.sun.star.uno.RuntimeException exClosing) {
+ System.out.println("exception during disposing of a document found!" +
+ " Doesn't influence test - but should be checked.");
+ }
+
+ String sMessage = "URL[\"" + sURL + "\"]";
+
+ if (nResult == nRequiredResult) {
+ System.out.println(sMessage + " expected result [" +
+ convertResult2String(nResult) + "] ");
+ } else {
+ fail(sMessage + " unexpected result [" +
+ convertResult2String(nResult) + "] " +
+ "\nrequired was [" +
+ convertResult2String(nRequiredResult) + "]" +
+ "\nwe got [" + convertResult2String(nResult) + "]"
+ );
+ }
+ }
+
+ 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!";
+ }
+
+ private XMultiServiceFactory getMSF()
+ {
+ final XMultiServiceFactory xMSF1 = UnoRuntime.queryInterface(XMultiServiceFactory.class, connection.getComponentContext().getServiceManager());
+ return xMSF1;
+ }
+
+ // setup and close connections
+ @BeforeClass
+ public static void setUpConnection() throws Exception
+ {
+ System.out.println("setUpConnection()");
+ connection.setUp();
+ }
+
+ @AfterClass
+ public static void tearDownConnection()
+ throws InterruptedException, com.sun.star.uno.Exception
+ {
+ System.out.println("tearDownConnection()");
+ connection.tearDown();
+ }
+ private static final OfficeConnection connection = new OfficeConnection();
+
+}
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/InteractionHandler.java b/framework/qa/complex/loadAllDocuments/InteractionHandler.java
new file mode 100644
index 000000000000..92d8f3c34543
--- /dev/null
+++ b/framework/qa/complex/loadAllDocuments/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;
+
+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/StatusIndicator.java b/framework/qa/complex/loadAllDocuments/StatusIndicator.java
new file mode 100644
index 000000000000..c28993010ed8
--- /dev/null
+++ b/framework/qa/complex/loadAllDocuments/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;
+
+// __________ 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/StreamSimulator.java b/framework/qa/complex/loadAllDocuments/StreamSimulator.java
new file mode 100644
index 000000000000..7b59c25d0a79
--- /dev/null
+++ b/framework/qa/complex/loadAllDocuments/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;
+
+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/TestDocument.java b/framework/qa/complex/loadAllDocuments/TestDocument.java
new file mode 100644
index 000000000000..fe41a6161c4a
--- /dev/null
+++ b/framework/qa/complex/loadAllDocuments/TestDocument.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.loadAllDocuments;
+
+import java.io.File;
+import org.openoffice.test.OfficeFileUrl;
+
+final class TestDocument
+{
+ public static String getUrl(String name)
+ {
+ return OfficeFileUrl.getAbsolute(new File("testdocuments", name));
+ }
+
+ private TestDocument() {}
+}
diff --git a/framework/qa/complex/loadAllDocuments/helper/makefile.mk b/framework/qa/complex/loadAllDocuments/helper/makefile.mk
new file mode 100644
index 000000000000..05a3c7a997ea
--- /dev/null
+++ b/framework/qa/complex/loadAllDocuments/helper/makefile.mk
@@ -0,0 +1,47 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+PRJ = ../../../..
+TARGET = CheckXComponentLoader
+PRJNAME = framework
+PACKAGE = complex/loadAllDocuments/helper
+
+# --- Settings -----------------------------------------------------
+.INCLUDE: settings.mk
+
+
+#----- compile .java files -----------------------------------------
+
+JARFILES = ridl.jar unoil.jar jurt.jar juh.jar java_uno.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..ebf0265620bf
--- /dev/null
+++ b/framework/qa/complex/loadAllDocuments/makefile.mk
@@ -0,0 +1,134 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+.IF "$(OOO_SUBSEQUENT_TESTS)" == ""
+nothing .PHONY:
+.ELSE
+
+PRJ = ../../..
+PRJNAME = framework
+TARGET = qa_complex_loadAllDocuments
+
+.IF "$(OOO_JUNIT_JAR)" != ""
+PACKAGE = complex/loadAllDocuments
+
+# here store only Files which contain a @Test
+JAVATESTFILES = \
+ CheckXComponentLoader.java
+
+# put here all other files
+JAVAFILES = $(JAVATESTFILES) \
+ InteractionHandler.java \
+ StatusIndicator.java \
+ StreamSimulator.java \
+ TestDocument.java
+
+JARFILES = OOoRunner.jar ridl.jar test.jar unoil.jar
+EXTRAJARFILES = $(OOO_JUNIT_JAR)
+
+# Sample how to debug
+# JAVAIFLAGS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=9003,suspend=y
+
+.END
+
+.INCLUDE: settings.mk
+.INCLUDE: target.mk
+.INCLUDE: installationtest.mk
+
+ALLTAR : javatest
+
+.END
+
+
+
+#
+#
+# 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 =
+# 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/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/password_check.sxw b/framework/qa/complex/loadAllDocuments/testdocuments/password_check.sxw
new file mode 100644
index 000000000000..ec545b99e22a
--- /dev/null
+++ b/framework/qa/complex/loadAllDocuments/testdocuments/password_check.sxw
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..36abfd55bbde
--- /dev/null
+++ b/framework/qa/complex/path_settings/PathSettingsTest.java
@@ -0,0 +1,1018 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public 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.PropertyVetoException;
+import com.sun.star.beans.UnknownPropertyException;
+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.WrappedTargetException;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.AnyConverter;
+
+// ---------- junit imports -----------------
+import java.util.ArrayList;
+import java.util.StringTokenizer;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.openoffice.test.OfficeConnection;
+import static org.junit.Assert.*;
+// ------------------------------------------
+
+public class PathSettingsTest
+{
+
+ private static XMultiServiceFactory xMSF;
+ // the test object: an instance of the tested service
+ private static Object aPathSettings = null;
+ // the properties of the service
+ private static Property[] xPropertyInfoOfPathSettings = null;
+ private static String[] aPathSettingNames = null;
+ private static String[] availablePropNames = new String[]
+ {
+ "Addin",
+ "AutoCorrect",
+ "AutoText",
+ "Backup",
+ "Basic",
+ "Bitmap",
+ "Config",
+ "Dictionary",
+ "Favorite",
+ "Filter",
+ "Fingerprint",
+ "Gallery",
+ "Graphic",
+ "Help",
+ "Linguistic",
+ "Module",
+ "Palette",
+ "Plugin",
+ "Storage",
+ "Temp",
+ "Template",
+ "UIConfig",
+ "UserConfig",
+ "Work",
+ };
+ // every path name from availablePropNames exist in this characteristics
+ // name
+ // name_internal
+ // name_user
+ // name_writable
+ private static String[] availablePropNameExtensions = new String[]
+ {
+ "",
+ "_internal",
+ "_user",
+ "_writable"
+ };
+ private static String[] aPathSettingValues = null;
+ ArrayList<Property> aListOfWorkingProperty;
+
+ /**
+ * 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 'aPathSettings' and 'xPropertyInfoOfPathSettings' variables.
+ */
+ @Before
+ public void before()
+ {
+ try
+ {
+ xMSF = getMSF();
+// aPathSettings = xMSF.createInstance("com.sun.star.util.PathSettings");
+ aPathSettings = xMSF.createInstance("com.sun.star.comp.framework.PathSettings");
+ assertNotNull("Can't instantiate com.sun.star.util.PathSettings.", aPathSettings);
+// System.out.println("Implementation: " + util.utils.getImplName(aPathSettings));
+// System.out.println("Service: ");
+ util.dbg.getSuppServices(aPathSettings);
+ final XPropertySet xPropSet_of_PathSettings = UnoRuntime.queryInterface(XPropertySet.class, aPathSettings);
+
+ xPropertyInfoOfPathSettings = xPropSet_of_PathSettings.getPropertySetInfo().getProperties();
+ aPathSettingNames = new String[xPropertyInfoOfPathSettings.length];
+ aPathSettingValues = new String[xPropertyInfoOfPathSettings.length];
+
+ aListOfWorkingProperty = new ArrayList<Property>();
+
+ // get intitial values and create new ones
+ for (int i = 0; i < xPropertyInfoOfPathSettings.length; i++)
+ {
+ final String sName = xPropertyInfoOfPathSettings[i].Name;
+ // System.out.println(sName);
+ aPathSettingNames[i] = sName;
+ Object o = xPropSet_of_PathSettings.getPropertyValue(sName);
+
+ String sValue = convertToString(o);
+ aPathSettingValues[i] = sValue;
+ aListOfWorkingProperty.add(xPropertyInfoOfPathSettings[i]);
+ }
+ }
+ catch (com.sun.star.uno.Exception e)
+ {
+ System.out.println(e.getClass().getName());
+ System.out.println("Message: " + e.getMessage());
+ // fail("Could not create an instance of the test object.");
+ }
+ catch (Exception e)
+ {
+ fail("What exception?");
+ }
+ }
+
+ private String convertToString(Object o)
+ {
+ String sValue = "";
+ try
+ {
+ if (AnyConverter.isString(o))
+ {
+ sValue = AnyConverter.toString(o);
+ }
+ else if (AnyConverter.isArray(o))
+ {
+ Object oValueList = AnyConverter.toArray(o);
+ String[] aValueList = (String[]) oValueList;
+ String sValues = "";
+ for (int j = 0; j < aValueList.length; j++)
+ {
+ if (sValues.length() > 0)
+ {
+ sValues += ";";
+ }
+ sValues += aValueList[j];
+ }
+ sValue = sValues;
+ }
+ else
+ {
+ System.out.println("Can't convert Object to String");
+ }
+ }
+ catch (com.sun.star.uno.Exception e)
+ {
+ /* ignore */
+ }
+ return sValue;
+ }
+
+ /**
+ * Simple existance test, if this fails, the Lists must update
+ */
+ @Test
+ public void checkInternalListConsistence()
+ {
+ // check if all Properties are in the internal test list
+ for (int i = 0; i < xPropertyInfoOfPathSettings.length; i++)
+ {
+ final String sName = xPropertyInfoOfPathSettings[i].Name;
+ boolean bOccur = checkIfNameExistsInList(sName, availablePropNames, availablePropNameExtensions);
+ assertTrue("TEST IS WRONG, Name:='" + sName + "' doesn't exist in internal Test list.", bOccur);
+ }
+
+ // check if all properties in the internal list also exist in real life
+ for (int i = 0; i < availablePropNames.length; i++)
+ {
+ final String aListName = availablePropNames[i];
+ for (int j = 0; j < availablePropNameExtensions.length; j++)
+ {
+ final String aSubListName = availablePropNameExtensions[j];
+ final String aName = aListName + aSubListName;
+ boolean bOccur = checkIfNameExistsInList(aName, aPathSettingNames, new String[]
+ {
+ ""
+ } /* list must not empty! */);
+ assertTrue("TEST IS WRONG, Name:='" + aName + "' from the internal test list do not occur in real life path settings.", bOccur);
+ }
+ }
+ }
+
+ /**
+ * Simple O(n^n) check if a given String (_sNameMustOccur) exist in the given list(+SubList) values.
+ * @param _sNameMustOccur
+ * @param _aList
+ * @param _aSubList
+ * @return true, if name occur
+ */
+ private boolean checkIfNameExistsInList(String _sNameMustOccur, String[] _aList, String[] _aSubList)
+ {
+ for (int i = 0; i < _aList.length; i++)
+ {
+ final String aListName = _aList[i];
+ for (int j = 0; j < _aSubList.length; j++)
+ {
+ final String aSubListName = _aSubList[j];
+ final String aName = aListName + aSubListName;
+ if (aName.equals(_sNameMustOccur))
+ {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ private String getPropertyValueAsString(String _sName)
+ {
+ final XPropertySet xPropSet_of_PathSettings = UnoRuntime.queryInterface(XPropertySet.class, aPathSettings);
+ String sValue = "";
+ {
+ Object o;
+ try
+ {
+ o = xPropSet_of_PathSettings.getPropertyValue(_sName);
+ sValue = convertToString(o);
+ }
+ catch (UnknownPropertyException ex)
+ {
+ }
+ catch (WrappedTargetException ex)
+ {
+ }
+ }
+ return sValue;
+ }
+
+ /**
+ * Shows the path settings
+ * @throws UnknownPropertyException
+ * @throws WrappedTargetException
+ */
+ @Test
+ public void showPathSettings() throws UnknownPropertyException, WrappedTargetException
+ {
+ System.out.println("\n---- All properties ----");
+ final XPropertySet xPropSet_of_PathSettings = UnoRuntime.queryInterface(XPropertySet.class, aPathSettings);
+
+// for (int i = 0; i < xPropertyInfoOfPathSettings.length; i++)
+ for (int i = 0; i < aListOfWorkingProperty.size(); i++)
+ {
+ final String sName = aListOfWorkingProperty.get(i).Name;
+ // aPathSettingWorkingNames[i] = sName;
+// System.out.print("PathSettings: Name:=");
+ System.out.print(sName);
+ Object o = xPropSet_of_PathSettings.getPropertyValue(sName);
+
+ // System.out.println("#### Object: '" + o.getClass().getName() + "' - '" + o.toString() + "'");
+ try
+ {
+ final String sValue = AnyConverter.toString(o);
+ // aPathSettingValues[i] = sValue;
+ // System.out.println("#### String " + sValue);
+ // System.out.println("Property Name: " + sName);
+ // System.out.println("Property Value: " + sValue);
+// System.out.print(" ==> ");
+// System.out.print(sValue);
+ }
+ catch (com.sun.star.uno.Exception e)
+ {
+// System.out.print(" FAILED ");
+ }
+ System.out.println();
+ }
+ System.out.println("---- Finish showing properties ----\n");
+ }
+
+ private boolean checkPaths(Object _o, Object _o2)
+ {
+ String sLeftPath = "";
+ String sRightPath = "";
+ if (AnyConverter.isArray(_o))
+ {
+ try
+ {
+ Object oValues = AnyConverter.toArray(_o);
+ sLeftPath = convertToString(oValues);
+ }
+ catch (com.sun.star.lang.IllegalArgumentException e)
+ {
+ }
+ }
+ else if (AnyConverter.isString(_o))
+ {
+ try
+ {
+ sLeftPath = AnyConverter.toString(_o);
+ }
+ catch (com.sun.star.lang.IllegalArgumentException e)
+ {
+ }
+ }
+
+ if (AnyConverter.isArray(_o2))
+ {
+ try
+ {
+ Object oValues = AnyConverter.toArray(_o2);
+ sRightPath = convertToString(oValues);
+ }
+ catch (com.sun.star.lang.IllegalArgumentException e)
+ {
+ }
+ }
+ else if (AnyConverter.isString(_o2))
+ {
+ try
+ {
+ sRightPath = AnyConverter.toString(_o2);
+ }
+ catch (com.sun.star.lang.IllegalArgumentException e)
+ {
+ }
+ }
+ return checkPaths(sLeftPath, sRightPath);
+ }
+
+ /**
+ * Check 2 given paths if the _aOtherPath exists in _aPath, _aPath could be a list separated by ';'
+ * @param _aPath
+ * @param _aOtherPath
+ * @return true, if _aOtherPath found
+ */
+ private boolean checkPaths(String _aPath, String _aOtherPath)
+ {
+ if (_aOtherPath.contains(";"))
+ {
+ StringTokenizer aToken = new StringTokenizer(_aOtherPath, ";");
+ int nCount = 0;
+ int nFound = 0;
+ while (aToken.hasMoreElements())
+ {
+ String sPath = (String)aToken.nextElement();
+ nCount ++;
+ if (checkPaths(_aPath, sPath))
+ {
+ nFound++;
+ }
+ }
+ if (nFound == nCount)
+ {
+ return true;
+ }
+ }
+ else if(_aPath.contains(";"))
+ {
+ StringTokenizer aToken = new StringTokenizer(_aPath, ";");
+ while (aToken.hasMoreElements())
+ {
+ String sToken = (String)aToken.nextElement();
+ if (sToken.equals(_aOtherPath))
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+ else if (_aPath.equals(_aOtherPath))
+ {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * This tests the XFastPropertySet interface implementation.
+ */
+ @Test
+ public void checkXFastPropertySet()
+ {
+ System.out.println("---- Testing the XFastPropertySet interface ----");
+
+
+ // do for all properties
+ // xPropertyInfoOfPathSettings.length
+ for (int i = 0; i < aListOfWorkingProperty.size(); i++)
+ {
+ final Property property = aListOfWorkingProperty.get(i); // xPropertyInfoOfPathSettings[i];
+ String name = property.Name;
+ // get property name and initial value
+ System.out.println("Test property with name: " + name);
+ boolean bResult;
+ if (name.endsWith("_writable"))
+ {
+ bResult = checkStringProperty(property);
+ }
+ else if (name.endsWith("_user"))
+ {
+ bResult = checkStringListProperty(property);
+ }
+ else if (name.endsWith("_internal"))
+ {
+ bResult = checkStringListProperty(property);
+ }
+ else
+ {
+ // old path settings
+ bResult = checkStringProperty(property);
+ }
+ System.out.print(" Test of property " + name + " finished");
+ if (bResult)
+ {
+ System.out.println(" [ok]");
+ }
+ else
+ {
+ System.out.println(" [FAILED]");
+ }
+ System.out.println();
+ }
+ System.out.println("---- Test of XFastPropertySet finished ----\n");
+ }
+
+ private boolean checkStringListProperty(Property property)
+ {
+ // creating instances
+ boolean bResult = true;
+ XFastPropertySet xFPS = UnoRuntime.queryInterface(XFastPropertySet.class, aPathSettings);
+
+ String name = property.Name;
+ int handle = property.Handle;
+
+ Object oValue;
+ try
+ {
+ oValue = xFPS.getFastPropertyValue(handle);
+ }
+ catch (UnknownPropertyException ex)
+ {
+ return false;
+ }
+ catch (WrappedTargetException ex)
+ {
+ return false;
+ }
+
+ if (!AnyConverter.isArray(oValue))
+ {
+ System.out.println(" Internal error, type wrong. PathSetting property with name:" + name + " should be an array.");
+ return false;
+ }
+
+ String val;
+ try
+ {
+ Object oValues = AnyConverter.toArray(oValue);
+
+
+ final String[] aValues = (String[])oValues;
+
+ // aNewValues contains a deep copy of aValues
+ String[] aNewValues = new String[aValues.length];
+ System.arraycopy(aValues, 0, aNewValues, 0, aValues.length);
+ if (aValues.length > 0)
+ {
+ val = aValues[0];
+ }
+ else
+ {
+ val = null;
+ aNewValues = new String[1]; // create a String list
+ }
+ System.out.println(" Property has initial value: '" + val + "'");
+
+ // set to a new correct value
+ String newVal = changeToCorrectValue(val);
+ assertFalse("newVal must not equal val.", newVal.equals(val));
+
+ System.out.println(" Try to change to a correct value '" + newVal + "'");
+ aNewValues[0] = newVal;
+
+ try
+ {
+ try
+ {
+ xFPS.setFastPropertyValue(handle, aNewValues);
+ }
+ catch (com.sun.star.lang.WrappedTargetException e)
+ {
+ System.out.println(" FAIL: setFastPropertyValue(handle:=" + handle + ", name:='" + name + "')" + e.getMessage());
+ bResult = false;
+ }
+
+ // Property_internal can't change we will not arrive bejond this line
+
+ // check the change
+ Object oObj = xFPS.getFastPropertyValue(handle);
+ if (!checkPaths(oObj, aNewValues))
+ {
+ System.out.println(" FAIL: Did not change value on property " + name + ".");
+ bResult = false;
+ }
+
+ // set back to initial setting
+ System.out.println(" Try to check");
+ try
+ {
+ xFPS.setFastPropertyValue(handle, oValue);
+ }
+ catch (com.sun.star.beans.PropertyVetoException e)
+ {
+ // should not occur
+ System.out.println(" FAIL: PropertyVetoException caught: " + e.getMessage());
+ bResult = false;
+ }
+ }
+ catch (com.sun.star.beans.PropertyVetoException e)
+ {
+ if (!name.endsWith("_internal"))
+ {
+ // should not occur
+ System.out.println(" FAIL: PropertyVetoException caught: " + e.getMessage());
+ bResult = false;
+ }
+ else
+ {
+ System.out.println(" OK: PropertyVetoException caught: " + e.getMessage() + " it seems not allowed to change internal values.");
+ }
+ }
+
+ // check if changed
+ Object checkVal3 = xFPS.getFastPropertyValue(handle);
+ if (!checkPaths(checkVal3, oValues))
+ {
+ System.out.println(" FAIL: Can't change value back to original on property " + name);
+ bResult = false;
+ }
+ }
+ catch (com.sun.star.uno.Exception e)
+ {
+ System.out.println(" FAIL: getFastPropertyValue(handle:=" + handle + ", name:='" + name + "')" + e.getMessage());
+ bResult = false;
+ }
+ return bResult;
+ }
+
+ private boolean checkStringProperty(Property property)
+ {
+ boolean bResult = true;
+ XFastPropertySet xFPS = UnoRuntime.queryInterface(XFastPropertySet.class, aPathSettings);
+ String name = property.Name;
+ int handle = property.Handle;
+ Object oValue;
+ try
+ {
+ oValue = xFPS.getFastPropertyValue(handle);
+ }
+ catch (UnknownPropertyException ex)
+ {
+ return false;
+ }
+ catch (WrappedTargetException ex)
+ {
+ return false;
+ }
+
+
+ try
+ {
+ String val = "";
+ val = AnyConverter.toString(oValue);
+ System.out.println(" Property has initial value: '" + val + "'");
+
+ // set to a new correct value
+ String newVal = changeToCorrectValue(val);
+ System.out.println(" Try to change to a correct value '" + newVal + "'");
+ xFPS.setFastPropertyValue(handle, newVal);
+
+ // check the change
+ String checkVal = (String) xFPS.getFastPropertyValue(handle);
+ if (!checkPaths(checkVal, newVal))
+ {
+ System.out.println(" FAIL: Did not change value on property " + name + ".");
+ bResult = false;
+ }
+ newVal = changeToIncorrectValue(val);
+ System.out.println(" Try to change to incorrect value '" + newVal + "'");
+ try
+ {
+ xFPS.setFastPropertyValue(handle, newVal);
+ }
+ catch (com.sun.star.lang.IllegalArgumentException e)
+ {
+ System.out.println(" Correctly thrown Exception caught.");
+ }
+
+ // check if changed
+ String checkVal2 = (String) xFPS.getFastPropertyValue(handle);
+ if (!checkPaths(checkVal2, checkVal))
+ {
+ System.out.println(" FAIL: Value did change on property " + name + " though it should not have.");
+ bResult = false;
+ }
+ else
+ {
+ System.out.println(" OK: Incorrect value was not set.");
+ }
+ // set back to initial setting
+ System.out.println(" Set back to initial value.");
+ try
+ {
+ xFPS.setFastPropertyValue(handle, val);
+ }
+ catch (com.sun.star.lang.IllegalArgumentException e)
+ {
+ System.out.println(" IllegalArgumentException caught: " + e.getMessage());
+ bResult = false;
+ }
+ // check if changed
+ String checkVal3 = (String) xFPS.getFastPropertyValue(handle);
+ if (!checkVal3.equals(val))
+ {
+ if (!checkPaths(checkVal3, val))
+ {
+ System.out.println(" FAIL: Can't change value back to original on property " + name);
+ System.out.println(" Value is: " + checkVal3);
+
+ bResult = false;
+ }
+ else
+ {
+ System.out.println(" OK: the pathsettings contains the original path.");
+ System.out.println(" Value is: " + checkVal3);
+ System.out.println(" Value should be: " + val);
+ }
+ }
+ else
+ {
+ System.out.println(" OK: Change value back to original on property " + name);
+ }
+ }
+ catch (com.sun.star.uno.Exception e)
+ {
+ System.out.println(" FAIL: getFastPropertyValue(handle:=" + handle + ", name:='" + name + "')" + e.getMessage());
+ bResult = false;
+ }
+ return bResult;
+ }
+
+ // ____________________
+ /**
+ * This tests the XMultiPropertySet interface implementation.
+ */
+
+ // The test checkXMultiPropertySet() has been marked as outdated!
+
+// @Test
+// public void checkXMultiPropertySet()
+// {
+// System.out.println("---- Testing the XMultiPropertySet interface ----");
+// XMultiPropertySet xMPS = UnoRuntime.queryInterface(XMultiPropertySet.class, aPathSettings);
+//
+// // xPropertyInfoOfPathSettings.length
+// String[] propertiesToTest = new String[1];
+// propertiesToTest[0] = availablePropNames[0];
+//
+// String[] correctVals = new String[propertiesToTest.length];
+// String[] incorrectVals = new String[propertiesToTest.length];
+//
+// String[] aPathSettingWorkingNames = null;
+// aPathSettingWorkingNames = new String[propertiesToTest.length];
+//
+// // get intitial values and create new ones
+// for (int i = 0; i < propertiesToTest.length; i++)
+// {
+// // Property aProp = aListOfWorkingProperty.get(i);
+// final String sName = propertiesToTest[i];
+// final String sValue = getPropertyValueAsString(sName);
+// aPathSettingWorkingNames[i] = sName;
+// correctVals[i] = changeToCorrectValue(sValue);
+// incorrectVals[i] = changeToIncorrectValue(sValue);
+// }
+//
+// try
+// {
+// // add a change listener
+// MyChangeListener mListener = new MyChangeListener();
+// xMPS.addPropertiesChangeListener(aPathSettingWorkingNames, mListener);
+//
+// // first change xPropertyInfoOfPathSettings to correct values
+// System.out.println("Change to correct values.");
+// xMPS.setPropertyValues(aPathSettingWorkingNames, correctVals);
+// assertTrue("Could not change to correct values with XMultiPropertySet.",
+// verifyPropertySet(xMPS, aPathSettingWorkingNames, correctVals) > 0);
+//
+// // second, change to incorrect values: expect an exception
+// System.out.println("Try to change to incorrect values.");
+// try
+// {
+// xMPS.setPropertyValues(aPathSettingWorkingNames, incorrectVals);
+// }
+// catch (com.sun.star.lang.IllegalArgumentException r)
+// {
+// System.out.println("Correctly thrown Exception caught.");
+// }
+// assertTrue("Did change to incorrect values with XMultiPropertySet,"
+// + " but should not have.",
+// verifyPropertySet(xMPS, aPathSettingWorkingNames, correctVals) > 0);
+//
+// // third, change back to initial values
+// System.out.println("Change back to initial values.");
+// xMPS.setPropertyValues(aPathSettingWorkingNames, aPathSettingValues);
+// assertTrue("Could not change back to initial values with"
+// + " XMultiPropertySet.",
+// verifyPropertySet(xMPS, aPathSettingWorkingNames, aPathSettingValues) > 0);
+//
+// // fire the event for the listener
+// System.out.println("Fire event.");
+// xMPS.firePropertiesChangeEvent(aPathSettingWorkingNames, mListener);
+// assertTrue("Event was not fired on XMultiPropertySet.",
+// mListener.changePropertiesEventFired());
+// }
+// catch (com.sun.star.uno.Exception e)
+// {
+//// e.printStackTrace();
+// System.out.println(e.getClass().getName());
+// System.out.println("Message: " + e.getMessage());
+// fail("Unexpected exception on XMultiPropertySet.");
+// }
+//
+// // test finished
+// System.out.println("---- Test of XMultiPropertySet finished ----\n");
+// }
+
+ /**
+ * Verify if the values of xPropSet_of_PathSettings are the same as vals.
+ * @param xPropSet_of_PathSettings A XMultiPropertySet.
+ * @param aPathSettingWorkingNames 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)
+// {
+// System.out.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)
+// {
+// System.out.println("Property '" + propNames[i]
+// + "' was supposed to have value:");
+// System.out.println(vals[i]);
+// System.out.println("but has value:");
+// System.out.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.
+ */
+
+// The test checkXPropertySet() has been marked as outdated!
+
+
+// @Test
+// public void checkXPropertySet()
+// {
+// System.out.println("---- Testing the XPropertySet interface ----");
+//
+// XPropertySet xPS = UnoRuntime.queryInterface(XPropertySet.class, aPathSettings);
+//
+// MyChangeListener mListener1 = new MyChangeListener();
+// MyChangeListener mListener2 = new MyChangeListener();
+//
+// for (int i = 0; i < xPropertyInfoOfPathSettings.length; i++)
+// {
+// // adding listeners
+// String name = aPathSettingNames[i];
+// System.out.println("Testing property '" + name + "'");
+// try
+// {
+// System.out.println("Add 2 Listeners.");
+// xPS.addPropertyChangeListener(name, mListener1);
+// xPS.addVetoableChangeListener(name, mListener1);
+// xPS.addPropertyChangeListener(name, mListener2);
+// xPS.addVetoableChangeListener(name, mListener2);
+//
+// // change the property
+// System.out.println("Change value.");
+// String changeVal = changeToCorrectValue(aPathSettingValues[i]);
+// xPS.setPropertyValue(name, changeVal);
+// String newVal = (String) xPS.getPropertyValue(name);
+//
+// assertTrue("Value did not change on property " + name + ".",
+// newVal.equals(changeVal));
+//
+// assertTrue("Listener 1 was not called.", checkListener(mListener1));
+// assertTrue("Listener 2 was not called.", checkListener(mListener2));
+//
+// mListener1.resetListener();
+// mListener2.resetListener();
+//
+// System.out.println("Remove Listener 1.");
+//
+// xPS.removePropertyChangeListener(name, mListener1);
+// xPS.removeVetoableChangeListener(name, mListener1);
+//
+// // change the property
+// System.out.println("Change value back.");
+// xPS.setPropertyValue(name, aPathSettingValues[i]);
+// newVal = (String) xPS.getPropertyValue(name);
+// assertTrue("Value did not change on property " + name,
+// newVal.equals(aPathSettingValues[i]));
+//
+// assertTrue("Listener was called, although it was removed on"
+// + " property " + name + ".", !checkListener(mListener1));
+// assertTrue("Listener 2 was not called on property " + name + ".",
+// checkListener(mListener2));
+// }
+// catch (com.sun.star.uno.Exception e)
+// {
+// System.out.println(e.getClass().getName());
+// System.out.println("Message: " + e.getMessage());
+// fail("Unexpcted exception on property " + name);
+// }
+// System.out.println("Finish testing property '" + aPathSettingNames[i] + "'\n");
+// }
+// System.out.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(""))
+ {
+ String sTempDir = System.getProperty("java.io.tmpdir");
+ sTempDir = util.utils.getFullURL(sTempDir);
+ return sTempDir; // "file:///tmp";
+ }
+ return graphical.FileHelper.appendPath(path, "tmp");
+ }
+
+ /**
+ * Change the given String to an incorrect path URL.
+ * @return The changed path URL.
+ */
+ private String changeToIncorrectValue(String path)
+ {
+ // return an illegal path
+ 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;
+ }
+ }
+
+ private XMultiServiceFactory getMSF()
+ {
+ final XMultiServiceFactory xMSF1 = UnoRuntime.queryInterface(XMultiServiceFactory.class, connection.getComponentContext().getServiceManager());
+ return xMSF1;
+ }
+
+ // setup and close connections
+ @BeforeClass
+ public static void setUpConnection() throws Exception
+ {
+ System.out.println("setUpConnection()");
+ connection.setUp();
+ }
+
+ @AfterClass
+ public static void tearDownConnection()
+ throws InterruptedException, com.sun.star.uno.Exception
+ {
+ System.out.println("tearDownConnection()");
+ connection.tearDown();
+ }
+ private static final OfficeConnection connection = new OfficeConnection();
+}
diff --git a/framework/qa/complex/path_settings/makefile.mk b/framework/qa/complex/path_settings/makefile.mk
new file mode 100755
index 000000000000..05900d46e190
--- /dev/null
+++ b/framework/qa/complex/path_settings/makefile.mk
@@ -0,0 +1,62 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+.IF "$(OOO_SUBSEQUENT_TESTS)" == ""
+nothing .PHONY:
+# @echo "OOO_SUBSEQUENT_TESTS not set, do nothing."
+.ELSE
+
+PRJ = ../../..
+PRJNAME = framework
+TARGET = qa_complex_path_settings
+
+.IF "$(OOO_JUNIT_JAR)" != ""
+PACKAGE = complex/path_settings
+
+# here store only Files which contain a @Test
+JAVATESTFILES = \
+ PathSettingsTest.java
+
+# put here all other files
+JAVAFILES = $(JAVATESTFILES)
+
+JARFILES = OOoRunner.jar ridl.jar test.jar unoil.jar
+EXTRAJARFILES = $(OOO_JUNIT_JAR)
+
+# Sample how to debug
+# JAVAIFLAGS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=9003,suspend=y
+
+.END
+
+.INCLUDE: settings.mk
+.INCLUDE: target.mk
+.INCLUDE: installationtest.mk
+
+ALLTAR : javatest
+
+.END
+
diff --git a/framework/qa/complex/path_substitution/PathSubstitutionTest.java b/framework/qa/complex/path_substitution/PathSubstitutionTest.java
new file mode 100755
index 000000000000..aeea9907e6bc
--- /dev/null
+++ b/framework/qa/complex/path_substitution/PathSubstitutionTest.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.path_substitution;
+
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.util.XStringSubstitution;
+
+import java.util.Vector;
+
+// ---------- junit imports -----------------
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.openoffice.test.OfficeConnection;
+import static org.junit.Assert.*;
+// ------------------------------------------
+
+/**
+ *
+ */
+public class PathSubstitutionTest
+{
+
+ 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
+ */
+ @Before 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.
+ */
+ @Test public void checkXStringSubstitution()
+ {
+ xMSF = getMSF();
+ System.out.println("---- Testing the XStringSubstitution interface ----");
+ System.out.println("Create intance of test object.\n");
+ XStringSubstitution oObj = null;
+ try
+ {
+ Object x = xMSF.createInstance(
+ "com.sun.star.util.PathSubstitution");
+ oObj = UnoRuntime.queryInterface(XStringSubstitution.class, x);
+ if (oObj == null)
+ {
+ throw new com.sun.star.uno.Exception();
+ }
+ }
+ catch (com.sun.star.uno.Exception e)
+ {
+ System.out.println(e.getClass().getName());
+ System.out.println("Message: " + e.getMessage());
+ fail("Could not create an instance of the test object.");
+ return;
+ }
+
+// initialize();
+
+ for (int i = 0; i < substVars.size(); i++)
+ {
+ String var = substVars.getVariable(i);
+ System.out.println("Testing var '" + var + "'");
+ try
+ {
+ String substVal = oObj.getSubstituteVariableValue(var);
+ System.out.println("\tvalue '" + substVal + "'");
+ substVars.putValue(i, substVal);
+
+ // simple check: let path in a string replace
+ String substString = var + "/additional/path";
+
+ System.out.println("Substitute '" + substString + "'");
+ String newValue = oObj.substituteVariables(substString, true);
+ System.out.println("Return value '" + newValue + "'");
+ // 2do: better check for correct substitution
+ assertTrue("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";
+
+ System.out.println("Substitute backwards '" + substString + "'");
+ newValue = oObj.reSubstituteVariables(substString);
+ System.out.println("Return value '" + newValue + "'");
+ // 2do: better check for correct substitution
+ assertTrue("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";
+
+ System.out.println("Substitute '" + substString + "'");
+ newValue = oObj.substituteVariables(substString, false);
+ System.out.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;
+ }
+ assertTrue("Did not substitute '"
+ + substString + "' to '" + newValue
+ + "' correctly:", erg);
+
+ }
+ catch (com.sun.star.uno.Exception e)
+ {
+ System.out.println(e.getClass().getName());
+ System.out.println("Message: " + e.getMessage());
+ fail("Could not create an instance of the test object.");
+ return;
+ }
+ System.out.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))
+ {
+ System.out.println("Greedy ReSubstitute");
+ String substString = progPth + "/additional/path";
+ String newVal = oObj.reSubstituteVariables(substString);
+ System.out.println("String '" + substString
+ + "' should be resubstituted with");
+ System.out.println("Variable '" + prog + "' instead of Variable '"
+ + inst + "'");
+ assertTrue("Did not reSubstitute '" + substString
+ + "' to '" + newVal + "' correctly:",
+ newVal.startsWith(prog));
+ }
+
+ System.out.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();
+ }
+ }
+
+ private XMultiServiceFactory getMSF()
+ {
+ final XMultiServiceFactory xMSF1 = UnoRuntime.queryInterface(XMultiServiceFactory.class, connection.getComponentContext().getServiceManager());
+ return xMSF1;
+ }
+
+ // setup and close connections
+ @BeforeClass
+ public static void setUpConnection() throws Exception
+ {
+ System.out.println("setUpConnection()");
+ connection.setUp();
+ }
+
+ @AfterClass
+ public static void tearDownConnection()
+ throws InterruptedException, com.sun.star.uno.Exception
+ {
+ System.out.println("tearDownConnection()");
+ connection.tearDown();
+ }
+ private static final OfficeConnection connection = new OfficeConnection();
+}
diff --git a/framework/qa/complex/path_substitution/makefile.mk b/framework/qa/complex/path_substitution/makefile.mk
new file mode 100755
index 000000000000..338affbf70d7
--- /dev/null
+++ b/framework/qa/complex/path_substitution/makefile.mk
@@ -0,0 +1,122 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+.IF "$(OOO_SUBSEQUENT_TESTS)" == ""
+nothing .PHONY:
+.ELSE
+
+PRJ = ../../..
+PRJNAME = framework
+TARGET = qa_complex_path_substitution
+
+.IF "$(OOO_JUNIT_JAR)" != ""
+PACKAGE = complex/path_substitution
+
+# here store only Files which contain a @Test
+JAVATESTFILES = \
+ PathSubstitutionTest.java
+
+# put here all other files
+JAVAFILES = $(JAVATESTFILES)
+
+JARFILES = OOoRunner.jar ridl.jar test.jar unoil.jar
+EXTRAJARFILES = $(OOO_JUNIT_JAR)
+
+# Sample how to debug
+# JAVAIFLAGS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=9003,suspend=y
+
+.END
+
+.INCLUDE: settings.mk
+.INCLUDE: target.mk
+.INCLUDE: installationtest.mk
+
+ALLTAR : javatest
+
+.END
+
+
+#
+#
+#
+#
+# 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/unoapi/Test.java b/framework/qa/unoapi/Test.java
new file mode 100644
index 000000000000..da9bb3bd5020
--- /dev/null
+++ b/framework/qa/unoapi/Test.java
@@ -0,0 +1,51 @@
+/*************************************************************************
+* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+*
+* Copyright 2000, 2010 Oracle and/or its affiliates.
+*
+* OpenOffice.org - a multi-platform office productivity suite
+*
+* This file is part of OpenOffice.org.
+*
+* OpenOffice.org is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License version 3
+* only, as published by the Free Software Foundation.
+*
+* OpenOffice.org is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License version 3 for more details
+* (a copy is included in the LICENSE file that accompanied this code).
+*
+* You should have received a copy of the GNU Lesser General Public License
+* version 3 along with OpenOffice.org. If not, see
+* <http://www.openoffice.org/license.html>
+* for a copy of the LGPLv3 License.
+************************************************************************/
+
+package org.openoffice.framework.qa.unoapi;
+
+import org.openoffice.Runner;
+import org.openoffice.test.OfficeConnection;
+import static org.junit.Assert.*;
+
+public final class Test {
+ @org.junit.Before public void setUp() throws Exception {
+ connection.setUp();
+ }
+
+ @org.junit.After public void tearDown()
+ throws InterruptedException, com.sun.star.uno.Exception
+ {
+ connection.tearDown();
+ }
+
+ @org.junit.Test public void test() {
+ assertTrue(
+ Runner.run(
+ "-sce", "framework.sce", "-xcl", "knownissues.xcl", "-tdoc",
+ "testdocuments", "-cs", connection.getDescription()));
+ }
+
+ private final OfficeConnection connection = new OfficeConnection();
+}
diff --git a/framework/qa/unoapi/framework.sce b/framework/qa/unoapi/framework.sce
new file mode 100755
index 000000000000..76f3d1b089ac
--- /dev/null
+++ b/framework/qa/unoapi/framework.sce
@@ -0,0 +1,35 @@
+-o fwl.ContentHandlerFactory
+-o fwl.FilterFactory
+-o fwl.FrameLoaderFactory
+-o fwl.SubstituteVariables
+#i113245 -o fwl.TypeDetection
+#i84346 -o fwl.PathSettings
+-o fwk.DispatchRecorder
+-o fwk.DispatchRecorderSupplier
+-o fwk.FooterMenuController
+-o fwk.ObjectMenuController
+-o fwk.StatusBarControllerFactory
+-o fwk.ToolBarsMenuController
+-o fwk.UICategoryDescription
+#i84423 -o fwk.JobExecutor
+#i84423 -o fwk.JobHandler
+-o fwk.MailToDispatcher
+-o fwk.ServiceHandler
+-o fwk.URLTransformer
+-o fwk.MacrosMenuController
+#i112746 -o fwk.ModuleManager
+-o fwk.UIElementFactoryManager
+-o fwk.UICommandDescription
+-o fwk.LayoutManager
+-o fwk.UIConfigurationManager
+-o fwk.MenuBarFactory
+-o fwk.FontSizeMenuController
+-o fwk.HeaderMenuController
+-o fwk.ControlMenuController
+-o fwk.FontMenuController
+-o fwk.ModuleUIConfigurationManagerSupplier
+-o fwk.ModuleUIConfigurationManager
+#i84321 -o fwk.PopupMenuControllerFactory
+#i88644 -o fwk.Frame
+-o fwk.Desktop
+
diff --git a/framework/qa/unoapi/knownissues.xcl b/framework/qa/unoapi/knownissues.xcl
new file mode 100755
index 000000000000..40f1965de639
--- /dev/null
+++ b/framework/qa/unoapi/knownissues.xcl
@@ -0,0 +1,59 @@
+### 112552 ###
+fwk.JobHandler::com::sun::star::frame::XDispatchProvider
+fwk.JobHandler::com::sun::star::lang::XInitialization
+
+### i8242 ###
+fwk.Desktop::com::sun::star::lang::XComponent
+
+### i30570 ###
+fwl.TypeDetection::com::sun::star::container::XNameReplace
+
+### i50165 ###
+fwk.UIConfigurationManager::com::sun::star::ui::XUIConfigurationStorage
+fwk.UIConfigurationManager::com::sun::star::ui::XUIConfigurationPersistence
+fwk.UIConfigurationManager::com::sun::star::ui::XUIConfiguration
+fwk.UIConfigurationManager::com::sun::star::ui::XUIConfigurationManager
+
+### i50578 ###
+fwk.StatusBarControllerFactory::com::sun::star::lang::XMultiComponentFactory
+
+### i68698 ###
+fwl.PathSettings::com::sun::star::beans::XMultiPropertySet
+
+### i74020 ###
+fwl.FilterFactory::com::sun::star::lang::XMultiServiceFactory
+
+### i30570 ###
+fwl.FilterFactory::com::sun::star::container::XNameReplace
+
+### i84321 ###
+fwk.PopupMenuControllerFactory
+# -> disabled in framework.sce
+
+### i84346 ###
+fwl.PathSettings::com::sun::star::beans::XMultiPropertySet
+#-> disabled in framework.sce
+
+### i84423 ###
+fwk.JobExecutor
+fwk.JobHandler
+#-> disabled in framework.sce
+
+### i88635 ###
+fwk.Desktop::com::sun::star::frame::XFramesSupplier
+
+### i87526 ###
+fwk.Frame::com::sun::star::lang::XComponent
+
+### i87865 ###
+fwk.Desktop::com::sun::star::frame::XDesktop
+
+### i88644 ###
+fwk.Frame
+#-> disabled in framework.sce
+
+### i90345 ###
+fwk.URLTransformer::com::sun::star::util::XURLTransformer
+
+### i111180 ###
+fwk.Desktop::com::sun::star::frame::XComponentLoader
diff --git a/framework/qa/unoapi/makefile.mk b/framework/qa/unoapi/makefile.mk
new file mode 100755
index 000000000000..38a6cf7cced8
--- /dev/null
+++ b/framework/qa/unoapi/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.
+#***********************************************************************/
+
+.IF "$(OOO_SUBSEQUENT_TESTS)" == ""
+nothing .PHONY:
+.ELSE
+
+PRJ = ../..
+PRJNAME = framework
+TARGET = qa_unoapi
+
+.IF "$(OOO_JUNIT_JAR)" != ""
+PACKAGE = org/openoffice/framework/qa/unoapi
+JAVATESTFILES = Test.java
+JAVAFILES = $(JAVATESTFILES)
+JARFILES = OOoRunner.jar ridl.jar test.jar
+EXTRAJARFILES = $(OOO_JUNIT_JAR)
+.END
+
+.INCLUDE: settings.mk
+.INCLUDE: target.mk
+.INCLUDE: installationtest.mk
+
+ALLTAR : javatest
+
+.END
diff --git a/framework/qa/unoapi/testdocuments/Calc_Link.sxc b/framework/qa/unoapi/testdocuments/Calc_Link.sxc
new file mode 100644
index 000000000000..086c04fe0480
--- /dev/null
+++ b/framework/qa/unoapi/testdocuments/Calc_Link.sxc
Binary files differ
diff --git a/framework/qa/unoapi/testdocuments/Writer_link.sxw b/framework/qa/unoapi/testdocuments/Writer_link.sxw
new file mode 100644
index 000000000000..5e5c8bdcb829
--- /dev/null
+++ b/framework/qa/unoapi/testdocuments/Writer_link.sxw
Binary files differ
diff --git a/framework/qa/unoapi/testdocuments/XTypeDetection.sxw b/framework/qa/unoapi/testdocuments/XTypeDetection.sxw
new file mode 100644
index 000000000000..b241f4ed87b6
--- /dev/null
+++ b/framework/qa/unoapi/testdocuments/XTypeDetection.sxw
Binary files differ
diff --git a/framework/qa/unoapi/testdocuments/delete.cfg b/framework/qa/unoapi/testdocuments/delete.cfg
new file mode 100755
index 000000000000..31fef95a0d47
--- /dev/null
+++ b/framework/qa/unoapi/testdocuments/delete.cfg
Binary files differ