summaryrefslogtreecommitdiff
path: root/qadevOOo/runner/util
diff options
context:
space:
mode:
Diffstat (limited to 'qadevOOo/runner/util')
-rw-r--r--qadevOOo/runner/util/AccessibilityTools.java461
-rw-r--r--qadevOOo/runner/util/BasicMacroTools.java261
-rw-r--r--qadevOOo/runner/util/BookmarkDsc.java84
-rw-r--r--qadevOOo/runner/util/CalcTools.java160
-rw-r--r--qadevOOo/runner/util/ControlDsc.java80
-rw-r--r--qadevOOo/runner/util/DBTools.java824
-rw-r--r--qadevOOo/runner/util/DefaultDsc.java81
-rw-r--r--qadevOOo/runner/util/DesktopTools.java515
-rw-r--r--qadevOOo/runner/util/DrawTools.java162
-rw-r--r--qadevOOo/runner/util/DynamicClassLoader.java123
-rw-r--r--qadevOOo/runner/util/FootnoteDsc.java84
-rw-r--r--qadevOOo/runner/util/FormTools.java349
-rw-r--r--qadevOOo/runner/util/FrameDsc.java126
-rw-r--r--qadevOOo/runner/util/InstCreator.java122
-rw-r--r--qadevOOo/runner/util/InstDescr.java53
-rw-r--r--qadevOOo/runner/util/ParagraphDsc.java85
-rw-r--r--qadevOOo/runner/util/PropertyName.java169
-rw-r--r--qadevOOo/runner/util/ReferenceMarkDsc.java84
-rw-r--r--qadevOOo/runner/util/RegistryTools.java370
-rw-r--r--qadevOOo/runner/util/SOfficeFactory.java629
-rw-r--r--qadevOOo/runner/util/ShapeDsc.java101
-rw-r--r--qadevOOo/runner/util/StyleFamilyDsc.java80
-rw-r--r--qadevOOo/runner/util/SysUtils.java153
-rw-r--r--qadevOOo/runner/util/TableDsc.java96
-rw-r--r--qadevOOo/runner/util/TextSectionDsc.java84
-rw-r--r--qadevOOo/runner/util/UITools.java814
-rw-r--r--qadevOOo/runner/util/ValueChanger.java994
-rw-r--r--qadevOOo/runner/util/ValueComparer.java266
-rw-r--r--qadevOOo/runner/util/WaitUnreachable.java127
-rw-r--r--qadevOOo/runner/util/WriterTools.java121
-rw-r--r--qadevOOo/runner/util/XInstCreator.java38
-rw-r--r--qadevOOo/runner/util/XLayerHandlerImpl.java119
-rw-r--r--qadevOOo/runner/util/XLayerImpl.java45
-rw-r--r--qadevOOo/runner/util/XMLTools.java939
-rw-r--r--qadevOOo/runner/util/XSchemaHandlerImpl.java137
-rw-r--r--qadevOOo/runner/util/compare/DocComparator.java52
-rw-r--r--qadevOOo/runner/util/compare/DocComparatorFactory.java64
-rw-r--r--qadevOOo/runner/util/compare/GraphicalComparator.java260
-rw-r--r--qadevOOo/runner/util/compare/PDFComparator.java62
-rw-r--r--qadevOOo/runner/util/compare/XMLComparator.java58
-rw-r--r--qadevOOo/runner/util/compare/makefile.mk54
-rw-r--r--qadevOOo/runner/util/db/DataSource.java163
-rw-r--r--qadevOOo/runner/util/db/DataSourceDescriptor.java74
-rw-r--r--qadevOOo/runner/util/db/DatabaseDocument.java90
-rw-r--r--qadevOOo/runner/util/dbg.java347
-rw-r--r--qadevOOo/runner/util/makefile.mk87
-rw-r--r--qadevOOo/runner/util/utils.java1020
47 files changed, 11267 insertions, 0 deletions
diff --git a/qadevOOo/runner/util/AccessibilityTools.java b/qadevOOo/runner/util/AccessibilityTools.java
new file mode 100644
index 000000000000..3fb964a2362b
--- /dev/null
+++ b/qadevOOo/runner/util/AccessibilityTools.java
@@ -0,0 +1,461 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package util;
+
+import com.sun.star.accessibility.XAccessible;
+import com.sun.star.accessibility.XAccessibleComponent;
+import com.sun.star.accessibility.XAccessibleContext;
+import com.sun.star.awt.XWindow;
+import com.sun.star.frame.XController;
+import com.sun.star.frame.XFrame;
+import com.sun.star.frame.XModel;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XInterface;
+
+import java.io.PrintWriter;
+
+
+public class AccessibilityTools {
+ public static XAccessibleContext SearchedContext = null;
+ public static XAccessible SearchedAccessible = null;
+ private static boolean debug = false;
+
+ public AccessibilityTools() {
+ //done = false;
+ SearchedContext = null;
+ }
+
+ public static XAccessible getAccessibleObject(XInterface xObject) {
+ return UnoRuntime.queryInterface(XAccessible.class, xObject);
+ }
+
+ public static XWindow getCurrentContainerWindow(XMultiServiceFactory msf,
+ XModel xModel) {
+ return getWindow(msf, xModel, true);
+ }
+
+ public static XWindow getCurrentWindow(XMultiServiceFactory msf,
+ XModel xModel) {
+ return getWindow(msf, xModel, false);
+ }
+
+ private static XWindow getWindow(XMultiServiceFactory msf, XModel xModel,
+ boolean containerWindow) {
+ XWindow xWindow = null;
+
+ try {
+ if (xModel == null) {
+ System.out.println("invalid model (==null)");
+ }
+
+ XController xController = xModel.getCurrentController();
+
+ if (xController == null) {
+ System.out.println("can't get controller from model");
+ }
+
+ XFrame xFrame = xController.getFrame();
+
+ if (xFrame == null) {
+ System.out.println("can't get frame from controller");
+ }
+
+ if (containerWindow)
+ xWindow = xFrame.getContainerWindow();
+ else
+ xWindow = xFrame.getComponentWindow();
+
+ if (xWindow == null) {
+ System.out.println("can't get window from frame");
+ }
+ } catch (Exception e) {
+ System.out.println("caught exception while getting current window" + e);
+ }
+
+ return xWindow;
+ }
+
+ public static XAccessibleContext getAccessibleObjectForRole(XAccessible xacc,
+ short role) {
+ SearchedContext = null;
+ SearchedAccessible = null;
+ getAccessibleObjectForRole_(xacc, role);
+
+ return SearchedContext;
+ }
+
+ public static XAccessibleContext getAccessibleObjectForRole(XAccessible xacc,
+ short role,
+ boolean ignoreShowing) {
+ SearchedContext = null;
+ SearchedAccessible = null;
+
+ if (ignoreShowing) {
+ getAccessibleObjectForRoleIgnoreShowing_(xacc, role);
+ } else {
+ getAccessibleObjectForRole_(xacc, role);
+ }
+
+ return SearchedContext;
+ }
+
+ public static void getAccessibleObjectForRoleIgnoreShowing_(XAccessible xacc,
+ short role) {
+ XAccessibleContext ac = xacc.getAccessibleContext();
+
+ if (ac.getAccessibleRole() == role) {
+ SearchedContext = ac;
+ SearchedAccessible = xacc;
+ } else {
+ int k = ac.getAccessibleChildCount();
+
+ if (ac.getAccessibleChildCount() > 100) {
+ k = 50;
+ }
+
+ for (int i = 0; i < k; i++) {
+ try {
+ getAccessibleObjectForRoleIgnoreShowing_(
+ ac.getAccessibleChild(i), role);
+
+ if (SearchedContext != null) {
+ return;
+ }
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
+ System.out.println("Couldn't get Child");
+ }
+ }
+ }
+ }
+
+ public static void getAccessibleObjectForRole_(XAccessible xacc,
+ short role) {
+ XAccessibleContext ac = xacc.getAccessibleContext();
+ boolean isShowing = ac.getAccessibleStateSet()
+ .contains(com.sun.star.accessibility.AccessibleStateType.SHOWING);
+
+ if ((ac.getAccessibleRole() == role) && isShowing) {
+ SearchedContext = ac;
+ SearchedAccessible = xacc;
+ } else {
+ int k = ac.getAccessibleChildCount();
+
+ if (ac.getAccessibleChildCount() > 100) {
+ k = 50;
+ }
+
+ for (int i = 0; i < k; i++) {
+ try {
+ getAccessibleObjectForRole_(ac.getAccessibleChild(i), role);
+
+ if (SearchedContext != null) {
+ return;
+ }
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
+ System.out.println("Couldn't get Child");
+ }
+ }
+ }
+ }
+
+ public static XAccessibleContext getAccessibleObjectForRole(XAccessible xacc,
+ short role,
+ String name) {
+ return getAccessibleObjectForRole(xacc, role, name, "");
+ }
+
+ public static XAccessibleContext getAccessibleObjectForRole(XAccessible xacc,
+ short role,
+ String name,
+ boolean ignoreShowing) {
+ if (ignoreShowing) {
+ return getAccessibleObjectForRoleIgnoreShowing(xacc, role, name,
+ "");
+ } else {
+ return getAccessibleObjectForRole(xacc, role, name, "");
+ }
+ }
+
+ public static XAccessibleContext getAccessibleObjectForRoleIgnoreShowing(XAccessible xacc,
+ short role,
+ String name,
+ String implName) {
+ XAccessibleContext ac = xacc.getAccessibleContext();
+ if ((ac.getAccessibleRole() == role) &&
+ (ac.getAccessibleName().indexOf(name) > -1) &&
+ (utils.getImplName(ac).indexOf(implName) > -1)) {
+ SearchedAccessible = xacc;
+
+ //System.out.println("FOUND the desired component -- "+ ac.getAccessibleName() +isShowing);
+ return ac;
+ } else {
+ int k = ac.getAccessibleChildCount();
+
+ if (ac.getAccessibleChildCount() > 100) {
+ k = 50;
+ }
+
+ for (int i = 0; i < k; i++) {
+ try {
+ XAccessibleContext ac1 = getAccessibleObjectForRoleIgnoreShowing(
+ ac.getAccessibleChild(i),
+ role, name, implName);
+
+ if (ac1 != null) {
+ return ac1;
+ }
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
+ System.out.println("Couldn't get Child");
+ }
+ }
+ }
+
+ return null;
+ }
+
+ public static XAccessibleContext getAccessibleObjectForRole(XAccessible xacc,
+ short role,
+ String name,
+ String implName) {
+ XAccessibleContext ac = xacc.getAccessibleContext();
+ boolean isShowing = ac.getAccessibleStateSet()
+ .contains(com.sun.star.accessibility.AccessibleStateType.SHOWING);
+
+ // hotfix for i91828:
+ // if role to serach is 0 then ignore the role.
+ if ( (role == 0 || ac.getAccessibleRole() == role) &&
+ (ac.getAccessibleName().indexOf(name) > -1) &&
+ (utils.getImplName(ac).indexOf(implName) > -1) &&
+ isShowing) {
+ SearchedAccessible = xacc;
+ //System.out.println("FOUND the desired component -- "+ ac.getAccessibleName() +isShowing);
+ return ac;
+ } else {
+ int k = ac.getAccessibleChildCount();
+
+ if (ac.getAccessibleChildCount() > 100) {
+ k = 50;
+ }
+
+ for (int i = 0; i < k; i++) {
+ try {
+ XAccessibleContext ac1 = getAccessibleObjectForRole(
+ ac.getAccessibleChild(i),
+ role, name, implName);
+
+ if (ac1 != null) {
+ return ac1;
+ }
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
+ System.out.println("Couldn't get Child");
+ }
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * This methods retunrs the <CODE>XAccessibleContext</CODE> of a named Sheet-Cell like "G5".<p>
+ * @param xSheetAcc The <CODE>XAccessibleContext</CODE> of a Sheet
+ * @param cellName The name of a cell like "A5"
+ * @return the <CODE>XAccessiblecontext</CODE> of the named cell
+ */
+ public static XAccessibleContext getSheetCell(XAccessibleContext xSheetAcc, String cellName){
+
+ int cellIndex = 0;
+ int column =0;
+ int charMem = 0;
+ for (int n=0; n<cellName.length(); n++){
+ String cha = cellName.substring(n,n+1);
+ System.out.println("char: " + cha + " ");
+
+ byte[] bytes = cha.getBytes();
+
+ if ((bytes[0] >= 'A') && (bytes[0] <= 'Z')){
+ charMem = bytes[0]-64;
+ column++;
+ if ( column == 2 ){
+ cellIndex += charMem * 26;
+ }
+ cellIndex= cellIndex+ (bytes[0]-65);
+ } else {
+ String sNumb = cellName.substring(n, cellName.length());
+ int iNumb = new Integer(0).valueOf(sNumb).intValue();
+ cellIndex += (iNumb-1) * 256;
+ System.out.println("numb:" + (iNumb-1) * 256);
+ }
+
+ }
+
+ //System.out.println("cellName: " + cellName + " cellIndex: " + cellIndex);
+
+ try {
+ XAccessibleContext ac = xSheetAcc.getAccessibleChild(cellIndex).getAccessibleContext();
+ System.out.println(ac.getAccessibleRole() + "," +
+ ac.getAccessibleName() + "(" +
+ ac.getAccessibleDescription() + "):" +
+ utils.getImplName(ac));
+
+ return ac;
+ } catch (com.sun.star.lang.IndexOutOfBoundsException ex) {
+ System.out.println("ERROR: could not get child at index " + cellIndex +"': " + ex.toString());
+ return null;
+ }
+ }
+
+ public static void printAccessibleTree(PrintWriter log, XAccessible xacc, boolean debugIsActive) {
+ debug = debugIsActive;
+ if (debug) printAccessibleTree(log, xacc, "");
+ }
+
+ public static void printAccessibleTree(PrintWriter log, XAccessible xacc) {
+ printAccessibleTree(log, xacc, "");
+ }
+
+ protected static void printAccessibleTree(PrintWriter log,
+ XAccessible xacc, String indent) {
+
+ XAccessibleContext ac = xacc.getAccessibleContext();
+
+ logging(log,indent + ac.getAccessibleRole() + "," +
+ ac.getAccessibleName() + "(" +
+ ac.getAccessibleDescription() + "):" +
+ utils.getImplName(ac));
+
+ XAccessibleComponent aComp = (XAccessibleComponent) UnoRuntime.queryInterface(
+ XAccessibleComponent.class, xacc);
+
+ if (aComp != null) {
+ String bounds = "(" + aComp.getBounds().X + "," +
+ aComp.getBounds().Y + ")" + " (" +
+ aComp.getBounds().Width + "," +
+ aComp.getBounds().Height + ")";
+ bounds = "The boundary Rectangle is " + bounds;
+ logging(log,indent + indent + bounds);
+ }
+
+ boolean isShowing = ac.getAccessibleStateSet()
+ .contains(com.sun.star.accessibility.AccessibleStateType.SHOWING);
+ logging(log,indent + indent + "StateType contains SHOWING: " +
+ isShowing);
+
+ int k = ac.getAccessibleChildCount();
+
+ if (ac.getAccessibleChildCount() > 100) {
+ k = 50;
+ }
+
+ for (int i = 0; i < k; i++) {
+ try {
+ printAccessibleTree(log, ac.getAccessibleChild(i),
+ indent + " ");
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
+ System.out.println("Couldn't get Child");
+ }
+ }
+
+ if (ac.getAccessibleChildCount() > 100) {
+ k = ac.getAccessibleChildCount();
+
+ int st = ac.getAccessibleChildCount() - 50;
+ logging(log,indent + " " + " ...... [skipped] ......");
+
+ for (int i = st; i < k; i++) {
+ try {
+ printAccessibleTree(log, ac.getAccessibleChild(i),
+ indent + " ");
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
+ System.out.println("Couldn't get Child");
+ }
+ }
+ }
+ }
+
+ public static String accessibleToString(Object AC) {
+ XAccessibleContext xAC = (XAccessibleContext) UnoRuntime.queryInterface(
+ XAccessibleContext.class, AC);
+
+ if (xAC != null) {
+ return "" + xAC.getAccessibleRole() + "," +
+ xAC.getAccessibleName() + "(" +
+ xAC.getAccessibleDescription() + "):";
+ }
+
+ XAccessible xA = (XAccessible) UnoRuntime.queryInterface(
+ XAccessible.class, AC);
+
+ if (xA == null) {
+ return "(Not supported)";
+ }
+
+ xAC = xA.getAccessibleContext();
+
+ return "" + xAC.getAccessibleRole() + "," + xAC.getAccessibleName() +
+ "(" + xAC.getAccessibleDescription() + ")";
+ }
+
+ public static boolean equals(XAccessible c1, XAccessible c2) {
+ if ((c1 == null) || (c2 == null)) {
+ return c1 == c2;
+ }
+
+ return AccessibilityTools.equals(c1.getAccessibleContext(),
+ c2.getAccessibleContext());
+ }
+
+ public static boolean equals(XAccessibleContext c1, XAccessibleContext c2) {
+ if ((c1 == null) || (c2 == null)) {
+ return c1 == c2;
+ }
+
+ if (c1.getAccessibleRole() != c2.getAccessibleRole()) {
+ return false;
+ }
+
+ if (!c1.getAccessibleName().equals(c2.getAccessibleName())) {
+ return false;
+ }
+
+ if (!c1.getAccessibleDescription()
+ .equals(c2.getAccessibleDescription())) {
+ return false;
+ }
+
+ if (c1.getAccessibleChildCount() != c2.getAccessibleChildCount()) {
+ return false;
+ }
+
+ return AccessibilityTools.equals(c1.getAccessibleParent(),
+ c2.getAccessibleParent());
+ }
+
+ private static void logging(PrintWriter log, String content){
+ if (debug) log.println(content);
+ }
+} \ No newline at end of file
diff --git a/qadevOOo/runner/util/BasicMacroTools.java b/qadevOOo/runner/util/BasicMacroTools.java
new file mode 100644
index 000000000000..0d64779137f7
--- /dev/null
+++ b/qadevOOo/runner/util/BasicMacroTools.java
@@ -0,0 +1,261 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package util;
+
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.container.XNameAccess;
+import com.sun.star.frame.XController;
+import com.sun.star.frame.XDispatch;
+import com.sun.star.frame.XDispatchProvider;
+import com.sun.star.frame.XFrame;
+import com.sun.star.frame.XModel;
+import com.sun.star.lang.XComponent;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.script.XLibraryContainer;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.util.*;
+import com.sun.star.util.URL;
+import com.sun.star.util.XURLTransformer;
+
+
+
+public class BasicMacroTools {
+ private final XDispatchProvider mDispProv;
+ private final XMultiServiceFactory mMSF;
+ private final XURLTransformer mParser;
+ private final XNameAccess mLCxNA; //LibraryContainer::XNameAccess
+ private final XLibraryContainer mLCxLC; //LibraryContainer::XLibraryContainer
+
+ /*
+ *While initializing the Basic Libraries will be appendend to the Document
+ */
+ public BasicMacroTools(XMultiServiceFactory msf, XModel xModel,
+ XComponent xDoc) throws java.lang.Exception {
+ try {
+ mMSF = msf;
+ mDispProv = makeDispatchProvider(mMSF, xModel);
+ mParser = makeParser(mMSF);
+
+ Object DocLibCont = null;
+
+ try {
+ XPropertySet xDocProps = (XPropertySet) UnoRuntime.queryInterface(
+ XPropertySet.class, xDoc);
+ DocLibCont = xDocProps.getPropertyValue("BasicLibraries");
+ } catch (com.sun.star.uno.Exception e) {
+ throw new Exception(
+ "Couldn't get BasicLibraries-Container from document: " + e.toString());
+ }
+
+ mLCxNA = (XNameAccess) UnoRuntime.queryInterface(XNameAccess.class,
+ DocLibCont);
+
+ mLCxLC = (XLibraryContainer) UnoRuntime.queryInterface(
+ XLibraryContainer.class, DocLibCont);
+
+ } catch (Exception e) {
+ throw new Exception("could not initialize BasicMacros " +
+ e.toString());
+ }
+ }
+
+ /*
+ * While initializing the Basic Libraries will be appendend to the Office
+ */
+ public BasicMacroTools(XMultiServiceFactory msf, XModel xModel)
+ throws java.lang.Exception {
+ try {
+ mMSF = msf;
+ mDispProv = makeDispatchProvider(mMSF, xModel);
+ mParser = makeParser(mMSF);
+
+ Object ASLC = null;
+
+ try {
+ ASLC = mMSF.createInstance(
+ "com.sun.star.script.ApplicationScriptLibraryContainer");
+ } catch (com.sun.star.uno.Exception e) {
+ throw new Exception(
+ "Couldn't create ApplicationScriptLibraryContainer" + e.toString());
+ }
+
+ mLCxNA = (XNameAccess) UnoRuntime.queryInterface(XNameAccess.class,
+ ASLC);
+
+ mLCxLC = (XLibraryContainer) UnoRuntime.queryInterface(
+ XLibraryContainer.class, ASLC);
+
+ } catch (Exception e) {
+ throw new Exception("could not initialize BasicMacros " +
+ e.toString());
+ }
+ }
+
+ private static XDispatchProvider makeDispatchProvider(XMultiServiceFactory mMSF,
+ XModel aModel)
+ throws java.lang.Exception {
+ XController xController = aModel.getCurrentController();
+ XFrame xFrame = xController.getFrame();
+
+ if (xFrame == null) {
+ throw new Exception("Could not create DispatchProvider");
+ }
+
+ return (XDispatchProvider) UnoRuntime.queryInterface(
+ XDispatchProvider.class, xFrame);
+ }
+
+ private static XURLTransformer makeParser(XMultiServiceFactory mMSF)
+ throws java.lang.Exception {
+ try {
+ return (com.sun.star.util.XURLTransformer) UnoRuntime.queryInterface(
+ XURLTransformer.class, mMSF.createInstance(
+ "com.sun.star.util.URLTransformer"));
+ } catch (Exception e) {
+ throw new Exception("could not create UTL-Transformer " +
+ e.toString());
+ }
+ }
+
+ public void loadLibrary(String LibraryName, String LibraryURL)
+ throws java.lang.Exception {
+ try {
+ appendLibrary(LibraryName, LibraryURL);
+ } catch (java.lang.Exception e) {
+ e.printStackTrace();
+ throw new Exception("ERROR: Could not append Library " +
+ LibraryName + e.toString());
+ }
+
+ try {
+ mLCxLC.loadLibrary(LibraryName);
+ } catch (com.sun.star.container.NoSuchElementException e) {
+ e.printStackTrace();
+ throw new Exception("ERROR: Could not load Library " +
+ LibraryName + e.toString());
+ } catch (com.sun.star.lang.WrappedTargetException e) {
+ e.printStackTrace();
+ throw new Exception("ERROR: Could not load Library " +
+ LibraryName + e.toString());
+ }
+ }
+
+ private void appendLibrary(String LibraryName, String LibraryURL)
+ throws java.lang.Exception {
+ try {
+ removeLibrary(LibraryName);
+ } catch (java.lang.Exception e) {
+ }
+
+ try {
+ mLCxLC.createLibraryLink(LibraryName, LibraryURL, false);
+ } catch (com.sun.star.container.ElementExistException e) {
+ e.printStackTrace();
+ throw new Exception("ERROR: Library " + LibraryName +
+ "already exist." + e.toString());
+ } catch (com.sun.star.uno.Exception e) {
+ e.printStackTrace();
+ throw new Exception("Could not link Basic library:" +
+ LibraryName + e.toString());
+ }
+ }
+
+ public void removeLibrary(String LibraryName) throws java.lang.Exception {
+ if (mLCxNA.hasByName(LibraryName)) {
+ try {
+ mLCxLC.removeLibrary(LibraryName);
+ } catch (com.sun.star.container.NoSuchElementException e) {
+ e.printStackTrace();
+ throw new Exception("Could not remove Basic library:" +
+ LibraryName + ": Library does not exist" + e.toString());
+ } catch (com.sun.star.lang.WrappedTargetException e) {
+ e.printStackTrace();
+ throw new Exception("Could not remove Basic library:" +
+ LibraryName + e.toString());
+ }
+ }
+ }
+
+ public void runMarco(String MacroName) throws java.lang.Exception {
+ URL[] aParseURL = new URL[1];
+ aParseURL[0] = new URL();
+ aParseURL[0].Complete = "macro://./" + MacroName; //Standard.Stock.GetSymbol('micro','')";
+ mParser.parseStrict(aParseURL);
+
+ URL aURL = aParseURL[0];
+ XDispatch xDispatcher = mDispProv.queryDispatch(aURL, "", 0);
+
+ if (xDispatcher != null) {
+ xDispatcher.dispatch(aURL, null);
+ } else {
+ throw new Exception("Could not run Macro " + MacroName);
+ }
+ }
+
+ /**
+ * Set the given <CODE>secureURL</CODE> as secure URL for marco execution.
+ * The macros of documents located in <CODE>secureURL</CODE> will be executed
+ * automatically.
+ * @param xMSF the XMultiServiceFactory
+ * @param secureURL the URL the documet is located
+ * @throws java.lang.Exception throws this exception on any error
+ */
+ public static void addSecureBasicMarcosURL(XMultiServiceFactory xMSF, String secureURL)
+ throws Exception {
+
+ secureURL = utils.getFullURL(secureURL);
+
+ // configure Office to allow to execute macos
+ PropertyValue[] ProvArgs = new PropertyValue [1];
+ PropertyValue Arg = new PropertyValue();
+ Arg.Name = "nodepath";
+ Arg.Value = "/org.openoffice.Office.Common/Security";
+ ProvArgs[0] = Arg;
+
+ Object oProvider = xMSF.createInstance("com.sun.star.configuration.ConfigurationProvider");
+
+
+ XMultiServiceFactory oProviderMSF = (XMultiServiceFactory)
+ UnoRuntime.queryInterface(XMultiServiceFactory.class, oProvider);
+
+ Object oSecure = oProviderMSF.createInstanceWithArguments(
+ "com.sun.star.configuration.ConfigurationUpdateAccess",
+ ProvArgs);
+
+ XPropertySet oSecureProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, oSecure);
+
+ Object oScripting = oSecureProps.getPropertyValue("Scripting");
+ XPropertySet oScriptingSettings = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, oScripting);
+
+ oScriptingSettings.setPropertyValue("SecureURL", new String[]{secureURL});
+ oScriptingSettings.setPropertyValue("OfficeBasic", new Integer(2));
+
+ XChangesBatch oSecureChange = (XChangesBatch) UnoRuntime.queryInterface(XChangesBatch.class, oSecure);
+ oSecureChange.commitChanges();
+ }
+}
diff --git a/qadevOOo/runner/util/BookmarkDsc.java b/qadevOOo/runner/util/BookmarkDsc.java
new file mode 100644
index 000000000000..5929192ac1df
--- /dev/null
+++ b/qadevOOo/runner/util/BookmarkDsc.java
@@ -0,0 +1,84 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package util;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.uno.XInterface;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.text.XTextContent;
+
+/**
+ * describes a Bookmark to be inserted in a container
+ */
+public class BookmarkDsc extends InstDescr {
+
+ final String service = "com.sun.star.text.Bookmark";
+ String ifcName = "com.sun.star.text.XTextContent";
+ private String name = null;
+
+
+ public BookmarkDsc() {
+ initBookmark();
+ }
+
+ public BookmarkDsc( String name ) {
+ this.name = name;
+ initBookmark();
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getIfcName() {
+ return ifcName;
+ }
+
+ public String getService() {
+ return service;
+ }
+
+ private void initBookmark() {
+ try {
+ ifcClass = Class.forName( ifcName );
+ }
+ catch( ClassNotFoundException cnfE ) {
+ }
+ }
+ public XInterface createInstance( XMultiServiceFactory docMSF ) {
+ Object ServiceObj = null;
+
+ try {
+ ServiceObj = docMSF.createInstance( service );
+ }
+ catch( com.sun.star.uno.Exception cssuE ){
+ }
+ XTextContent BM = (XTextContent)UnoRuntime.queryInterface( ifcClass,
+ ServiceObj );
+ return BM;
+ }
+} \ No newline at end of file
diff --git a/qadevOOo/runner/util/CalcTools.java b/qadevOOo/runner/util/CalcTools.java
new file mode 100644
index 000000000000..08a8b945839a
--- /dev/null
+++ b/qadevOOo/runner/util/CalcTools.java
@@ -0,0 +1,160 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************
+ */
+
+package util;
+
+import com.sun.star.container.XIndexAccess;
+import com.sun.star.lang.IllegalArgumentException;
+import com.sun.star.lang.IndexOutOfBoundsException;
+import com.sun.star.lang.WrappedTargetException;
+import com.sun.star.lang.XComponent;
+import com.sun.star.sheet.XCellRangeData;
+import com.sun.star.sheet.XSpreadsheet;
+import com.sun.star.sheet.XSpreadsheetDocument;
+import com.sun.star.sheet.XSpreadsheets;
+import com.sun.star.table.XCellRange;
+import com.sun.star.uno.AnyConverter;
+import com.sun.star.uno.Exception;
+import com.sun.star.uno.Type;
+import com.sun.star.uno.UnoRuntime;
+
+/**
+ * This class contains some usefull mathods to handle Calc documents
+ * and its sheets.
+ */
+public class CalcTools {
+
+ /**
+ * fills a range of a calc sheet with computed data of type
+ * <CODE>Double</CODE>.
+ * @param xSheetDoc the Clac documents wich should be filled
+ * @param sheetNumber the number of the sheet of <CODE>xSheetDoc</CODE>
+ * @param startCellX the cell number of the X start point (row) of the range to fill
+ * @param startCellY the cell number of the Y start point (column) of the range to fill
+ * @param rangeLengthX the size of the range expansion in X-direction
+ * @param rangeLengthY the size of the range expansion in Y-direction
+ * @throws java.lang.Exception on any error an <CODE>java.lang.Exception</CODE> was thrown
+ */
+ public static void fillCalcSheetWithContent(XComponent xSheetDoc, int sheetNumber,
+ int startCellX, int startCellY, int rangeLengthX, int rangeLengthY)
+ throws java.lang.Exception {
+ try{
+ XSpreadsheet xSheet = getSpreadSheetFromSheetDoc(xSheetDoc, sheetNumber);
+
+ fillCalcSheetWithContent(xSheet, startCellX, startCellY, rangeLengthX, rangeLengthY);
+
+ } catch (Exception e){
+ throw new Exception(
+ "Couldn't fill CalcSheet with content: " + e.toString());
+ }
+ }
+
+ /**
+ * fills a range of a calc sheet with computed data of type
+ * <CODE>Double</CODE>.
+ * @param xSheet the sheet to fill with content
+ * @param startCellX the cell number of the X start point (row) of the range to fill
+ * @param startCellY the cell number of the Y start point (column) of the range to fill
+ * @param rangeLengthX the size of the range expansion in X-direction
+ * @param rangeLengthY the size of the range expansion in Y-direction
+ * @throws java.lang.Exception on any error an <CODE>java.lang.Exception</CODE> was thrown
+ */
+ public static void fillCalcSheetWithContent(XSpreadsheet xSheet,
+ int startCellX, int startCellY, int rangeLengthX, int rangeLengthY)
+ throws java.lang.Exception {
+
+ try{
+ // create a range with content
+ Object[][] newData = new Object[rangeLengthY][rangeLengthX];
+ for (int i=0; i<rangeLengthY; i++) {
+ for (int j=0; j<rangeLengthX; j++) {
+ newData[i][j] = new Double(10*i +j);
+ }
+ }
+ XCellRange xRange = null;
+ try {
+ xRange = xSheet.getCellRangeByPosition(startCellX, startCellY,
+ startCellX+rangeLengthX-1, startCellY+rangeLengthY-1);
+ } catch ( IndexOutOfBoundsException e){
+ throw new Exception(
+ "Couldn't get CellRange from sheett: " + e.toString());
+ }
+
+ XCellRangeData xRangeData = (XCellRangeData) UnoRuntime.queryInterface(XCellRangeData.class, xRange);
+
+ xRangeData.setDataArray(newData);
+ } catch (Exception e){
+ throw new Exception(
+ "Couldn't fill CalcSheet with content: " + e.toString());
+ }
+ }
+
+ /**
+ *
+ * returns an <CODE>XSpreadsheet</CODE> from a Calc document.
+ * @param xSheetDoc the Calc docuent which containes the sheet
+ * @param sheetNumber the number of the sheet to return
+ * @throws java.lang.Exception on any error an <CODE>java.lang.Exception</CODE> was thrown
+ * @return calc sheet
+ * @see com.sun.star.sheet.XSpreadsheet
+ */
+ public static XSpreadsheet getSpreadSheetFromSheetDoc(XComponent xSheetDoc, int sheetNumber)
+ throws java.lang.Exception {
+
+ XSpreadsheet xSheet = null;
+
+ try{
+ XSpreadsheetDocument xSpreadsheetDoc = (XSpreadsheetDocument)
+ UnoRuntime.queryInterface(XSpreadsheetDocument.class, xSheetDoc);
+
+ XSpreadsheets xSpreadsheets = xSpreadsheetDoc.getSheets();
+
+ XIndexAccess xSheetsIndexArray = (XIndexAccess)
+ UnoRuntime.queryInterface(XIndexAccess.class, xSpreadsheets);
+
+ try{
+ xSheet = (XSpreadsheet) AnyConverter.toObject(
+ new Type(XSpreadsheet.class),xSheetsIndexArray.getByIndex(sheetNumber));
+
+ } catch (IllegalArgumentException e){
+ throw new Exception(
+ "Couldn't get sheet '" +sheetNumber + "' : " + e.toString());
+ } catch (IndexOutOfBoundsException e){
+ throw new Exception(
+ "Couldn't get sheet '" +sheetNumber + "' : " + e.toString());
+ } catch (WrappedTargetException e){
+ throw new Exception(
+ "Couldn't get sheet '" +sheetNumber + "' : " + e.toString());
+ }
+ } catch (Exception e){
+ throw new Exception(
+ "Couldn't get sheet '" +sheetNumber + "' : " + e.toString());
+ }
+ return xSheet;
+ }
+}
diff --git a/qadevOOo/runner/util/ControlDsc.java b/qadevOOo/runner/util/ControlDsc.java
new file mode 100644
index 000000000000..f2f1a82e63f4
--- /dev/null
+++ b/qadevOOo/runner/util/ControlDsc.java
@@ -0,0 +1,80 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package util;
+
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.uno.XInterface;
+import com.sun.star.uno.UnoRuntime;
+
+/**
+ * Describes a Control to be inserted in a container
+ */
+
+public class ControlDsc extends InstDescr {
+
+ private String name = null;
+ final String ifcName = "com.sun.star.form.XFormComponent";
+ String service = "com.sun.star.form.component.CommandButton";
+
+ public ControlDsc( String kind ) {
+ service="com.sun.star.form.component."+kind;
+ initControl();
+ }
+ public String getName() {
+ return name;
+ }
+
+ public String getIfcName() {
+ return ifcName;
+ }
+ public String getService() {
+ return service;
+ }
+
+ private void initControl() {
+ try {
+ ifcClass = Class.forName( ifcName );
+ }
+ catch( ClassNotFoundException cnfE ) {
+ }
+ }
+ public XInterface createInstance( XMultiServiceFactory docMSF ) {
+
+ Object SrvObj = null;
+ try {
+ SrvObj = docMSF.createInstance( service );
+ }
+ catch( com.sun.star.uno.Exception cssuE ){
+ }
+
+ XInterface Control = (XInterface)UnoRuntime.queryInterface(ifcClass, SrvObj );
+
+ return Control;
+
+ }
+}
diff --git a/qadevOOo/runner/util/DBTools.java b/qadevOOo/runner/util/DBTools.java
new file mode 100644
index 000000000000..440274d8fd9a
--- /dev/null
+++ b/qadevOOo/runner/util/DBTools.java
@@ -0,0 +1,824 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package util;
+
+import com.sun.star.uno.Exception;
+import java.io.PrintWriter ;
+
+// access the implementations via names
+import com.sun.star.uno.XInterface;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.uno.UnoRuntime;
+
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.sdbc.XConnection ;
+import com.sun.star.sdbc.XResultSet ;
+import com.sun.star.sdbc.XResultSetUpdate ;
+import com.sun.star.sdbc.XStatement ;
+import com.sun.star.sdbc.XRowUpdate ;
+import com.sun.star.util.Date ;
+import com.sun.star.uno.XNamingService ;
+import com.sun.star.task.XInteractionHandler ;
+import com.sun.star.sdb.XCompletedConnection ;
+import com.sun.star.container.XEnumeration ;
+import com.sun.star.container.XEnumerationAccess ;
+import com.sun.star.io.XInputStream ;
+import com.sun.star.io.XTextInputStream ;
+import com.sun.star.io.XDataInputStream ;
+import com.sun.star.container.XNameAccess ;
+import com.sun.star.frame.XStorable;
+import com.sun.star.sdb.XDocumentDataSource;
+import com.sun.star.sdbc.XCloseable ;
+import java.sql.Statement;
+import java.sql.Connection;
+import java.sql.DriverManager;
+
+/**
+* Provides useful methods for working with SOffice databases.
+* Database creation, data transfering, outputting infromation.
+*/
+public class DBTools {
+
+ private XMultiServiceFactory xMSF = null ;
+ private XNamingService dbContext = null ;
+ private PrintWriter m_log = null;
+
+ //JDBC driver
+ public final static String TST_JDBC_DRIVER = "org.gjt.mm.mysql.Driver";
+
+ // constants for TestDB table column indexes
+ public final static int TST_STRING = 1 ;
+ public final static int TST_INT = 2 ;
+ public final static int TST_DOUBLE = 5 ;
+ public final static int TST_DATE = 6 ;
+ public final static int TST_BOOLEAN = 10 ;
+ public final static int TST_CHARACTER_STREAM = 11 ;
+ public final static int TST_BINARY_STREAM = 12 ;
+
+ // constants for TestDB columns names
+ public final static String TST_STRING_F = "_TEXT" ;
+ public final static String TST_INT_F = "_INT" ;
+ public final static String TST_DOUBLE_F = "_DOUBLE" ;
+ public final static String TST_DATE_F = "_DATE" ;
+ public final static String TST_BOOLEAN_F = "_BOOL" ;
+ public final static String TST_CHARACTER_STREAM_F = "_MEMO1" ;
+ public final static String TST_BINARY_STREAM_F = "_MEMO2" ;
+
+ /**
+ * Values for filling test table.
+ */
+ public final static Object[][] TST_TABLE_VALUES = new Object[][] {
+ {"String1", new Integer(1), null, null, new Double(1.1),
+ new Date((short) 1,(short) 1, (short) 2001), null, null, null,
+ Boolean.TRUE, null, null},
+ {"String2", new Integer(2), null, null, new Double(1.2),
+ new Date((short) 2, (short) 1,(short) 2001), null, null, null,
+ Boolean.FALSE, null, null},
+ {null, null, null, null, null,
+ null, null, null, null,
+ null, null, null}
+ } ;
+
+ /**
+ * Array of lengths of streams for each row in of the
+ * <code>TST_TABLE_VALUES</code> constants.
+ */
+ public final static int[] TST_STREAM_LENGTHS = {0, 0, 0} ;
+
+ /**
+ * It's just a structure with some useful methods for representing
+ * <code>com.sun.star.sdb.DataSource</code> service. All this
+ * service's properties are stored in appropriate class fields.
+ * Class also allows to construct its instances using service
+ * information, and create new service instance upon class
+ * fields.
+ * @see com.sun.star.sdb.DataSource
+ */
+ public class DataSourceInfo {
+ /**
+ * Representation of <code>'Name'</code> property.
+ */
+ public String Name = null ;
+ /**
+ * Representation of <code>'URL'</code> property.
+ */
+ public String URL = null ;
+ /**
+ * Representation of <code>'Info'</code> property.
+ */
+ public PropertyValue[] Info = null ;
+ /**
+ * Representation of <code>'User'</code> property.
+ */
+ public String User = null ;
+ /**
+ * Representation of <code>'Password'</code> property.
+ */
+ public String Password = null ;
+ /**
+ * Representation of <code>'IsPasswordRequired'</code> property.
+ */
+ public Boolean IsPasswordRequired = null ;
+ /**
+ * Representation of <code>'SuppressVersionColumns'</code> property.
+ */
+ public Boolean SuppressVersionColumns = null ;
+ /**
+ * Representation of <code>'IsReadOnly'</code> property.
+ */
+ public Boolean IsReadOnly = null ;
+ /**
+ * Representation of <code>'TableFilter'</code> property.
+ */
+ public String[] TableFilter = null ;
+ /**
+ * Representation of <code>'TableTypeFilter'</code> property.
+ */
+ public String[] TableTypeFilter = null ;
+
+ /**
+ * Creates an empty instance.
+ */
+ public DataSourceInfo()
+ {
+ }
+
+ /**
+ * Creates an instance laying upon specified DataSource.
+ * @param dataSource All source properties are copied into
+ * class fields.
+ */
+ public DataSourceInfo(Object dataSource) {
+ XPropertySet xProps = (XPropertySet)
+ UnoRuntime.queryInterface(XPropertySet.class, dataSource) ;
+
+ try {
+ Name = (String)xProps.getPropertyValue("Name") ;
+ URL = (String)xProps.getPropertyValue("URL") ;
+ Info = (PropertyValue[])xProps.getPropertyValue("Info") ;
+ User = (String)xProps.getPropertyValue("User") ;
+ Password = (String)xProps.getPropertyValue("Password") ;
+ IsPasswordRequired = (Boolean)xProps.getPropertyValue("IsPasswordRequired") ;
+ SuppressVersionColumns = (Boolean)
+ xProps.getPropertyValue("SuppressVersionColumns") ;
+ IsReadOnly = (Boolean)xProps.getPropertyValue("IsReadOnly") ;
+ TableFilter = (String[])xProps.getPropertyValue("TableFilter") ;
+ TableTypeFilter = (String[])xProps.getPropertyValue("TableTypeFilter") ;
+ } catch (com.sun.star.beans.UnknownPropertyException e) {
+ System.err.println("util.DBTools.DataSourceInfo: Error retrieving property") ;
+ e.printStackTrace(System.err) ;
+ } catch (com.sun.star.lang.WrappedTargetException e) {
+ System.err.println("util.DBTools.DataSourceInfo: Error retrieving property") ;
+ e.printStackTrace(System.err) ;
+ }
+ }
+
+ /**
+ * Prints datasource info.
+ * @param out Stream to which information is printed.
+ */
+ public void printInfo(PrintWriter out) {
+ out.println("Name = '" + Name + "'") ;
+ out.println(" URL = '" + URL + "'") ;
+ out.print(" Info = ") ;
+ if (Info == null) out.println("null") ;
+ else {
+ out.print("{") ;
+ for (int i = 0; i < Info.length; i++) {
+ out.print(Info[i].Name + " = '" + Info[i].Value + "'") ;
+ if (i + 1 < Info.length) out.print("; ") ;
+ }
+ out.println("}") ;
+ }
+ out.println(" User = '" + User + "'") ;
+ out.println(" Password = '" + Password + "'") ;
+ out.println(" IsPasswordRequired = '" + IsPasswordRequired + "'") ;
+ out.println(" SuppressVersionColumns = '" + SuppressVersionColumns + "'") ;
+ out.println(" IsReadOnly = '" + IsReadOnly + "'") ;
+ out.print(" TableFilter = ") ;
+ if (TableFilter == null) out.println("null") ;
+ else {
+ out.print("{") ;
+ for (int i = 0; i < TableFilter.length; i++) {
+ out.print("'" + TableFilter[i] + "'") ;
+ if (i+1 < TableFilter.length) out.print("; ");
+ }
+ out.println("}") ;
+ }
+ out.print(" TableTypeFilter = ") ;
+ if (TableTypeFilter == null) out.println("null") ;
+ else {
+ out.print("{") ;
+ for (int i = 0; i < TableTypeFilter.length; i++) {
+ out.print("'" + TableTypeFilter[i] + "'") ;
+ if (i+1 < TableTypeFilter.length) out.print("; ");
+ }
+ out.println("}") ;
+ }
+ }
+
+ /**
+ * Creates new <code>com.sun.star.sdb.DataSource</code> service
+ * instance and copies all fields (which are not null) to
+ * appropriate service properties.
+ * @return <code>com.sun.star.sdb.DataSource</code> service.
+ */
+ public Object getDataSourceService() throws Exception
+ {
+ Object src = src = xMSF.createInstance("com.sun.star.sdb.DataSource") ;
+
+ XPropertySet props = (XPropertySet) UnoRuntime.queryInterface
+ (XPropertySet.class, src) ;
+
+ if (Name != null) props.setPropertyValue("Name", Name) ;
+ if (URL != null) props.setPropertyValue("URL", URL) ;
+ if (Info != null) props.setPropertyValue("Info", Info) ;
+ if (User != null) props.setPropertyValue("User", User) ;
+ if (Password != null) props.setPropertyValue("Password", Password) ;
+ if (IsPasswordRequired != null) props.setPropertyValue("IsPasswordRequired", IsPasswordRequired) ;
+ if (SuppressVersionColumns != null) props.setPropertyValue("SuppressVersionColumns", SuppressVersionColumns) ;
+ if (IsReadOnly != null) props.setPropertyValue("IsReadOnly", IsReadOnly) ;
+ if (TableFilter != null) props.setPropertyValue("TableFilter", TableFilter) ;
+ if (TableTypeFilter != null) props.setPropertyValue("TableTypeFilter", TableTypeFilter) ;
+
+ return src ;
+ }
+ }
+
+ /**
+ * Creates class instance.
+ * @param xMSF <code>XMultiServiceFactory</code>.
+ */
+ public DBTools(XMultiServiceFactory xMSF, PrintWriter _logger )
+ {
+ this.xMSF = xMSF ;
+ this.m_log = _logger;
+
+ try {
+ Object cont = xMSF.createInstance("com.sun.star.sdb.DatabaseContext") ;
+
+ dbContext = (XNamingService) UnoRuntime.queryInterface
+ (XNamingService.class, cont) ;
+
+ } catch (com.sun.star.uno.Exception e) {}
+ }
+
+ /**
+ * Returns new instance of <code>DataSourceInfo</code> class.
+ */
+ public DataSourceInfo newDataSourceInfo() { return new DataSourceInfo() ;}
+
+ /**
+ * Returns new instance of <code>DataSourceInfo</code> class.
+ */
+ public DataSourceInfo newDataSourceInfo(Object dataSource) {
+ return new DataSourceInfo(dataSource);
+ }
+
+ /**
+ * Registers the datasource on the specified name in
+ * <code>DatabaseContext</code> service.
+ * @param name Name which dataSource will have in global context.
+ * @param dataSource <code>DataSource</code> object which is to
+ * be registered.
+ */
+ public void registerDB(String name, Object dataSource)
+ throws com.sun.star.uno.Exception {
+
+ dbContext.registerObject(name, dataSource) ;
+ }
+
+
+ /**
+ * First tries to revoke the datasource with the specified
+ * name and then registers a new one.
+ * @param name Name which dataSource will have in global context.
+ * @param dataSource <code>DataSource</code> object which is to
+ * be registered.
+ */
+ public void reRegisterDB(String name, Object dataSource)
+ throws com.sun.star.uno.Exception {
+
+ try {
+ revokeDB(name) ;
+ } catch (com.sun.star.uno.Exception e) {}
+
+ XDocumentDataSource xDDS = (XDocumentDataSource)
+ UnoRuntime.queryInterface(XDocumentDataSource.class, dataSource);
+ XStorable store = (XStorable) UnoRuntime.queryInterface(XStorable.class,
+ xDDS.getDatabaseDocument());
+ String aFile = utils.getOfficeTemp(xMSF) + name + ".odb";
+ store.storeAsURL(aFile, new PropertyValue[] { });
+
+ registerDB(name, dataSource) ;
+ }
+
+ /**
+ * RESERVED. Not used.
+ */
+ public XConnection connectToTextDB(String contextName,
+ String dbDir, String fileExtension)
+ throws com.sun.star.uno.Exception {
+
+ try {
+ XInterface newSource = (XInterface) xMSF.createInstance
+ ("com.sun.star.sdb.DataSource") ;
+
+ XPropertySet xSrcProp = (XPropertySet)
+ UnoRuntime.queryInterface(XPropertySet.class, newSource);
+
+ xSrcProp.setPropertyValue("URL", "sdbc:text:" + dirToUrl(dbDir));
+
+ PropertyValue extParam = new PropertyValue() ;
+ extParam.Name = "EXT" ;
+ extParam.Value = fileExtension ;
+
+ xSrcProp.setPropertyValue("Info", new PropertyValue[] {extParam}) ;
+
+ dbContext.registerObject(contextName, newSource) ;
+
+ Object handler = xMSF.createInstance("com.sun.star.sdb.InteractionHandler");
+ XInteractionHandler xHandler = (XInteractionHandler)
+ UnoRuntime.queryInterface(XInteractionHandler.class, handler) ;
+
+ XCompletedConnection xSrcCon = (XCompletedConnection)
+ UnoRuntime.queryInterface(XCompletedConnection.class, newSource) ;
+
+ XConnection con = xSrcCon.connectWithCompletion(xHandler) ;
+
+ return con ;
+ } finally {
+ try {
+ dbContext.revokeObject(contextName) ;
+ } catch (Exception e) {}
+ }
+ }
+
+ /**
+ * Registers DBase database (directory with DBF files) in the
+ * global DB context, then connects to it.
+ * @param contextName Name under which DB will be registered.
+ * @param dbDir The directory with DBF tables.
+ * @return Connection to the DB.
+ */
+ public XConnection connectToDBase(String contextName,
+ String dbDir)
+ throws com.sun.star.uno.Exception {
+
+ try {
+ XInterface newSource = (XInterface) xMSF.createInstance
+ ("com.sun.star.sdb.DataSource") ;
+
+ XPropertySet xSrcProp = (XPropertySet)
+ UnoRuntime.queryInterface(XPropertySet.class, newSource);
+ xSrcProp.setPropertyValue("URL", "sdbc:dbase:" + dirToUrl(dbDir));
+
+ dbContext.registerObject(contextName, newSource) ;
+
+ XConnection con = connectToSource(newSource) ;
+
+ return con ;
+ } catch(com.sun.star.uno.Exception e) {
+ try {
+ dbContext.revokeObject(contextName) ;
+ } catch (Exception ex) {}
+
+ throw e ;
+ }
+ }
+
+ /**
+ * Performs connection to DataSource specified.
+ * @param dbSource <code>com.sun.star.sdb.DataSource</code> service
+ * specified data source which must be already registered in the
+ * <code>DatabaseContext</code> service.
+ * @param dbSource Data source to be connected to.
+ * @return Connection to the data source.
+ */
+ public XConnection connectToSource(Object dbSource)
+ throws com.sun.star.uno.Exception {
+
+ Object handler = xMSF.createInstance("com.sun.star.sdb.InteractionHandler");
+ XInteractionHandler xHandler = (XInteractionHandler)
+ UnoRuntime.queryInterface(XInteractionHandler.class, handler) ;
+
+ XCompletedConnection xSrcCon = (XCompletedConnection)
+ UnoRuntime.queryInterface(XCompletedConnection.class, dbSource) ;
+
+ return xSrcCon.connectWithCompletion(xHandler) ;
+ }
+
+ /**
+ * Registers Test data source in the <code>DatabaseContext</code> service.
+ * This source always has name <code>'APITestDatabase'</code> and it
+ * is registered in subdirectory <code>TestDB</code> of directory
+ * <code>docPath</code> which is supposed to be a directory with test
+ * documents, but can be any other (it must have subdirectory with DBF
+ * tables). If such data source doesn't exists or exists with
+ * different URL it is recreated and reregistered.
+ * @param docPath Path to database <code>TestDB</code> directory.
+ * @return <code>com.sun.star.sdb.DataSource</code> service
+ * implementation which represents TestDB.
+ */
+ public Object registerTestDB(String docPath)
+ throws com.sun.star.uno.Exception {
+
+ String testURL = null ;
+ if (docPath.endsWith("/") || docPath.endsWith("\\"))
+ testURL = dirToUrl(docPath + "TestDB") ;
+ else
+ testURL = dirToUrl(docPath + "/" + "TestDB") ;
+ testURL = "sdbc:dbase:" + testURL ;
+
+ String existURL = null ;
+
+ XNameAccess na = (XNameAccess) UnoRuntime.queryInterface
+ (XNameAccess.class, dbContext) ;
+
+ Object src = null ;
+ if (na.hasByName("APITestDatabase")) {
+ src = dbContext.getRegisteredObject("APITestDatabase") ;
+
+ XPropertySet srcPs = (XPropertySet) UnoRuntime.queryInterface
+ (XPropertySet.class, src) ;
+
+ existURL = (String) srcPs.getPropertyValue("URL") ;
+ }
+
+ if (src == null || !testURL.equals(existURL)) {
+ // test data source must be reregistered.
+ DataSourceInfo info = new DataSourceInfo() ;
+ info.URL = testURL ;
+ src = info.getDataSourceService() ;
+ reRegisterDB("APITestDatabase", src) ;
+ src = dbContext.getRegisteredObject("APITestDatabase") ;
+ }
+
+ return src ;
+ }
+
+ /**
+ * Connects to <code>DataSource</code> specially created for testing.
+ * This source always has name <code>'APITestDatabase'</code> and it
+ * is registered in subdirectory <code>TestDB</code> of directory
+ * <code>docPath</code> which is supposed to be a directory with test
+ * documents, but can be any other (it must have subdirectory with DBF
+ * tables). If such data source doesn't exists or exists with
+ * different URL it is recreated and reregistered. Finally connection
+ * performed.
+ * @param docPath Path to database <code>TestDB</code> directory.
+ * @return Connection to test database.
+ */
+ public XConnection connectToTestDB(String docPath)
+ throws com.sun.star.uno.Exception {
+
+ return connectToSource(registerTestDB(docPath)) ;
+ }
+
+ /**
+ * Empties the table in the specified source.
+ * @param con Connection to the DataSource where appropriate
+ * table exists.
+ * @param table The name of the table where all rows will be deleted.
+ * @return Number of rows deleted.
+ */
+
+ // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ // Currently doesn't work because of bugs 85509, 85510
+
+ public int deleteAllRows(XConnection con, String table)
+ throws com.sun.star.sdbc.SQLException {
+
+ XStatement stat = con.createStatement() ;
+
+ XResultSet set = stat.executeQuery("SELECT * FROM " + table) ;
+
+ XResultSetUpdate updt = (XResultSetUpdate) UnoRuntime.queryInterface
+ (XResultSetUpdate.class, set) ;
+
+ int count = 0 ;
+ set.last() ;
+ int rowNum = set.getRow() ;
+ set.first() ;
+
+ for (int i = 0; i < rowNum; i++) {
+ updt.deleteRow() ;
+ set.next() ;
+ count ++ ;
+ }
+
+ XCloseable xClose = (XCloseable) UnoRuntime.queryInterface
+ (XCloseable.class, set) ;
+ xClose.close() ;
+
+ return count ;
+ }
+
+ /**
+ * Inserts row into test table of the specified connection.
+ * Test table has some predefined format which includes as much
+ * field types as possible. For every column type constants
+ * {@link #TST_STRING TST_STRING}, {@link #TST_INT TST_INT}, etc.
+ * are declared for column index fast find.
+ * @param con Connection to data source where test table exists.
+ * @param table Test table name.
+ * @param values Values to be inserted into test table. Values of
+ * this array inserted into appropriate fields depending on their
+ * types. So <code>String</code> value of the array is inserted
+ * into the field of <code>CHARACTER</code> type, etc.
+ * @param streamLength Is optional. It is used only if in values
+ * list <code>XCharacterInputStream</code> or <code>XBinaryInputStream
+ * </code> types specified. In this case the parameter specifies
+ * the length of the stream for inserting.
+ */
+ public void addRowToTestTable(XConnection con, String table, Object[] values,
+ int streamLength)
+ throws com.sun.star.sdbc.SQLException {
+
+ XStatement stat = con.createStatement() ;
+
+ XResultSet set = stat.executeQuery("SELECT * FROM " + table) ;
+
+ XResultSetUpdate updt = (XResultSetUpdate) UnoRuntime.queryInterface
+ (XResultSetUpdate.class, set) ;
+
+ XRowUpdate rowUpdt = (XRowUpdate) UnoRuntime.queryInterface
+ (XRowUpdate.class, set) ;
+
+ updt.moveToInsertRow() ;
+
+ for (int i = 0; i < values.length; i++) {
+ if (values[i] instanceof String) {
+ rowUpdt.updateString(TST_STRING, (String) values[i]) ;
+ } else
+ if (values[i] instanceof Integer) {
+ rowUpdt.updateInt(TST_INT, ((Integer) values[i]).intValue()) ;
+ } else
+ if (values[i] instanceof Double) {
+ rowUpdt.updateDouble(TST_DOUBLE, ((Double) values[i]).doubleValue()) ;
+ } else
+ if (values[i] instanceof Date) {
+ rowUpdt.updateDate(TST_DATE, (Date) values[i]) ;
+ } else
+ if (values[i] instanceof Boolean) {
+ rowUpdt.updateBoolean(TST_BOOLEAN, ((Boolean) values[i]).booleanValue()) ;
+ } else
+ if (values[i] instanceof XTextInputStream) {
+ rowUpdt.updateCharacterStream(TST_CHARACTER_STREAM, (XInputStream) values[i],
+ streamLength) ;
+ } else
+ if (values[i] instanceof XDataInputStream) {
+ rowUpdt.updateBinaryStream(TST_BINARY_STREAM, (XInputStream) values[i],
+ streamLength) ;
+ }
+ }
+
+ updt.insertRow() ;
+
+ XCloseable xClose = (XCloseable) UnoRuntime.queryInterface
+ (XCloseable.class, set) ;
+ xClose.close() ;
+ }
+
+ /**
+ * Initializes test table specified of the connection specified.
+ * Deletes all record from table, and then inserts data from
+ * <code>TST_TABLE_VALUES</code> constant array. <p>
+ * Test table has some predefined format which includes as much
+ * field types as possible. For every column type constants
+ * {@link #TST_STRING TST_STRING}, {@link #TST_INT TST_INT}, etc.
+ * are declared for column index fast find.
+ * @param con Connection to data source where test table exists.
+ * @param table Test table name.
+ */
+ public void initializeTestTable(XConnection con, String table)
+ throws com.sun.star.sdbc.SQLException {
+
+ deleteAllRows(con, table) ;
+
+ for (int i = 0; i < TST_TABLE_VALUES.length; i++) {
+ addRowToTestTable(con, table, TST_TABLE_VALUES[i], TST_STREAM_LENGTHS[i]) ;
+ }
+ }
+
+ /**
+ * Prints full info about currently registered DataSource's.
+ */
+ public void printRegisteredDatabasesInfo(PrintWriter out) {
+ XEnumerationAccess dbContEA = (XEnumerationAccess)
+ UnoRuntime.queryInterface(XEnumerationAccess.class, dbContext) ;
+
+ XEnumeration xEnum = dbContEA.createEnumeration() ;
+
+ out.println("DatabaseContext registered DataSource's :") ;
+ while (xEnum.hasMoreElements()) {
+ try {
+ DataSourceInfo inf = new DataSourceInfo(xEnum.nextElement()) ;
+ inf.printInfo(out) ;
+ } catch (com.sun.star.container.NoSuchElementException e) {}
+ catch (com.sun.star.lang.WrappedTargetException e) {}
+ }
+ }
+
+ /**
+ * Convert system pathname to SOffice URL string
+ * (for example 'C:\Temp\DBDir\' -> 'file:///C|/Temp/DBDir/').
+ * (for example '\\server\Temp\DBDir\' -> 'file://server/Temp/DBDir/').
+ * Already converted string retured unchanged.
+ */
+ public static String dirToUrl(String dir) {
+ String retVal = null;
+ if (dir.startsWith("file:/")) retVal = dir;
+ else {
+ retVal = dir.replace(':', '|').replace('\\', '/');
+
+ if (dir.startsWith("\\\\")) {
+ retVal = "file:" + retVal;
+ }
+
+ else retVal = "file:///" + retVal ;
+ }
+ return retVal;
+ }
+
+ /**
+ * Revokes datasource from global DB context.
+ * @param name DataSource name to be revoked.
+ */
+ public void revokeDB(String name) throws com.sun.star.uno.Exception
+ {
+ dbContext.revokeObject(name) ;
+ }
+
+ /**
+ * Initializes test table specified of the connection specified
+ * using JDBC driver. Drops table with the name <code>tbl_name</code>,
+ * creates new table with this name and then inserts data from
+ * <code>TST_TABLE_VALUES</code> constant array. <p>
+ * Test table has some predefined format which includes as much
+ * field types as possible. For every column type constants
+ * {@link #TST_STRING TST_STRING}, {@link #TST_INT TST_INT}, etc.
+ * are declared for column index fast find.
+ * @param tbl_name Test table name.
+ */
+ public void initTestTableUsingJDBC(String tbl_name, DataSourceInfo dsi)
+ throws java.sql.SQLException,
+ ClassNotFoundException {
+ //register jdbc driver
+ if ( dsi.Info[0].Name.equals("JavaDriverClass") ) {
+ Class.forName((String)dsi.Info[0].Value);
+ } else {
+ Class.forName(TST_JDBC_DRIVER);
+ }
+
+ //getting connection
+ Connection connection = null;
+
+ connection = DriverManager.getConnection(
+ dsi.URL, dsi.User, dsi.Password);
+ Statement statement = connection.createStatement();
+
+ //drop table
+ dropMySQLTable(statement, tbl_name);
+
+ //create table
+ createMySQLTable(statement, tbl_name);
+
+ //insert some content
+ insertContentMySQLTable(statement, tbl_name);
+ }
+
+ /**
+ * Inserts data from <code>TST_TABLE_VALUES</code> constant array
+ * to test table <code>tbl_name</code>.
+ * @param statement object used for executing a static SQL
+ * statement and obtaining the results produced by it.
+ * @param tbl_name Test table name.
+ */
+ protected void insertContentMySQLTable(Statement statement, String tbl_name)
+ throws java.sql.SQLException {
+
+
+ for(int i = 0; i < DBTools.TST_TABLE_VALUES.length; i++) {
+ String query = "insert into " + tbl_name + " values (";
+ int j = 0;
+ while(j < DBTools.TST_TABLE_VALUES[i].length) {
+ if (j > 0) {
+ query += ", ";
+ }
+ Object value = DBTools.TST_TABLE_VALUES[i][j];
+ if (value instanceof String ||
+ value instanceof Date) {
+ query += "'";
+ }
+ if (value instanceof Date) {
+ Date date = (Date)value;
+ query += date.Year + "-" + date.Month +
+ "-" + date.Day;
+ } else if (value instanceof Boolean) {
+ query += (((Boolean)value).booleanValue())
+ ? "1" : "0";
+ } else {
+ query += value;
+ }
+
+ if (value instanceof String ||
+ value instanceof Date) {
+ query += "'";
+ }
+ j++;
+ }
+ query += ")";
+ statement.executeUpdate(query);
+ }
+ }
+
+ /**
+ * Creates test table specified.
+ * Test table has some predefined format which includes as much
+ * field types as possible. For every column type constants
+ * {@link #TST_STRING TST_STRING}, {@link #TST_INT TST_INT}, etc.
+ * are declared for column index fast find.
+ * @param statement object used for executing a static SQL
+ * statement and obtaining the results produced by it.
+ * @param table Test table name.
+ */
+ protected void createMySQLTable(Statement statement, String tbl_name)
+ throws java.sql.SQLException {
+
+ final String empty_col_name = "Column";
+ int c = 0;
+ String query = "create table " + tbl_name + " (";
+ for (int i = 0; i < TST_TABLE_VALUES[0].length; i++) {
+ if (i > 0) query += ",";
+
+ switch(i + 1) {
+ case TST_BINARY_STREAM:
+ query += TST_BINARY_STREAM_F + " BLOB";
+ break;
+ case TST_BOOLEAN:
+ query += TST_BOOLEAN_F + " TINYINT";
+ break;
+ case TST_CHARACTER_STREAM:
+ query += TST_CHARACTER_STREAM_F + " TEXT";
+ break;
+ case TST_DATE:
+ query += TST_DATE_F + " DATE";
+ break;
+ case TST_DOUBLE:
+ query += TST_DOUBLE_F + " DOUBLE";
+ break;
+ case TST_INT:
+ query += TST_INT_F + " INT";
+ break;
+ case TST_STRING:
+ query += TST_STRING_F + " TEXT";
+ break;
+ default: query += empty_col_name + (c++) + " INT";
+ if (c == 1) {
+ query += " NOT NULL AUTO_INCREMENT";
+ }
+ }
+ }
+ query += ", PRIMARY KEY (" + empty_col_name + "0)";
+ query += ")";
+ statement.execute(query);
+ }
+
+ /**
+ * Drops table.
+ * @param statement object used for executing a static SQL
+ * statement and obtaining the results produced by it.
+ * @param table Test table name.
+ */
+ protected void dropMySQLTable(Statement statement, String tbl_name)
+ throws java.sql.SQLException {
+ statement.executeUpdate("drop table if exists " + tbl_name);
+ }
+}
diff --git a/qadevOOo/runner/util/DefaultDsc.java b/qadevOOo/runner/util/DefaultDsc.java
new file mode 100644
index 000000000000..07a2cdd2c5cc
--- /dev/null
+++ b/qadevOOo/runner/util/DefaultDsc.java
@@ -0,0 +1,81 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package util;
+
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.uno.XInterface;
+import com.sun.star.uno.UnoRuntime;
+
+/**
+ * Defaultdescriptor:
+ * This descriptor is useful for instances in default values.
+ */
+public class DefaultDsc extends InstDescr {
+
+ private String name = null;
+ String ifcName = null;
+ String service = null;
+
+ public DefaultDsc( String Interface, String kind ) {
+ service = kind;
+ ifcName = Interface;
+ initDefault();
+ }
+ public String getName() {
+ return name;
+ }
+
+ public String getIfcName() {
+ return ifcName;
+ }
+ public String getService() {
+ return service;
+ }
+
+ private void initDefault() {
+ try {
+ ifcClass = Class.forName( ifcName );
+ }
+ catch( ClassNotFoundException cnfE ) {
+ }
+ }
+ public XInterface createInstance( XMultiServiceFactory docMSF ) {
+
+ Object SrvObj = null;
+ try {
+ SrvObj = docMSF.createInstance( service );
+ }
+ catch( com.sun.star.uno.Exception cssuE ){
+ }
+
+ XInterface Default = (XInterface)UnoRuntime.queryInterface(ifcClass, SrvObj );
+
+ return Default;
+
+ }
+}
diff --git a/qadevOOo/runner/util/DesktopTools.java b/qadevOOo/runner/util/DesktopTools.java
new file mode 100644
index 000000000000..3384a8b83423
--- /dev/null
+++ b/qadevOOo/runner/util/DesktopTools.java
@@ -0,0 +1,515 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package util;
+
+import com.sun.star.awt.Rectangle;
+import com.sun.star.awt.WindowDescriptor;
+import com.sun.star.awt.XToolkit;
+import com.sun.star.awt.XWindowPeer;
+import com.sun.star.awt.XTopWindow;
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.container.XEnumeration;
+import com.sun.star.container.XNameReplace;
+import com.sun.star.frame.XComponentLoader;
+import com.sun.star.frame.XDesktop;
+import com.sun.star.frame.XFrame;
+import com.sun.star.frame.XModel;
+import com.sun.star.lang.XComponent;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.lang.XServiceInfo;
+import com.sun.star.uno.UnoRuntime;
+
+// access the implementations via names
+import com.sun.star.uno.XInterface;
+import com.sun.star.util.XCloseable;
+import com.sun.star.util.XModifiable;
+import com.sun.star.view.XViewSettingsSupplier;
+import helper.ConfigHelper;
+import java.util.Vector;
+import lib.StatusException;
+
+/**
+ * contains helper methods for the Desktop
+ */
+public class DesktopTools
+{
+
+ /**
+ * Queries the XComponentLoader
+ *
+ * @param xMSF the MultiServiceFactory
+ * @return the gained XComponentLoader
+ */
+ public static XComponentLoader getCLoader(XMultiServiceFactory xMSF)
+ {
+ XDesktop oDesktop = (XDesktop) UnoRuntime.queryInterface(
+ XDesktop.class, createDesktop(xMSF));
+
+ XComponentLoader oCLoader = (XComponentLoader) UnoRuntime.queryInterface(
+ XComponentLoader.class, oDesktop);
+
+ return oCLoader;
+ } // finish getCLoader
+
+ /**
+ * Creates an Instance of the Desktop service
+ *
+ * @param xMSF the MultiServiceFactory
+ * @return the gained Object
+ */
+ public static Object createDesktop(XMultiServiceFactory xMSF)
+ {
+ Object oInterface;
+
+ try
+ {
+ oInterface = xMSF.createInstance("com.sun.star.comp.framework.Desktop");
+ }
+ catch (com.sun.star.uno.Exception e)
+ {
+ throw new IllegalArgumentException("Desktop Service not available");
+ }
+
+ return oInterface;
+ } //finish createDesktop
+
+ /**
+ * returns a XEnumeration containing all components containing on the desktop
+ * @param xMSF the XMultiServiceFactory
+ * @return XEnumeration of all components on the desktop
+ */
+ public static XEnumeration getAllComponents(XMultiServiceFactory xMSF)
+ {
+ XDesktop xDesktop = (XDesktop) UnoRuntime.queryInterface(
+ XDesktop.class, createDesktop(xMSF));
+ return xDesktop.getComponents().createEnumeration();
+ }
+
+ /**
+ * returns the current component on the desktop
+ * @param xMSF the XMultiServiceFactory
+ * @return XComponent of the current component on the desktop
+ */
+ public static XComponent getCurrentComponent(XMultiServiceFactory xMSF)
+ {
+ XDesktop xDesktop = (XDesktop) UnoRuntime.queryInterface(
+ XDesktop.class, createDesktop(xMSF));
+ return xDesktop.getCurrentComponent();
+ }
+
+ /**
+ * returns the current component on the desktop
+ * @param xMSF the XMultiServiceFactory
+ * @return XComponent of the current component on the desktop
+ */
+ public static XFrame getCurrentFrame(XMultiServiceFactory xMSF)
+ {
+ XDesktop xDesktop = (XDesktop) UnoRuntime.queryInterface(
+ XDesktop.class, createDesktop(xMSF));
+ return xDesktop.getCurrentFrame();
+ }
+
+ /**
+ * returns an object arrary of all open documents
+ * @param xMSF the MultiServiceFactory
+ * @return returns an Array of document kinds like ["swriter"]
+ */
+ /**
+ * returns an array of all open documents
+ * @param xMSF the XMultiSerivceFactory
+ * @return returns an array of all open documents
+ */
+ public static Object[] getAllOpenDocuments(XMultiServiceFactory xMSF)
+ {
+ Vector components = new Vector();
+ XDesktop xDesktop = (XDesktop) UnoRuntime.queryInterface(
+ XDesktop.class, createDesktop(xMSF));
+
+ XEnumeration allComp = getAllComponents(xMSF);
+
+ while (allComp.hasMoreElements())
+ {
+ try
+ {
+ XComponent xComponent = (XComponent) UnoRuntime.queryInterface(
+ XComponent.class, allComp.nextElement());
+
+ if (getDocumentType(xComponent) != null)
+ {
+ components.add(xComponent);
+ }
+
+ }
+ catch (com.sun.star.container.NoSuchElementException e)
+ {
+ }
+ catch (com.sun.star.lang.WrappedTargetException e)
+ {
+ }
+ }
+ return components.toArray();
+ }
+
+ /**
+ * Returns the document type for the given XComponent of an document
+ * @param xComponent the document to query for its type
+ * @return possible:
+ * <ul>
+ * <li>swriter</li>
+ * <li>scalc</li>
+ * <li>sdraw</li>
+ * <li>smath</li>
+ * </ul>
+ * or <CODE>null</CODE>
+ */
+ public static String getDocumentType(XComponent xComponent)
+ {
+ XServiceInfo sInfo = (XServiceInfo) UnoRuntime.queryInterface(
+ XServiceInfo.class, xComponent);
+
+ if (sInfo == null)
+ {
+ return "";
+ }
+ else if (sInfo.supportsService("com.sun.star.sheet.SpreadsheetDocument"))
+ {
+ return "scalc";
+ }
+ else if (sInfo.supportsService("com.sun.star.text.TextDocument"))
+ {
+ return "swriter";
+ }
+ else if (sInfo.supportsService("com.sun.star.drawing.DrawingDocument"))
+ {
+ return "sdraw";
+ }
+ else if (sInfo.supportsService("com.sun.star.presentation.PresentationDocument"))
+ {
+ return "simpress";
+ }
+ else if (sInfo.supportsService("com.sun.star.formula.FormulaProperties"))
+ {
+ return "smath";
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ /**
+ * Opens a new document of a given kind
+ * with arguments
+ * @return the XComponent Interface of the document
+ * @param kind the kind of document to load.<br>
+ * possible:
+ * <ul>
+ * <li>swriter</li>
+ * <li>scalc</li>
+ * <li>sdaw</li>
+ * <li>smath</li>
+ * </ul>
+ * @param Args arguments which passed to the document to load
+ * @param xMSF the MultiServiceFactory
+ */
+ public static XComponent openNewDoc(XMultiServiceFactory xMSF, String kind,
+ PropertyValue[] Args)
+ {
+ XComponent oDoc = null;
+
+ try
+ {
+ oDoc = getCLoader(xMSF).loadComponentFromURL("private:factory/" + kind,
+ "_blank", 0, Args);
+ }
+ catch (com.sun.star.uno.Exception e)
+ {
+ throw new IllegalArgumentException("Document could not be opened");
+ }
+
+ return oDoc;
+ } //finish openNewDoc
+
+ /**
+ * loads a document of from a given url
+ * with arguments
+ * @return the XComponent Interface of the document
+ * @param url the URL of the document to load.
+ * @param Args arguments which passed to the document to load
+ * @param xMSF the MultiServiceFactory
+ */
+ public static XComponent loadDoc(XMultiServiceFactory xMSF, String url,
+ PropertyValue[] Args)
+ {
+ XComponent oDoc = null;
+ if (Args == null)
+ {
+ Args = new PropertyValue[0];
+ }
+ try
+ {
+ oDoc = getCLoader(xMSF).loadComponentFromURL(url, "_blank", 0, Args);
+ }
+ catch (com.sun.star.uno.Exception e)
+ {
+ throw new IllegalArgumentException("Document could not be loaded");
+ }
+
+ bringWindowToFront(oDoc);
+ return oDoc;
+ } //finish openNewDoc
+
+ /**
+ * closes a given document
+ * @param DocumentToClose the document to close
+ */
+ public static void closeDoc(XInterface DocumentToClose)
+ {
+ if (DocumentToClose == null)
+ {
+ return;
+ }
+
+ String kd = System.getProperty("KeepDocument");
+ if (kd != null)
+ {
+ System.out.println("The property 'KeepDocument' is set and so the document won't be disposed");
+ return;
+ }
+ XModifiable modified = (XModifiable) UnoRuntime.queryInterface(XModifiable.class, DocumentToClose);
+ XCloseable closer = (XCloseable) UnoRuntime.queryInterface(XCloseable.class, DocumentToClose);
+
+ try
+ {
+ if (modified != null)
+ {
+ modified.setModified(false);
+ }
+ closer.close(true);
+ }
+ catch (com.sun.star.util.CloseVetoException e)
+ {
+ // e.printStackTrace();
+ System.out.println("Couldn't close document");
+ }
+ catch (com.sun.star.lang.DisposedException e)
+ {
+ // e.printStackTrace();
+ System.out.println("Couldn't close document");
+ }
+ catch (java.lang.NullPointerException e)
+ {
+ // e.printStackTrace();
+ System.out.println("Couldn't close document");
+ }
+ catch (com.sun.star.beans.PropertyVetoException e)
+ {
+ // e.printStackTrace();
+ System.out.println("Couldn't close document");
+ }
+ }
+
+ /**
+ * Creates a floating XWindow with the size of X=500 Y=100 width=400 height=600
+ * @param xMSF the MultiServiceFactory
+ * @throws lib.StatusException if it is not possible to create a floating window a lib.StatusException was thrown
+ * @return a floating XWindow
+ */
+ public static XWindowPeer createFloatingWindow(XMultiServiceFactory xMSF)
+ throws StatusException
+ {
+ return createFloatingWindow(xMSF, 500, 100, 400, 600);
+ }
+
+ /**
+ * Creates a floating XWindow on the given position and size.
+ * @return a floating XWindow
+ * @param X the X-Postion of the floating XWindow
+ * @param Y the Y-Postion of the floating XWindow
+ * @param width the width of the floating XWindow
+ * @param height the height of the floating XWindow
+ * @param xMSF the MultiServiceFactory
+ * @throws lib.StatusException if it is not possible to create a floating window a lib.StatusException was thrown
+ */
+ public static XWindowPeer createFloatingWindow(XMultiServiceFactory xMSF, int X, int Y, int width, int height)
+ throws StatusException
+ {
+
+ XInterface oObj = null;
+
+ try
+ {
+ oObj = (XInterface) xMSF.createInstance("com.sun.star.awt.Toolkit");
+ }
+ catch (com.sun.star.uno.Exception e)
+ {
+ throw new StatusException("Couldn't get toolkit", e);
+ }
+
+ XToolkit tk = (XToolkit) UnoRuntime.queryInterface(
+ XToolkit.class, oObj);
+
+ WindowDescriptor descriptor = new com.sun.star.awt.WindowDescriptor();
+
+ descriptor.Type = com.sun.star.awt.WindowClass.TOP;
+ descriptor.WindowServiceName = "modelessdialog";
+ descriptor.ParentIndex = -1;
+
+ Rectangle bounds = new com.sun.star.awt.Rectangle();
+ bounds.X = X;
+ bounds.Y = Y;
+ bounds.Width = width;
+ bounds.Height = height;
+
+ descriptor.Bounds = bounds;
+ descriptor.WindowAttributes = (com.sun.star.awt.WindowAttribute.BORDER +
+ com.sun.star.awt.WindowAttribute.MOVEABLE +
+ com.sun.star.awt.WindowAttribute.SIZEABLE +
+ com.sun.star.awt.WindowAttribute.CLOSEABLE +
+ com.sun.star.awt.VclWindowPeerAttribute.CLIPCHILDREN);
+
+ XWindowPeer xWindow = null;
+
+ try
+ {
+ xWindow = tk.createWindow(descriptor);
+ }
+ catch (com.sun.star.lang.IllegalArgumentException e)
+ {
+ throw new StatusException("Could not create window", e);
+ }
+
+ return xWindow;
+
+ }
+
+ /**
+ * zoom to have a view over the hole page
+ * @param xDoc the document to zoom
+ */
+ public static void zoomToEntirePage(XInterface xDoc)
+ {
+ try
+ {
+ XModel xMod = (XModel) UnoRuntime.queryInterface(XModel.class, xDoc);
+ XInterface oCont = xMod.getCurrentController();
+ XViewSettingsSupplier oVSSupp = (XViewSettingsSupplier) UnoRuntime.queryInterface(XViewSettingsSupplier.class, oCont);
+
+ XInterface oViewSettings = oVSSupp.getViewSettings();
+ XPropertySet oViewProp = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, oViewSettings);
+ oViewProp.setPropertyValue("ZoomType",
+ new Short(com.sun.star.view.DocumentZoomType.ENTIRE_PAGE));
+
+ utils.shortWait(5000);
+ }
+ catch (Exception e)
+ {
+ System.out.println("Could not zoom to entire page: " + e.toString());
+ }
+
+ }
+
+ /**
+ * This function docks the Stylist onto the right side of the window.</p>
+ * Note:<P>
+ * Since the svt.viewoptions cache the view configuration at start up
+ * the chage of the docking will be effective at a restart.
+ * @param xMSF the XMultiServiceFactory
+ */
+ public static void dockStylist(XMultiServiceFactory xMSF)
+ {
+ // prepare Window-Settings
+ try
+ {
+ ConfigHelper aConfig = new ConfigHelper(xMSF,
+ "org.openoffice.Office.Views", false);
+
+ // Is node "5539" (slot-id for navigator) available? If not, insert it
+ XNameReplace x5539 = aConfig.getOrInsertGroup("Windows", "5539");
+
+ aConfig.updateGroupProperty(
+ "Windows", "5539", "WindowState", "952,180,244,349;1;0,0,0,0;");
+
+ aConfig.insertOrUpdateExtensibleGroupProperty(
+ "Windows", "5539", "UserData", "Data", "V2,V,0,AL:(5,16,0/0/244/349,244;610)");
+
+ // Is node "SplitWindow2" available? If not, instert it.
+ aConfig.getOrInsertGroup("Windows", "SplitWindow2");
+
+ aConfig.insertOrUpdateExtensibleGroupProperty(
+ "Windows", "SplitWindow2", "UserData", "UserItem", "V1,2,1,0,5539");
+
+ aConfig.flush();
+ aConfig = null;
+
+ }
+ catch (com.sun.star.uno.Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Due to typo deprecated
+ * @param xModel
+ * @deprecated
+ */
+ @Deprecated
+ public static void bringWindowToFromt(XModel xModel)
+ {
+ bringWindowToFront(xModel);
+ }
+
+ /**
+ * This function brings a document to the front.<P>
+ * NOTE: it is not possible to change the window order of your Window-Manager!!
+ * Only the order of Office documents are changeable.
+ * @param xModel the XModel of the document to bring to top
+ */
+ public static void bringWindowToFront(XModel xModel)
+ {
+ // System.out.println("DEBUG: bring to front xModel");
+
+ XTopWindow xTopWindow =
+ (XTopWindow) UnoRuntime.queryInterface(
+ XTopWindow.class,
+ xModel.getCurrentController().getFrame().getContainerWindow());
+
+ xTopWindow.toFront();
+ }
+
+ public static void bringWindowToFront(XComponent xComponent)
+ {
+ // System.out.println("DEBUG: bring to front xComponent");
+ XModel xModel = (XModel) UnoRuntime.queryInterface(XModel.class, xComponent);
+ if (xModel != null)
+ {
+ bringWindowToFront(xModel);
+ }
+ }
+}
diff --git a/qadevOOo/runner/util/DrawTools.java b/qadevOOo/runner/util/DrawTools.java
new file mode 100644
index 000000000000..d5f862cb49a7
--- /dev/null
+++ b/qadevOOo/runner/util/DrawTools.java
@@ -0,0 +1,162 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package util;
+
+// access the implementations via names
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.uno.UnoRuntime;
+
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.lang.XComponent;
+import com.sun.star.drawing.XDrawPages;
+import com.sun.star.drawing.XDrawPagesSupplier;
+import com.sun.star.drawing.XDrawPage;
+import com.sun.star.drawing.XShapes;
+import com.sun.star.drawing.XShape;
+
+
+import util.DesktopTools;
+import util.InstCreator;
+import util.ShapeDsc;
+
+import com.sun.star.uno.AnyConverter;
+import com.sun.star.uno.Type;
+
+/**
+ * contains helper methods for draw documents
+ */
+
+
+public class DrawTools {
+
+ /**
+ * Opens a new draw document
+ * with arguments
+ * @param xMSF the MultiServiceFactory
+ * @return the XComponent Interface of the document
+ */
+
+ public static XComponent createDrawDoc( XMultiServiceFactory xMSF ) {
+ PropertyValue[] Args = new PropertyValue [0];
+ XComponent DrawDoc = DesktopTools.openNewDoc( xMSF, "sdraw", Args );
+ return DrawDoc;
+ } // finish createDrawDoc
+
+ /**
+ * gets the XDrawPages container of a draw document
+ *
+ * @param aDoc the draw document
+ * @return the XDrawpages container of the document
+ */
+
+ public static XDrawPages getDrawPages ( XComponent aDoc ) {
+ XDrawPages oDPn = null;
+ try {
+ XDrawPagesSupplier oDPS = (XDrawPagesSupplier)
+ UnoRuntime.queryInterface(XDrawPagesSupplier.class,aDoc);
+
+ oDPn = oDPS.getDrawPages();
+ } catch ( Exception e ) {
+ throw new IllegalArgumentException( "Couldn't get drawpages" );
+ }
+ return oDPn;
+ } // finish getDrawPages
+
+ /**
+ * gets the specified XDrawPage of a draw document
+ *
+ * @param aDoc the draw document
+ * @param nr the index of the DrawPage
+ * @return the XDrawpage with index nr of the document
+ */
+
+ public static XDrawPage getDrawPage ( XComponent aDoc, int nr ) {
+ XDrawPage oDP = null;
+ try {
+ oDP = (XDrawPage) AnyConverter.toObject(
+ new Type(XDrawPage.class),getDrawPages( aDoc ).getByIndex( nr ));
+ } catch ( Exception e ) {
+ throw new IllegalArgumentException( "Couldn't get drawpage" );
+ }
+ return oDP;
+ }
+
+ /**
+ * gets the XShapes container of a draw page
+ *
+ * @param oDP the draw page
+ * @return the XDrawShape container of the drawpage
+ */
+
+ public static XShapes getShapes ( XDrawPage oDP ) {
+ return (XShapes) UnoRuntime.queryInterface(XShapes.class,oDP);
+ }
+
+ /**
+ * creates a XShape
+ *
+ * @param oDoc the document
+ * @param height the height of the shape
+ * @param width the width of the shape
+ * @param x the x-position of the shape
+ * @param y the y-position of the shape
+ * @param kind the kind of the shape ('Ellipse', 'Line' or 'Rectangle')
+ * @return the created XShape
+ */
+
+ public XShape createShape( XComponent oDoc, int height, int width, int x,
+ int y, String kind ) {
+ //possible values for kind are 'Ellipse', 'Line' and 'Rectangle'
+
+ ShapeDsc sDsc = new ShapeDsc( height, width, x, y, kind );
+ InstCreator instCreate = new InstCreator( oDoc, sDsc );
+ XShape oShape = (XShape)instCreate.getInstance();
+
+ return oShape;
+ }
+
+ /**
+ * creates a XShape and adds it to the documents
+ * first drawpage
+ * @param oDoc the document
+ * @param height the height of the shape
+ * @param width the width of the shape
+ * @param x the x-position of the shape
+ * @param y the y-position of the shape
+ * @param kind the kind of the shape ('Ellipse', 'Line' or 'Rectangle')
+ * @return the created XShape
+ */
+
+ public void addShape( XComponent oDoc, int height, int width, int x,
+ int y, String kind ) {
+
+ getShapes(getDrawPage(oDoc,0)).add(createShape( oDoc, height, width, x,
+ y, kind ) );
+ }
+
+}
diff --git a/qadevOOo/runner/util/DynamicClassLoader.java b/qadevOOo/runner/util/DynamicClassLoader.java
new file mode 100644
index 000000000000..659593e69346
--- /dev/null
+++ b/qadevOOo/runner/util/DynamicClassLoader.java
@@ -0,0 +1,123 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package util;
+
+import java.lang.reflect.Constructor;
+
+public class DynamicClassLoader {
+
+ /**
+ * This method returns a class created by its name
+ * created by call to <code>Class.forName()</code>.<p>
+ * This method must be overloaded if another loading
+ * policy is required for Component and Interface
+ * testing classes.
+ * @param className The name of the class to create.
+ * @return The created class.
+ */
+ public static Class forName(String className)
+ throws ClassNotFoundException {
+
+ return Class.forName(className) ;
+ }
+
+ /**
+ * Get an instance of a class. The empty constructor is used.
+ * @param className The class to instantiate.
+ * @return The instance of the class.
+ */
+ public Object getInstance(String className)
+ throws IllegalArgumentException {
+ try {
+ Class cls = DynamicClassLoader.forName(className);
+ return cls.newInstance();
+ } catch ( ClassNotFoundException e ) {
+ throw new IllegalArgumentException("Couldn't find " + className
+ + " " + e);
+ } catch ( IllegalAccessException e ) {
+ throw new IllegalArgumentException("Couldn't access " + className
+ + " " + e);
+ } catch ( InstantiationException e ) {
+ throw new IllegalArgumentException("Couldn't instantiate " +
+ className + " " + e);
+ }
+ }
+
+ /**
+ * Get an instance of a class. The constructor matching to the
+ * arguments is used and the arguments are given to this constructor.
+ * @param className The class to instantiate.
+ * @param ctorArgs Arguments for the constructor.
+ * @return The instance of the class.
+ */
+ public Object getInstance(String className, Object[] ctorArgs)
+ throws IllegalArgumentException {
+ Class[] ctorType = new Class[ctorArgs.length];
+ for(int i=0; i<ctorType.length; i++) {
+ ctorType[i] = ctorArgs[i].getClass();
+ }
+ return getInstance(className, ctorType, ctorArgs);
+
+ }
+
+ /**
+ * Get an instance of a class. The constructor matching to the
+ * given calss types is used and the instance is created using the arguments
+ * for the constructor.
+ * @param className The class to instantiate.
+ * @param ctorClassTypes The class types matching to the constructor.
+ * @param ctorArgs Arguments for the constructor.
+ * @return The instance of the class.
+ */
+ public Object getInstance(String className, Class[]ctorClassTypes, Object[] ctorArgs)
+ throws IllegalArgumentException {
+ try {
+ Class cls = DynamicClassLoader.forName(className);
+ Constructor ctor = cls.getConstructor(ctorClassTypes);
+ System.out.println("ctor: " + ctor.getName() + " " + ctor.getModifiers());
+
+ return ctor.newInstance(ctorArgs);
+ } catch ( ClassNotFoundException e ) {
+ throw new IllegalArgumentException("Couldn't find " + className
+ + " " + e);
+ } catch ( IllegalAccessException e ) {
+ throw new IllegalArgumentException("Couldn't access " + className
+ + " " + e);
+ } catch ( NoSuchMethodException e ) {
+ throw new IllegalArgumentException("Couldn't find constructor for " + className
+ + " " + e);
+ } catch ( java.lang.reflect.InvocationTargetException e ) {
+ e.printStackTrace();
+ throw new IllegalArgumentException("Couldn't invoke " +
+ className + " " + e);
+ } catch ( InstantiationException e ) {
+ throw new IllegalArgumentException("Couldn't instantiate " +
+ className + " " + e);
+ }
+ }
+}
diff --git a/qadevOOo/runner/util/FootnoteDsc.java b/qadevOOo/runner/util/FootnoteDsc.java
new file mode 100644
index 000000000000..ce7b62d4003b
--- /dev/null
+++ b/qadevOOo/runner/util/FootnoteDsc.java
@@ -0,0 +1,84 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package util;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.uno.XInterface;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.text.XTextContent;
+
+/**
+ * describes a Footnote to be inserted in a container
+ */
+public class FootnoteDsc extends InstDescr {
+
+ final String service = "com.sun.star.text.Footnote";
+ String ifcName = "com.sun.star.text.XTextContent";
+ private String name = null;
+
+
+ public FootnoteDsc() {
+ initFootnote();
+ }
+
+ public FootnoteDsc( String name ) {
+ this.name = name;
+ initFootnote();
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getIfcName() {
+ return ifcName;
+ }
+
+ public String getService() {
+ return service;
+ }
+
+ private void initFootnote() {
+ try {
+ ifcClass = Class.forName( ifcName );
+ }
+ catch( ClassNotFoundException cnfE ) {
+ }
+ }
+ public XInterface createInstance( XMultiServiceFactory docMSF ) {
+ Object ServiceObj = null;
+
+ try {
+ ServiceObj = docMSF.createInstance( service );
+ }
+ catch( com.sun.star.uno.Exception cssuE ){
+ }
+ XTextContent FN = (XTextContent)UnoRuntime.queryInterface( ifcClass,
+ ServiceObj );
+ return FN;
+ }
+} \ No newline at end of file
diff --git a/qadevOOo/runner/util/FormTools.java b/qadevOOo/runner/util/FormTools.java
new file mode 100644
index 000000000000..46515043f677
--- /dev/null
+++ b/qadevOOo/runner/util/FormTools.java
@@ -0,0 +1,349 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package util;
+
+// access the implementations via names
+import com.sun.star.uno.XInterface;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.lang.XComponent;
+import com.sun.star.drawing.XControlShape;
+import com.sun.star.drawing.XDrawPage;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.awt.Size;
+import com.sun.star.awt.Point;
+import com.sun.star.awt.XControlModel;
+import com.sun.star.container.XNameContainer;
+import com.sun.star.container.XIndexContainer;
+import com.sun.star.form.XFormsSupplier;
+import com.sun.star.form.XForm;
+import com.sun.star.form.XLoadable;
+import com.sun.star.text.XTextDocument;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.uno.AnyConverter;
+import com.sun.star.uno.Type;
+
+/**
+ * contains helper methods forms
+ */
+
+public class FormTools {
+
+
+ /**
+ * creates a XControlShape
+ *
+ * @param oDoc the document
+ * @param height the height of the shape
+ * @param width the width of the shape
+ * @param x the x-position of the shape
+ * @param y the y-position of the shape
+ * @param kind the kind of the shape
+ * @return the created XControlShape
+ */
+ public static XControlShape createControlShape( XComponent oDoc, int height,
+ int width, int x, int y, String kind ) {
+
+ Size size = new Size();
+ Point position = new Point();
+ XControlShape oCShape = null;
+ XControlModel aControl = null;
+
+ //get MSF
+ XMultiServiceFactory oDocMSF = (XMultiServiceFactory)
+ UnoRuntime.queryInterface( XMultiServiceFactory.class, oDoc );
+
+ try{
+ Object oInt = oDocMSF.createInstance("com.sun.star.drawing.ControlShape");
+ Object aCon = oDocMSF.createInstance("com.sun.star.form.component."+kind);
+ XPropertySet model_props = (XPropertySet)
+ UnoRuntime.queryInterface(XPropertySet.class,aCon);
+ model_props.setPropertyValue("DefaultControl","com.sun.star.form.control."+kind);
+ aControl = (XControlModel) UnoRuntime.queryInterface( XControlModel.class, aCon );
+ oCShape = (XControlShape) UnoRuntime.queryInterface( XControlShape.class, oInt );
+ size.Height = height;
+ size.Width = width;
+ position.X = x;
+ position.Y = y;
+ oCShape.setSize(size);
+ oCShape.setPosition(position);
+ } catch ( com.sun.star.uno.Exception e ) {
+ // Some exception occures.FAILED
+ System.out.println( "Couldn't create instance "+ e );
+ }
+
+ oCShape.setControl(aControl);
+
+ return oCShape;
+ } // finish createControlShape
+
+ public static XControlShape createUnoControlShape( XComponent oDoc, int height,
+ int width, int x, int y, String kind, String defControl ) {
+
+ Size size = new Size();
+ Point position = new Point();
+ XControlShape oCShape = null;
+ XControlModel aControl = null;
+
+ //get MSF
+ XMultiServiceFactory oDocMSF = (XMultiServiceFactory) UnoRuntime.queryInterface( XMultiServiceFactory.class, oDoc );
+
+ try{
+ Object oInt = oDocMSF.createInstance("com.sun.star.drawing.ControlShape");
+ Object aCon = oDocMSF.createInstance("com.sun.star.form.component."+kind);
+ XPropertySet model_props = (XPropertySet)
+ UnoRuntime.queryInterface(XPropertySet.class,aCon);
+ model_props.setPropertyValue("DefaultControl","com.sun.star.awt."+defControl);
+ aControl = (XControlModel) UnoRuntime.queryInterface( XControlModel.class, aCon );
+ oCShape = (XControlShape) UnoRuntime.queryInterface( XControlShape.class, oInt );
+ size.Height = height;
+ size.Width = width;
+ position.X = x;
+ position.Y = y;
+ oCShape.setSize(size);
+ oCShape.setPosition(position);
+
+
+ } catch ( com.sun.star.uno.Exception e ) {
+ // Some exception occures.FAILED
+ System.out.println( "Couldn't create instance "+ e );
+ }
+
+ oCShape.setControl(aControl);
+
+ return oCShape;
+ } // finish createControlShape
+
+ public static XControlShape createControlShapeWithDefaultControl( XComponent oDoc, int height,
+ int width, int x, int y, String kind ) {
+
+ Size size = new Size();
+ Point position = new Point();
+ XControlShape oCShape = null;
+ XControlModel aControl = null;
+
+ //get MSF
+ XMultiServiceFactory oDocMSF = (XMultiServiceFactory) UnoRuntime.queryInterface( XMultiServiceFactory.class, oDoc );
+
+ try{
+ Object oInt = oDocMSF.createInstance("com.sun.star.drawing.ControlShape");
+ Object aCon = oDocMSF.createInstance("com.sun.star.form.component."+kind);
+
+ aControl = (XControlModel) UnoRuntime.queryInterface( XControlModel.class, aCon );
+ oCShape = (XControlShape) UnoRuntime.queryInterface( XControlShape.class, oInt );
+ size.Height = height;
+ size.Width = width;
+ position.X = x;
+ position.Y = y;
+ oCShape.setSize(size);
+ oCShape.setPosition(position);
+
+
+ } catch ( com.sun.star.uno.Exception e ) {
+ // Some exception occures.FAILED
+ System.out.println( "Couldn't create instance "+ e );
+ }
+
+ oCShape.setControl(aControl);
+
+ return oCShape;
+ } // finish createControlShape
+
+ public static XInterface createControl( XComponent oDoc, String kind ) {
+
+ XInterface oControl = null;
+
+ XMultiServiceFactory oDocMSF = (XMultiServiceFactory)
+ UnoRuntime.queryInterface( XMultiServiceFactory.class, oDoc );
+
+ try{
+ oControl = (XInterface) oDocMSF.createInstance(
+ "com.sun.star.form.component."+kind);
+ } catch ( Exception e ) {
+ // Some exception occures.FAILED
+ System.out.println( "Couldn't create instance "+ kind + ": "+ e );
+ }
+ return oControl;
+ } // finish createControl
+
+ public static XNameContainer getForms ( XDrawPage oDP )
+ {
+ XFormsSupplier oFS = (XFormsSupplier) UnoRuntime.queryInterface(
+ XFormsSupplier.class,oDP);
+ return oFS.getForms();
+ } //finish getForms
+
+ public static XIndexContainer getIndexedForms ( XDrawPage oDP )
+ {
+ XFormsSupplier oFS = (XFormsSupplier) UnoRuntime.queryInterface(
+ XFormsSupplier.class,oDP);
+ return (XIndexContainer)UnoRuntime.queryInterface( XIndexContainer.class,
+ oFS.getForms() );
+ } //finish getIndexedForms
+
+ public static void insertForm ( XComponent aDoc, XNameContainer Forms,
+ String aName ) {
+ try {
+ XInterface oControl = createControl(aDoc, "Form");
+ XForm oForm = (XForm) UnoRuntime.queryInterface(XForm.class, oControl);
+ Forms.insertByName(aName,oForm);
+ } catch ( Exception e ) {
+ throw new IllegalArgumentException( "Couldn't insert Form" );
+ }
+ }
+
+ public static XControlShape insertControlShape( XComponent oDoc, int height,
+ int width, int x, int y, String kind ) {
+
+ XControlShape aShape = createControlShape(oDoc,height,width,x,y,kind);
+ XDrawPage oDP = DrawTools.getDrawPage(oDoc,0);
+ DrawTools.getShapes(oDP).add(aShape);
+ return aShape;
+ }
+
+ public static XLoadable bindForm( XTextDocument aDoc ) {
+ XLoadable formLoader = null;
+
+ try {
+ Object aForm = FormTools.getIndexedForms(WriterTools.getDrawPage(aDoc)).getByIndex(0);
+ XForm the_form = null;
+ try {
+ the_form = (XForm) AnyConverter.toObject(new Type(XForm.class), aForm);
+ } catch (com.sun.star.lang.IllegalArgumentException iae) {
+ System.out.println("### Couldn't convert Any");
+ }
+ XPropertySet formProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, the_form);
+ formProps.setPropertyValue("DataSourceName","Bibliography");
+ formProps.setPropertyValue("Command","biblio");
+ formProps.setPropertyValue("CommandType",new Integer(com.sun.star.sdb.CommandType.TABLE));
+ formLoader = (XLoadable) UnoRuntime.queryInterface(XLoadable.class, the_form);
+ }
+ catch (Exception ex) {
+ System.out.println("Exception: "+ex);
+ ex.printStackTrace(System.out);
+ }
+
+ return formLoader;
+ }
+
+ /**
+ * Binds <code>'Standard'</code> form of <code>aDoc</code> Writer document
+ * to the <code>tableName</code> table of <code>sourceName</code>
+ * Data Source.
+ * @param aDoc Writer document where DB controls are added.
+ * @param sourceName The name of DataSource in the <code>DatabaseContext</code>.
+ * @param tableName The name of the table to which controls are bound.
+ * @return <code>com.sun.star.form.component.DatabaseForm</code> service
+ * implementation which is the bound form inside the document.
+ */
+ public static XLoadable bindForm( XTextDocument aDoc, String sourceName, String tableName )
+ throws com.sun.star.uno.Exception {
+
+ XForm the_form = (XForm) AnyConverter.toObject(new Type(XForm.class),
+ FormTools.getIndexedForms(WriterTools.getDrawPage(aDoc)).getByIndex(0));
+ XPropertySet formProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, the_form);
+ formProps.setPropertyValue("DataSourceName",sourceName);
+ formProps.setPropertyValue("Command",tableName);
+ formProps.setPropertyValue("CommandType",new Integer(com.sun.star.sdb.CommandType.TABLE));
+
+ return (XLoadable) UnoRuntime.queryInterface(XLoadable.class, the_form);
+ }
+
+ public static XLoadable bindForm( XTextDocument aDoc, String formName ) {
+ XLoadable formLoader = null;
+
+ try {
+ XForm the_form = (XForm) FormTools.getForms(WriterTools.getDrawPage(aDoc)).getByName(formName);
+ XPropertySet formProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, the_form);
+ formProps.setPropertyValue("DataSourceName","Bibliography");
+ formProps.setPropertyValue("Command","biblio");
+ formProps.setPropertyValue("CommandType",new Integer(com.sun.star.sdb.CommandType.TABLE));
+ formLoader = (XLoadable) UnoRuntime.queryInterface(XLoadable.class, the_form);
+ }
+ catch (Exception ex) {
+ System.out.println("Exception: "+ex);
+ ex.printStackTrace(System.out);
+ }
+
+ return formLoader;
+ }
+
+ /**
+ * Binds the form with the name specified of <code>aDoc</code> Writer document
+ * to the <code>tableName</code> table of <code>sourceName</code>
+ * Data Source.
+ * @param aDoc Writer document where DB controls are added.
+ * @param formName The name of the form to be bound.
+ * @param sourceName The name of DataSource in the <code>DatabaseContext</code>.
+ * @param tableName The name of the table to which controls are bound.
+ * @return <code>com.sun.star.form.component.DatabaseForm</code> service
+ * implementation which is the bound form inside the document.
+ */
+ public static XLoadable bindForm( XTextDocument aDoc, String formName, String sourceName,
+ String tableName) throws com.sun.star.uno.Exception {
+
+ XForm the_form = (XForm) AnyConverter.toObject(new Type(XForm.class),
+ FormTools.getForms(WriterTools.getDrawPage(aDoc)).getByName(formName));
+ XPropertySet formProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, the_form);
+ formProps.setPropertyValue("DataSourceName",sourceName);
+ formProps.setPropertyValue("Command",tableName);
+ formProps.setPropertyValue("CommandType",new Integer(com.sun.star.sdb.CommandType.TABLE));
+
+ return (XLoadable) UnoRuntime.queryInterface(XLoadable.class, the_form);
+ }
+
+ public static void switchDesignOf(XMultiServiceFactory xMSF, XTextDocument aDoc) {
+ try {
+ com.sun.star.frame.XController aController = aDoc.getCurrentController();
+ com.sun.star.frame.XFrame aFrame = aController.getFrame();
+ com.sun.star.frame.XDispatchProvider aDispProv = (com.sun.star.frame.XDispatchProvider)
+ UnoRuntime.queryInterface(com.sun.star.frame.XDispatchProvider.class,aFrame);
+ com.sun.star.util.URL aURL = new com.sun.star.util.URL();
+ aURL.Complete = ".uno:SwitchControlDesignMode";
+
+ Object instance = xMSF.createInstance("com.sun.star.util.URLTransformer");
+ com.sun.star.util.XURLTransformer atrans =
+ (com.sun.star.util.XURLTransformer)UnoRuntime.queryInterface(
+ com.sun.star.util.XURLTransformer.class,instance);
+ com.sun.star.util.URL[] aURLA = new com.sun.star.util.URL[1];
+ aURLA[0] = aURL;
+ atrans.parseStrict(aURLA);
+ aURL = aURLA[0];
+
+ com.sun.star.frame.XDispatch aDisp = (com.sun.star.frame.XDispatch)aDispProv.queryDispatch(aURL, "",
+ com.sun.star.frame.FrameSearchFlag.SELF |
+ com.sun.star.frame.FrameSearchFlag.CHILDREN);
+
+ com.sun.star.beans.PropertyValue[] noArgs = new com.sun.star.beans.PropertyValue[0];
+ aDisp.dispatch(aURL, noArgs);
+ } catch (Exception e) {
+ System.out.println("******* Mist");
+ e.printStackTrace();
+ }
+ }
+
+}
diff --git a/qadevOOo/runner/util/FrameDsc.java b/qadevOOo/runner/util/FrameDsc.java
new file mode 100644
index 000000000000..4bfb64e8459c
--- /dev/null
+++ b/qadevOOo/runner/util/FrameDsc.java
@@ -0,0 +1,126 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package util;
+
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.uno.XInterface;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.text.XTextFrame;
+import com.sun.star.drawing.XShape;
+import com.sun.star.awt.Size;
+import com.sun.star.beans.XPropertySet;
+/**
+ * the class FrameDsc
+ */
+public class FrameDsc extends InstDescr {
+
+ private Size size = null;
+ private int height = 2000;
+ private int width = 2000;
+ private String name = null;
+ private int autoheigth = 0;
+ private int anchorType = 0;// bound at paragraph
+
+ final String ifcName = "com.sun.star.text.XTextFrame";
+ final String service = "com.sun.star.text.TextFrame";
+
+ public FrameDsc() {
+ initFrame();
+ }
+
+ public FrameDsc( int nHeight, int nWidth ) {
+ height = nHeight;
+ width = nWidth;
+ initFrame();
+ }
+
+ public FrameDsc( String FrameName, int nHeight, int nWidth ) {
+ name = FrameName;
+ height = nHeight;
+ width = nWidth;
+ initFrame();
+ }
+ public String getName() {
+ return name;
+ }
+ public String getIfcName() {
+ return ifcName;
+ }
+ public String getService() {
+ return service;
+ }
+
+ private void initFrame() {
+ try {
+ ifcClass = Class.forName( ifcName );
+ }
+ catch( ClassNotFoundException cnfE ) {
+ }
+ }
+ public XInterface createInstance( XMultiServiceFactory docMSF ) {
+ Object SrvObj = null;
+
+ size = new Size();
+ size.Height = height;
+ size.Width = width;
+
+ try {
+ SrvObj = docMSF.createInstance( service );
+ }
+ catch( com.sun.star.uno.Exception cssuE ){
+ }
+ XShape shape = (XShape)UnoRuntime.queryInterface( XShape.class, SrvObj );
+ try {
+ shape.setSize(size);
+ }
+ catch( com.sun.star.beans.PropertyVetoException pvE ){
+ }
+
+ XTextFrame TF = (XTextFrame)UnoRuntime.queryInterface( ifcClass, SrvObj );
+
+ XPropertySet oPropSet = (XPropertySet)
+ UnoRuntime.queryInterface( XPropertySet.class, SrvObj );
+
+
+ try {
+ oPropSet.setPropertyValue("AnchorType", new Integer(2));
+ }
+ catch( com.sun.star.beans.UnknownPropertyException upE ){
+ }
+ catch( com.sun.star.beans.PropertyVetoException pvE ){
+ }
+ catch( com.sun.star.lang.IllegalArgumentException iaE ){
+ }
+ catch( com.sun.star.lang.WrappedTargetException wtE ){
+ }
+
+
+
+ return TF;
+ }
+}
diff --git a/qadevOOo/runner/util/InstCreator.java b/qadevOOo/runner/util/InstCreator.java
new file mode 100644
index 000000000000..b76066d7e95e
--- /dev/null
+++ b/qadevOOo/runner/util/InstCreator.java
@@ -0,0 +1,122 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package util;
+
+import util.XInstCreator;
+
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XInterface;
+import com.sun.star.text.XTextTablesSupplier;
+import com.sun.star.text.XTextFramesSupplier;
+import com.sun.star.text.XTextSectionsSupplier;
+import com.sun.star.text.XFootnotesSupplier;
+import com.sun.star.text.XBookmarksSupplier;
+import com.sun.star.container.XNameAccess;
+import com.sun.star.container.XIndexAccess;
+
+
+public class InstCreator implements XInstCreator {
+ XInterface xParent;
+ XMultiServiceFactory xMSF;
+ XInterface xInstance;
+ XIndexAccess xIA;
+ InstDescr iDsc;
+
+ public InstCreator( XInterface xParent, InstDescr iDsc ) {
+ this.xParent = xParent;
+ this.iDsc = iDsc;
+
+ xMSF = (XMultiServiceFactory)UnoRuntime.queryInterface(
+ XMultiServiceFactory.class, xParent );
+
+ xInstance = createInstance();
+ xIA = createCollection();
+ }
+ public XInterface getInstance() {
+ return xInstance;
+ }
+
+ public XInterface createInstance() {
+ XInterface xIfc = null;
+ Object xObj = null;
+
+ xIfc = iDsc.createInstance( xMSF );
+
+ return xIfc;
+ }
+
+ public XIndexAccess getCollection() {
+ return xIA;
+ }
+
+ private XIndexAccess createCollection() {
+ XNameAccess oNA = null;
+
+ if ( iDsc instanceof TableDsc ) {
+ XTextTablesSupplier oTTS = (XTextTablesSupplier)
+ UnoRuntime.queryInterface(
+ XTextTablesSupplier.class, xParent );
+
+ oNA = oTTS.getTextTables();
+ }
+ if ( iDsc instanceof FrameDsc ) {
+ XTextFramesSupplier oTTS = (XTextFramesSupplier)
+ UnoRuntime.queryInterface(
+ XTextFramesSupplier.class, xParent );
+
+ oNA = oTTS.getTextFrames();
+ }
+ if ( iDsc instanceof BookmarkDsc ) {
+ XBookmarksSupplier oTTS = (XBookmarksSupplier)
+ UnoRuntime.queryInterface(
+ XBookmarksSupplier.class, xParent );
+
+ oNA = oTTS.getBookmarks();
+ }
+
+ if ( iDsc instanceof FootnoteDsc ) {
+ XFootnotesSupplier oTTS = (XFootnotesSupplier)
+ UnoRuntime.queryInterface(
+ XFootnotesSupplier.class, xParent );
+
+ return( oTTS.getFootnotes() );
+ }
+
+ if ( iDsc instanceof TextSectionDsc ) {
+ XTextSectionsSupplier oTSS = (XTextSectionsSupplier)
+ UnoRuntime.queryInterface(
+ XTextSectionsSupplier.class, xParent );
+
+ oNA = oTSS.getTextSections();
+ }
+
+ return (XIndexAccess)UnoRuntime.queryInterface(
+ XIndexAccess.class, oNA);
+ }
+} \ No newline at end of file
diff --git a/qadevOOo/runner/util/InstDescr.java b/qadevOOo/runner/util/InstDescr.java
new file mode 100644
index 000000000000..e8343bc866e3
--- /dev/null
+++ b/qadevOOo/runner/util/InstDescr.java
@@ -0,0 +1,53 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package util;
+
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.uno.XInterface;
+/**
+ * the class InstDescr
+ */
+abstract public class InstDescr {
+
+ protected Class ifcClass = null;
+
+ protected abstract String getIfcName();
+ protected abstract String getName();
+
+ /**
+ * the method getIfcClass
+ */
+ public Class getIfcClass() {
+ return ifcClass;
+ }
+ /**
+ * the method getService
+ */
+ protected abstract String getService();
+ protected abstract XInterface createInstance( XMultiServiceFactory docMSF );
+} \ No newline at end of file
diff --git a/qadevOOo/runner/util/ParagraphDsc.java b/qadevOOo/runner/util/ParagraphDsc.java
new file mode 100644
index 000000000000..acaa630baad5
--- /dev/null
+++ b/qadevOOo/runner/util/ParagraphDsc.java
@@ -0,0 +1,85 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package util;
+
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.uno.XInterface;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.text.XTextContent;
+
+/**
+ * the class ParagraphDsc
+ */
+public class ParagraphDsc extends InstDescr {
+
+ final String service = "com.sun.star.text.Paragraph";
+ String ifcName = "com.sun.star.text.XTextContent";
+ private String name = null;
+
+
+ public ParagraphDsc() {
+ initParagraph();
+ }
+
+ public ParagraphDsc( String name ) {
+ this.name = name;
+ initParagraph();
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getIfcName() {
+ return ifcName;
+ }
+
+ public String getService() {
+ return service;
+ }
+
+ private void initParagraph() {
+ try {
+ ifcClass = Class.forName( ifcName );
+ }
+ catch( ClassNotFoundException cnfE ) {
+ }
+ }
+ public XInterface createInstance( XMultiServiceFactory docMSF ) {
+ Object ServiceObj = null;
+
+ try {
+ ServiceObj = docMSF.createInstance( service );
+ }
+ catch( com.sun.star.uno.Exception cssuE ){
+ }
+ XTextContent PG = (XTextContent)UnoRuntime.queryInterface( ifcClass,
+ ServiceObj );
+ return PG;
+ }
+} \ No newline at end of file
diff --git a/qadevOOo/runner/util/PropertyName.java b/qadevOOo/runner/util/PropertyName.java
new file mode 100644
index 000000000000..075fa4d9704e
--- /dev/null
+++ b/qadevOOo/runner/util/PropertyName.java
@@ -0,0 +1,169 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package util;
+
+/**
+ * This interfaces describes some key names which are used in <CODE>lib.TestParameters</CODE>.
+ */
+
+public interface PropertyName {
+ /**
+ * parameter name: "AppExecutionCommand"
+ */
+ final public static String APP_EXECUTION_COMMAND = "AppExecutionCommand";
+ /**
+ * parameter name: "AppKillCommand"
+ */
+ final public static String APP_KILL_COMMAND = "AppKillCommand";
+ /**
+ * parameter name: "ConnectionString"
+ */
+ final public static String CONNECTION_STRING = "ConnectionString";
+ final public static String PIPE_CONNECTION_STRING = "PipeConnectionString";
+ final public static String USE_PIPE_CONNECTION = "UsePipeConnection";
+
+ /**
+ * parameter name: "TestBase"
+ */
+ final public static String TEST_BASE = "TestBase";
+ /**
+ * parameter name: "TestDocumentPath"
+ */
+ final public static String TEST_DOCUMENT_PATH = "TestDocumentPath";
+ /**
+ * parameter name: "LoggingIsActive"
+ */
+ final public static String LOGGING_IS_ACTIVE = "LoggingIsActive";
+ /**
+ * parameter name: "DebugIsActive"
+ */
+ final public static String DEBUG_IS_ACTIVE = "DebugIsActive";
+ /**
+ * parameter name: "OutProduceer"
+ */
+ final public static String OUT_PRODUCER = "OutProducer";
+ /**
+ * parameter name: "ShortWait"
+ */
+ final public static String SHORT_WAIT= "ShortWait";
+ /**
+ * internal only, no parameter
+ */
+ final public static String OFFICE_PROVIDER = "OfficeProvider";
+ /**
+ * internal only, no parameter
+ */
+ final public static String OFFICE_WATCHER = "Watcher";
+ /**
+ * internal only, no parameter
+ */
+ final public static String LOG_WRITER = "LogWriter";
+ /**
+ * parameter name: "TimeOut"<p>
+ * time out given in milli seconds
+ */
+ final public static String TIME_OUT = "TimeOut";
+ /**
+ * parameter name: "ThreadTimeOut"
+ */
+ final public static String THREAD_TIME_OUT = "ThreadTimeOut";
+ /**
+ * parameter name: "OfficeCloseTimeOut"
+ */
+ final public static String OFFICE_CLOSE_TIME_OUT = "OfficeCloseTimeOut";
+ /**
+ * parameter name: "OperatingSystem"
+ */
+ final public static String OPERATING_SYSTEM = "OperatingSystem";
+ /**
+ * parameter name: "AutoRestart"
+ */
+ final public static String AUTO_RESTART = "AutoRestart";
+ /**
+ * parameter name: "NewOfficeInstance"
+ */
+ final public static String NEW_OFFICE_INSTANCE = "NewOfficeInstance";
+ /**
+ * parameter name: "KeepDocument"
+ */
+ final public static String KEEP_DOCUMENT = "KeepDocument";
+ /**
+ * parameter name: "SRC_ROOT"<p>
+ * path to the source root of OpenOffice.org
+ */
+ final public static String SRC_ROOT = "SRC_ROOT";
+ /**
+ * parameter name: "Version"<p>
+ * the name of the version to test
+ */
+ final public static String VERSION = "Version";
+
+ /**
+ * parameter name "Shell"<p>
+ * Path to a shell.
+ * This shell is used to run some commands outside of Java
+ * example: /bin/tcsh c:\\myShell\\myShell.exe
+ */
+ final public static String SHELL = "Shell";
+ /**
+ * parameter name "Cygwin"<p>
+ * If Cygwin is set to TRUE it indicates if the runner runs in a Cygwin
+ * environment
+ */
+ final public static String CYGWIN = "Cygwin";
+ /**
+ * parameter name: "NoCwsAttach"<p>
+ * If this paraeter is set to "true" , a status of CWS-UnoAPI-Tests was not attached to EIS<p>
+ * @see tests.complex.unoapi.CheckModuleAPI
+ */
+ final public static String NO_CWS_ATTACH = "NoCwsAttach";
+ /**
+ * internal only, no parameter
+ */
+ final public static String WNTMSCI = "wntmsci";
+ /**
+ * internal only, no parameter
+ */
+ final public static String UNXLNGI = "unxlngi";
+ /**
+ * internal only, no parameter
+ */
+ final public static String UNXSOLS = "unxsols";
+ /**
+ * internal only, no parameter
+ */
+ final public static String UNXSOLI = "unxsoli";
+ /**
+ * internal only, no parameter
+ */
+ final public static String UNXMACXI = "unxmacxi";
+
+ /**
+ * can be used to dont backup the user layer, faster office start/stop but less secure default is to backup the user layer
+ */
+ final public static String DONT_BACKUP_USERLAYER = "DontBackupUserLayer";
+}
diff --git a/qadevOOo/runner/util/ReferenceMarkDsc.java b/qadevOOo/runner/util/ReferenceMarkDsc.java
new file mode 100644
index 000000000000..948fab207a13
--- /dev/null
+++ b/qadevOOo/runner/util/ReferenceMarkDsc.java
@@ -0,0 +1,84 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package util;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.uno.XInterface;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.text.XTextContent;
+
+/**
+ * the class ReferenceMarkDsc
+ */
+public class ReferenceMarkDsc extends InstDescr {
+
+ final String service = "com.sun.star.text.ReferenceMark";
+ String ifcName = "com.sun.star.text.XTextContent";
+ private String name = null;
+
+
+ public ReferenceMarkDsc() {
+ initReferenceMark();
+ }
+
+ public ReferenceMarkDsc( String name ) {
+ this.name = name;
+ initReferenceMark();
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getIfcName() {
+ return ifcName;
+ }
+
+ public String getService() {
+ return service;
+ }
+
+ private void initReferenceMark() {
+ try {
+ ifcClass = Class.forName( ifcName );
+ }
+ catch( ClassNotFoundException cnfE ) {
+ }
+ }
+ public XInterface createInstance( XMultiServiceFactory docMSF ) {
+ Object ServiceObj = null;
+
+ try {
+ ServiceObj = docMSF.createInstance( service );
+ }
+ catch( com.sun.star.uno.Exception cssuE ){
+ }
+ XTextContent RM = (XTextContent)UnoRuntime.queryInterface( ifcClass,
+ ServiceObj );
+ return RM;
+ }
+} \ No newline at end of file
diff --git a/qadevOOo/runner/util/RegistryTools.java b/qadevOOo/runner/util/RegistryTools.java
new file mode 100644
index 000000000000..199eb1c01451
--- /dev/null
+++ b/qadevOOo/runner/util/RegistryTools.java
@@ -0,0 +1,370 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package util;
+
+// access the implementations via names
+import com.sun.star.uno.UnoRuntime;
+import java.io.PrintWriter ;
+
+import com.sun.star.registry.XRegistryKey ;
+import com.sun.star.registry.XSimpleRegistry ;
+import com.sun.star.registry.RegistryKeyType ;
+import com.sun.star.registry.RegistryValueType ;
+import com.sun.star.registry.InvalidRegistryException ;
+import com.sun.star.lang.XMultiServiceFactory ;
+import com.sun.star.uno.Exception;
+
+public class RegistryTools {
+
+ /**
+ * Creates 'com.sun.star.registry.SimpleRegistry'
+ * service.
+ * @param xMSF Multiservice factory.
+ * @return Service created.
+ */
+ public static XSimpleRegistry createRegistryService
+ (XMultiServiceFactory xMSF) throws com.sun.star.uno.Exception {
+
+ Object oInterface = xMSF.createInstance
+ ("com.sun.star.registry.SimpleRegistry");
+ return (XSimpleRegistry) UnoRuntime.queryInterface (
+ XSimpleRegistry.class, oInterface) ;
+ }
+
+ /**
+ * Opens registry file for reading/writing. If file doesn't
+ * exist a new one created.
+ * @param file Registry file name.
+ * @param xMSF Multiservice factory.
+ * @return Opened registry.
+ */
+ public static XSimpleRegistry openRegistry
+ (String file, XMultiServiceFactory xMSF)
+ throws com.sun.star.uno.Exception {
+
+ XSimpleRegistry reg = createRegistryService(xMSF) ;
+
+ reg.open(file, false, true) ;
+
+ return reg ;
+ }
+
+ /**
+ * Compares two registry keys, their names, value
+ * types and values.
+ * return <code>true</code> if key names, value types
+ * and values are equal, else returns <code>false</code>.
+ */
+ public static boolean compareKeys
+ (XRegistryKey key1, XRegistryKey key2) {
+
+ if (key1 == null || key2 == null ||
+ !key1.isValid() || !key2.isValid())
+
+ return false ;
+
+ String keyName1 = getShortKeyName(key1.getKeyName()) ;
+ String keyName2 = getShortKeyName(key2.getKeyName()) ;
+
+ if (!keyName1.equals(keyName2)) return false ;
+
+ try {
+ if (key1.getValueType() != key2.getValueType()) return false ;
+ } catch (InvalidRegistryException e) {
+ return false ;
+ }
+
+ RegistryValueType type ;
+ try {
+ type = key1.getValueType() ;
+
+ if (type.equals(RegistryValueType.ASCII)) {
+ if (!key1.getAsciiValue().equals(key2.getAsciiValue()))
+ return false ;
+ } else
+ if (type.equals(RegistryValueType.STRING)) {
+ if (!key1.getStringValue().equals(key2.getStringValue()))
+ return false ;
+ } else
+ if (type.equals(RegistryValueType.LONG)) {
+ if (key1.getLongValue() != key2.getLongValue())
+ return false ;
+ } else
+ if (type.equals(RegistryValueType.BINARY)) {
+ byte[] bin1 = key1.getBinaryValue() ;
+ byte[] bin2 = key2.getBinaryValue() ;
+ if (bin1.length != bin2.length)
+ return false ;
+ for (int i = 0; i < bin1.length; i++)
+ if (bin1[i] != bin2[i]) return false ;
+ } else
+ if (type.equals(RegistryValueType.ASCIILIST)) {
+ String[] list1 = key1.getAsciiListValue() ;
+ String[] list2 = key2.getAsciiListValue() ;
+ if (list1.length != list2.length)
+ return false ;
+ for (int i = 0; i < list1.length; i++)
+ if (!list1[i].equals(list2[i])) return false ;
+ } else
+ if (type.equals(RegistryValueType.STRINGLIST)) {
+ String[] list1 = key1.getStringListValue() ;
+ String[] list2 = key2.getStringListValue() ;
+ if (list1.length != list2.length)
+ return false ;
+ for (int i = 0; i < list1.length; i++)
+ if (!list1[i].equals(list2[i])) return false ;
+ } else
+ if (type.equals(RegistryValueType.LONGLIST)) {
+ int[] list1 = key1.getLongListValue() ;
+ int[] list2 = key2.getLongListValue() ;
+ if (list1.length != list2.length)
+ return false ;
+ for (int i = 0; i < list1.length; i++)
+ if (list1[i] != list2[i]) return false ;
+ }
+ } catch (Exception e) {
+ return false ;
+ }
+
+ return true ;
+ }
+
+ /**
+ * Gets name of the key relative to its parent.
+ * For example if full name of key is '/key1/subkey'
+ * short key name is 'subkey'
+ * @param keyName Full key name.
+ * @return Short key name.
+ */
+ public static String getShortKeyName(String keyName) {
+ if (keyName == null) return null ;
+ int idx = keyName.lastIndexOf("/") ;
+ if (idx < 0) return keyName ;
+ else return keyName.substring(idx + 1) ;
+ }
+
+ /**
+ * Compare all child keys.
+ * @param compareRoot If <code>true</code> method also
+ * compare root keys, if <code>false</code> it begins recursive
+ * comparing from children of root keys.
+ * @return <code>true</code> if keys and their sub keys are equal.
+ */
+ protected static boolean compareKeyTrees
+ (XRegistryKey tree1, XRegistryKey tree2, boolean compareRoot) {
+
+ if (compareRoot && !compareKeys(tree1, tree2)) return false ;
+
+ try {
+ String[] keyNames1 = tree1.getKeyNames() ;
+ String[] keyNames2 = tree2.getKeyNames() ;
+
+ if (keyNames1 == null && keyNames2 == null) return true ;
+
+ if (keyNames1 == null || keyNames2 == null ||
+ keyNames2.length != keyNames1.length)
+ return false ;
+
+ for (int i = 0; i < keyNames1.length; i++) {
+
+ String keyName = getShortKeyName(keyNames1[i]) ;
+ XRegistryKey key2 = tree2.openKey(keyName) ;
+
+ if (key2 == null)
+ // key with the same name doesn't exist in the second tree
+ return false ;
+
+ if (!tree1.getKeyType(keyName).equals(
+ tree2.getKeyType(keyName)))
+ return false ;
+
+ if (tree1.getKeyType(keyName).equals(
+ RegistryKeyType.LINK)) {
+
+ if (!getShortKeyName(tree1.getLinkTarget(keyName)).equals(
+ getShortKeyName(tree2.getLinkTarget(keyName))))
+
+ return false ;
+ } else {
+
+ if (compareKeyTrees(tree1.openKey(keyName),
+ tree2.openKey(keyName), true) == false) return false ;
+ }
+ }
+ } catch (InvalidRegistryException e) {
+ return false ;
+ }
+
+ return true ;
+ }
+
+ /**
+ * Compare keys specified and all their child keys.
+ * @return <code>true</code> if keys and their sub keys are equal.
+ */
+ public static boolean compareKeyTrees
+ (XRegistryKey tree1, XRegistryKey tree2) {
+
+ return compareKeyTrees(tree1, tree2, false) ;
+ }
+
+ /**
+ * Prints to a specified output about all keys and subkeys information
+ * (key name, type, value, link target, attributes) recursively.
+ * @param reg Registry for which information is needed.
+ * @param out Output stream.
+ */
+ public static void printRegistryInfo(XSimpleRegistry reg, PrintWriter out) {
+ try {
+ printRegistryInfo(reg.getRootKey(), out) ;
+ } catch (com.sun.star.registry.InvalidRegistryException e) {
+ out.println("!!! Can't open root registry key for info printing") ;
+ }
+ }
+
+ /**
+ * Prints to a specified output about all keys and subkeys information
+ * (key name, type, value, link target, attributes) recursively.
+ * @param root Key for which subkeys (and further) information is required.
+ * @param out Output stream.
+ */
+ public static void printRegistryInfo(XRegistryKey root, PrintWriter out) {
+ if (root == null) {
+ out.println("/(null)") ;
+ return ;
+ }
+
+ out.println("/") ;
+ try {
+ printTreeInfo(root, out, " ") ;
+ } catch (com.sun.star.registry.InvalidRegistryException e) {
+ out.println("Exception accessing registry :") ;
+ e.printStackTrace(out) ;
+ }
+ }
+
+ private static void printTreeInfo(XRegistryKey key,
+ PrintWriter out, String margin)
+ throws com.sun.star.registry.InvalidRegistryException {
+
+ String[] subKeys = key.getKeyNames() ;
+
+ if (subKeys == null || subKeys.length == 0) return ;
+
+ for (int i = 0; i < subKeys.length; i++) {
+ printKeyInfo(key, subKeys[i], out, margin) ;
+ XRegistryKey subKey = key.openKey
+ (getShortKeyName(subKeys[i])) ;
+ printTreeInfo(subKey, out, margin + " ") ;
+ subKey.closeKey() ;
+ }
+ }
+
+ private static void printKeyInfo(XRegistryKey parentKey,
+ String keyName, PrintWriter out, String margin)
+ throws com.sun.star.registry.InvalidRegistryException {
+
+ out.print(margin) ;
+ keyName = getShortKeyName(keyName) ;
+ XRegistryKey key = parentKey.openKey(keyName) ;
+ if (key != null)
+ out.print("/" + getShortKeyName(key.getKeyName()) + " ") ;
+ else {
+ out.println("(null)") ;
+ return ;
+ }
+
+ if (!key.isValid()) {
+ out.println("(not valid)") ;
+ return ;
+ }
+
+ if (key.isReadOnly()) {
+ out.print("(read only) ") ;
+ }
+
+ if (parentKey.getKeyType(keyName) == RegistryKeyType.LINK) {
+ out.println("(link to " + parentKey.getLinkTarget(keyName) + ")") ;
+ return ;
+ }
+
+ RegistryValueType type ;
+ try {
+ type = key.getValueType() ;
+
+ if (type.equals(RegistryValueType.ASCII)) {
+ out.println("[ASCII] = '" + key.getAsciiValue() + "'") ;
+ } else
+ if (type.equals(RegistryValueType.STRING)) {
+ out.println("[STRING] = '" + key.getStringValue() + "'") ;
+ } else
+ if (type.equals(RegistryValueType.LONG)) {
+ out.println("[LONG] = " + key.getLongValue()) ;
+ } else
+ if (type.equals(RegistryValueType.BINARY)) {
+ out.print("[BINARY] = {") ;
+ byte[] bin = key.getBinaryValue() ;
+ for (int i = 0; i < bin.length; i++)
+ out.print("" + bin[i] + ",") ;
+ out.println("}") ;
+ } else
+ if (type.equals(RegistryValueType.ASCIILIST)) {
+ out.print("[ASCIILIST] = {") ;
+ String[] list = key.getAsciiListValue() ;
+ for (int i = 0; i < list.length; i++)
+ out.print("'" + list[i] + "',") ;
+ out.println("}") ;
+ } else
+ if (type.equals(RegistryValueType.STRINGLIST)) {
+ out.print("[STRINGLIST] = {") ;
+ String[] list = key.getStringListValue() ;
+ for (int i = 0; i < list.length; i++)
+ out.print("'" + list[i] + "',") ;
+ out.println("}") ;
+ } else
+ if (type.equals(RegistryValueType.LONGLIST)) {
+ out.print("[LONGLIST] = {") ;
+ int[] list = key.getLongListValue() ;
+ for (int i = 0; i < list.length; i++)
+ out.print("" + list[i] + ",") ;
+ out.println("}") ;
+ } else {
+ out.println("") ;
+ }
+ } catch (com.sun.star.uno.Exception e) {
+ out.println("Exception occured : ") ;
+ e.printStackTrace(out) ;
+ } finally {
+ key.closeKey() ;
+ }
+ }
+
+
+// public static void compareKeyTrees
+
+}
diff --git a/qadevOOo/runner/util/SOfficeFactory.java b/qadevOOo/runner/util/SOfficeFactory.java
new file mode 100644
index 000000000000..80493fdee058
--- /dev/null
+++ b/qadevOOo/runner/util/SOfficeFactory.java
@@ -0,0 +1,629 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package util;
+
+import java.util.Hashtable;
+// access the implementations via names
+import com.sun.star.uno.XInterface;
+import com.sun.star.lang.XMultiServiceFactory;
+
+import com.sun.star.uno.UnoRuntime;
+// staroffice interfaces to provide desktop and componentloader
+// and components i.e. spreadsheets, writerdocs etc.
+import com.sun.star.frame.XDesktop;
+import com.sun.star.frame.XComponentLoader;
+import com.sun.star.lang.XComponent;
+import com.sun.star.lang.XServiceInfo;
+
+// name - value pair
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.beans.PropertyState;
+
+// additional classes required for testcase
+import com.sun.star.sheet.*;
+import com.sun.star.text.*;
+import com.sun.star.container.*;
+import com.sun.star.chart.*;
+import com.sun.star.drawing.*;
+import com.sun.star.awt.*;
+
+public class SOfficeFactory {
+
+ private static Hashtable lookup = new Hashtable(10);
+ protected XComponentLoader oCLoader;
+
+ private SOfficeFactory(XMultiServiceFactory xMSF) {
+ // get XInterface of Desktop service
+ Object oInterface;
+ try {
+ oInterface = xMSF.createInstance("com.sun.star.frame.Desktop");
+ } catch (com.sun.star.uno.Exception e) {
+ throw new IllegalArgumentException(
+ "Desktop Service not available");
+ }
+
+ // query the desktop interface and then it's componentloader
+ XDesktop oDesktop = (XDesktop) UnoRuntime.queryInterface(
+ XDesktop.class, oInterface);
+
+ oCLoader = (XComponentLoader) UnoRuntime.queryInterface(
+ XComponentLoader.class, oDesktop);
+ }
+
+ public static SOfficeFactory getFactory(XMultiServiceFactory xMSF) {
+
+ SOfficeFactory soFactory = (SOfficeFactory) lookup.get(new Integer(xMSF.hashCode()).toString());
+
+ if (soFactory == null) {
+ soFactory = new SOfficeFactory(xMSF);
+ lookup.put(new Integer(xMSF.hashCode()).toString(), soFactory);
+ }
+
+ return soFactory;
+ }
+
+ // *********************************************************
+ // Document creation. The documents needed are created here.
+ // *********************************************************
+ /**
+ * method which opens a new TextDocument
+ *
+ * @see XTextDocument
+ */
+ public XTextDocument createTextDoc(String frameName)
+ throws com.sun.star.uno.Exception {
+
+ XComponent oDoc = openDoc("swriter", frameName);
+
+ if (oDoc != null) {
+ DesktopTools.bringWindowToFront(oDoc);
+ return (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, oDoc);
+ } else {
+ return null;
+ }
+
+ } // finished createTextDoc
+
+ /**
+ * method which opens a new TextDocument
+ *
+ * @see XTextDocument
+ */
+ public XTextDocument createTextDoc(String frameName, PropertyValue[] mediaDescriptor)
+ throws com.sun.star.uno.Exception {
+
+ XComponent oDoc = openDoc("swriter", frameName, mediaDescriptor);
+
+ if (oDoc != null) {
+ DesktopTools.bringWindowToFront(oDoc);
+ return (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, oDoc);
+ } else {
+ return null;
+ }
+ } // finished createTextDoc
+
+ /**
+ * method which opens a new SpreadsheetDocument
+ *
+ * @see XSpreadsheetDocument
+ */
+ public XSpreadsheetDocument createCalcDoc(String frameName)
+ throws com.sun.star.uno.Exception {
+
+ XComponent oDoc = openDoc("scalc", frameName);
+
+ if (oDoc != null) {
+ DesktopTools.bringWindowToFront(oDoc);
+ return (XSpreadsheetDocument) UnoRuntime.queryInterface(XSpreadsheetDocument.class, oDoc);
+ } else {
+ return null;
+ }
+ } // finished createCalcDoc
+
+ /**
+ * method which opens a new SpreadsheetDocument
+ *
+ * @see XSpreadsheetDocument
+ */
+ public XSpreadsheetDocument createCalcDoc(String frameName, PropertyValue[] mediaDescriptor)
+ throws com.sun.star.uno.Exception {
+
+ XComponent oDoc = openDoc("scalc", frameName, mediaDescriptor);
+
+ if (oDoc != null) {
+ DesktopTools.bringWindowToFront(oDoc);
+ return (XSpreadsheetDocument) UnoRuntime.queryInterface(XSpreadsheetDocument.class, oDoc);
+ } else {
+ return null;
+ }
+ } // finished createCalcDoc
+
+ /**
+ * method which opens a new DrawDocument
+ */
+ public XComponent createDrawDoc(String frameName)
+ throws com.sun.star.uno.Exception {
+
+ return openDoc("sdraw", frameName);
+ } // finished createDrawDoc
+
+ /**
+ * method which opens a new ImpressDocument
+ */
+ /**
+ * method which opens a new DrawDocument
+ */
+ public XComponent createDrawDoc(String frameName, PropertyValue[] mediaDescriptor)
+ throws com.sun.star.uno.Exception {
+
+ return openDoc("sdraw", frameName, mediaDescriptor);
+ } // finished createDrawDoc
+
+ /**
+ * method which opens a new ImpressDocument
+ */
+ public XComponent createImpressDoc(String frameName)
+ throws com.sun.star.uno.Exception {
+
+ return openDoc("simpress", frameName);
+ } // finished createImpressDoc
+
+ /**
+ * method which opens a new ImpressDocument
+ */
+ public XComponent createImpressDoc(String frameName, PropertyValue[] mediaDescriptor)
+ throws com.sun.star.uno.Exception {
+
+ return openDoc("simpress", frameName, mediaDescriptor);
+ } // finished createImpressDoc
+
+ /**
+ * method which opens a new MathDocument
+ */
+ public XComponent createMathDoc(String frameName)
+ throws com.sun.star.uno.Exception {
+
+ return openDoc("smath", frameName);
+ } // finished createMathDoc
+
+ /**
+ * method which opens a new MathDocument
+ */
+ public XComponent createMathDoc(String frameName, PropertyValue[] mediaDescriptor)
+ throws com.sun.star.uno.Exception {
+
+ return openDoc("smath", frameName, mediaDescriptor);
+ } // finished createMathDoc
+
+ /**
+ * method which opens a new ChartDocument
+ *
+ * @see XChartDocument
+ */
+ public XChartDocument createChartDoc(String frameName)
+ throws com.sun.star.uno.Exception {
+
+// XComponent oDoc = loadDocument(
+// util.utils.getFullTestURL("emptyChart.sds"));
+
+ XComponent oDoc = loadDocument("private:factory/schart");
+
+ if (oDoc != null) {
+ DesktopTools.bringWindowToFront(oDoc);
+ return (XChartDocument) UnoRuntime.queryInterface(XChartDocument.class, oDoc);
+ } else {
+ return null;
+ }
+
+ } // finished createChartDoc
+
+ /**
+ * creates a simple TextTable defaultet to 2 rows and 2 columns
+ */
+ public static XTextTable createTextTable(XTextDocument xTextDoc)
+ throws com.sun.star.uno.Exception {
+
+ TableDsc tDsc = new TableDsc();
+ InstCreator instCreate = new InstCreator(xTextDoc, tDsc);
+
+ XTextTable oTable = (XTextTable) instCreate.getInstance();
+ return oTable;
+ }
+
+ /**
+ * creates a TextTable with a specified count of rows and columns
+ */
+ public static XTextTable createTextTable(XTextDocument xTextDoc,
+ int rows, int columns)
+ throws com.sun.star.uno.Exception {
+
+ TableDsc tDsc = new TableDsc(rows, columns);
+ InstCreator instCreate = new InstCreator(xTextDoc, tDsc);
+
+ XTextTable oTable = (XTextTable) instCreate.getInstance();
+ return oTable;
+ }
+
+ /**
+ * creates a simple TextFrame
+ * ... to be continued
+ */
+ public static XTextFrame createTextFrame(XTextDocument xTextDoc)
+ throws com.sun.star.uno.Exception {
+
+ FrameDsc tDsc = new FrameDsc();
+ InstCreator instCreate = new InstCreator(xTextDoc, tDsc);
+
+ XTextFrame oFrame = (XTextFrame) instCreate.getInstance();
+ return oFrame;
+ }
+
+ /**
+ * creates a simple TextFrame
+ * ... to be continued
+ */
+ public static XTextFrame createTextFrame(XTextDocument xTextDoc,
+ int height, int width) {
+
+ FrameDsc tDsc = new FrameDsc(height, width);
+ InstCreator instCreate = new InstCreator(xTextDoc, tDsc);
+
+ XTextFrame oFrame = (XTextFrame) instCreate.getInstance();
+ return oFrame;
+ }
+
+ public static void insertString(XTextDocument xTextDoc, String cString)
+ throws com.sun.star.uno.Exception {
+ XText xText = xTextDoc.getText();
+ XText oText = (XText) UnoRuntime.queryInterface(
+ XText.class, xText);
+
+ XTextCursor oCursor = oText.createTextCursor();
+ oText.insertString(oCursor, cString, false);
+ }
+
+ public static void insertTextContent(XTextDocument xTextDoc,
+ XTextContent xCont)
+ throws com.sun.star.lang.IllegalArgumentException {
+ XText xText = xTextDoc.getText();
+ XText oText = (XText) UnoRuntime.queryInterface(
+ XText.class, xText);
+
+ XTextCursor oCursor = oText.createTextCursor();
+ oText.insertTextContent(oCursor, xCont, false);
+ }
+
+ public static com.sun.star.table.XCell getFirstTableCell(
+ XTextContent oTable) {
+
+ String CellNames[] = ((XTextTable) oTable).getCellNames();
+
+ com.sun.star.table.XCell oCell = ((XTextTable) oTable).getCellByName(
+ CellNames[0]);
+ return oCell;
+
+ }
+
+ /**
+ * the method createBookmark
+ */
+ public static XTextContent createBookmark(XTextDocument xTextDoc)
+ throws com.sun.star.uno.Exception {
+
+ BookmarkDsc tDsc = new BookmarkDsc();
+ InstCreator instCreate = new InstCreator(xTextDoc, tDsc);
+
+ XTextContent oBookmark = (XTextContent) instCreate.getInstance();
+ return oBookmark;
+
+ } /// finish createBookmark
+
+ /**
+ * the method createReferenceMark
+ */
+ public static XTextContent createReferenceMark(XTextDocument xTextDoc)
+ throws com.sun.star.uno.Exception {
+
+ ReferenceMarkDsc tDsc = new ReferenceMarkDsc();
+ InstCreator instCreate = new InstCreator(xTextDoc, tDsc);
+
+ XTextContent oReferenceMark = (XTextContent) instCreate.getInstance();
+ return oReferenceMark;
+
+ } /// finish createReferenceMark
+
+ /**
+ * the method createFootnote
+ */
+ public static XTextContent createFootnote(XTextDocument xTextDoc)
+ throws com.sun.star.uno.Exception {
+
+ FootnoteDsc tDsc = new FootnoteDsc();
+ InstCreator instCreate = new InstCreator(xTextDoc, tDsc);
+
+ XTextContent oFootnote = (XTextContent) instCreate.getInstance();
+ return oFootnote;
+
+ } /// finish createFootnote
+
+ /**
+ * the method create Index
+ */
+ public static XTextContent createIndex(XTextDocument xTextDoc, String kind)
+ throws com.sun.star.uno.Exception {
+
+ XMultiServiceFactory oDocMSF = (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class,
+ xTextDoc);
+
+ Object oInt = oDocMSF.createInstance(kind);
+
+ XTextContent xTC = (XTextContent) UnoRuntime.queryInterface(XDocumentIndex.class, oInt);
+
+ return xTC;
+
+ }
+
+ public static XSpreadsheet createSpreadsheet(XSpreadsheetDocument oDoc)
+ throws com.sun.star.uno.Exception {
+
+ XMultiServiceFactory oDocMSF = (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, oDoc);
+
+ Object oInt = oDocMSF.createInstance(
+ "com.sun.star.sheet.Spreadsheet");
+
+ XSpreadsheet oSpreadsheet = (XSpreadsheet) UnoRuntime.queryInterface(XSpreadsheet.class, oInt);
+
+ return oSpreadsheet;
+ }
+
+ public static XIndexAccess getTableCollection(XTextDocument oDoc) {
+
+ XTextTablesSupplier oTTS = (XTextTablesSupplier) UnoRuntime.queryInterface(XTextTablesSupplier.class, oDoc);
+
+ XNameAccess oNA = oTTS.getTextTables();
+ XIndexAccess oIA = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, oNA);
+
+ return oIA;
+ }
+
+ public static String getUniqueName(XInterface oInterface, String prefix) {
+ XNameAccess oNameAccess = (XNameAccess) UnoRuntime.queryInterface(XNameAccess.class, oInterface);
+ if (oNameAccess == null) {
+ return null;
+ }
+ int i;
+ for (i = 0; oNameAccess.hasByName(prefix + i); i++) {
+ }
+ ;
+ return prefix + i;
+ }
+
+ public XShape createShape(XComponent oDoc, int height, int width, int x, int y, String kind) {
+ //possible values for kind are 'Ellipse', 'Line' and 'Rectangle'
+
+ ShapeDsc sDsc = new ShapeDsc(height, width, x, y, kind);
+ InstCreator instCreate = new InstCreator(oDoc, sDsc);
+
+ XShape oShape = (XShape) instCreate.getInstance();
+
+ return oShape;
+
+ }
+
+ /**
+ * creates a Diagram wich specified in kind(String)
+ */
+ public XDiagram createDiagram(XComponent oDoc, String kind) {
+ XInterface oInterface = null;
+ XDiagram oDiagram = null;
+
+ //get LineDiagram
+ XMultiServiceFactory oDocMSF = (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, oDoc);
+
+ try {
+ oInterface = (XInterface) oDocMSF.createInstance("com.sun.star.chart." + kind);
+ oDiagram = (XDiagram) UnoRuntime.queryInterface(XDiagram.class, oInterface);
+ } catch (Exception e) {
+ // Some exception occures.FAILED
+ System.out.println("Couldn't create " + kind + "-Diagram " + e);
+ }
+ return oDiagram;
+ }
+
+ /*
+ // create a Control-Instance which specified in kind(String)
+ */
+ public XInterface createControl(XComponent oDoc, String kind) {
+
+ XInterface oControl = null;
+
+ XMultiServiceFactory oDocMSF = (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, oDoc);
+
+ try {
+ oControl = (XInterface) oDocMSF.createInstance("com.sun.star.form.component." + kind);
+ } catch (Exception e) {
+ // Some exception occures.FAILED
+ System.out.println("Couldn't create instance " + kind + ": " + e);
+ }
+ return oControl;
+ }
+
+ /*
+ // create an Instance which is specified in kind(String)
+ */
+ public Object createInstance(XComponent oDoc, String kind) {
+
+ Object oInstance = null;
+
+ XMultiServiceFactory oDocMSF = (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, oDoc);
+
+ try {
+ oInstance = (Object) oDocMSF.createInstance(kind);
+ } catch (Exception e) {
+ // Some exception occures.FAILED
+ System.out.println("Couldn't create instance " + kind + ": " + e);
+ }
+ return oInstance;
+ }
+
+ public XControlShape createControlShape(XComponent oDoc, int height, int width, int x, int y, String kind) {
+
+ Size size = new Size();
+ Point position = new Point();
+ XControlShape oCShape = null;
+ XControlModel aControl = null;
+
+ //get MSF
+ XMultiServiceFactory oDocMSF = (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, oDoc);
+
+ try {
+ Object oInt = oDocMSF.createInstance("com.sun.star.drawing.ControlShape");
+ Object aCon = oDocMSF.createInstance("com.sun.star.form.component." + kind);
+ aControl = (XControlModel) UnoRuntime.queryInterface(XControlModel.class, aCon);
+ oCShape = (XControlShape) UnoRuntime.queryInterface(XControlShape.class, oInt);
+ size.Height = height;
+ size.Width = width;
+ position.X = x;
+ position.Y = y;
+ oCShape.setSize(size);
+ oCShape.setPosition(position);
+
+
+ } catch (Exception e) {
+ // Some exception occures.FAILED
+ System.out.println("Couldn't create instance " + e);
+ }
+
+ try {
+ oCShape.setControl(aControl);
+ } catch (Exception e) {
+ // Some exception occures.FAILED
+ System.out.println("Couldn't get Control " + e);
+ }
+
+
+ return oCShape;
+
+ }
+
+ public XComponent loadDocument(String fileName)
+ throws com.sun.star.lang.IllegalArgumentException,
+ com.sun.star.io.IOException,
+ com.sun.star.uno.Exception {
+
+ // that noargs thing for load attributes
+ PropertyValue[] szEmptyArgs = new PropertyValue[0];
+ String frameName = "_blank";
+
+ XComponent oDoc = oCLoader.loadComponentFromURL(
+ fileName, frameName, 0, szEmptyArgs);
+
+ if (oDoc == null) {
+ return null;
+ }
+ DesktopTools.bringWindowToFront(oDoc);
+ return oDoc;
+ }
+
+ public XComponent loadDocument(String fileName, PropertyValue[] Args)
+ throws com.sun.star.lang.IllegalArgumentException,
+ com.sun.star.io.IOException,
+ com.sun.star.uno.Exception {
+
+ // that noargs thing for load attributes
+ String frameName = "_blank";
+
+ XComponent oDoc = oCLoader.loadComponentFromURL(
+ fileName, frameName, 0, Args);
+
+ if (oDoc == null) {
+ return null;
+ }
+ DesktopTools.bringWindowToFront(oDoc);
+
+ return oDoc;
+ }
+
+ public XComponent openDoc(String kind, String frameName)
+ throws com.sun.star.lang.IllegalArgumentException,
+ com.sun.star.io.IOException,
+ com.sun.star.uno.Exception {
+
+ // that noargs thing for load attributes
+ PropertyValue[] Args = null;
+ if (kind.equals("simpress")) {
+ Args = new PropertyValue[1];
+ PropertyValue Arg = new PropertyValue();
+ Arg.Name = "OpenFlags";
+ Arg.Value = "S";
+ Arg.Handle = -1;
+ Arg.State = PropertyState.DEFAULT_VALUE;
+ Args[0] = Arg;
+ } else {
+ Args = new PropertyValue[0];
+ }
+
+ if (frameName == null) {
+ frameName = "_blank";
+ }
+ // load a blank a doc
+ XComponent oDoc = oCLoader.loadComponentFromURL("private:factory/" + kind, frameName, 40, Args);
+ DesktopTools.bringWindowToFront(oDoc);
+
+ return oDoc;
+
+ } // finished openDoc
+
+ public XComponent openDoc(String kind, String frameName, PropertyValue[] mediaDescriptor)
+ throws com.sun.star.lang.IllegalArgumentException,
+ com.sun.star.io.IOException,
+ com.sun.star.uno.Exception {
+
+ if (frameName == null) {
+ frameName = "_blank";
+ }
+ // load a blank a doc
+ XComponent oDoc = oCLoader.loadComponentFromURL(
+ "private:factory/" + kind, frameName, 40, mediaDescriptor);
+ DesktopTools.bringWindowToFront(oDoc);
+
+ return oDoc;
+
+ } // finished openDoc
+
+ // query for XServiceInfo
+ public Object queryXServiceInfo(Object oObj) {
+ if (oObj != null) {
+ XServiceInfo oInfo = (XServiceInfo) UnoRuntime.queryInterface(
+ XServiceInfo.class, oObj);
+ System.out.println("!!!! XServiceInfo n.a. !!!! ");
+ } else {
+ System.out.println("Object is empty!!!! ");
+ }
+ return null;
+ } // finish queryXServiceInfo
+} \ No newline at end of file
diff --git a/qadevOOo/runner/util/ShapeDsc.java b/qadevOOo/runner/util/ShapeDsc.java
new file mode 100644
index 000000000000..df9364a7d9a2
--- /dev/null
+++ b/qadevOOo/runner/util/ShapeDsc.java
@@ -0,0 +1,101 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package util;
+
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.uno.XInterface;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.drawing.*;
+import com.sun.star.awt.*;
+/**
+ * the class TableDsc
+ */
+public class ShapeDsc extends InstDescr {
+
+ private int x = 0;
+ private int y = 0;
+ private int height = 0;
+ private int width = 0;
+ private String name = null;
+ final String ifcName = "com.sun.star.drawing.XShape";
+ String service = "com.sun.star.drawing.RectangleShape";
+
+ public ShapeDsc( int nheight, int nwidth, int nx, int ny, String kind ) {
+ x=nx;
+ y=ny;
+ height=nheight;
+ width=nwidth;
+ service="com.sun.star.drawing."+kind+"Shape";
+ initShape();
+ }
+ public String getName() {
+ return name;
+ }
+
+ public String getIfcName() {
+ return ifcName;
+ }
+ public String getService() {
+ return service;
+ }
+
+ private void initShape() {
+ try {
+ ifcClass = Class.forName( ifcName );
+ }
+ catch( ClassNotFoundException cnfE ) {
+ }
+ }
+ public XInterface createInstance( XMultiServiceFactory docMSF ) {
+
+
+ Object SrvObj = null;
+ try {
+ SrvObj = docMSF.createInstance( service );
+ }
+ catch( com.sun.star.uno.Exception cssuE ){
+ }
+
+ XShape Sh = (XShape)UnoRuntime.queryInterface(ifcClass, SrvObj );
+ Size size = new Size();
+ Point position = new Point();
+ size.Height = height;
+ size.Width = width;
+ position.X = x;
+ position.Y = y;
+ try {
+ Sh.setSize(size);
+ Sh.setPosition(position);
+ }
+ catch ( com.sun.star.beans.PropertyVetoException e) {
+ }
+
+ return Sh;
+
+ }
+} \ No newline at end of file
diff --git a/qadevOOo/runner/util/StyleFamilyDsc.java b/qadevOOo/runner/util/StyleFamilyDsc.java
new file mode 100644
index 000000000000..eed3835bfab4
--- /dev/null
+++ b/qadevOOo/runner/util/StyleFamilyDsc.java
@@ -0,0 +1,80 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package util;
+
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.uno.XInterface;
+import com.sun.star.uno.UnoRuntime;
+
+/**
+ * the class StyleFamilyDsc
+ */
+public class StyleFamilyDsc extends InstDescr {
+
+ private String name = null;
+ final String ifcName = "com.sun.star.style.XStyle";
+ String service = "com.sun.star.style.CharacterStyle";
+
+ public StyleFamilyDsc( String kind ) {
+ service = "com.sun.star.style." + kind;
+ initStyleFamily();
+ }
+ public String getName() {
+ return name;
+ }
+
+ public String getIfcName() {
+ return ifcName;
+ }
+ public String getService() {
+ return service;
+ }
+
+ private void initStyleFamily() {
+ try {
+ ifcClass = Class.forName( ifcName );
+ }
+ catch( ClassNotFoundException cnfE ) {
+ }
+ }
+ public XInterface createInstance( XMultiServiceFactory docMSF ) {
+
+
+ Object SrvObj = null;
+ try {
+ SrvObj = docMSF.createInstance( service );
+ }
+ catch( com.sun.star.uno.Exception cssuE ){
+ }
+
+ XInterface StyleFamily = (XInterface)UnoRuntime.queryInterface(ifcClass, SrvObj );
+
+ return StyleFamily;
+
+ }
+}
diff --git a/qadevOOo/runner/util/SysUtils.java b/qadevOOo/runner/util/SysUtils.java
new file mode 100644
index 000000000000..110b7ea549d7
--- /dev/null
+++ b/qadevOOo/runner/util/SysUtils.java
@@ -0,0 +1,153 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package util;
+
+import java.io.File;
+import java.io.FileFilter;
+import java.util.ArrayList;
+
+import com.sun.star.frame.XDesktop;
+import com.sun.star.frame.XFrame;
+import com.sun.star.lang.XComponent;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.datatransfer.clipboard.*;
+import com.sun.star.datatransfer.*;
+
+public class SysUtils {
+
+ public static String getJavaPath() {
+ String cp = (String) System.getProperty("java.class.path");
+ String jh = (String) System.getProperty("java.home");
+ String fs = (String) System.getProperty("file.separator");
+ jh = jh + fs + "bin" + fs;
+ jh = jh + "java -classpath "+cp;
+ return jh;
+ }
+
+ static ArrayList files = new ArrayList();
+
+ public static Object[] traverse( String afileDirectory ) {
+
+ File fileDirectory = new File(afileDirectory);
+ // Testing, if the file is a directory, and if so, it throws an exception
+ if ( !fileDirectory.isDirectory() ) {
+ throw new IllegalArgumentException(
+ "not a directory: " + fileDirectory.getName()
+ );
+ }
+
+ // Getting all files and directories in the current directory
+ File[] entries = fileDirectory.listFiles(
+ new FileFilter() {
+ public boolean accept( File pathname ) {
+ return true;
+ }
+ }
+ );
+
+ // Iterating for each file and directory
+ for ( int i = 0; i < entries.length; ++i ) {
+ // Testing, if the entry in the list is a directory
+ if ( entries[ i ].isDirectory() ) {
+ // Recursive call for the new directory
+ traverse( entries[ i ].getAbsolutePath() );
+ } else {
+ // adding file to List
+ try {
+ // Composing the URL by replacing all backslashs
+ String stringUrl = "file:///"
+ + entries[ i ].getAbsolutePath().replace( '\\', '/' );
+ files.add(stringUrl);
+ }
+ catch( Exception exception ) {
+ exception.printStackTrace();
+ }
+
+ }
+ }
+ return files.toArray();
+ }
+
+ public static XComponent getActiveComponent(XMultiServiceFactory msf) {
+ XComponent ac = null;
+ try {
+ Object desk = msf.createInstance("com.sun.star.frame.Desktop");
+ XDesktop xDesk = (XDesktop) UnoRuntime.queryInterface(XDesktop.class,desk);
+ ac = xDesk.getCurrentComponent();
+ } catch (com.sun.star.uno.Exception e) {
+ System.out.println("Couldn't get active Component");
+ }
+ return ac;
+ }
+
+ public static XFrame getActiveFrame(XMultiServiceFactory msf) {
+ try {
+ Object desk = msf.createInstance("com.sun.star.frame.Desktop");
+ XDesktop xDesk = (XDesktop) UnoRuntime.queryInterface(XDesktop.class,desk);
+ return xDesk.getCurrentFrame();
+ } catch (com.sun.star.uno.Exception e) {
+ System.out.println("Couldn't get active Component");
+ }
+
+ return null;
+ }
+
+ /**
+ * Tries to obtain text data from cliboard if such one exists.
+ * The method iterates through all 'text/plain' supported data
+ * flavors and returns the first non-null String value.
+ *
+ * @param msf MultiserviceFactory
+ * @return First found string clipboard contents or null if no
+ * text contents were found.
+ * @throws com.sun.star.uno.Exception if system clipboard is not accessible.
+ */
+ public static String getSysClipboardText(XMultiServiceFactory msf)
+ throws com.sun.star.uno.Exception {
+
+ XClipboard xCB = (XClipboard) UnoRuntime.queryInterface
+ (XClipboard.class, msf.createInstance
+ ("com.sun.star.datatransfer.clipboard.SystemClipboard"));
+
+ XTransferable xTrans = xCB.getContents();
+
+ DataFlavor[] dfs = xTrans.getTransferDataFlavors();
+
+ for (int i = 0; i < dfs.length; i++) {
+ if (dfs[i].MimeType.startsWith("text/plain")) {
+ Object data = xTrans.getTransferData(dfs[i]);
+ if (data != null && data instanceof String) {
+ return (String) data;
+ }
+ }
+ }
+
+ return null;
+ }
+}
diff --git a/qadevOOo/runner/util/TableDsc.java b/qadevOOo/runner/util/TableDsc.java
new file mode 100644
index 000000000000..d933bc0cb041
--- /dev/null
+++ b/qadevOOo/runner/util/TableDsc.java
@@ -0,0 +1,96 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package util;
+
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.uno.XInterface;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.text.XTextTable;
+/**
+ * the class TableDsc
+ */
+public class TableDsc extends InstDescr {
+
+ private int rows = 0;
+ private int columns = 0;
+ private String name = null;
+ final String ifcName = "com.sun.star.text.XTextTable";
+ final String service = "com.sun.star.text.TextTable";
+
+ public TableDsc() {
+ initTable();
+ }
+
+ public TableDsc( int nRows, int nColumns ) {
+ rows = nRows;
+ columns = nColumns;
+ initTable();
+ }
+
+ public TableDsc( String TableName, int nRows, int nColumns ) {
+ name = TableName;
+ rows = nRows;
+ columns = nColumns;
+ initTable();
+ }
+ public String getName() {
+ return name;
+ }
+ public String getIfcName() {
+ return ifcName;
+ }
+ public String getService() {
+ return service;
+ }
+
+ private void initTable() {
+ try {
+ ifcClass = Class.forName( ifcName );
+ }
+ catch( ClassNotFoundException cnfE ) {
+ }
+ }
+ public XInterface createInstance( XMultiServiceFactory docMSF ) {
+ Object SrvObj = null;
+ try {
+ SrvObj = docMSF.createInstance( service );
+ }
+ catch( com.sun.star.uno.Exception cssuE ){
+ }
+
+ XTextTable TT = (XTextTable)UnoRuntime.queryInterface(
+ ifcClass, SrvObj );
+
+ if ( rows > 0 && columns > 0 ) {
+ TT.initialize( rows, columns );
+ }
+
+ return TT;
+
+ }
+}
diff --git a/qadevOOo/runner/util/TextSectionDsc.java b/qadevOOo/runner/util/TextSectionDsc.java
new file mode 100644
index 000000000000..3afcbbce5dd5
--- /dev/null
+++ b/qadevOOo/runner/util/TextSectionDsc.java
@@ -0,0 +1,84 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package util;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.uno.XInterface;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.text.XTextContent;
+
+/**
+ * the class TextSectionDsc
+ */
+public class TextSectionDsc extends InstDescr {
+
+ final String service = "com.sun.star.text.TextSection";
+ String ifcName = "com.sun.star.text.XTextContent";
+ private String name = null;
+
+
+ public TextSectionDsc() {
+ initTextSection();
+ }
+
+ public TextSectionDsc( String name ) {
+ this.name = name;
+ initTextSection();
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getIfcName() {
+ return ifcName;
+ }
+
+ public String getService() {
+ return service;
+ }
+
+ private void initTextSection() {
+ try {
+ ifcClass = Class.forName( ifcName );
+ }
+ catch( ClassNotFoundException cnfE ) {
+ }
+ }
+ public XInterface createInstance( XMultiServiceFactory docMSF ) {
+ Object ServiceObj = null;
+
+ try {
+ ServiceObj = docMSF.createInstance( service );
+ }
+ catch( com.sun.star.uno.Exception cssuE ){
+ }
+ XTextContent PG = (XTextContent)UnoRuntime.queryInterface( ifcClass,
+ ServiceObj );
+ return PG;
+ }
+} \ No newline at end of file
diff --git a/qadevOOo/runner/util/UITools.java b/qadevOOo/runner/util/UITools.java
new file mode 100644
index 000000000000..c9562949632f
--- /dev/null
+++ b/qadevOOo/runner/util/UITools.java
@@ -0,0 +1,814 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package util;
+
+import com.sun.star.awt.Point;
+import com.sun.star.awt.XTopWindow;
+import com.sun.star.awt.XWindow;
+import com.sun.star.text.XTextDocument;
+import com.sun.star.uno.UnoRuntime;
+
+import com.sun.star.frame.XModel;
+import com.sun.star.uno.XInterface;
+import com.sun.star.accessibility.XAccessible;
+import com.sun.star.accessibility.XAccessibleAction;
+import com.sun.star.accessibility.AccessibleRole;
+import com.sun.star.accessibility.XAccessibleComponent;
+import com.sun.star.awt.XExtendedToolkit;
+import com.sun.star.accessibility.XAccessibleContext;
+import com.sun.star.accessibility.XAccessibleEditableText;
+import com.sun.star.accessibility.XAccessibleSelection;
+import com.sun.star.accessibility.XAccessibleText;
+import com.sun.star.accessibility.XAccessibleValue;
+import com.sun.star.lang.XMultiServiceFactory;
+import java.awt.Robot;
+import java.awt.event.InputEvent;
+import java.io.PrintWriter;
+import java.util.Vector;
+import util.AccessibilityTools;
+
+
+/**
+ * This class supports some functions to handle easily accessible objects
+ */
+public class UITools {
+
+ private static final AccessibilityTools mAT = new AccessibilityTools();
+ private final XAccessible mXRoot;
+ private final XMultiServiceFactory mMSF;
+
+ public UITools(XMultiServiceFactory msf, XModel xModel)
+ {
+ mMSF = msf;
+ mXRoot = makeRoot(mMSF, xModel);
+ }
+
+ public UITools(XMultiServiceFactory msf, XTextDocument xTextDoc)
+ {
+ mMSF = msf;
+ XModel xModel = (XModel) UnoRuntime.queryInterface(XModel.class, xTextDoc);
+ mXRoot = makeRoot(mMSF, xModel);
+ }
+
+ public UITools(XMultiServiceFactory msf, XWindow xWindow)
+ {
+ mMSF = msf;
+ mXRoot = makeRoot(xWindow);
+ }
+
+ private static XAccessible makeRoot(XMultiServiceFactory msf, XModel aModel)
+ {
+ XWindow xWindow = mAT.getCurrentWindow(msf, aModel);
+ return mAT.getAccessibleObject(xWindow);
+ }
+
+
+ private static String getString(XInterface xInt)
+ {
+ XAccessibleText oText = (XAccessibleText)
+ UnoRuntime.queryInterface(XAccessibleText.class, xInt);
+ return oText.getText();
+ }
+
+ private static void setString(XInterface xInt, String cText)
+ {
+ XAccessibleEditableText oText = (XAccessibleEditableText)
+ UnoRuntime.queryInterface(XAccessibleEditableText.class, xInt);
+
+ oText.setText(cText);
+ }
+
+ private static Object getValue(XInterface xInt)
+ {
+ XAccessibleValue oValue = (XAccessibleValue)
+ UnoRuntime.queryInterface(XAccessibleValue.class, xInt);
+ return oValue.getCurrentValue();
+ }
+
+ private static XAccessible makeRoot(XWindow xWindow)
+ {
+ return mAT.getAccessibleObject(xWindow);
+ }
+
+ /**
+ * get the root element of the accessible tree
+ * @return the root element
+ */
+ public XAccessible getRoot()
+ {
+ return mXRoot;
+ }
+
+ /**
+ * Helper mathod: set a text into AccessibleEdit field
+ * @param textfiledName is the name of the text field
+ * @param stringToSet is the string to set
+ * @throws java.lang.Exception if something fail
+ */
+ public void setTextEditFiledText(String textfiledName, String stringToSet)
+ throws java.lang.Exception
+ {
+ XInterface oTextField = mAT.getAccessibleObjectForRole(mXRoot,
+ AccessibleRole.TEXT, textfiledName);
+ setString(oTextField, stringToSet);
+ }
+
+ /**
+ * returns the button by the given name
+ * @param buttonName is name name of the button to get
+ * @return a XAccessibleContext of the button
+ * @throws java.lang.Exception if something fail
+ */
+ public XAccessibleContext getButton(String buttonName) throws java.lang.Exception
+ {
+ return mAT.getAccessibleObjectForRole
+ (mXRoot, AccessibleRole.PUSH_BUTTON, buttonName);
+ }
+
+ /**
+ * Helper method: gets button via accessibility and 'click' it</code>
+ * @param buttonName is name name of the button to click
+ * @throws java.lang.Exception if something fail
+ */
+
+ public void clickButton(String buttonName) throws java.lang.Exception
+ {
+
+ XAccessibleContext oButton =mAT.getAccessibleObjectForRole
+ (mXRoot, AccessibleRole.PUSH_BUTTON, buttonName);
+ if (oButton == null){
+ throw new Exception("Could not get button '" + buttonName + "'");
+ }
+ XAccessibleAction oAction = (XAccessibleAction)
+ UnoRuntime.queryInterface(XAccessibleAction.class, oButton);
+
+ // "click" the button
+ try{
+ oAction.doAccessibleAction(0);
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
+ throw new Exception("Could not do accessible action with '" +
+ buttonName + "'" + e.toString());
+ }
+ }
+
+
+
+ /**
+ * Helper method: gets button via accessibility and 'click' it
+ * @param buttonName The name of the button in the accessibility tree
+ * @param toBePressed desired state of the toggle button
+ *
+ * @return true if the state of the button could be changed in the desired manner
+ */
+ private boolean clickToggleButton(String buttonName, boolean toBePressed)
+ {
+ XAccessibleContext oButton =mAT.getAccessibleObjectForRole
+ (mXRoot, AccessibleRole.TOGGLE_BUTTON, buttonName);
+
+ if (oButton != null){
+ boolean isChecked = oButton.getAccessibleStateSet().contains(com.sun.star.accessibility.AccessibleStateType.CHECKED);
+ if((isChecked && !toBePressed) || (!isChecked && toBePressed)){
+ XAccessibleAction oAction = (XAccessibleAction)
+ UnoRuntime.queryInterface(XAccessibleAction.class, oButton);
+ try{
+ // "click" the button
+ oAction.doAccessibleAction(0);
+ return true;
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
+ System.out.println("Could not do accessible action with '"
+ + buttonName + "'" + e.toString());
+ return false;
+ }
+ }else
+ //no need to press togglebar, do nothing
+ return true;
+ } else{
+ System.out.println("Could not get button '" + buttonName + "'");
+ return false;
+ }
+ }
+
+ /**
+ * Deactivates toggle button via Accessibility
+ * @param buttonName The name of the button in the Accessibility tree
+ *
+ * @return true if the button could be set to deactivated
+ */
+ public boolean deactivateToggleButton(String buttonName){
+ return clickToggleButton(buttonName, false);
+ }
+
+ /**
+ * Activates toggle button via Accessibility
+ * @param buttonName The name of the button in the Accessibility tree
+ *
+ * @return true if the button could be set to activated
+ */
+ public boolean activateToggleButton(String buttonName){
+ return clickToggleButton(buttonName, true);
+ }
+
+ /**
+ * returns the value of named radio button
+ * @param buttonName the name of the button to get the value of
+ * @throws java.lang.Exception if something fail
+ * @return Integer
+ */
+ public Integer getRadioButtonValue(String buttonName)
+ throws java.lang.Exception
+ {
+ try {
+ XInterface xRB =mAT.getAccessibleObjectForRole(mXRoot,
+ AccessibleRole.RADIO_BUTTON, buttonName);
+
+ return (Integer) getValue(xRB);
+ } catch (Exception e) {
+ throw new Exception("Could not get value from RadioButton '"
+ + buttonName + "' : " + e.toString());
+ }
+ }
+
+ /**
+ * returns the named graphic
+ * @param GraphicName the name of the graphic
+ * @return XInterface
+ * @throws java.lang.Exception if something fail
+ */
+ public XInterface getGraphic(String GraphicName) throws java.lang.Exception
+ {
+ return mAT.getAccessibleObjectForRole(mXRoot, AccessibleRole.GRAPHIC,
+ GraphicName);
+ }
+
+
+ /**
+ * set a named radio button the a given value
+ * @param buttonName the name of the button to set
+ * @param iValue the value to set
+ * @throws java.lang.Exception if something fail
+ */
+ public void setRadioButtonValue(String buttonName, int iValue)
+ throws java.lang.Exception
+ {
+ try {
+ XInterface xRB =mAT.getAccessibleObjectForRole(mXRoot, AccessibleRole.RADIO_BUTTON, buttonName);
+ if(xRB == null)
+ System.out.println("AccessibleObjectForRole couldn't be found for " + buttonName);
+ XAccessibleValue oValue = (XAccessibleValue)
+ UnoRuntime.queryInterface(XAccessibleValue.class, xRB);
+ if(oValue == null)
+ System.out.println("XAccessibleValue couldn't be queried for " + buttonName);
+ oValue.setCurrentValue(new Integer(iValue));
+ } catch (Exception e) {
+ e.printStackTrace();
+
+ throw new Exception("Could not set value to RadioButton '"
+ + buttonName + "' : " + e.toString());
+ }
+
+ }
+
+ /**
+ * select an item in nanmed listbox
+ * @param ListBoxName the name of the listbox
+ * @param nChildIndex the index of the item to set
+ * @throws java.lang.Exception if something fail
+ */
+ public void selectListboxItem(String ListBoxName, int nChildIndex)
+ throws java.lang.Exception
+ {
+ try {
+ XAccessibleContext xListBox = null;
+
+ xListBox =mAT.getAccessibleObjectForRole(mXRoot,
+ AccessibleRole.COMBO_BOX, ListBoxName);
+ if (xListBox == null){
+ xListBox =mAT.getAccessibleObjectForRole(mXRoot,
+ AccessibleRole.PANEL, ListBoxName);
+ }
+ XAccessible xListBoxAccess = (XAccessible)
+ UnoRuntime.queryInterface(XAccessible.class, xListBox);
+
+ // if a List is not pulled to be open all entries are not visiblle, therefore the
+ // boolean argument
+ XAccessibleContext xList =mAT.getAccessibleObjectForRole(
+ xListBoxAccess, AccessibleRole.LIST, true);
+ XAccessibleSelection xListSelect = (XAccessibleSelection)
+ UnoRuntime.queryInterface(XAccessibleSelection.class, xList);
+
+ xListSelect.selectAccessibleChild(nChildIndex);
+
+ } catch (Exception e) {
+ throw new Exception("Could not select item '" +nChildIndex+
+ "' in listbox '" + ListBoxName + "' : " + e.toString());
+ }
+ }
+
+ /**
+ * This method returns all entries as XInterface of a list box
+ * @param ListBoxName the name of the listbox
+ * @return Object[] containing XInterface
+ * @throws java.lang.Exception if something fail
+ */
+
+ public Object[] getListBoxObjects(String ListBoxName)
+ throws java.lang.Exception
+ {
+ Vector Items = new Vector();
+ try {
+ XAccessibleContext xListBox = null;
+ XAccessibleContext xList = null;
+
+ xListBox =mAT.getAccessibleObjectForRole(mXRoot,
+ AccessibleRole.COMBO_BOX, ListBoxName);
+ if (xListBox == null){
+ xListBox =mAT.getAccessibleObjectForRole(mXRoot,
+ AccessibleRole.PANEL, ListBoxName);
+ }
+
+ if (xListBox == null){
+ // get the list of TreeListBox
+ xList =mAT.getAccessibleObjectForRole(mXRoot,
+ AccessibleRole.TREE, ListBoxName);
+
+ // all other list boxes have a children of kind of LIST
+ } else {
+
+ XAccessible xListBoxAccess = (XAccessible)
+ UnoRuntime.queryInterface(XAccessible.class, xListBox);
+ // if a List is not pulled to be open all entries are not visiblle, therefore the
+ // boolean argument
+ xList =mAT.getAccessibleObjectForRole(
+ xListBoxAccess, AccessibleRole.LIST, true);
+ }
+
+ for (int i=0;i<xList.getAccessibleChildCount();i++) {
+ try {
+ XAccessible xChild = xList.getAccessibleChild(i);
+ XAccessibleContext xChildCont =
+ xChild.getAccessibleContext();
+ XInterface xChildInterface = (XInterface)
+ UnoRuntime.queryInterface(XInterface.class, xChildCont);
+ Items.add(xChildInterface);
+
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
+ throw new Exception("Could not get child form list of '"
+ + ListBoxName + "' : " + e.toString());
+ }
+ }
+
+ } catch (Exception e) {
+ throw new Exception("Could not get list of items from '"
+ + ListBoxName + "' : " + e.toString());
+ }
+ Object[]ret = new XInterface[Items.size()];
+ for (int i=0;i<Items.size();i++){
+ ret[i] = Items.get(i);
+ }
+ return ret;
+ }
+
+ /**
+ * Helper method: returns the entry manes of a List-Box
+ * @param ListBoxName the name of the listbox
+ * @return the listbox entry names
+ * @throws java.lang.Exception if something fail
+ */
+
+ public String[] getListBoxItems(String ListBoxName)
+ throws java.lang.Exception
+ {
+ Vector Items = new Vector();
+ try {
+ XAccessibleContext xListBox = null;
+ XAccessibleContext xList = null;
+
+ xListBox =mAT.getAccessibleObjectForRole(mXRoot,
+ AccessibleRole.COMBO_BOX, ListBoxName);
+ if (xListBox == null){
+ xListBox =mAT.getAccessibleObjectForRole(mXRoot,
+ AccessibleRole.PANEL, ListBoxName);
+ }
+
+ if (xListBox == null){
+ // get the list of TreeListBox
+ xList =mAT.getAccessibleObjectForRole(mXRoot,
+ AccessibleRole.TREE, ListBoxName);
+
+ // all other list boxes have a children of kind of LIST
+ } else {
+
+ XAccessible xListBoxAccess = (XAccessible)
+ UnoRuntime.queryInterface(XAccessible.class, xListBox);
+ // if a List is not pulled to be open all entries are not visiblle, therefore the
+ // boolean argument
+ xList =mAT.getAccessibleObjectForRole(
+ xListBoxAccess, AccessibleRole.LIST, true);
+ }
+
+ for (int i=0;i<xList.getAccessibleChildCount();i++) {
+ try {
+ XAccessible xChild = xList.getAccessibleChild(i);
+ XAccessibleContext xChildCont =
+ xChild.getAccessibleContext();
+ XInterface xChildInterface = (XInterface)
+ UnoRuntime.queryInterface(XInterface.class, xChildCont);
+ Items.add(getString(xChildInterface));
+
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
+ throw new Exception("Could not get child form list of '"
+ + ListBoxName + "' : " + e.toString());
+ }
+ }
+
+ } catch (Exception e) {
+ throw new Exception("Could not get list of items from '"
+ + ListBoxName + "' : " + e.toString());
+ }
+ String[]ret = new String[Items.size()];
+ return (String[])Items.toArray(ret);
+ }
+ /**
+ * set to a named nureric filed a given value
+ * @param NumericFieldName the name of the nureic field
+ * @param cValue the value to set
+ * @throws java.lang.Exception if something fail
+ */
+ public void setNumericFieldValue(String NumericFieldName, String cValue)
+ throws java.lang.Exception
+ {
+ try{
+ XInterface xNumericField =mAT.getAccessibleObjectForRole(
+ mXRoot, AccessibleRole.TEXT, NumericFieldName);
+ //util.dbg.printInterfaces(xNumericField);
+ XAccessibleEditableText oValue = (XAccessibleEditableText)
+ UnoRuntime.queryInterface(
+ XAccessibleEditableText.class, xNumericField);
+
+ setString(xNumericField, cValue);
+ } catch (Exception e) {
+ throw new Exception("Could not set value '" + cValue +
+ "' into NumericField '" + NumericFieldName + "' : " + e.toString());
+ }
+ }
+
+ /**
+ * returns the value of a numeric field
+ * @param NumericFieldName the name of the numreic field
+ * @throws java.lang.Exception if something fail
+ * @return the value of the named numeric filed
+ */
+ public String getNumericFieldValue(String NumericFieldName)
+ throws java.lang.Exception
+ {
+ try{
+ XInterface xNumericField =mAT.getAccessibleObjectForRole(
+ mXRoot, AccessibleRole.TEXT, NumericFieldName);
+ return (String) getString(xNumericField);
+
+ } catch (Exception e) {
+ throw new Exception("Could get value from NumericField '"
+ + NumericFieldName + "' : " + e.toString());
+ }
+ }
+
+ private String removeCharactersFromCurrencyString(String stringVal)
+ throws java.lang.Exception
+ {
+ try{
+ int beginIndex = 0;
+ int endIndex = 0;
+ boolean startFound = false;
+ // find the first numeric character in stringVal
+ for(int i = 0; i < stringVal.length(); i++){
+ int numVal = Character.getNumericValue(stringVal.charAt(i));
+ // if ascii is a numeric value
+ if (numVal != -1){
+ beginIndex = i;
+ break;
+ }
+ }
+ // find the last numeric character in stringVal
+ for(int i = stringVal.length()-1; i > 0; i--){
+ int numVal = Character.getNumericValue(stringVal.charAt(i));
+ if (numVal != -1){
+ endIndex = i+1;
+ break;
+ }
+ }
+ String currencyVal = stringVal.substring(beginIndex, endIndex);
+
+ currencyVal = currencyVal.substring(0, currencyVal.length()-3) +
+ "#" + currencyVal.substring(currencyVal.length()-2);
+
+ currencyVal = utils.replaceAll13(currencyVal, ",", "");
+ currencyVal = utils.replaceAll13(currencyVal, "\\.", "");
+ currencyVal = utils.replaceAll13(currencyVal, "#", ".");
+
+ return currencyVal;
+ } catch (Exception e) {
+ throw new Exception("Could get remove characters from currency string '"
+ + stringVal + "' : " + e.toString());
+ }
+
+ }
+
+ /**
+ * returns the numeric value of a numeric filed. This is needed ie. for
+ * fileds include the moneytary unit.
+ * @param NumericFieldName the name of the numeric filed
+ * @return the value of the numeric filed
+ * @throws java.lang.Exception if something fail
+ */
+ public Double getNumericFieldNumericValue(String NumericFieldName)
+ throws java.lang.Exception
+ {
+ try{
+ Double retValue = null;
+ String sValue = getNumericFieldValue(NumericFieldName);
+ String sAmount = removeCharactersFromCurrencyString(sValue);
+ retValue = retValue.valueOf(sAmount);
+
+ return retValue;
+
+ } catch (Exception e) {
+ throw new Exception("Could get numeric value from NumericField '"
+ + NumericFieldName + "' : " + e.toString());
+ }
+ }
+
+
+ /**
+ * returns the content of a TextBox
+ * @param TextFieldName the name of the textbox
+ * @return the value of the text box
+ * @throws java.lang.Exception if something fail
+ */
+ public String getTextBoxText(String TextFieldName)
+ throws java.lang.Exception
+ {
+ String TextFieldText = null;
+ try{
+ XAccessibleContext xTextField =mAT.getAccessibleObjectForRole(mXRoot,
+ AccessibleRole.SCROLL_PANE, TextFieldName);
+ XAccessible xTextFieldAccess = (XAccessible)
+ UnoRuntime.queryInterface(XAccessible.class, xTextField);
+ XAccessibleContext xFrame =mAT.getAccessibleObjectForRole(
+ xTextFieldAccess, AccessibleRole.TEXT_FRAME);
+ for (int i=0;i<xFrame.getAccessibleChildCount();i++) {
+ try {
+ XAccessible xChild = xFrame.getAccessibleChild(i);
+ XAccessibleContext xChildCont =
+ xChild.getAccessibleContext();
+ XInterface xChildInterface = (XInterface)
+ UnoRuntime.queryInterface(XInterface.class, xChildCont);
+ TextFieldText += (getString(xChildInterface));
+
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
+ throw new Exception("Could not get child fom TextFrame of '"
+ + TextFieldName + "' : " + e.toString());
+ }
+ }
+ return TextFieldText;
+ } catch (Exception e) {
+ throw new Exception("Could not get content fom Textbox '"
+ + TextFieldName + "' : " + e.toString());
+ }
+ }
+
+ /**
+ * set a value to a named check box
+ * @param CheckBoxName the name of the check box
+ * @param Value the value to set
+ *<ul>
+ * <li>0: not checked </li>
+ * <li>1: checked </li>
+ * <li>2: don't know </li>
+ *</ul>
+ * @throws java.lang.Exception if something fail
+ */
+ public void setCheckBoxValue(String CheckBoxName, Integer Value)
+ throws java.lang.Exception
+ {
+ try {
+ XInterface xCheckBox =mAT.getAccessibleObjectForRole(mXRoot,
+ AccessibleRole.CHECK_BOX, CheckBoxName);
+ XAccessibleValue xCheckBoxValue = (XAccessibleValue)
+ UnoRuntime.queryInterface(XAccessibleValue.class, xCheckBox);
+ xCheckBoxValue.setCurrentValue(Value);
+
+ } catch (Exception e) {
+ throw new Exception("Could not set value to CheckBox '"
+ + CheckBoxName + "' : " + e.toString());
+ }
+ }
+
+ /**
+ * returns the value of the named check box
+ * @param CheckBoxName the name of the check box
+ * @return the value of the check box
+ * @throws java.lang.Exception if something fail
+ */
+ public Integer getCheckBoxValue(String CheckBoxName)
+ throws java.lang.Exception
+ {
+ try {
+ XInterface xCheckBox =mAT.getAccessibleObjectForRole(mXRoot,
+ AccessibleRole.CHECK_BOX, CheckBoxName);
+ XAccessibleValue xCheckBoxValue = (XAccessibleValue)
+ UnoRuntime.queryInterface(XAccessibleValue.class, xCheckBox);
+
+ return (Integer) xCheckBoxValue.getCurrentValue();
+ } catch (Exception e) {
+ throw new Exception("Could not set value to CheckBox '"
+ + CheckBoxName + "' : " + e.toString());
+ }
+ }
+
+ /**
+ * returns the message of a Basic-MessageBox
+ * @return the message of a Basic-MessageBox
+ * @throws java.lang.Exception if something fail
+ */
+ public String getMsgBoxText()
+ throws java.lang.Exception
+ {
+ String cMessage = null;
+ try{
+ XAccessibleContext xMessage =mAT.getAccessibleObjectForRole(mXRoot,
+ AccessibleRole.LABEL);
+
+ XInterface xMessageInterface = (XInterface)
+ UnoRuntime.queryInterface(XInterface.class, xMessage);
+ cMessage += (getString(xMessageInterface));
+
+
+ return cMessage;
+ } catch (Exception e) {
+ throw new Exception("Could not get message from Basic-MessageBox: " + e.toString());
+ }
+ }
+
+ /**
+ * fetch the window which is equal to the given <CODE>WindowName</CODE>
+ * @return the named window
+ * @throws java.lang.Exception if something fail
+ */
+ public XWindow getTopWindow(String WindowName, boolean debug) throws java.lang.Exception
+ {
+ XInterface xToolKit = null;
+ try {
+ xToolKit = (XInterface) mMSF.createInstance("com.sun.star.awt.Toolkit") ;
+ } catch (com.sun.star.uno.Exception e) {
+ throw new Exception("Could not toolkit: " + e.toString());
+ }
+ XExtendedToolkit tk = (XExtendedToolkit)
+ UnoRuntime.queryInterface(XExtendedToolkit.class, xToolKit);
+
+ int count = tk.getTopWindowCount();
+
+ XTopWindow retWindow = null;
+
+ if (debug) System.out.println("getTopWindow ->");
+
+ for (int i=0; i < count ; i++){
+ XTopWindow xTopWindow = tk.getTopWindow(i);
+ XAccessible xAcc = mAT.getAccessibleObject(xTopWindow);
+ String accName = xAcc.getAccessibleContext().getAccessibleName();
+
+ if (debug){
+ System.out.println("AccessibleName: " + accName);
+ }
+
+ if (WindowName.equals(accName)){
+ if (debug) System.out.println("-> found window with name '" + WindowName + "'");
+ retWindow = xTopWindow;
+ }
+ }
+
+
+ if (debug) {
+ if (retWindow == null) System.out.println("could not found window with name '" + WindowName + "'");
+ System.out.println("<- getTopWindow ");
+ }
+ return (XWindow) UnoRuntime.queryInterface(XWindow.class, retWindow);
+ }
+
+ public void clickMiddleOfAccessibleObject(short role, String name){
+
+ XAccessibleContext xAcc =mAT.getAccessibleObjectForRole(mXRoot, role, name);
+ XAccessibleComponent aComp = (XAccessibleComponent) UnoRuntime.queryInterface(
+ XAccessibleComponent.class, xAcc);
+
+ System.out.println(xAcc.getAccessibleRole() + "," +
+ xAcc.getAccessibleName() + "(" +
+ xAcc.getAccessibleDescription() + "):" +
+ utils.getImplName(xAcc));
+
+ if (aComp != null) {
+ Point location = aComp.getLocationOnScreen();
+ String bounds = "(" + aComp.getBounds().X + "," +
+ aComp.getBounds().Y + ")" + " (" +
+ aComp.getBounds().Width + "," +
+ aComp.getBounds().Height + ")";
+ System.out.println("The boundary Rectangle is " + bounds);
+ try {
+ Robot rob = new Robot();
+ int x = aComp.getLocationOnScreen().X + (aComp.getBounds().Width / 2);
+ int y = aComp.getLocationOnScreen().Y + (aComp.getBounds().Height / 2);
+ System.out.println("try to click mouse button on x/y " + x + "/" + y);
+ rob.mouseMove(x, y);
+ rob.mousePress(InputEvent.BUTTON1_MASK);
+ rob.mouseRelease(InputEvent.BUTTON1_MASK);
+ } catch (java.awt.AWTException e) {
+ System.out.println("couldn't press mouse button");
+ }
+
+ }
+ }
+
+ public void doubleClickMiddleOfAccessibleObject(short role, String name) {
+ XAccessibleContext xAcc =mAT.getAccessibleObjectForRole(mXRoot, role, name);
+ XAccessibleComponent aComp = (XAccessibleComponent) UnoRuntime.queryInterface(
+ XAccessibleComponent.class, xAcc);
+
+ System.out.println(xAcc.getAccessibleRole() + "," +
+ xAcc.getAccessibleName() + "(" +
+ xAcc.getAccessibleDescription() + "):" +
+ utils.getImplName(xAcc));
+
+ if (aComp != null) {
+ Point location = aComp.getLocationOnScreen();
+ String bounds = "(" + aComp.getBounds().X + "," +
+ aComp.getBounds().Y + ")" + " (" +
+ aComp.getBounds().Width + "," +
+ aComp.getBounds().Height + ")";
+ System.out.println("The boundary Rectangle is " + bounds);
+ try {
+ Robot rob = new Robot();
+ int x = aComp.getLocationOnScreen().X + (aComp.getBounds().Width / 2);
+ int y = aComp.getLocationOnScreen().Y + (aComp.getBounds().Height / 2);
+ System.out.println("try to double click mouse button on x/y " + x + "/" + y);
+ rob.mouseMove(x, y);
+ rob.mousePress(InputEvent.BUTTON1_MASK);
+ rob.mouseRelease(InputEvent.BUTTON1_MASK);
+ utils.shortWait(100);
+ rob.mousePress(InputEvent.BUTTON1_MASK);
+ rob.mouseRelease(InputEvent.BUTTON1_MASK);
+ } catch (java.awt.AWTException e) {
+ System.out.println("couldn't press mouse button");
+ }
+
+ }
+ }
+
+ /**
+ * <B>DEPRECATED</B>
+ * Since <CODE>AccessibilityTools</CODE> handle parameter <CODE>debugIsActive</CODE>
+ * this function does not work anymore.
+ * @deprecated Since <CODE>AccessibilityTools</CODE> handle parameter <CODE>debugIsActive</CODE>
+ * this function does not work anymore.
+ * @param log logWriter
+ */
+ public void printAccessibleTree(PrintWriter log)
+ {
+ mAT.printAccessibleTree(log, mXRoot);
+ }
+
+
+ /**
+ * Prints the accessible tree to the <CODE>logWriter</CODE> only if <CODE>debugIsActive</CODE>
+ * is set to <CODE>true</CODE>
+ * @param log logWriter
+ * @param debugIsActive prints only if this parameter is set to TRUE
+ */
+ public void printAccessibleTree(PrintWriter log, boolean debugIsActive) {
+ mAT.printAccessibleTree(log, mXRoot, debugIsActive);
+ }
+
+}
diff --git a/qadevOOo/runner/util/ValueChanger.java b/qadevOOo/runner/util/ValueChanger.java
new file mode 100644
index 000000000000..d63202d54e33
--- /dev/null
+++ b/qadevOOo/runner/util/ValueChanger.java
@@ -0,0 +1,994 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package util;
+
+import com.sun.star.awt.Point;
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.drawing.PolygonFlags;
+//import util.BitmapLoader;
+import com.sun.star.uno.Enum ;
+import java.lang.reflect.Field ;
+import java.lang.reflect.Method ;
+import java.lang.reflect.Modifier ;
+import java.lang.reflect.Array ;
+import com.sun.star.uno.Any;
+import com.sun.star.uno.AnyConverter;
+
+
+public class ValueChanger {
+
+
+ // Method to change a Value, thought for properties
+ public static Object changePValue( Object oldValue ) {
+
+ Object newValue = null;
+
+ if (oldValue instanceof com.sun.star.uno.Any) {
+ try {
+ oldValue = AnyConverter.toObject(((Any) oldValue).getType(),oldValue);
+ } catch (com.sun.star.lang.IllegalArgumentException iae) {
+ }
+ }
+
+ if (oldValue == null)
+ return null;
+
+ if (oldValue instanceof Boolean) {
+ boolean oldbool = ((Boolean) oldValue).booleanValue();
+ newValue = new Boolean(!oldbool);
+ } else
+
+ if (oldValue instanceof Integer) {
+ int oldint = ((Integer) oldValue).intValue();
+ newValue = new Integer(oldint+5);
+ } else
+
+ if (oldValue instanceof Long) {
+ long oldlong = ((Long) oldValue).longValue();
+ newValue = new Long(oldlong + 15);
+ } else
+
+ if (oldValue instanceof Short) {
+ short oldshort = ((Short) oldValue).shortValue();
+ newValue = new Short((short) (oldshort + 1));
+ } else
+
+ if (oldValue instanceof Byte) {
+ byte oldbyte = ((Byte) oldValue).byteValue();
+ newValue = new Byte((byte) (oldbyte + 1));
+ } else
+
+ if (oldValue instanceof Float) {
+ float oldfloat = ((Float) oldValue).floatValue();
+ newValue = new Float((float) (oldfloat + 16.7));
+ } else
+
+ if (oldValue instanceof Double) {
+ double olddouble = ((Double) oldValue).doubleValue();
+ newValue = new Double(olddouble + 17.8);
+ } else
+
+ if (oldValue instanceof String) {
+ String oldString = (String) oldValue;
+ newValue = oldString + "New";
+ } else
+
+
+ if (oldValue instanceof com.sun.star.chart.ChartAxisArrangeOrderType) {
+ Object AO1 = com.sun.star.chart.ChartAxisArrangeOrderType.AUTO;
+ Object AO2= com.sun.star.chart.ChartAxisArrangeOrderType.SIDE_BY_SIDE;
+ Object AO3= com.sun.star.chart.ChartAxisArrangeOrderType.STAGGER_EVEN;
+ Object AO4= com.sun.star.chart.ChartAxisArrangeOrderType.STAGGER_ODD;
+
+ if (oldValue.equals(AO1)) newValue = AO2;
+ if (oldValue.equals(AO2)) newValue = AO3;
+ if (oldValue.equals(AO3)) newValue = AO4;
+ if (oldValue.equals(AO4)) newValue = AO1;
+ } else
+
+ if (oldValue instanceof com.sun.star.view.PaperOrientation) {
+ Object OR1 = com.sun.star.view.PaperOrientation.LANDSCAPE;
+ Object OR2 = com.sun.star.view.PaperOrientation.PORTRAIT;
+
+ if (oldValue.equals(OR1)) newValue = OR2;
+ else newValue = OR1;
+ } else
+
+ if (oldValue instanceof com.sun.star.lang.Locale) {
+ Object Loc1 = new com.sun.star.lang.Locale("en","US","");
+ Object Loc2 = new com.sun.star.lang.Locale("de","DE","");
+
+ if (oldValue.equals(Loc1)) newValue = Loc2;
+ else newValue = Loc1;
+ } else
+
+ if (oldValue instanceof com.sun.star.style.ParagraphAdjust) {
+ Object PA1 = com.sun.star.style.ParagraphAdjust.LEFT;
+ Object PA2 = com.sun.star.style.ParagraphAdjust.CENTER;
+
+ if (oldValue.equals(PA1)) newValue = PA2;
+ else newValue = PA1;
+ } else
+
+ if (oldValue instanceof com.sun.star.style.LineSpacing) {
+ com.sun.star.style.LineSpacing LS = new com.sun.star.style.LineSpacing();
+ com.sun.star.style.LineSpacing LSold = (com.sun.star.style.LineSpacing) oldValue;
+ LS.Height = (short) ((LSold.Height)+1);
+ LS.Mode = (short) ((LSold.Mode)+1);
+ newValue = LS;
+ } else
+
+ if (oldValue instanceof com.sun.star.drawing.Direction3D) {
+ com.sun.star.drawing.Direction3D D3D = new com.sun.star.drawing.Direction3D();
+ com.sun.star.drawing.Direction3D D3Dold = (com.sun.star.drawing.Direction3D) oldValue;
+ D3D.DirectionX = D3Dold.DirectionX + .5;
+ D3D.DirectionY = D3Dold.DirectionY + .5;
+ D3D.DirectionZ = D3Dold.DirectionZ + .5;
+ newValue = D3D;
+ } else
+
+ if (oldValue instanceof com.sun.star.style.GraphicLocation) {
+ Object GL1 = com.sun.star.style.GraphicLocation.AREA;
+ Object GL2 = com.sun.star.style.GraphicLocation.LEFT_BOTTOM;
+
+ if (oldValue.equals(GL1)) newValue = GL2;
+ else newValue = GL1;
+ } else
+
+ if (oldValue instanceof com.sun.star.style.TabStop) {
+ com.sun.star.style.TabStop TS = new com.sun.star.style.TabStop();
+ com.sun.star.style.TabStop TSold = (com.sun.star.style.TabStop) oldValue;
+ com.sun.star.style.TabAlign TA1 = com.sun.star.style.TabAlign.CENTER;
+ com.sun.star.style.TabAlign TA2 = com.sun.star.style.TabAlign.RIGHT;
+
+ if ((TSold.Alignment).equals(TA1)) TS.Alignment = TA2;
+ else TS.Alignment = TA1;
+
+ TS.Position = ((TSold.Position)+1);
+
+ newValue = TS;
+ } else
+
+ if (oldValue instanceof com.sun.star.style.DropCapFormat) {
+ com.sun.star.style.DropCapFormat DCF = new com.sun.star.style.DropCapFormat();
+ com.sun.star.style.DropCapFormat DCFold = (com.sun.star.style.DropCapFormat) oldValue;
+ DCF.Count = (byte) ((DCFold.Count)+1);
+ DCF.Distance = (short) ((DCFold.Distance)+1);
+ DCF.Lines = (byte) ((DCFold.Lines)+1);
+ newValue = DCF;
+ } else
+
+ if (oldValue instanceof com.sun.star.text.TextContentAnchorType) {
+ com.sun.star.text.TextContentAnchorType TCAT1 = com.sun.star.text.TextContentAnchorType.AS_CHARACTER;
+ com.sun.star.text.TextContentAnchorType TCAT2 = com.sun.star.text.TextContentAnchorType.AT_CHARACTER;
+ com.sun.star.text.TextContentAnchorType TCAT3 = com.sun.star.text.TextContentAnchorType.AT_FRAME;
+ com.sun.star.text.TextContentAnchorType TCAT4 = com.sun.star.text.TextContentAnchorType.AT_PAGE;
+ com.sun.star.text.TextContentAnchorType TCAT5 = com.sun.star.text.TextContentAnchorType.AT_PARAGRAPH;
+ if (oldValue.equals(TCAT1)) newValue = TCAT2;
+ if (oldValue.equals(TCAT2)) newValue = TCAT3;
+ if (oldValue.equals(TCAT3)) newValue = TCAT4;
+ if (oldValue.equals(TCAT4)) newValue = TCAT5;
+ if (oldValue.equals(TCAT5)) newValue = TCAT1;
+ } else
+
+ if (oldValue instanceof com.sun.star.text.WrapTextMode) {
+ com.sun.star.text.WrapTextMode WTM1 = com.sun.star.text.WrapTextMode.DYNAMIC;
+ com.sun.star.text.WrapTextMode WTM2 = com.sun.star.text.WrapTextMode.LEFT;
+ com.sun.star.text.WrapTextMode WTM3 = com.sun.star.text.WrapTextMode.NONE;
+ com.sun.star.text.WrapTextMode WTM4 = com.sun.star.text.WrapTextMode.PARALLEL;
+ com.sun.star.text.WrapTextMode WTM5 = com.sun.star.text.WrapTextMode.RIGHT;
+ com.sun.star.text.WrapTextMode WTM6 = com.sun.star.text.WrapTextMode.THROUGHT;
+ if (oldValue.equals(WTM1)) newValue = WTM2;
+ if (oldValue.equals(WTM2)) newValue = WTM3;
+ if (oldValue.equals(WTM3)) newValue = WTM4;
+ if (oldValue.equals(WTM4)) newValue = WTM5;
+ if (oldValue.equals(WTM5)) newValue = WTM6;
+ if (oldValue.equals(WTM6)) newValue = WTM1;
+ } else
+
+ if (oldValue instanceof com.sun.star.awt.Size) {
+ com.sun.star.awt.Size oldSize = (com.sun.star.awt.Size) oldValue;
+ com.sun.star.awt.Size newSize = new com.sun.star.awt.Size();
+ newSize.Height = oldSize.Height +1;
+ newSize.Width = oldSize.Width +1;
+ newValue = newSize;
+ } else
+
+ if (oldValue instanceof com.sun.star.awt.Rectangle) {
+ com.sun.star.awt.Rectangle oldRectangle = (com.sun.star.awt.Rectangle) oldValue;
+ com.sun.star.awt.Rectangle newRectangle = new com.sun.star.awt.Rectangle();
+ newRectangle.Height =oldRectangle.Height +1;
+ newRectangle.Width = oldRectangle.Width +1;
+ newRectangle.X =oldRectangle.Y +1;
+ newRectangle.Y = oldRectangle.X +1;
+ newValue = newRectangle;
+ } else
+
+ if (oldValue instanceof com.sun.star.awt.Point) {
+ com.sun.star.awt.Point oldPoint = (com.sun.star.awt.Point) oldValue;
+ com.sun.star.awt.Point newPoint = new com.sun.star.awt.Point();
+ newPoint.X = oldPoint.X +1;
+ newPoint.Y = oldPoint.Y +1;
+ newValue = newPoint;
+ } else
+
+ if (oldValue instanceof com.sun.star.table.ShadowFormat) {
+ com.sun.star.table.ShadowFormat SF = new com.sun.star.table.ShadowFormat();
+ com.sun.star.table.ShadowFormat SFold = (com.sun.star.table.ShadowFormat) oldValue;
+ SF.IsTransparent = (! SFold.IsTransparent);
+ SF.ShadowWidth = (short) ((SFold.ShadowWidth)+1);
+ newValue = SF;
+ } else
+
+ if (oldValue instanceof com.sun.star.awt.FontSlant) {
+ com.sun.star.awt.FontSlant FS1 = com.sun.star.awt.FontSlant.DONTKNOW;
+ com.sun.star.awt.FontSlant FS2 = com.sun.star.awt.FontSlant.ITALIC;
+ com.sun.star.awt.FontSlant FS3 = com.sun.star.awt.FontSlant.NONE;
+ com.sun.star.awt.FontSlant FS4 = com.sun.star.awt.FontSlant.OBLIQUE;
+ com.sun.star.awt.FontSlant FS5 = com.sun.star.awt.FontSlant.REVERSE_ITALIC;
+ com.sun.star.awt.FontSlant FS6 = com.sun.star.awt.FontSlant.REVERSE_OBLIQUE;
+ if (oldValue.equals(FS1)) newValue = FS2;
+ if (oldValue.equals(FS2)) newValue = FS3;
+ if (oldValue.equals(FS3)) newValue = FS4;
+ if (oldValue.equals(FS4)) newValue = FS5;
+ if (oldValue.equals(FS5)) newValue = FS6;
+ if (oldValue.equals(FS6)) newValue = FS1;
+ } else
+
+ if (oldValue instanceof com.sun.star.table.CellHoriJustify) {
+ com.sun.star.table.CellHoriJustify CHJ1 = com.sun.star.table.CellHoriJustify.BLOCK;
+ com.sun.star.table.CellHoriJustify CHJ2 = com.sun.star.table.CellHoriJustify.CENTER;
+ com.sun.star.table.CellHoriJustify CHJ3 = com.sun.star.table.CellHoriJustify.LEFT;
+ com.sun.star.table.CellHoriJustify CHJ4 = com.sun.star.table.CellHoriJustify.REPEAT;
+ com.sun.star.table.CellHoriJustify CHJ5 = com.sun.star.table.CellHoriJustify.RIGHT;
+ com.sun.star.table.CellHoriJustify CHJ6 = com.sun.star.table.CellHoriJustify.STANDARD;
+ if (oldValue.equals(CHJ1)) newValue = CHJ2;
+ if (oldValue.equals(CHJ2)) newValue = CHJ3;
+ if (oldValue.equals(CHJ3)) newValue = CHJ4;
+ if (oldValue.equals(CHJ4)) newValue = CHJ5;
+ if (oldValue.equals(CHJ5)) newValue = CHJ6;
+ if (oldValue.equals(CHJ6)) newValue = CHJ1;
+ } else
+
+ if (oldValue instanceof com.sun.star.table.CellVertJustify) {
+ com.sun.star.table.CellVertJustify CVJ1 = com.sun.star.table.CellVertJustify.BOTTOM;
+ com.sun.star.table.CellVertJustify CVJ2 = com.sun.star.table.CellVertJustify.CENTER;
+ com.sun.star.table.CellVertJustify CVJ3 = com.sun.star.table.CellVertJustify.STANDARD;
+ com.sun.star.table.CellVertJustify CVJ4 = com.sun.star.table.CellVertJustify.TOP;
+ if (oldValue.equals(CVJ1)) newValue = CVJ2;
+ if (oldValue.equals(CVJ2)) newValue = CVJ3;
+ if (oldValue.equals(CVJ3)) newValue = CVJ4;
+ if (oldValue.equals(CVJ4)) newValue = CVJ1;
+ } else
+
+ if (oldValue instanceof com.sun.star.table.CellOrientation) {
+ com.sun.star.table.CellOrientation CO1 = com.sun.star.table.CellOrientation.BOTTOMTOP;
+ com.sun.star.table.CellOrientation CO2 = com.sun.star.table.CellOrientation.STACKED;
+ com.sun.star.table.CellOrientation CO3 = com.sun.star.table.CellOrientation.STANDARD;
+ com.sun.star.table.CellOrientation CO4 = com.sun.star.table.CellOrientation.TOPBOTTOM;
+ if (oldValue.equals(CO1)) newValue = CO2;
+ if (oldValue.equals(CO2)) newValue = CO3;
+ if (oldValue.equals(CO3)) newValue = CO4;
+ if (oldValue.equals(CO4)) newValue = CO1;
+ } else
+
+ if (oldValue instanceof com.sun.star.util.CellProtection) {
+ com.sun.star.util.CellProtection CP = new com.sun.star.util.CellProtection();
+ com.sun.star.util.CellProtection CPold = (com.sun.star.util.CellProtection) oldValue;
+ CP.IsFormulaHidden = (! CPold.IsFormulaHidden);
+ CP.IsHidden = (! CPold.IsHidden);
+ CP.IsLocked = (! CPold.IsLocked);
+ CP.IsPrintHidden = (! CPold.IsPrintHidden);
+ newValue = CP;
+ } else
+
+ if (oldValue instanceof com.sun.star.table.TableBorder) {
+ com.sun.star.table.TableBorder TBold = (com.sun.star.table.TableBorder) oldValue;
+ com.sun.star.table.TableBorder TB = new com.sun.star.table.TableBorder();
+ TB.IsBottomLineValid = (! TBold.IsBottomLineValid);
+ TB.IsDistanceValid = (! TBold.IsDistanceValid);
+ TB.IsRightLineValid = (! TBold.IsRightLineValid);
+ TB.IsTopLineValid = (! TBold.IsTopLineValid);
+ newValue = TB;
+ } else
+/*
+ if (oldValue instanceof com.sun.star.awt.XBitmap) {
+ newValue = new BitmapLoader();
+ }
+*/
+ if (oldValue instanceof com.sun.star.drawing.FillStyle) {
+ com.sun.star.drawing.FillStyle FS1 = com.sun.star.drawing.FillStyle.NONE;
+ com.sun.star.drawing.FillStyle FS2 = com.sun.star.drawing.FillStyle.SOLID;
+ com.sun.star.drawing.FillStyle FS3 = com.sun.star.drawing.FillStyle.GRADIENT;
+ com.sun.star.drawing.FillStyle FS4 = com.sun.star.drawing.FillStyle.HATCH;
+ com.sun.star.drawing.FillStyle FS5 = com.sun.star.drawing.FillStyle.BITMAP;
+ if (oldValue.equals(FS1)) newValue = FS2;
+ if (oldValue.equals(FS2)) newValue = FS3;
+ if (oldValue.equals(FS3)) newValue = FS4;
+ if (oldValue.equals(FS4)) newValue = FS5;
+ if (oldValue.equals(FS5)) newValue = FS1;
+ } else
+
+ if (oldValue instanceof com.sun.star.awt.Gradient){
+ com.sun.star.awt.Gradient _newValue = (com.sun.star.awt.Gradient)oldValue;
+ _newValue.Angle += 10;
+ _newValue.Border += 1;
+ _newValue.EndColor += 1000;
+ _newValue.EndIntensity -= 10;
+ _newValue.StartColor += 500;
+ _newValue.StartIntensity += 10;
+ _newValue.StepCount += 50;
+ _newValue.Style = com.sun.star.awt.GradientStyle.RADIAL;
+ _newValue.XOffset += 10;
+ _newValue.YOffset += 10;
+ newValue = _newValue;
+ } else
+
+ if (oldValue instanceof com.sun.star.text.GraphicCrop){
+ com.sun.star.text.GraphicCrop _newValue = (com.sun.star.text.GraphicCrop)oldValue;
+ _newValue.Bottom += 10;
+ _newValue.Left += 10;
+ _newValue.Right += 10;
+ _newValue.Top += 10;
+ newValue = _newValue;
+ } else
+
+ if (oldValue instanceof com.sun.star.drawing.BitmapMode){
+ com.sun.star.drawing.BitmapMode bm1 = com.sun.star.drawing.BitmapMode.NO_REPEAT;
+ com.sun.star.drawing.BitmapMode bm2 = com.sun.star.drawing.BitmapMode.REPEAT;
+ com.sun.star.drawing.BitmapMode bm3 = com.sun.star.drawing.BitmapMode.STRETCH;
+ if (oldValue.equals(bm1)) newValue = bm2;
+ if (oldValue.equals(bm2)) newValue = bm3;
+ if (oldValue.equals(bm3)) newValue = bm3;
+ } else
+
+ if (oldValue instanceof com.sun.star.drawing.TextAdjust){
+ com.sun.star.drawing.TextAdjust TA1 = com.sun.star.drawing.TextAdjust.BLOCK;
+ com.sun.star.drawing.TextAdjust TA2 = com.sun.star.drawing.TextAdjust.CENTER;
+ com.sun.star.drawing.TextAdjust TA3 = com.sun.star.drawing.TextAdjust.LEFT;
+ com.sun.star.drawing.TextAdjust TA4 = com.sun.star.drawing.TextAdjust.RIGHT;
+ com.sun.star.drawing.TextAdjust TA5 = com.sun.star.drawing.TextAdjust.STRETCH;
+ if (oldValue.equals(TA1)) newValue = TA2;
+ if (oldValue.equals(TA2)) newValue = TA3;
+ if (oldValue.equals(TA3)) newValue = TA4;
+ if (oldValue.equals(TA4)) newValue = TA5;
+ if (oldValue.equals(TA5)) newValue = TA1;
+ } else
+ if (oldValue instanceof com.sun.star.drawing.TextFitToSizeType){
+ com.sun.star.drawing.TextFitToSizeType TF1 = com.sun.star.drawing.TextFitToSizeType.ALLLINES;
+ com.sun.star.drawing.TextFitToSizeType TF2 = com.sun.star.drawing.TextFitToSizeType.NONE;
+ com.sun.star.drawing.TextFitToSizeType TF3 = com.sun.star.drawing.TextFitToSizeType.PROPORTIONAL;
+ com.sun.star.drawing.TextFitToSizeType TF4 = com.sun.star.drawing.TextFitToSizeType.RESIZEATTR;
+ if (oldValue.equals(TF1)) newValue = TF2;
+ if (oldValue.equals(TF2)) newValue = TF3;
+ if (oldValue.equals(TF3)) newValue = TF4;
+ if (oldValue.equals(TF4)) newValue = TF1;
+ } else
+ if (oldValue instanceof com.sun.star.drawing.TextAnimationKind){
+ com.sun.star.drawing.TextAnimationKind AK1 = com.sun.star.drawing.TextAnimationKind.NONE;
+ com.sun.star.drawing.TextAnimationKind AK2 = com.sun.star.drawing.TextAnimationKind.SLIDE;
+ com.sun.star.drawing.TextAnimationKind AK3 = com.sun.star.drawing.TextAnimationKind.SCROLL;
+ com.sun.star.drawing.TextAnimationKind AK4 = com.sun.star.drawing.TextAnimationKind.BLINK;
+ com.sun.star.drawing.TextAnimationKind AK5 = com.sun.star.drawing.TextAnimationKind.ALTERNATE;
+
+ if (oldValue.equals(AK1)) newValue = AK2;
+ if (oldValue.equals(AK2)) newValue = AK3;
+ if (oldValue.equals(AK3)) newValue = AK4;
+ if (oldValue.equals(AK4)) newValue = AK5;
+ if (oldValue.equals(AK5)) newValue = AK1;
+ } else
+ if (oldValue instanceof com.sun.star.drawing.TextAnimationDirection){
+ com.sun.star.drawing.TextAnimationDirection AD1 = com.sun.star.drawing.TextAnimationDirection.LEFT;
+ com.sun.star.drawing.TextAnimationDirection AD2 = com.sun.star.drawing.TextAnimationDirection.RIGHT;
+ com.sun.star.drawing.TextAnimationDirection AD3 = com.sun.star.drawing.TextAnimationDirection.DOWN;
+ com.sun.star.drawing.TextAnimationDirection AD4 = com.sun.star.drawing.TextAnimationDirection.UP;
+ if (oldValue.equals(AD1)) newValue = AD2;
+ if (oldValue.equals(AD2)) newValue = AD3;
+ if (oldValue.equals(AD3)) newValue = AD4;
+ if (oldValue.equals(AD4)) newValue = AD1;
+ } else
+ if (oldValue instanceof com.sun.star.drawing.LineStyle){
+ com.sun.star.drawing.LineStyle LS1 = com.sun.star.drawing.LineStyle.NONE;
+ com.sun.star.drawing.LineStyle LS2 = com.sun.star.drawing.LineStyle.DASH;
+ com.sun.star.drawing.LineStyle LS3 = com.sun.star.drawing.LineStyle.SOLID;
+ if (oldValue.equals(LS1)) newValue = LS2;
+ if (oldValue.equals(LS2)) newValue = LS3;
+ if (oldValue.equals(LS3)) newValue = LS1;
+ } else
+ if (oldValue instanceof com.sun.star.drawing.LineJoint){
+ com.sun.star.drawing.LineJoint LJ1 = com.sun.star.drawing.LineJoint.BEVEL;
+ com.sun.star.drawing.LineJoint LJ2 = com.sun.star.drawing.LineJoint.MIDDLE;
+ com.sun.star.drawing.LineJoint LJ3 = com.sun.star.drawing.LineJoint.MITER;
+ com.sun.star.drawing.LineJoint LJ4 = com.sun.star.drawing.LineJoint.NONE;
+ com.sun.star.drawing.LineJoint LJ5 = com.sun.star.drawing.LineJoint.ROUND;
+ if (oldValue.equals(LJ1)) newValue = LJ2;
+ if (oldValue.equals(LJ2)) newValue = LJ3;
+ if (oldValue.equals(LJ3)) newValue = LJ4;
+ if (oldValue.equals(LJ4)) newValue = LJ5;
+ if (oldValue.equals(LJ5)) newValue = LJ1;
+ } else
+ if (oldValue instanceof com.sun.star.drawing.LineDash){
+ com.sun.star.drawing.LineDash _newValue = (com.sun.star.drawing.LineDash)oldValue;
+ _newValue.Dashes += 1;
+ _newValue.DashLen += 10;
+ _newValue.Distance += 20;
+ _newValue.DotLen += 10;
+ _newValue.Dots += 10;
+ _newValue.Style = com.sun.star.drawing.DashStyle.RECT;
+ newValue = _newValue;
+ } else
+ if (oldValue instanceof com.sun.star.drawing.Hatch){
+ com.sun.star.drawing.Hatch _newValue = (com.sun.star.drawing.Hatch) oldValue;
+ _newValue.Angle += 10;
+ _newValue.Color += 1000;
+ _newValue.Distance += 10;
+ _newValue.Style = com.sun.star.drawing.HatchStyle.DOUBLE;
+ } else
+ if (oldValue instanceof com.sun.star.drawing.RectanglePoint){
+ com.sun.star.drawing.RectanglePoint RP1 = com.sun.star.drawing.RectanglePoint.LEFT_BOTTOM;
+ com.sun.star.drawing.RectanglePoint RP2 = com.sun.star.drawing.RectanglePoint.LEFT_MIDDLE;
+ com.sun.star.drawing.RectanglePoint RP3 = com.sun.star.drawing.RectanglePoint.LEFT_TOP;
+ com.sun.star.drawing.RectanglePoint RP4 = com.sun.star.drawing.RectanglePoint.MIDDLE_BOTTOM;
+ com.sun.star.drawing.RectanglePoint RP5 = com.sun.star.drawing.RectanglePoint.MIDDLE_MIDDLE;
+ com.sun.star.drawing.RectanglePoint RP6 = com.sun.star.drawing.RectanglePoint.MIDDLE_TOP;
+ com.sun.star.drawing.RectanglePoint RP7 = com.sun.star.drawing.RectanglePoint.RIGHT_BOTTOM;
+ com.sun.star.drawing.RectanglePoint RP8 = com.sun.star.drawing.RectanglePoint.RIGHT_MIDDLE;
+ com.sun.star.drawing.RectanglePoint RP9 = com.sun.star.drawing.RectanglePoint.RIGHT_TOP;
+
+ if (oldValue.equals(RP1)) newValue = RP2;
+ if (oldValue.equals(RP2)) newValue = RP3;
+ if (oldValue.equals(RP3)) newValue = RP4;
+ if (oldValue.equals(RP4)) newValue = RP5;
+ if (oldValue.equals(RP5)) newValue = RP6;
+ if (oldValue.equals(RP6)) newValue = RP7;
+ if (oldValue.equals(RP7)) newValue = RP8;
+ if (oldValue.equals(RP8)) newValue = RP9;
+ if (oldValue.equals(RP9)) newValue = RP1;
+
+ } else
+ if (oldValue instanceof com.sun.star.chart.ChartErrorCategory){
+ com.sun.star.chart.ChartErrorCategory CC1 = com.sun.star.chart.ChartErrorCategory.CONSTANT_VALUE;
+ com.sun.star.chart.ChartErrorCategory CC2 = com.sun.star.chart.ChartErrorCategory.ERROR_MARGIN;
+ com.sun.star.chart.ChartErrorCategory CC3 = com.sun.star.chart.ChartErrorCategory.NONE;
+ com.sun.star.chart.ChartErrorCategory CC4 = com.sun.star.chart.ChartErrorCategory.PERCENT;
+ com.sun.star.chart.ChartErrorCategory CC5 = com.sun.star.chart.ChartErrorCategory.STANDARD_DEVIATION;
+ com.sun.star.chart.ChartErrorCategory CC6 = com.sun.star.chart.ChartErrorCategory.VARIANCE;
+ if (oldValue.equals(CC1)) newValue = CC2;
+ if (oldValue.equals(CC2)) newValue = CC3;
+ if (oldValue.equals(CC3)) newValue = CC4;
+ if (oldValue.equals(CC4)) newValue = CC5;
+ if (oldValue.equals(CC5)) newValue = CC6;
+ if (oldValue.equals(CC6)) newValue = CC1;
+ } else
+ if (oldValue instanceof com.sun.star.chart.ChartErrorIndicatorType){
+ com.sun.star.chart.ChartErrorIndicatorType IT1 = com.sun.star.chart.ChartErrorIndicatorType.LOWER;
+ com.sun.star.chart.ChartErrorIndicatorType IT2 = com.sun.star.chart.ChartErrorIndicatorType.NONE;
+ com.sun.star.chart.ChartErrorIndicatorType IT3 = com.sun.star.chart.ChartErrorIndicatorType.TOP_AND_BOTTOM;
+ com.sun.star.chart.ChartErrorIndicatorType IT4 = com.sun.star.chart.ChartErrorIndicatorType.UPPER;
+ if (oldValue.equals(IT1)) newValue = IT2;
+ if (oldValue.equals(IT2)) newValue = IT3;
+ if (oldValue.equals(IT3)) newValue = IT4;
+ if (oldValue.equals(IT4)) newValue = IT1;
+ } else
+ if (oldValue instanceof com.sun.star.chart.ChartRegressionCurveType){
+ com.sun.star.chart.ChartRegressionCurveType CT1 = com.sun.star.chart.ChartRegressionCurveType.EXPONENTIAL;
+ com.sun.star.chart.ChartRegressionCurveType CT2 = com.sun.star.chart.ChartRegressionCurveType.LINEAR;
+ com.sun.star.chart.ChartRegressionCurveType CT3 = com.sun.star.chart.ChartRegressionCurveType.LOGARITHM;
+ com.sun.star.chart.ChartRegressionCurveType CT4 = com.sun.star.chart.ChartRegressionCurveType.NONE;
+ com.sun.star.chart.ChartRegressionCurveType CT5 = com.sun.star.chart.ChartRegressionCurveType.POLYNOMIAL;
+ com.sun.star.chart.ChartRegressionCurveType CT6 = com.sun.star.chart.ChartRegressionCurveType.POWER;
+ if (oldValue.equals(CT1)) newValue = CT2;
+ if (oldValue.equals(CT2)) newValue = CT3;
+ if (oldValue.equals(CT3)) newValue = CT4;
+ if (oldValue.equals(CT4)) newValue = CT5;
+ if (oldValue.equals(CT5)) newValue = CT6;
+ if (oldValue.equals(CT6)) newValue = CT1;
+
+ } else
+ if (oldValue instanceof com.sun.star.chart.ChartDataRowSource){
+ com.sun.star.chart.ChartDataRowSource RS1 = com.sun.star.chart.ChartDataRowSource.COLUMNS;
+ com.sun.star.chart.ChartDataRowSource RS2 = com.sun.star.chart.ChartDataRowSource.ROWS;
+ if (oldValue.equals(RS1)) newValue = RS2;
+ if (oldValue.equals(RS2)) newValue = RS1;
+ } else
+ if (oldValue instanceof com.sun.star.awt.FontDescriptor){
+ com.sun.star.awt.FontDescriptor _newValue = (com.sun.star.awt.FontDescriptor)oldValue;
+ _newValue.CharacterWidth += 5;
+ _newValue.CharSet = com.sun.star.awt.CharSet.ANSI;
+ _newValue.Family = com.sun.star.awt.FontFamily.DECORATIVE;
+ _newValue.Height += 2;
+ _newValue.Kerning = !_newValue.Kerning;
+ _newValue.Name = "Courier";
+ _newValue.Orientation += 45;
+ _newValue.Pitch = com.sun.star.awt.FontPitch.VARIABLE;
+ _newValue.Slant = com.sun.star.awt.FontSlant.REVERSE_ITALIC;
+ _newValue.Strikeout = com.sun.star.awt.FontStrikeout.X;
+ _newValue.StyleName = "Bold";
+ _newValue.Type = com.sun.star.awt.FontType.SCALABLE;
+ _newValue.Underline = com.sun.star.awt.FontUnderline.BOLDDASHDOTDOT;
+ _newValue.Weight += 5;
+ _newValue.Width += 6;
+ _newValue.WordLineMode = !_newValue.WordLineMode;
+
+ newValue = _newValue;
+ } else
+ if (oldValue instanceof com.sun.star.form.NavigationBarMode){
+ com.sun.star.form.NavigationBarMode BM1 = com.sun.star.form.NavigationBarMode.CURRENT;
+ com.sun.star.form.NavigationBarMode BM2 = com.sun.star.form.NavigationBarMode.NONE;
+ com.sun.star.form.NavigationBarMode BM3 = com.sun.star.form.NavigationBarMode.PARENT;
+ if (oldValue.equals(BM1)) newValue = BM2;
+ if (oldValue.equals(BM2)) newValue = BM3;
+ if (oldValue.equals(BM3)) newValue = BM1;
+ } else
+ if (oldValue instanceof com.sun.star.form.FormSubmitEncoding){
+ com.sun.star.form.FormSubmitEncoding SE1 = com.sun.star.form.FormSubmitEncoding.MULTIPART;
+ com.sun.star.form.FormSubmitEncoding SE2 = com.sun.star.form.FormSubmitEncoding.TEXT;
+ com.sun.star.form.FormSubmitEncoding SE3 = com.sun.star.form.FormSubmitEncoding.URL;
+ if (oldValue.equals(SE1)) newValue = SE2;
+ if (oldValue.equals(SE2)) newValue = SE3;
+ if (oldValue.equals(SE3)) newValue = SE1;
+ } else
+ if (oldValue instanceof com.sun.star.form.FormSubmitMethod){
+ com.sun.star.form.FormSubmitMethod FM1 = com.sun.star.form.FormSubmitMethod.GET;
+ com.sun.star.form.FormSubmitMethod FM2 = com.sun.star.form.FormSubmitMethod.POST;
+ if (oldValue.equals(FM1)) newValue = FM2;
+ if (oldValue.equals(FM2)) newValue = FM1;
+ } else
+
+ if (oldValue instanceof com.sun.star.text.SectionFileLink){
+ com.sun.star.text.SectionFileLink _newValue =
+ new com.sun.star.text.SectionFileLink();
+
+ _newValue.FileURL = util.utils.getFullTestURL("SwXTextSection.sdw");
+ newValue=_newValue;
+ } else
+
+ if (oldValue instanceof com.sun.star.table.BorderLine){
+ com.sun.star.table.BorderLine _newValue = (com.sun.star.table.BorderLine)oldValue;
+ _newValue.Color += 2;
+ _newValue.InnerLineWidth += 2;
+ _newValue.LineDistance += 2;
+ _newValue.OuterLineWidth += 3;
+ newValue=_newValue;
+ } else
+
+ if (oldValue instanceof com.sun.star.text.XTextColumns){
+ com.sun.star.text.XTextColumns _newValue = (com.sun.star.text.XTextColumns)oldValue;
+ _newValue.setColumnCount((short)1);
+ newValue=_newValue;
+ } else
+
+ if (oldValue instanceof com.sun.star.form.FormButtonType){
+ com.sun.star.form.FormButtonType BT1 = com.sun.star.form.FormButtonType.PUSH;
+ com.sun.star.form.FormButtonType BT2 = com.sun.star.form.FormButtonType.RESET;
+ com.sun.star.form.FormButtonType BT3 = com.sun.star.form.FormButtonType.SUBMIT;
+ com.sun.star.form.FormButtonType BT4 = com.sun.star.form.FormButtonType.URL;
+
+ if (oldValue.equals(BT1)) newValue = BT2;
+ if (oldValue.equals(BT2)) newValue = BT3;
+ if (oldValue.equals(BT3)) newValue = BT4;
+ if (oldValue.equals(BT4)) newValue = BT1;
+
+ } else
+ if (oldValue instanceof com.sun.star.form.ListSourceType){
+ com.sun.star.form.ListSourceType ST1 = com.sun.star.form.ListSourceType.QUERY;
+ com.sun.star.form.ListSourceType ST2 = com.sun.star.form.ListSourceType.SQL;
+ com.sun.star.form.ListSourceType ST3 = com.sun.star.form.ListSourceType.SQLPASSTHROUGH;
+ com.sun.star.form.ListSourceType ST4 = com.sun.star.form.ListSourceType.TABLE;
+ com.sun.star.form.ListSourceType ST5 = com.sun.star.form.ListSourceType.TABLEFIELDS;
+ com.sun.star.form.ListSourceType ST6 = com.sun.star.form.ListSourceType.VALUELIST;
+ if (oldValue.equals(ST1)) newValue = ST2;
+ if (oldValue.equals(ST2)) newValue = ST3;
+ if (oldValue.equals(ST3)) newValue = ST4;
+ if (oldValue.equals(ST4)) newValue = ST5;
+ if (oldValue.equals(ST5)) newValue = ST6;
+ if (oldValue.equals(ST6)) newValue = ST1;
+ } else
+ if (oldValue instanceof com.sun.star.table.BorderLine){
+ com.sun.star.table.BorderLine _newValue = (com.sun.star.table.BorderLine)oldValue;
+ _newValue.Color += 1000;
+ _newValue.InnerLineWidth += 2;
+ _newValue.LineDistance +=3;
+ _newValue.OuterLineWidth += 3;
+ newValue = _newValue;
+ } else
+ if (oldValue instanceof com.sun.star.sheet.DataPilotFieldOrientation) {
+ com.sun.star.sheet.DataPilotFieldOrientation FO1 = com.sun.star.sheet.DataPilotFieldOrientation.PAGE;
+ com.sun.star.sheet.DataPilotFieldOrientation FO2 = com.sun.star.sheet.DataPilotFieldOrientation.COLUMN;
+ com.sun.star.sheet.DataPilotFieldOrientation FO3 = com.sun.star.sheet.DataPilotFieldOrientation.DATA;
+ com.sun.star.sheet.DataPilotFieldOrientation FO4 = com.sun.star.sheet.DataPilotFieldOrientation.HIDDEN;
+ com.sun.star.sheet.DataPilotFieldOrientation FO5 = com.sun.star.sheet.DataPilotFieldOrientation.ROW;
+ if (oldValue.equals(FO1)) newValue = FO2;
+ if (oldValue.equals(FO2)) newValue = FO3;
+ if (oldValue.equals(FO3)) newValue = FO4;
+ if (oldValue.equals(FO4)) newValue = FO5;
+ if (oldValue.equals(FO5)) newValue = FO1;
+ } else
+ if (oldValue instanceof com.sun.star.sheet.GeneralFunction) {
+ com.sun.star.sheet.GeneralFunction GF1 = com.sun.star.sheet.GeneralFunction.NONE;
+ com.sun.star.sheet.GeneralFunction GF2 = com.sun.star.sheet.GeneralFunction.AVERAGE;
+ com.sun.star.sheet.GeneralFunction GF3 = com.sun.star.sheet.GeneralFunction.COUNT;
+ com.sun.star.sheet.GeneralFunction GF4 = com.sun.star.sheet.GeneralFunction.COUNTNUMS;
+ com.sun.star.sheet.GeneralFunction GF5 = com.sun.star.sheet.GeneralFunction.MAX;
+ com.sun.star.sheet.GeneralFunction GF6 = com.sun.star.sheet.GeneralFunction.MIN;
+ com.sun.star.sheet.GeneralFunction GF7 = com.sun.star.sheet.GeneralFunction.AUTO;
+ com.sun.star.sheet.GeneralFunction GF8 = com.sun.star.sheet.GeneralFunction.PRODUCT;
+ com.sun.star.sheet.GeneralFunction GF9 = com.sun.star.sheet.GeneralFunction.STDEV;
+ com.sun.star.sheet.GeneralFunction GF10 = com.sun.star.sheet.GeneralFunction.STDEVP;
+ com.sun.star.sheet.GeneralFunction GF11 = com.sun.star.sheet.GeneralFunction.SUM;
+ com.sun.star.sheet.GeneralFunction GF12 = com.sun.star.sheet.GeneralFunction.VAR;
+ com.sun.star.sheet.GeneralFunction GF13 = com.sun.star.sheet.GeneralFunction.VARP;
+
+ if (oldValue.equals(GF1)) newValue = GF2;
+ if (oldValue.equals(GF2)) newValue = GF3;
+ if (oldValue.equals(GF3)) newValue = GF4;
+ if (oldValue.equals(GF4)) newValue = GF5;
+ if (oldValue.equals(GF5)) newValue = GF6;
+ if (oldValue.equals(GF6)) newValue = GF7;
+ if (oldValue.equals(GF7)) newValue = GF8;
+ if (oldValue.equals(GF8)) newValue = GF9;
+ if (oldValue.equals(GF9)) newValue = GF10;
+ if (oldValue.equals(GF10)) newValue = GF11;
+ if (oldValue.equals(GF11)) newValue = GF12;
+ if (oldValue.equals(GF12)) newValue = GF13;
+ if (oldValue.equals(GF13)) newValue = GF1;
+ } else
+
+ if (oldValue instanceof com.sun.star.table.CellAddress){
+ com.sun.star.table.CellAddress _newValue = (com.sun.star.table.CellAddress)oldValue;
+ _newValue.Column += 1;
+ _newValue.Row += 1;
+ newValue = _newValue;
+ } else
+
+ if (oldValue instanceof com.sun.star.table.TableOrientation){
+ com.sun.star.table.TableOrientation TO1 = com.sun.star.table.TableOrientation.COLUMNS;
+ com.sun.star.table.TableOrientation TO2 = com.sun.star.table.TableOrientation.ROWS;
+ if (oldValue.equals(TO1)) newValue = TO2; else newValue = TO1;
+ } else
+
+ if (oldValue instanceof com.sun.star.sheet.DataImportMode){
+ com.sun.star.sheet.DataImportMode DIM1 = com.sun.star.sheet.DataImportMode.NONE;
+ com.sun.star.sheet.DataImportMode DIM2 = com.sun.star.sheet.DataImportMode.QUERY;
+ com.sun.star.sheet.DataImportMode DIM3 = com.sun.star.sheet.DataImportMode.SQL;
+ com.sun.star.sheet.DataImportMode DIM4 = com.sun.star.sheet.DataImportMode.TABLE;
+
+ if (oldValue.equals(DIM1)) newValue = DIM2;
+ if (oldValue.equals(DIM2)) newValue = DIM3;
+ if (oldValue.equals(DIM3)) newValue = DIM4;
+ if (oldValue.equals(DIM4)) newValue = DIM1;
+
+ } else
+
+// if (oldValue instanceof com.sun.star.text.TableColumnSeparator[]){
+// com.sun.star.text.TableColumnSeparator[] _newValue = (com.sun.star.text.TableColumnSeparator[]) oldValue;
+// com.sun.star.text.TableColumnSeparator sep = new com.sun.star.text.TableColumnSeparator();
+// sep.IsVisible = ! _newValue[0].IsVisible;
+// _newValue[0] = sep;
+// newValue = _newValue;
+// } else
+
+ if (oldValue instanceof com.sun.star.style.BreakType){
+ com.sun.star.style.BreakType BT1 = com.sun.star.style.BreakType.COLUMN_AFTER;
+ com.sun.star.style.BreakType BT2 = com.sun.star.style.BreakType.COLUMN_BEFORE;
+ com.sun.star.style.BreakType BT3 = com.sun.star.style.BreakType.COLUMN_BOTH;
+ com.sun.star.style.BreakType BT4 = com.sun.star.style.BreakType.PAGE_AFTER;
+ com.sun.star.style.BreakType BT5 = com.sun.star.style.BreakType.PAGE_BEFORE;
+ com.sun.star.style.BreakType BT6 = com.sun.star.style.BreakType.PAGE_BOTH;
+ com.sun.star.style.BreakType BT7 = com.sun.star.style.BreakType.NONE;
+ if (oldValue.equals(BT1)) newValue = BT2;
+ if (oldValue.equals(BT2)) newValue = BT3;
+ if (oldValue.equals(BT3)) newValue = BT4;
+ if (oldValue.equals(BT4)) newValue = BT5;
+ if (oldValue.equals(BT6)) newValue = BT6;
+ if (oldValue.equals(BT6)) newValue = BT7;
+ if (oldValue.equals(BT7)) newValue = BT1;
+ } else
+ if (oldValue instanceof PropertyValue){
+ PropertyValue newVal = new PropertyValue();
+ newVal.Name = ((PropertyValue)oldValue).Name;
+ newVal.Value = changePValue(((PropertyValue)oldValue).Value);
+ newValue = newVal;
+ } else
+ if (oldValue instanceof com.sun.star.sheet.ValidationAlertStyle){
+ com.sun.star.sheet.ValidationAlertStyle VAS1 = com.sun.star.sheet.ValidationAlertStyle.INFO;
+ com.sun.star.sheet.ValidationAlertStyle VAS2 = com.sun.star.sheet.ValidationAlertStyle.MACRO;
+ com.sun.star.sheet.ValidationAlertStyle VAS3 = com.sun.star.sheet.ValidationAlertStyle.STOP;
+ com.sun.star.sheet.ValidationAlertStyle VAS4 = com.sun.star.sheet.ValidationAlertStyle.WARNING;
+
+ if (oldValue.equals(VAS1)) newValue = VAS2;
+ if (oldValue.equals(VAS2)) newValue = VAS3;
+ if (oldValue.equals(VAS3)) newValue = VAS4;
+ if (oldValue.equals(VAS4)) newValue = VAS1;
+
+ } else
+ if (oldValue instanceof com.sun.star.sheet.ValidationType){
+ com.sun.star.sheet.ValidationType VT1 = com.sun.star.sheet.ValidationType.ANY;
+ com.sun.star.sheet.ValidationType VT2 = com.sun.star.sheet.ValidationType.CUSTOM;
+ com.sun.star.sheet.ValidationType VT3 = com.sun.star.sheet.ValidationType.DATE;
+ com.sun.star.sheet.ValidationType VT4 = com.sun.star.sheet.ValidationType.DECIMAL;
+ com.sun.star.sheet.ValidationType VT5 = com.sun.star.sheet.ValidationType.LIST;
+ com.sun.star.sheet.ValidationType VT6 = com.sun.star.sheet.ValidationType.TEXT_LEN;
+ com.sun.star.sheet.ValidationType VT7 = com.sun.star.sheet.ValidationType.TIME;
+ com.sun.star.sheet.ValidationType VT8 = com.sun.star.sheet.ValidationType.WHOLE;
+
+ if (oldValue.equals(VT1)) newValue = VT2;
+ if (oldValue.equals(VT2)) newValue = VT3;
+ if (oldValue.equals(VT3)) newValue = VT4;
+ if (oldValue.equals(VT4)) newValue = VT5;
+ if (oldValue.equals(VT5)) newValue = VT6;
+ if (oldValue.equals(VT6)) newValue = VT7;
+ if (oldValue.equals(VT7)) newValue = VT8;
+ if (oldValue.equals(VT8)) newValue = VT1;
+
+ } else
+ if (oldValue instanceof com.sun.star.text.WritingMode){
+ if (oldValue.equals(com.sun.star.text.WritingMode.LR_TB)) {
+ newValue = com.sun.star.text.WritingMode.TB_RL;
+ } else {
+ newValue = com.sun.star.text.WritingMode.LR_TB;
+ }
+ } else
+ if (oldValue instanceof com.sun.star.uno.Enum) {
+ // universal changer for Enumerations
+ try {
+ Class enumClass = oldValue.getClass() ;
+ Field[] flds = enumClass.getFields() ;
+
+ newValue = null ;
+
+ for (int i = 0; i < flds.length; i++) {
+ if (Enum.class.equals(flds[i].getType().getSuperclass())) {
+
+ Enum value = (Enum) flds[i].get(null) ;
+ if (newValue == null && !value.equals(oldValue)) {
+ newValue = value ;
+ break ;
+ }
+ }
+ }
+ } catch (Exception e) {
+ System.err.println("Exception occured while changing Enumeration value:") ;
+ e.printStackTrace(System.err) ;
+ }
+ if (newValue == null) newValue = oldValue ;
+
+ } else
+ if (oldValue instanceof com.sun.star.style.TabStop[]){
+ com.sun.star.style.TabStop[] _newValue = (com.sun.star.style.TabStop[]) oldValue;
+ if (_newValue.length == 0) {
+ _newValue = new com.sun.star.style.TabStop[1];
+ }
+ com.sun.star.style.TabStop sep = new com.sun.star.style.TabStop();
+ sep.Position += 1;
+ _newValue[0] = sep;
+ newValue = _newValue;
+ } else
+ if (oldValue instanceof short[]){
+ short[] oldArr = (short[])oldValue;
+ int len = oldArr.length;
+ short[] newArr = new short[len + 1];
+ for (int i = 0; i < len; i++) {
+ newArr[i] = (short)(oldArr[i] + 1);
+ }
+ newArr[len] = 5;
+ newValue = newArr;
+ } else
+ if (oldValue instanceof String[]){
+ String[] oldArr = (String[])oldValue;
+ int len = oldArr.length;
+ String[] newArr = new String[len + 1];
+ for (int i = 0; i < len; i++) {
+ newArr[i] = "_" + oldArr[i];
+ }
+ newArr[len] = "_dummy";
+ newValue = newArr;
+ } else
+ if (oldValue instanceof PropertyValue){
+ PropertyValue newVal = new PropertyValue();
+ newVal.Name = ((PropertyValue)oldValue).Name;
+ newVal.Value = changePValue(((PropertyValue)oldValue).Value);
+ newValue = newVal;
+ } else
+ if (oldValue instanceof com.sun.star.util.DateTime) {
+ com.sun.star.util.DateTime oldDT = (com.sun.star.util.DateTime) oldValue;
+ com.sun.star.util.DateTime newDT = new com.sun.star.util.DateTime();
+ newDT.Day = (short) (oldDT.Day+(short) 1);
+ newDT.Hours = (short) (oldDT.Hours+(short) 1);
+ newValue = newDT;
+ } else
+ if (oldValue instanceof com.sun.star.text.TableColumnSeparator) {
+ com.sun.star.text.TableColumnSeparator oldTCS = (com.sun.star.text.TableColumnSeparator) oldValue;
+ com.sun.star.text.TableColumnSeparator newTCS = new com.sun.star.text.TableColumnSeparator();
+ newTCS.IsVisible = !(oldTCS.IsVisible);
+ newTCS.Position = (short) (oldTCS.Position+(short) 1);
+ newValue = newTCS;
+ } else
+ if (oldValue instanceof com.sun.star.drawing.HomogenMatrix3) {
+ com.sun.star.drawing.HomogenMatrix3 oldHM = (com.sun.star.drawing.HomogenMatrix3) oldValue;
+ com.sun.star.drawing.HomogenMatrix3 newHM = new com.sun.star.drawing.HomogenMatrix3();
+ newHM.Line1.Column1 = oldHM.Line1.Column1+1;
+ newHM.Line2.Column2 = oldHM.Line2.Column2+1;
+ newHM.Line3.Column3 = oldHM.Line3.Column3+1;
+ newValue = newHM;
+ } else
+
+ if (oldValue instanceof com.sun.star.drawing.PolyPolygonBezierCoords) {
+ com.sun.star.drawing.PolyPolygonBezierCoords oldPPC = (com.sun.star.drawing.PolyPolygonBezierCoords) oldValue;
+ com.sun.star.drawing.PolyPolygonBezierCoords newPPC = new com.sun.star.drawing.PolyPolygonBezierCoords();
+ newPPC.Coordinates = oldPPC.Coordinates;
+ newPPC.Flags = oldPPC.Flags;
+ PolygonFlags[][] fArray = new PolygonFlags[1][1];
+ PolygonFlags[] flags = new PolygonFlags[1];
+ flags[0] = PolygonFlags.NORMAL;
+ fArray[0] = flags;
+ Point[][] pArray = new Point[1][1];
+ Point[] points = new Point[1];
+ Point aPoint = new Point();
+ aPoint.X = 1;
+ aPoint.Y = 2;
+ points[0] = aPoint;
+ pArray[0] = points;
+ if ( oldPPC.Coordinates.length == 0 ) {
+ newPPC.Coordinates = pArray;
+ newPPC.Flags = fArray;
+ } else {
+ if ( oldPPC.Coordinates[0].length == 0 ) {
+ newPPC.Coordinates = pArray;
+ newPPC.Flags = fArray;
+ } else {
+ newPPC.Coordinates[0][0].X = oldPPC.Coordinates[0][0].X +1;
+ newPPC.Coordinates[0][0].Y = oldPPC.Coordinates[0][0].Y +1;
+ }
+ }
+ newValue = newPPC;
+ } else
+ if (oldValue.getClass().isArray()) {
+ // changer for arrays : changes all elements
+ Class arrType = oldValue.getClass().getComponentType() ;
+ newValue = Array.newInstance(arrType, Array.getLength(oldValue)) ;
+ for (int i = 0; i < Array.getLength(newValue); i++) {
+ if (!arrType.isPrimitive()) {
+ Object elem = changePValue(Array.get(oldValue, i)) ;
+ Array.set(newValue, i, elem);
+ } else {
+ if (Boolean.TYPE.equals(arrType)) {
+ Array.setBoolean(newValue, i, !Array.getBoolean(oldValue, i));
+ } else
+ if (Byte.TYPE.equals(arrType)) {
+ Array.setByte(newValue, i,
+ (byte) (Array.getByte(oldValue, i) + 1));
+ } else
+ if (Character.TYPE.equals(arrType)) {
+ Array.setChar(newValue, i,
+ (char) (Array.getChar(oldValue, i) + 1));
+ } else
+ if (Double.TYPE.equals(arrType)) {
+ Array.setDouble(newValue, i, Array.getDouble(oldValue, i) + 1);
+ } else
+ if (Float.TYPE.equals(arrType)) {
+ Array.setFloat(newValue, i, Array.getFloat(oldValue, i) + 1);
+ } else
+ if (Integer.TYPE.equals(arrType)) {
+ Array.setInt(newValue, i, Array.getInt(oldValue, i) + 1);
+ } else
+ if (Long.TYPE.equals(arrType)) {
+ Array.setLong(newValue, i, Array.getLong(oldValue, i) + 1);
+ } else
+ if (Short.TYPE.equals(arrType)) {
+ Array.setShort(newValue, i,
+ (short) (Array.getShort(oldValue, i) + 1));
+ }
+ }
+ }
+ } else
+ if (isStructure(oldValue)) {
+ // universal changer for structures
+ Class clazz = oldValue.getClass() ;
+ try {
+ newValue = clazz.newInstance() ;
+ Field[] fields = clazz.getFields();
+ for (int i = 0; i < fields.length; i++) {
+ if ((fields[i].getModifiers() & Modifier.PUBLIC) != 0) {
+ Class fType = fields[i].getType() ;
+ Field field = fields[i] ;
+ if (!fType.isPrimitive()) {
+ field.set(newValue, changePValue(field.get(oldValue)));
+ } else {
+ if (Boolean.TYPE.equals(fType)) {
+ field.setBoolean(newValue, !field.getBoolean(oldValue));
+ } else
+ if (Byte.TYPE.equals(fType)) {
+ field.setByte(newValue, (byte) (field.getByte(oldValue) + 1));
+ } else
+ if (Character.TYPE.equals(fType)) {
+ field.setChar(newValue, (char) (field.getChar(oldValue) + 1));
+ } else
+ if (Double.TYPE.equals(fType)) {
+ field.setDouble(newValue, field.getDouble(oldValue) + 1);
+ } else
+ if (Float.TYPE.equals(fType)) {
+ field.setFloat(newValue, field.getFloat(oldValue) + 1);
+ } else
+ if (Integer.TYPE.equals(fType)) {
+ field.setInt(newValue, field.getInt(oldValue) + 1);
+ } else
+ if (Long.TYPE.equals(fType)) {
+ field.setLong(newValue, field.getLong(oldValue) + 1);
+ } else
+ if (Short.TYPE.equals(fType)) {
+ field.setShort(newValue, (short) (field.getShort(oldValue) + 1));
+ }
+ }
+ }
+ }
+ } catch (IllegalAccessException e) {
+ e.printStackTrace() ;
+ } catch (InstantiationException e) {
+ e.printStackTrace() ;
+ }
+
+ } else
+ {
+ System.out.println("ValueChanger don't know type " + oldValue.getClass());
+ }
+
+ return newValue;
+
+ } // end of Change PValue
+
+ /**
+ * Checks if the passed value is the API structure.
+ * The value assumed to be a structure if there are no public
+ * methods, and all public fields are not static or final.
+ *
+ * @param val the value to be checked.
+ * @return <code>true</code> if the value is acssumed to be a
+ * structure.
+ */
+ private static boolean isStructure(Object val) {
+ boolean result = true ;
+
+ Class clazz = val.getClass() ;
+
+ Method[] meth = clazz.getDeclaredMethods() ;
+ for (int i = 0; i < meth.length; i++) {
+ result &= (meth[i].getModifiers() & Modifier.PUBLIC) == 0 ;
+ }
+
+ Field[] fields = clazz.getDeclaredFields() ;
+ for (int i = 0; i < fields.length; i++) {
+ int mod = fields[i].getModifiers() ;
+ // If the field is PUBLIC it must not be STATIC or FINAL
+ result &= ((mod & Modifier.PUBLIC) == 0) ||
+ (((mod & Modifier.STATIC) == 0) && ((mod & Modifier.FINAL) == 0)) ;
+ }
+
+ return result ;
+ }
+}
diff --git a/qadevOOo/runner/util/ValueComparer.java b/qadevOOo/runner/util/ValueComparer.java
new file mode 100644
index 000000000000..dd9749119a8f
--- /dev/null
+++ b/qadevOOo/runner/util/ValueComparer.java
@@ -0,0 +1,266 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package util;
+
+import com.sun.star.beans.PropertyValue;
+import java.lang.reflect.Array;
+import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
+import com.sun.star.uno.Type;
+import com.sun.star.uno.Enum;
+import com.sun.star.uno.XInterface;
+import com.sun.star.uno.Any;
+import com.sun.star.uno.AnyConverter;
+import java.util.HashMap;
+
+
+public class ValueComparer {
+
+ // Method to change a Value, thought for properties
+ public static boolean equalValue( Object first, Object second ) {
+
+ if (first instanceof com.sun.star.uno.Any) {
+ try {
+ first = AnyConverter.toObject(((Any) first).getType(),first);
+ } catch (com.sun.star.lang.IllegalArgumentException iae) {
+ }
+ }
+ if (second instanceof com.sun.star.uno.Any) {
+ try {
+ second = AnyConverter.toObject(((Any) second).getType(),second);
+ } catch (com.sun.star.lang.IllegalArgumentException iae) {
+ }
+ }
+ boolean eq = false;
+ try {
+ if ( (first==null) || (second == null) ) {
+ eq = (first == second);
+ }
+ else {
+ if ( util.utils.isVoid(first) && util.utils.isVoid(second) ) {
+ eq=true;
+ } else if ( util.utils.isVoid(first) || util.utils.isVoid(second) ) {
+ eq = (first == second);
+ } else {
+ eq = compareObjects(first, second);
+ }
+ }
+ }
+ catch (Exception e) {
+ System.out.println("Exception occured while comparing Objects");
+ e.printStackTrace();
+ }
+ return eq;
+ } // end of equalValue
+
+ static boolean compareArrayOfPropertyValue(PropertyValue[] pv1, PropertyValue[] pv2){
+ if ( pv1.length != pv2.length) {
+ return false;
+ }
+ HashMap hm1 = new HashMap();
+ boolean result = true;
+ int i = 0;
+
+ for (i = 0; i < pv1.length; i++){
+ hm1.put(pv1[i].Name, pv1[i].Value);
+ }
+
+ i = 0;
+ while (i < pv2.length && result) {
+ result &= equalValue(hm1.get(pv2[i].Name),pv2[i].Value);
+ i++;
+ }
+ return result;
+ }
+
+ static boolean compareArrays(Object op1, Object op2) throws Exception {
+
+ if (op1 instanceof PropertyValue[] && op2 instanceof PropertyValue[]) {
+ return compareArrayOfPropertyValue((PropertyValue[])op1,(PropertyValue[])op2);
+ }
+ boolean result = true;
+ if((op1.getClass().getComponentType() == op2.getClass().getComponentType())
+ && (Array.getLength(op1) == Array.getLength(op2)))
+ {
+ Class zClass = op1.getClass().getComponentType();
+
+ for(int i = 0; i < Array.getLength(op1); ++ i)
+ result = result & compareObjects(Array.get(op1, i), Array.get(op2, i));
+ } else {
+ result = false ;
+ }
+
+ return result;
+ }
+
+ static boolean compareInterfaces(XInterface op1, XInterface op2) {
+ return op1 == op2;
+ }
+
+ static boolean compareUntil(Class zClass, Class untilClass, Object op1, Object op2) throws Exception {
+ boolean result = true;
+
+ // write inherited members first
+ Class superClass = zClass.getSuperclass();
+ if(superClass != null && superClass != untilClass)
+ result = result & compareUntil(superClass, untilClass, op1, op2);
+
+ Field fields[] = zClass.getDeclaredFields();
+
+ for(int i = 0; i < fields.length && result; ++ i) {
+ if((fields[i].getModifiers() & (Modifier.STATIC | Modifier.TRANSIENT)) == 0) { // neither static nor transient ?
+ Object obj1 = fields[i].get(op1);
+ Object obj2 = fields[i].get(op2);
+ if (obj1 instanceof com.sun.star.uno.Any) {
+ try {
+ if (utils.isVoid(obj1)) {
+ obj1 = null;
+ } else {
+ obj1 = AnyConverter.toObject(((Any) obj1).getType(),obj1);
+ }
+ } catch (com.sun.star.lang.IllegalArgumentException iae) {
+ }
+ }
+ if (obj2 instanceof com.sun.star.uno.Any) {
+ try {
+ if (utils.isVoid(obj2)) {
+ obj2 = null;
+ } else {
+ obj2 = AnyConverter.toObject(((Any) obj2).getType(),obj2);
+ }
+ } catch (com.sun.star.lang.IllegalArgumentException iae) {
+ }
+ }
+
+ result = result & compareObjects(obj1, obj2);
+
+ }
+ }
+
+ return result;
+ }
+
+ static boolean compareStructs(Object op1, Object op2) throws Exception {
+ boolean result = true;
+
+ if(op1.getClass() != op2.getClass())
+ result = false;
+ else {
+ result = compareUntil(op1.getClass(), Object.class, op1, op2);
+ }
+
+ return result;
+ }
+
+ static boolean compareThrowable(Throwable op1, Throwable op2) throws Exception {
+ boolean result = true;
+
+ if(op1.getClass() != op2.getClass())
+ result = false;
+ else {
+ result = compareUntil(op1.getClass(), Throwable.class, op1, op2);
+
+ result = result & op1.getMessage().equals(op2.getMessage());
+ }
+
+ return result;
+ }
+
+ static boolean compareEnums(Enum en1, Enum en2) {
+ return en1.getValue() == en2.getValue();
+ }
+
+ static boolean compareObjects(Object op1, Object op2) throws Exception {
+ boolean result = false;
+
+ if(op1 == op2)
+ result = true;
+
+ if ( (op1==null) || (op2 == null) ) {
+ result = (op1 == op2);
+ }
+
+ else if(op1.getClass().isPrimitive() && op2.getClass().isPrimitive())
+ result = op1.equals(op2);
+
+ else if(op1.getClass() == Byte.class && op2.getClass() == Byte.class)
+ result = op1.equals(op2);
+
+ else if(op1.getClass() == Type.class && op2.getClass() == Type.class)
+ result = op1.equals(op2);
+
+ else if(op1.getClass() == Boolean.class && op2.getClass() == Boolean.class)
+ result = op1.equals(op2);
+
+ else if(op1.getClass() == Short.class && op2.getClass() == Short.class)
+ result = op1.equals(op2);
+
+ else if(Throwable.class.isAssignableFrom(op1.getClass()) && Throwable.class.isAssignableFrom(op2.getClass()))
+ result = compareThrowable((Throwable)op1, (Throwable)op2);
+
+ else if(op1.getClass() == Integer.class && op2.getClass() == Integer.class)
+ result = op1.equals(op2);
+
+ else if(op1.getClass() == Character.class && op2.getClass() == Character.class)
+ result = op1.equals(op2);
+
+ else if(op1.getClass() == Long.class && op2.getClass() == Long.class)
+ result = op1.equals(op2);
+
+ else if(op1.getClass() == Void.class && op2.getClass() == Void.class)
+ result = op1.equals(op2);
+
+ else if(op1.getClass() == Float.class && op2.getClass() == Float.class)
+ result = op1.equals(op2);
+
+ else if(op1.getClass() == Double.class && op2.getClass() == Double.class)
+ result = op1.equals(op2);
+
+ else if(op1.getClass().isArray() && op2.getClass().isArray())
+ result = compareArrays(op1, op2);
+
+ else if(op1.getClass() == Void.class || op2.getClass() == void.class) // write nothing ?
+ result = true;
+
+ else if(XInterface.class.isAssignableFrom(op1.getClass()) && XInterface.class.isAssignableFrom(op2.getClass()))
+ compareInterfaces((XInterface)op1, (XInterface)op2);
+
+ else if(Enum.class.isAssignableFrom(op1.getClass()) && Enum.class.isAssignableFrom(op2.getClass()))
+ compareEnums((Enum)op1, (Enum)op2);
+
+ else if(op1.getClass() == String.class && op2.getClass() == String.class) // is it a String ?
+ result = ((String)op1).equals((String)op2);
+
+ else // otherwise it must be a struct
+ result = compareStructs(op1, op2);
+
+ return result;
+ }
+
+
+}
diff --git a/qadevOOo/runner/util/WaitUnreachable.java b/qadevOOo/runner/util/WaitUnreachable.java
new file mode 100644
index 000000000000..f756c9fae648
--- /dev/null
+++ b/qadevOOo/runner/util/WaitUnreachable.java
@@ -0,0 +1,127 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package util;
+
+import java.lang.ref.PhantomReference;
+import java.lang.ref.ReferenceQueue;
+
+/**
+ * Wait until an object has become unreachable.
+ *
+ * <p>Instances of this class will typically be used as either:</p>
+ * <pre>
+ * SomeType o = new SomeType(...);
+ * ... // use "o"
+ * WaitUnreachable u = new WaitUnreachable(o);
+ * o = null;
+ * u.waitUnreachable();
+ * </pre>
+ * <p>or:</p>
+ * <pre>
+ * WaitUnreachable u = new WaitUnreachable(new SomeType(...));
+ * ... // use "(SomeType) u.get()"
+ * u.waitUnreachable();
+ * </pre>
+ */
+public final class WaitUnreachable {
+ /**
+ * Creates a new waiter.
+ *
+ * @param obj the object on which to wait
+ */
+ public WaitUnreachable(Object obj) {
+ this.obj = obj;
+ queue = new ReferenceQueue();
+ ref = new PhantomReference(obj, queue);
+ }
+
+ /**
+ * Gets the object on which to wait.
+ *
+ * @return the object on which to wait, or <code>null</code> if
+ * <code>waitUnreachable</code> has already been called
+ */
+ public synchronized Object get() {
+ return obj;
+ }
+
+ /**
+ * Starts waiting for the object to become unreachable.
+ *
+ * <p>This blocks the current thread until the object has become
+ * unreachable.</p>
+ *
+ * <p>Actually, this method waits until the JVM has <em>detected</em> that
+ * the object has become unreachable. This is not deterministic, but this
+ * methods makes a best effort to cause the JVM to eventually detect the
+ * situation. With a typical JVM, this should suffice.</p>
+ */
+ public void waitUnreachable() {
+ synchronized (this) {
+ obj = null;
+ }
+ System.out.println("waiting for gc");
+ while (queue.poll() == null) {
+ System.gc();
+ System.runFinalization();
+ byte[] dummy = new byte[1024];
+ }
+ }
+
+ /**
+ * Ensures that an object will be finalized as soon as possible.
+ *
+ * <p>This does not block the current thread. Instead, a new thread is
+ * spawned that busy waits for the given object to become unreachable.</p>
+ *
+ * <p>This method cannot guarantee that the given object is eventually
+ * finalized, but it makes a best effort. With a typical JVM, this should
+ * suffice.</p>
+ *
+ * @param obj the object of which to ensure finalization
+ */
+ public static void ensureFinalization(final Object obj) {
+ final class WaitThread extends Thread {
+ public WaitThread(Object obj) {
+ super("ensureFinalization");
+ unreachable = new WaitUnreachable(obj);
+ }
+
+ public void run() {
+ unreachable.waitUnreachable();
+ }
+
+ private final WaitUnreachable unreachable;
+ };
+ new WaitThread(obj).start();
+ }
+
+ private Object obj;
+ private final ReferenceQueue queue;
+ private final PhantomReference ref;
+}
diff --git a/qadevOOo/runner/util/WriterTools.java b/qadevOOo/runner/util/WriterTools.java
new file mode 100644
index 000000000000..33b5d4f61aab
--- /dev/null
+++ b/qadevOOo/runner/util/WriterTools.java
@@ -0,0 +1,121 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package util;
+
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.container.XNamed;
+import com.sun.star.drawing.XDrawPage;
+import com.sun.star.drawing.XDrawPageSupplier;
+import com.sun.star.lang.XComponent;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.text.XText;
+import com.sun.star.text.XTextContent;
+import com.sun.star.text.XTextCursor;
+import com.sun.star.text.XTextDocument;
+import com.sun.star.uno.UnoRuntime;
+
+// access the implementations via names
+import com.sun.star.uno.XInterface;
+
+import util.DesktopTools;
+
+
+public class WriterTools {
+ public static XTextDocument createTextDoc(XMultiServiceFactory xMSF) {
+ PropertyValue[] Args = new PropertyValue[0];
+ XComponent comp = DesktopTools.openNewDoc(xMSF, "swriter", Args);
+ XTextDocument WriterDoc = (XTextDocument) UnoRuntime.queryInterface(
+ XTextDocument.class, comp);
+
+ return WriterDoc;
+ } // finish createTextDoc
+
+ public static XTextDocument loadTextDoc(XMultiServiceFactory xMSF,
+ String url) {
+ PropertyValue[] Args = new PropertyValue[0];
+ XTextDocument WriterDoc = loadTextDoc(xMSF, url, Args);
+
+ return WriterDoc;
+ } // finish createTextDoc
+
+ public static XTextDocument loadTextDoc(XMultiServiceFactory xMSF,
+ String url, PropertyValue[] Args) {
+ XComponent comp = DesktopTools.loadDoc(xMSF, url, Args);
+ XTextDocument WriterDoc = (XTextDocument) UnoRuntime.queryInterface(
+ XTextDocument.class, comp);
+
+ return WriterDoc;
+ } // finish createTextDoc
+
+ public static XDrawPage getDrawPage(XTextDocument aDoc) {
+ XDrawPage oDP = null;
+
+ try {
+ XDrawPageSupplier oDPS = (XDrawPageSupplier) UnoRuntime.queryInterface(
+ XDrawPageSupplier.class, aDoc);
+ oDP = (XDrawPage) oDPS.getDrawPage();
+ } catch (Exception e) {
+ throw new IllegalArgumentException("Couldn't get drawpage");
+ }
+
+ return oDP;
+ }
+
+ public static void insertTextGraphic(XTextDocument aDoc,
+ XMultiServiceFactory xMSF, int hpos,
+ int vpos, int width, int height,
+ String pic, String name) {
+ try {
+ Object oGObject = (XInterface) xMSF.createInstance(
+ "com.sun.star.text.GraphicObject");
+
+ XText the_text = aDoc.getText();
+ XTextCursor the_cursor = the_text.createTextCursor();
+ XTextContent the_content = (XTextContent) UnoRuntime.queryInterface(
+ XTextContent.class, oGObject);
+ the_text.insertTextContent(the_cursor, the_content, true);
+
+ XPropertySet oProps = (XPropertySet) UnoRuntime.queryInterface(
+ XPropertySet.class, oGObject);
+
+ String fullURL = util.utils.getFullTestURL(pic);
+ oProps.setPropertyValue("GraphicURL", fullURL);
+ oProps.setPropertyValue("HoriOrientPosition", new Integer(hpos));
+ oProps.setPropertyValue("VertOrientPosition", new Integer(vpos));
+ oProps.setPropertyValue("Width", new Integer(width));
+ oProps.setPropertyValue("Height", new Integer(height));
+
+ XNamed the_name = (XNamed) UnoRuntime.queryInterface(XNamed.class,
+ oGObject);
+ the_name.setName(name);
+ } catch (Exception ex) {
+ System.out.println("Exception while insertin TextGraphic");
+ ex.printStackTrace();
+ }
+ }
+} \ No newline at end of file
diff --git a/qadevOOo/runner/util/XInstCreator.java b/qadevOOo/runner/util/XInstCreator.java
new file mode 100644
index 000000000000..2f6ec3ecf272
--- /dev/null
+++ b/qadevOOo/runner/util/XInstCreator.java
@@ -0,0 +1,38 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package util;
+
+import com.sun.star.uno.XInterface;
+import com.sun.star.container.XIndexAccess;
+
+public interface XInstCreator {
+
+ XInterface getInstance();
+ XInterface createInstance();
+ XIndexAccess getCollection();
+}
diff --git a/qadevOOo/runner/util/XLayerHandlerImpl.java b/qadevOOo/runner/util/XLayerHandlerImpl.java
new file mode 100644
index 000000000000..e3a0ae3a1b23
--- /dev/null
+++ b/qadevOOo/runner/util/XLayerHandlerImpl.java
@@ -0,0 +1,119 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package util;
+
+public class XLayerHandlerImpl
+ implements com.sun.star.configuration.backend.XLayerHandler {
+ protected String calls = "";
+ protected String ls = System.getProperty("line.separator");
+
+ public void addOrReplaceNode(String str, short param)
+ throws com.sun.star.configuration.backend.MalformedDataException,
+ com.sun.star.lang.WrappedTargetException {
+ calls += ("addOrReplace(" + str + "," + param + ");" + ls);
+ }
+
+ public void addOrReplaceNodeFromTemplate(String str,
+ com.sun.star.configuration.backend.TemplateIdentifier templateIdentifier,
+ short param)
+ throws com.sun.star.configuration.backend.MalformedDataException,
+ com.sun.star.lang.WrappedTargetException {
+ calls += ("addOrReplaceNodeFromTemplate(" + str + "," + templateIdentifier + ");" + ls);
+ }
+
+ public void addProperty(String str, short param,
+ com.sun.star.uno.Type type)
+ throws com.sun.star.configuration.backend.MalformedDataException,
+ com.sun.star.lang.WrappedTargetException {
+ calls += ("addProperty(" + str + "," + param + "," + type + ");" + ls);
+ }
+
+ public void addPropertyWithValue(String str, short param, Object obj)
+ throws com.sun.star.configuration.backend.MalformedDataException,
+ com.sun.star.lang.WrappedTargetException {
+ calls += ("addPropertyWithValue(" + str + "," + param + "," + obj + ");" + ls);
+ }
+
+ public void dropNode(String str)
+ throws com.sun.star.configuration.backend.MalformedDataException,
+ com.sun.star.lang.WrappedTargetException {
+ calls += ("dropNode(" + str + ");" + ls);
+ }
+
+ public void endLayer()
+ throws com.sun.star.configuration.backend.MalformedDataException,
+ com.sun.star.lang.WrappedTargetException {
+ calls += ("endLayer();" + ls);
+ }
+
+ public void endNode()
+ throws com.sun.star.configuration.backend.MalformedDataException,
+ com.sun.star.lang.WrappedTargetException {
+ calls += ("endNode();" + ls);
+ }
+
+ public void endProperty()
+ throws com.sun.star.configuration.backend.MalformedDataException,
+ com.sun.star.lang.WrappedTargetException {
+ calls += ("endProperty();" + ls);
+ }
+
+ public void overrideNode(String str, short param, boolean param2)
+ throws com.sun.star.configuration.backend.MalformedDataException,
+ com.sun.star.lang.WrappedTargetException {
+ calls += ("overrideNode(" + str + "," + param + "," + param2 + ");" + ls);
+ }
+
+ public void overrideProperty(String str, short param,
+ com.sun.star.uno.Type type, boolean param3)
+ throws com.sun.star.configuration.backend.MalformedDataException,
+ com.sun.star.lang.WrappedTargetException {
+ calls += ("overrideProperty(" + str + "," + param + "," + type + "," + param3 + ");" + ls);
+ }
+
+ public void setPropertyValue(Object obj)
+ throws com.sun.star.configuration.backend.MalformedDataException,
+ com.sun.star.lang.WrappedTargetException {
+ calls += ("setPropertyValue(" + obj + ");" + ls);
+ }
+
+ public void setPropertyValueForLocale(Object obj, String str)
+ throws com.sun.star.configuration.backend.MalformedDataException,
+ com.sun.star.lang.WrappedTargetException {
+ calls += ("setPropertyValueForLocale(" + obj + "," + str + ");" + ls);
+ }
+
+ public void startLayer()
+ throws com.sun.star.configuration.backend.MalformedDataException,
+ com.sun.star.lang.WrappedTargetException {
+ calls = "startLayer();" + ls;
+ }
+
+ public String getCalls() {
+ return calls;
+ }
+} \ No newline at end of file
diff --git a/qadevOOo/runner/util/XLayerImpl.java b/qadevOOo/runner/util/XLayerImpl.java
new file mode 100644
index 000000000000..72dc2a2fa6aa
--- /dev/null
+++ b/qadevOOo/runner/util/XLayerImpl.java
@@ -0,0 +1,45 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package util;
+
+public class XLayerImpl implements com.sun.star.configuration.backend.XLayer {
+
+ protected boolean wasCalled = false;
+
+ public XLayerImpl() {
+ }
+
+ public void readData(com.sun.star.configuration.backend.XLayerHandler xLayerHandler) throws com.sun.star.lang.NullPointerException, com.sun.star.lang.WrappedTargetException, com.sun.star.configuration.backend.MalformedDataException {
+ wasCalled = true;
+ }
+
+ public boolean hasBeenCalled() {
+ return wasCalled;
+ }
+
+}
diff --git a/qadevOOo/runner/util/XMLTools.java b/qadevOOo/runner/util/XMLTools.java
new file mode 100644
index 000000000000..a744afe0a3f8
--- /dev/null
+++ b/qadevOOo/runner/util/XMLTools.java
@@ -0,0 +1,939 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package util;
+
+import java.io.PrintWriter ;
+import java.util.Vector ;
+import java.util.Hashtable ;
+import java.util.Enumeration ;
+import java.util.HashSet ;
+
+// access the implementations via names
+import com.sun.star.uno.XInterface;
+import com.sun.star.io.XOutputStream;
+import com.sun.star.io.XInputStream;
+import com.sun.star.io.XActiveDataSource;
+import com.sun.star.ucb.XSimpleFileAccess;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.xml.sax.XDocumentHandler;
+import com.sun.star.uno.Any;
+import com.sun.star.uno.Type;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.xml.sax.XLocator;
+import com.sun.star.xml.sax.XAttributeList;
+import com.sun.star.xml.sax.XParser ;
+import com.sun.star.xml.sax.InputSource ;
+import com.sun.star.lang.XComponent;
+import com.sun.star.document.XExporter;
+import com.sun.star.document.XImporter;
+import com.sun.star.document.XFilter;
+
+
+public class XMLTools {
+
+ /**
+ * The implementation of <code>com.sun.star.xml.sax.XAttributeList</code>
+ * where attributes and their values can be added.
+ */
+ public static class AttributeList implements XAttributeList {
+ private static class Attribute {
+ public String Name ;
+ public String Type ;
+ public String Value ;
+ }
+ private Hashtable attrByName = new Hashtable() ;
+ private Vector attributes = new Vector() ;
+ private PrintWriter log = null ;
+
+ /**
+ * Creates a class instance.
+ */
+ public AttributeList() {}
+
+ /**
+ * Constructs a list which will report to <code>log</code>
+ * specified about each <code>XDocumentHandler</code> method
+ * call.
+ */
+ public AttributeList(PrintWriter log) {
+ this.log = log ;
+ }
+
+ public AttributeList(XAttributeList list) {
+ if (list == null) return ;
+ for (short i = 0; i < list.getLength(); i++) {
+ add(list.getNameByIndex(i), list.getTypeByIndex(i),
+ list.getValueByIndex(i)) ;
+ }
+ }
+
+ /**
+ * Adds an attribute with type and value specified.
+ * @param name The attribute name.
+ * @param type Value type (usually 'CDATA' used).
+ * @param value Attribute value.
+ */
+ public void add(String name, String type, String value) {
+ Attribute attr = new Attribute() ;
+ attr.Name = name ;
+ attr.Type = type ;
+ attr.Value = value ;
+ attributes.add(attr) ;
+ attrByName.put(attr.Name, attr) ;
+ }
+
+ /**
+ * Adds an attribute with value specified. As a type of
+ * value 'CDATA' string specified.
+ * @param name The attribute name.
+ * @param value Attribute value.
+ */
+ public void add(String name, String value) {
+ add(name, "CDATA", value) ;
+ }
+
+ /**
+ * Clears all attributes added before.
+ */
+ public void clear() {
+ attrByName.clear() ;
+ attributes.clear() ;
+ }
+
+ /***************************************
+ * XAttributeList methods
+ ****************************************/
+
+ public short getLength() {
+ if (log != null)
+ log.println("getLength() called -> " + attributes.size()) ;
+ return (short) attributes.size() ;
+ }
+
+ public String getNameByIndex(short idx) {
+ String name = ((Attribute) attributes.get(idx)).Name ;
+ if (log != null)
+ log.println("getNameByIndex(" + idx + ") called -> '" +
+ name + "'") ;
+ return name ;
+ }
+
+ public String getTypeByIndex(short idx) {
+ String type = ((Attribute) attributes.get(idx)).Type ;
+ if (log != null)
+ log.println("getTypeByIndex(" + idx + ") called -> '" +
+ type + "'") ;
+ return type;
+ }
+
+ public String getTypeByName(String name) {
+ String type = ((Attribute) attrByName.get(name)).Type ;
+ if (log != null)
+ log.println("getTypeByName('" + name + "') called -> '" +
+ type + "'") ;
+ return type;
+ }
+ public String getValueByIndex(short idx) {
+ String value = ((Attribute) attributes.get(idx)).Value ;
+ if (log != null)
+ log.println("getValueByIndex(" + idx + ") called -> '" +
+ value + "'") ;
+ return value;
+ }
+
+ public String getValueByName(String name) {
+ String value = ((Attribute) attrByName.get(name)).Value ;
+ if (log != null)
+ log.println("getValueByName('" + name + "') called -> '" +
+ value + "'") ;
+ return value;
+ }
+ }
+
+ /**
+ * This class writes all XML data handled into a stream specified
+ * in the constructor.
+ */
+ public static class XMLWriter implements XDocumentHandler {
+ private PrintWriter _log = null ;
+ private String align = "" ;
+
+ /**
+ * Creates a SAX handler which writes all XML data
+ * handled into a <code>log</code> stream specified.
+ */
+ public XMLWriter(PrintWriter log) {
+ _log = log ;
+ }
+
+ /**
+ * Creates a SAX handler which does nothing.
+ */
+ public XMLWriter() {
+ }
+
+ public void processingInstruction(String appl, String data) {
+ if (_log == null) return ;
+ _log.println(align + "<?" + appl + " " + data + "?>") ;
+ }
+ public void startDocument() {
+ if (_log == null) return ;
+ _log.println("START DOCUMENT:") ;
+ }
+ public void endDocument() {
+ if (_log == null) return ;
+ _log.println("END DOCUMENT:") ;
+ }
+ public void setDocumentLocator(XLocator loc) {
+ if (_log == null) return ;
+ _log.println("DOCUMENT LOCATOR: ('" + loc.getPublicId() +
+ "','" + loc.getSystemId() + "')") ;
+ }
+ public void startElement(String name, XAttributeList attr) {
+ if (_log == null) return ;
+ _log.print(align + "<" + name + " ") ;
+ if (attr != null) {
+ short attrLen = attr.getLength() ;
+ for (short i = 0; i < attrLen; i++) {
+ if (i != 0) _log.print(align + " ") ;
+ _log.print(attr.getNameByIndex(i) + "[" +
+ attr.getTypeByIndex(i) + "]=\"" +
+ attr.getValueByIndex(i) + "\"") ;
+ if (i+1 != attrLen) {
+ _log.println() ;
+ }
+ }
+ }
+ _log.println(">") ;
+
+ align += " " ;
+ }
+
+ public void endElement(String name) {
+ if (_log == null) return ;
+ align = align.substring(3) ;
+ _log.println(align + "</" + name + ">") ;
+ }
+
+ public void characters(String chars) {
+ if (_log == null) return ;
+ _log.println(align + chars) ;
+ }
+ public void ignorableWhitespace(String sp) {
+ if (_log == null) return ;
+ _log.println(sp) ;
+ }
+ }
+
+ /**
+ * Checks if the XML structure is well formed (i.e. all tags opened must be
+ * closed and all tags opened inside a tag must be closed
+ * inside the same tag). It also checks parameters passed.
+ * If any collisions found appropriate error message is
+ * output into a stream specified. No XML data output, i.e.
+ * no output will be performed if no errors occur.<p>
+ * After document is completed there is a way to cehck
+ * if the XML data and structure was valid.
+ */
+ public static class XMLWellFormChecker extends XMLWriter {
+ protected boolean docStarted = false ;
+ protected boolean docEnded = false ;
+ protected Vector tagStack = new Vector() ;
+ protected boolean wellFormed = true ;
+ protected boolean noOtherErrors = true ;
+ protected PrintWriter log = null ;
+ protected boolean printXMLData = false ;
+
+ public XMLWellFormChecker(PrintWriter log) {
+ super() ;
+ this.log = log ;
+ }
+
+ public XMLWellFormChecker(PrintWriter log_, boolean printXMLData) {
+ super(printXMLData ? log_ : null) ;
+ this.printXMLData = printXMLData ;
+ this.log = log_ ;
+ }
+
+ /**
+ * Reset all values. This is important e.g. for test of XFilter
+ * interface, where 'filter()' method istbstarted twice.
+ */
+ public void reset() {
+ docStarted = false ;
+ docEnded = false ;
+ tagStack = new Vector() ;
+ wellFormed = true ;
+ noOtherErrors = true ;
+ PrintWriter log = null ;
+ printXMLData = false ;
+ }
+
+ public void startDocument() {
+ super.startDocument();
+
+ if (docStarted) {
+ printError("Document is started twice.") ;
+ wellFormed = false ;
+ }
+
+ docStarted = true ;
+ }
+ public void endDocument() {
+ super.endDocument();
+ if (!docStarted) {
+ wellFormed = false ;
+ printError("Document ended but not started.") ;
+ }
+ docEnded = true ;
+ }
+ public void startElement(String name, XAttributeList attr) {
+ super.startElement(name, attr);
+ if (attr == null) {
+ printError("attribute list passed as parameter to startElement()"+
+ " method has null value for tag <" + name + ">") ;
+ noOtherErrors = false ;
+ }
+ tagStack.add(0, name) ;
+ }
+ public void endElement(String name) {
+ super.endElement(name);
+ if (wellFormed) {
+ if (tagStack.size() == 0) {
+ wellFormed = false ;
+ printError("No tags to close (bad closing tag </" + name + ">)") ;
+ } else {
+ String startTag = (String) tagStack.elementAt(0) ;
+ tagStack.remove(0) ;
+ if (!startTag.equals(name)) {
+ wellFormed = false ;
+ printError("Bad closing tag: </" + name +
+ ">; tag expected: </" + startTag + ">");
+ }
+ }
+ }
+ }
+
+ /**
+ * Checks if there were no errors during document handling.
+ * I.e. startDocument() and endDocument() must be called,
+ * XML must be well formed, paramters must be valid.
+ */
+ public boolean isWellFormed() {
+ if (!docEnded) {
+ printError("Document was not ended.") ;
+ wellFormed = false ;
+ }
+
+ return wellFormed && noOtherErrors ;
+ }
+
+ /**
+ * Prints error message and all tags where error occured inside.
+ * Also prints "Tag trace" in case if the full XML data isn't
+ * printed.
+ */
+ public void printError(String msg) {
+ log.println("!!! Error: " + msg) ;
+ if (printXMLData) return ;
+ log.println(" Tag trace :") ;
+ for (int i = 0; i < tagStack.size(); i++) {
+ String tag = (String) tagStack.elementAt(i) ;
+ log.println(" <" + tag + ">") ;
+ }
+ }
+ }
+
+ /**
+ * Beside structure of XML this class also can check existence
+ * of tags, inner tags, and character data. After document
+ * completion there is a way to check if required tags and
+ * character data was found. If there any error occurs an
+ * appropriate message is output.
+ */
+ public static class XMLTagsChecker extends XMLWellFormChecker {
+ protected Hashtable tags = new Hashtable() ;
+ protected Hashtable chars = new Hashtable() ;
+ protected boolean allOK = true ;
+
+ public XMLTagsChecker(PrintWriter log) {
+ super(log) ;
+ }
+
+ /**
+ * Adds a tag name which must be contained in the XML data.
+ */
+ public void addTag(String tag) {
+ tags.put(tag, "") ;
+ }
+ /**
+ * Adds a tag name which must be contained in the XML data and
+ * must be inside the tag with name <code>outerTag</code>.
+ */
+ public void addTagEnclosed(String tag, String outerTag) {
+ tags.put(tag, outerTag) ;
+ }
+ /**
+ * Adds a character data which must be contained in the XML data.
+ */
+ public void addCharacters(String ch) {
+ chars.put(ch, "") ;
+ }
+ /**
+ * Adds a character data which must be contained in the XML data and
+ * must be inside the tag with name <code>outerTag</code>.
+ */
+ public void addCharactersEnclosed(String ch, String outerTag) {
+ chars.put(ch, outerTag) ;
+ }
+
+ public void startElement(String name, XAttributeList attrs) {
+ super.startElement(name, attrs) ;
+ if (tags.containsKey(name)) {
+ String outerTag = (String) tags.get(name);
+ if (!outerTag.equals("")) {
+ boolean isInTag = false ;
+ for (int i = 0; i < tagStack.size(); i++) {
+ if (outerTag.equals((String) tagStack.elementAt(i))) {
+ isInTag = true ;
+ break ;
+ }
+ }
+ if (!isInTag) {
+ printError("Required tag <" + name + "> found, but is not enclosed in tag <" +
+ outerTag + ">") ;
+ allOK = false ;
+ }
+ }
+ tags.remove(name) ;
+ }
+ }
+
+ public void characters(String ch) {
+ super.characters(ch) ;
+
+ if (chars.containsKey(ch)) {
+ String outerTag = (String) chars.get(ch);
+ if (!outerTag.equals("")) {
+ boolean isInTag = false ;
+ for (int i = 0; i < tagStack.size(); i++) {
+ if (outerTag.equals((String) tagStack.elementAt(i))) {
+ isInTag = true ;
+ break ;
+ }
+ }
+ if (!isInTag) {
+ printError("Required characters '" + ch + "' found, but are not enclosed in tag <" +
+ outerTag + ">") ;
+ allOK = false ;
+ }
+ }
+ chars.remove(ch) ;
+ }
+ }
+
+ /**
+ * Checks if the XML data was valid and well formed and if
+ * all necessary tags and character data was found.
+ */
+ public boolean checkTags() {
+ allOK &= isWellFormed() ;
+
+ Enumeration badTags = tags.keys() ;
+ Enumeration badChars = chars.keys() ;
+
+ if (badTags.hasMoreElements()) {
+ allOK = false ;
+ log.println("Required tags were not found in export :") ;
+ while(badTags.hasMoreElements()) {
+ log.println(" <" + ((String) badTags.nextElement()) + ">") ;
+ }
+ }
+ if (badChars.hasMoreElements()) {
+ allOK = false ;
+ log.println("Required characters were not found in export :") ;
+ while(badChars.hasMoreElements()) {
+ log.println(" <" + ((String) badChars.nextElement()) + ">") ;
+ }
+ }
+ reset();
+ return allOK ;
+ }
+ }
+
+ /**
+ * Represents an XML tag which must be found in XML data written.
+ * This tag can contain only its name or tag name and attribute
+ * name, or attribute value additionally.
+ */
+ public static class Tag {
+ private String name = null;
+ private String[][] attrList = new String[0][3] ;
+
+ /**
+ * Creates tag which has only a name. Attributes don't make sense.
+ * @param tagName The name of the tag.
+ */
+ public Tag(String tagName) {
+ name = tagName ;
+ }
+
+ /**
+ * Creates a tag with the name specified, which must have an
+ * attribute with name specified. The value of this attribute
+ * doesn't make sense.
+ * @param tagName The name of the tag.
+ * @param attrName The name of attribute which must be contained
+ * in the tag.
+ */
+ public Tag(String tagName, String attrName) {
+ name = tagName ;
+ attrList = new String[1][3] ;
+ attrList[0][0] = attrName ;
+ }
+
+ /**
+ * Creates a tag with the name specified, which must have an
+ * attribute with the value specified. The type of value
+ * assumed to be 'CDATA'.
+ * @param tagName The name of the tag.
+ * @param attrName The name of attribute which must be contained
+ * in the tag.
+ * @param attrValue Attribute value.
+ */
+ public Tag(String tagName, String attrName, String attrValue) {
+ name = tagName ;
+ attrList = new String[1][3] ;
+ attrList[0][0] = attrName ;
+ attrList[0][1] = "CDATA" ;
+ attrList[0][2] = attrValue ;
+ }
+
+ /**
+ * Creates a tag with the name specified, which must have
+ * attributes specified. The value of thesee attributes
+ * doesn't make sense.
+ * @param tagName The name of the tag.
+ * @param attrNames Array with names of attributes which must
+ * be contained in the tag.
+ */
+ public Tag(String tagName, String[] attrNames) {
+ name = tagName ;
+ attrList = new String[attrNames.length][3] ;
+ for (int i = 0; i < attrNames.length; i++) {
+ attrList[i][0] = attrNames[i] ;
+ }
+ }
+
+ /**
+ * Creates a tag with the name specified, which must have an
+ * attributes with their values specified. The type of all values
+ * assumed to be 'CDATA'.
+ * @param tagName The name of the tag.
+ * @param attrValues An array with attribute names and their values.
+ * <code>attrValues[N][0]</code> element contains the name of Nth
+ * attribute, and <code>attrValues[N][1]</code> element contains
+ * value of Nth attribute, if value is <code>null</code> then the
+ * attribute value can be any.
+ */
+ public Tag(String tagName, String[][] attrValues) {
+ name = tagName ;
+ attrList = new String[attrValues.length][3] ;
+ for (int i = 0; i < attrValues.length; i++) {
+ attrList[i][0] = attrValues[i][0] ;
+ attrList[i][1] = "CDATA" ;
+ attrList[i][2] = attrValues[i][1] ;
+ }
+ }
+
+ /**
+ * Gets tag String description.
+ */
+ public String toString() {
+ String ret = "<" + name ;
+ for (int i = 0; i < attrList.length; i++) {
+ ret += " " + attrList[i][0] + "=";
+ if (attrList[i][2] == null) {
+ ret += "(not specified)";
+ } else {
+ ret += "\"" + attrList[i][2] + "\"";
+ }
+ }
+ ret += ">";
+
+ return ret ;
+ }
+
+ protected boolean checkAttr(int attrListIdx, XAttributeList list) {
+ short j = 0 ;
+ int listLen = list.getLength();
+ while(j < listLen) {
+ if (attrList[attrListIdx][0].equals(list.getNameByIndex(j))) {
+ if (attrList[attrListIdx][2] == null) return true ;
+ return attrList[attrListIdx][2].equals(list.getValueByIndex(j)) ;
+ }
+ j++ ;
+ }
+ return false ;
+ }
+
+ /**
+ * Checks if this tag matches tag passed in parameters.
+ * I.e. if tag specifies only it's name it mathes if names
+ * are equal (attributes don't make sense). If there are
+ * some attributes names specified in this tag method checks
+ * if all names present in attribute list <code>list</code>
+ * (attributes' values don't make sense). If attributes specified
+ * with values method checks if these attributes exist and
+ * have appropriate values.
+ */
+ public boolean isMatchTo(String tagName, XAttributeList list) {
+ if (!name.equals(tagName)) return false;
+ boolean result = true ;
+ for (int i = 0; i < attrList.length; i++) {
+ result &= checkAttr(i, list) ;
+ }
+ return result ;
+ }
+ }
+
+ /**
+ * Class realises extended XML data checking. It has possibilities
+ * to check if a tag exists, if it has some attributes with
+ * values, and if this tag is contained in another tag (which
+ * also can specify any attributes). It can check if some
+ * character data exists inside any tag specified.
+ */
+ public static class XMLChecker extends XMLWellFormChecker {
+ protected HashSet tagSet = new HashSet() ;
+ protected Vector tags = new Vector() ;
+ protected Vector chars = new Vector() ;
+ protected Vector tagStack = new Vector() ;
+ protected Vector attrStack = new Vector() ;
+
+ public XMLChecker(PrintWriter log, boolean writeXML) {
+ super(log, writeXML) ;
+ }
+
+ public void addTag(Tag tag) {
+ tags.add(new Tag[] {tag, null}) ;
+ tagSet.add(tag.name) ;
+ }
+
+ public void addTagEnclosed(Tag tag, Tag outerTag) {
+ tags.add(new Tag[] {tag, outerTag}) ;
+ tagSet.add(tag.name) ;
+ }
+
+ public void addCharacters(String ch) {
+ chars.add(new Object[] {ch.trim(), null}) ;
+ }
+
+ public void addCharactersEnclosed(String ch, Tag outerTag) {
+ chars.add(new Object[] {ch.trim(), outerTag}) ;
+ }
+
+ public void startElement(String name, XAttributeList attr) {
+ try {
+ super.startElement(name, attr);
+
+ if (tagSet.contains(name)) {
+ for (int i = 0; i < tags.size(); i++) {
+ Tag[] tag = (Tag[]) tags.elementAt(i);
+ if (tag[0].isMatchTo(name, attr)) {
+ if (tag[1] == null) {
+ tags.remove(i--);
+ } else {
+ boolean isInStack = false ;
+ for (int j = 0; j < tagStack.size(); j++) {
+ if (tag[1].isMatchTo((String) tagStack.elementAt(j),
+ (XAttributeList) attrStack.elementAt(j))) {
+
+ isInStack = true ;
+ break ;
+ }
+ }
+ if (isInStack) {
+ tags.remove(i--) ;
+ }
+ }
+ }
+ }
+ }
+
+ tagStack.add(0, name) ;
+ attrStack.add(0, new AttributeList(attr));
+ } catch (Exception e) {
+ e.printStackTrace(log);
+ }
+ }
+
+ public void characters(String ch) {
+ super.characters(ch) ;
+ for (int i = 0; i < chars.size(); i++) {
+ Object[] chr = (Object[]) chars.elementAt(i);
+ if (((String) chr[0]).equals(ch)) {
+ if (chr[1] == null) {
+ chars.remove(i--);
+ } else {
+ boolean isInStack = false ;
+ for (int j = 0; j < tagStack.size(); j++) {
+ if (((Tag) chr[1]).isMatchTo((String) tagStack.elementAt(j),
+ (XAttributeList) attrStack.elementAt(j))) {
+
+ isInStack = true ;
+ break ;
+ }
+ }
+ if (isInStack) {
+ chars.remove(i--) ;
+ }
+ }
+ }
+ }
+ }
+
+ public void endElement(String name) {
+ try {
+ super.endElement(name);
+
+ if (tagStack.size() > 0) {
+ tagStack.remove(0) ;
+ attrStack.remove(0) ;
+ }
+ } catch(Exception e) {
+ e.printStackTrace(log) ;
+ }
+ }
+
+ public boolean check() {
+ if (tags.size()> 0) {
+ log.println("!!! Error: Some tags were not found :") ;
+ for (int i = 0; i < tags.size(); i++) {
+ Tag[] tag = (Tag[]) tags.elementAt(i) ;
+ log.println(" Tag " + tag[0] + " was not found");
+ if (tag[1] != null)
+ log.println(" inside tag " + tag[1]) ;
+ }
+ }
+ if (chars.size() > 0) {
+ log.println("!!! Error: Some character data blocks were not found :") ;
+ for (int i = 0; i < chars.size(); i++) {
+ Object[] ch = (Object[]) chars.elementAt(i) ;
+ log.println(" Character data \"" + ch[0] + "\" was not found ") ;
+ if (ch[1] != null)
+ log.println(" inside tag " + ch[1]) ;
+ }
+ }
+
+ if (!isWellFormed())
+ log.println("!!! Some errors were found in XML structure") ;
+
+ boolean result = tags.size() == 0 && chars.size() == 0 && isWellFormed();
+ reset();
+ return result;
+ }
+ }
+
+ /**
+ * Creates <code>XDocumentHandler</code> implementation in form
+ * of <code>com.sun.star.xml.sax.Writer</code> service, which
+ * writes XML data into a <code>com.sun.star.io.Pipe</code>
+ * created.
+ * @return Single element array which contains the handler
+ * contained in <code>Any</code> structure.
+ */
+ public static Object[] getDocumentHandler(XMultiServiceFactory xMSF) {
+ Object[] ret = new Object[1];
+ try {
+ XInterface Writer = (XInterface) xMSF.createInstance(
+ "com.sun.star.xml.sax.Writer");
+ XInterface oPipe = (XInterface) xMSF.createInstance
+ ( "com.sun.star.io.Pipe" );
+ XOutputStream xPipeOutput = (XOutputStream) UnoRuntime.
+ queryInterface(XOutputStream.class, oPipe) ;
+
+ XActiveDataSource xADS = (XActiveDataSource)
+ UnoRuntime.queryInterface(XActiveDataSource.class,Writer);
+ xADS.setOutputStream(xPipeOutput);
+ XDocumentHandler handler = (XDocumentHandler)
+ UnoRuntime.queryInterface(XDocumentHandler.class,Writer);
+
+ Any arg = new Any(new Type(XDocumentHandler.class),handler);
+
+ ret[0] = arg;
+ } catch (com.sun.star.uno.Exception e) {
+ e.printStackTrace();
+ }
+ return ret;
+ }
+
+ public static PropertyValue[] createMediaDescriptor(String[] propNames, Object[] values) {
+ PropertyValue[] props = new PropertyValue[propNames.length] ;
+
+ for (int i = 0; i < props.length; i++) {
+ props[i] = new PropertyValue() ;
+ props[i].Name = propNames[i] ;
+ if (values != null && i < values.length) {
+ props[i].Value = values[i] ;
+ }
+ }
+
+ return props ;
+ }
+
+ /**
+ * Gets the hanlder, which writes all the XML data passed to the
+ * file specified.
+ * @param xMSF Soffice <code>ServiceManager</code> factory.
+ * @param fileURL The file URL (in form file:///<path>) to which
+ * XML data is written.
+ * @return SAX handler to which XML data has to be written.
+ */
+ public static XDocumentHandler getFileXMLWriter(XMultiServiceFactory xMSF, String fileURL)
+ throws com.sun.star.uno.Exception
+ {
+ XInterface oFacc = (XInterface)xMSF.createInstance(
+ "com.sun.star.comp.ucb.SimpleFileAccess");
+ XSimpleFileAccess xFacc = (XSimpleFileAccess)UnoRuntime.queryInterface
+ (XSimpleFileAccess.class, oFacc) ;
+
+ XInterface oWriter = (XInterface)xMSF.createInstance(
+ "com.sun.star.xml.sax.Writer");
+ XActiveDataSource xWriterDS = (XActiveDataSource)
+ UnoRuntime.queryInterface(XActiveDataSource.class, oWriter);
+ XDocumentHandler xDocHandWriter = (XDocumentHandler) UnoRuntime.queryInterface
+ (XDocumentHandler.class, oWriter) ;
+
+ if (xFacc.exists(fileURL))
+ xFacc.kill(fileURL);
+ XOutputStream fOut = xFacc.openFileWrite(fileURL) ;
+ xWriterDS.setOutputStream(fOut);
+
+ return xDocHandWriter ;
+ }
+
+ /**
+ * Parses XML file and passes its data to the SAX handler specified.
+ * @param xMSF Soffice <code>ServiceManager</code> factory.
+ * @param fileURL XML file name (in form file:///<path>) to be parsed.
+ * @param handler SAX handler to which XML data from file will
+ * be transferred.
+ */
+ public static void parseXMLFile(XMultiServiceFactory xMSF,
+ String fileURL, XDocumentHandler handler) throws com.sun.star.uno.Exception
+ {
+ XInterface oFacc = (XInterface)xMSF.createInstance(
+ "com.sun.star.comp.ucb.SimpleFileAccess");
+ XSimpleFileAccess xFacc = (XSimpleFileAccess)UnoRuntime.queryInterface
+ (XSimpleFileAccess.class, oFacc) ;
+ XInputStream oIn = xFacc.openFileRead(fileURL) ;
+
+ XInterface oParser = (XInterface)xMSF.createInstance(
+ "com.sun.star.xml.sax.Parser");
+ XParser xParser = (XParser) UnoRuntime.queryInterface(XParser.class, oParser);
+
+ xParser.setDocumentHandler(handler) ;
+ InputSource inSrc = new InputSource() ;
+ inSrc.aInputStream = oIn ;
+ xParser.parseStream(inSrc) ;
+
+ oIn.closeInput();
+ }
+
+ /**
+ * Exports document (the whole or a part) into the file specified
+ * in XML format.
+ * @param xMSF Soffice <code>ServiceManager</code> factory.
+ * @param xDoc Document to be exported.
+ * @param docType Type of document (for example 'Calc', 'Writer', 'Draw')
+ * The type must start with <b>capital</b> letter.
+ * @param exportType The type of export specifies if the whole
+ * document will be exported or one of its parts (Meta info, Styles, etc.).
+ * The following types supported (it also depends of document type) :
+ * "" (empty string) - for the whole document ;
+ * "Content" - only content exported ;
+ * "Meta" - meta document info exported ;
+ * "Settings" - view settings of document exported ;
+ * "Styles" - document styles exported ;
+ * @param fileURL XML file name (in form file:///<path>) to be exported to.
+ */
+ public static void exportDocument(XMultiServiceFactory xMSF, XComponent xDoc,
+ String docType, String exportType, String fileURL)
+ throws com.sun.star.uno.Exception {
+
+ XDocumentHandler xDocHandWriter = XMLTools.getFileXMLWriter(xMSF, fileURL) ;
+
+ Any arg = new Any(new Type(XDocumentHandler.class), xDocHandWriter);
+ XInterface oExp = (XInterface)xMSF.createInstanceWithArguments(
+ "com.sun.star.comp." + docType + ".XML" + exportType + "Exporter",
+ new Object[] {arg});
+
+ XExporter xExp = (XExporter) UnoRuntime.queryInterface
+ (XExporter.class, oExp) ;
+ xExp.setSourceDocument(xDoc) ;
+
+ XFilter filter = (XFilter) UnoRuntime.queryInterface(XFilter.class, oExp) ;
+ filter.filter(XMLTools.createMediaDescriptor(
+ new String[] {"FilterName"},
+ new Object[] {"Custom filter"})) ;
+ }
+
+ /**
+ * Imports document (the whole or a part) from the file specified
+ * in XML format.
+ * @param xMSF Soffice <code>ServiceManager</code> factory.
+ * @param xDoc Target document to be imported.
+ * @param docType Type of document (for example 'Calc', 'Writer', 'Draw')
+ * The type must start with <b>capital</b> letter.
+ * @param exportType The type of export specifies if the whole
+ * document will be exported or one of its parts (Meta info, Styles, etc.).
+ * The following types supported (it hardly depends of XML data in file) :
+ * "" (empty string) - for the whole document ;
+ * "Content" - only content exported ;
+ * "Meta" - meta document info exported ;
+ * "Settings" - view settings of document exported ;
+ * "Styles" - document styles exported ;
+ * @param fileURL XML file name (in form file:///<path>) to be imported from.
+ */
+ public static void importDocument(XMultiServiceFactory xMSF, XComponent xDoc,
+ String docType, String importType, String fileURL)
+ throws com.sun.star.uno.Exception {
+
+ XInterface oImp = (XInterface)xMSF.createInstance(
+ "com.sun.star.comp." + docType + ".XML" + importType + "Importer");
+ XImporter xImp = (XImporter) UnoRuntime.queryInterface
+ (XImporter.class, oImp) ;
+ XDocumentHandler xDocHandImp = (XDocumentHandler) UnoRuntime.queryInterface
+ (XDocumentHandler.class, oImp) ;
+
+ xImp.setTargetDocument(xDoc) ;
+ parseXMLFile(xMSF, fileURL, xDocHandImp) ;
+ }
+} \ No newline at end of file
diff --git a/qadevOOo/runner/util/XSchemaHandlerImpl.java b/qadevOOo/runner/util/XSchemaHandlerImpl.java
new file mode 100644
index 000000000000..cac0754d9f20
--- /dev/null
+++ b/qadevOOo/runner/util/XSchemaHandlerImpl.java
@@ -0,0 +1,137 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package util;
+
+public class XSchemaHandlerImpl
+ implements com.sun.star.configuration.backend.XSchemaHandler {
+ protected String calls = "";
+ protected String ls = System.getProperty("line.separator");
+
+ public void addInstance(String str,
+ com.sun.star.configuration.backend.TemplateIdentifier templateIdentifier)
+ throws com.sun.star.configuration.backend.MalformedDataException,
+ com.sun.star.lang.WrappedTargetException {
+ calls += ("addInstance();" + ls);
+ }
+
+ public void addItemType(com.sun.star.configuration.backend.TemplateIdentifier templateIdentifier)
+ throws com.sun.star.configuration.backend.MalformedDataException,
+ com.sun.star.lang.WrappedTargetException {
+ calls += ("addItemType();" + ls);
+ }
+
+ public void addProperty(String str, short param,
+ com.sun.star.uno.Type type)
+ throws com.sun.star.configuration.backend.MalformedDataException,
+ com.sun.star.lang.WrappedTargetException {
+ calls += ("addProperty();" + ls);
+ }
+
+ public void addPropertyWithDefault(String str, short param, Object obj)
+ throws com.sun.star.configuration.backend.MalformedDataException,
+ com.sun.star.lang.WrappedTargetException {
+ calls += ("addPropertyWithDefault();" + ls);
+ }
+
+ public void endComponent()
+ throws com.sun.star.configuration.backend.MalformedDataException,
+ com.sun.star.lang.WrappedTargetException {
+ calls += ("endComponent();" + ls);
+ }
+
+ public void endNode()
+ throws com.sun.star.configuration.backend.MalformedDataException,
+ com.sun.star.lang.WrappedTargetException {
+ calls += ("endNode();" + ls);
+ }
+
+ public void endSchema()
+ throws com.sun.star.configuration.backend.MalformedDataException,
+ com.sun.star.lang.WrappedTargetException {
+ calls += ("endSchema();" + ls);
+ }
+
+ public void endTemplate()
+ throws com.sun.star.configuration.backend.MalformedDataException,
+ com.sun.star.lang.WrappedTargetException {
+ calls += ("endTemplate();" + ls);
+ }
+
+ public void importComponent(String str)
+ throws com.sun.star.configuration.backend.MalformedDataException,
+ com.sun.star.lang.WrappedTargetException {
+ calls += ("importComponent();" + ls);
+ }
+
+ public void startComponent(String str)
+ throws com.sun.star.configuration.backend.MalformedDataException,
+ com.sun.star.lang.WrappedTargetException {
+ calls += ("startComponent();" + ls);
+ }
+
+ public void startGroup(String str, short param)
+ throws com.sun.star.configuration.backend.MalformedDataException,
+ com.sun.star.lang.WrappedTargetException {
+ calls += ("startGroup();" + ls);
+ }
+
+ public void startGroupTemplate(com.sun.star.configuration.backend.TemplateIdentifier templateIdentifier,
+ short param)
+ throws com.sun.star.configuration.backend.MalformedDataException,
+ com.sun.star.lang.WrappedTargetException {
+ calls += ("startGroupTemplate();" + ls);
+ }
+
+ public void startSchema()
+ throws com.sun.star.configuration.backend.MalformedDataException,
+ com.sun.star.lang.WrappedTargetException {
+ calls += ("startSchema();" + ls);
+ }
+
+ public void startSet(String str, short param,
+ com.sun.star.configuration.backend.TemplateIdentifier templateIdentifier)
+ throws com.sun.star.configuration.backend.MalformedDataException,
+ com.sun.star.lang.WrappedTargetException {
+ calls += ("startSet();" + ls);
+ }
+
+ public void startSetTemplate(com.sun.star.configuration.backend.TemplateIdentifier templateIdentifier,
+ short param,
+ com.sun.star.configuration.backend.TemplateIdentifier templateIdentifier2)
+ throws com.sun.star.configuration.backend.MalformedDataException,
+ com.sun.star.lang.WrappedTargetException {
+ calls += ("startSetTemplate();" + ls);
+ }
+
+ public String getCalls() {
+ return calls;
+ }
+
+ public void cleanCalls() {
+ calls = "";
+ }
+} \ No newline at end of file
diff --git a/qadevOOo/runner/util/compare/DocComparator.java b/qadevOOo/runner/util/compare/DocComparator.java
new file mode 100644
index 000000000000..365850fa4839
--- /dev/null
+++ b/qadevOOo/runner/util/compare/DocComparator.java
@@ -0,0 +1,52 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package util.compare;
+
+import java.io.IOException;
+
+/**
+ *
+ *
+ */
+
+public interface DocComparator {
+
+ public boolean isReferenceExistent() throws IOException;
+
+ public void createReference() throws IOException;
+
+ public boolean compare() throws IOException;
+
+
+ public boolean isDiffReferenceExistent() throws IOException;
+
+ public void createDiffReference() throws IOException;
+
+ public boolean compareDiff() throws IOException;
+
+}
diff --git a/qadevOOo/runner/util/compare/DocComparatorFactory.java b/qadevOOo/runner/util/compare/DocComparatorFactory.java
new file mode 100644
index 000000000000..5f68606932c0
--- /dev/null
+++ b/qadevOOo/runner/util/compare/DocComparatorFactory.java
@@ -0,0 +1,64 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package util.compare;
+
+import lib.TestParameters;
+import util.compare.GraphicalComparator;
+
+public class DocComparatorFactory
+{
+ /**
+ * @param s is a name like 'ooo' 'pdf' or 'msoffice'
+ * @return a new DocComparator Object
+ */
+ static public DocComparator createComparator(String s, TestParameters aParams) throws IllegalArgumentException
+ {
+ if (s.toLowerCase().equals("gfx") || s.toLowerCase().equals("graphical"))
+ {
+ return GraphicalComparator.getInstance(aParams);
+ }
+/*
+ else if (s.toLowerCase().equals("xml"))
+ {
+ return new XMLCompare.create(aParams);
+ }
+*/
+ else if (s.toLowerCase().equals("pdf"))
+ {
+ // return new PDFComparator.create(aParams);
+ throw new IllegalArgumentException("PDF not implemented yet.");
+ }
+ else
+ {
+ throw new IllegalArgumentException("DocComparator for '" + s + "' not supported!");
+ }
+
+ // unreachable: return null;
+ }
+
+}
diff --git a/qadevOOo/runner/util/compare/GraphicalComparator.java b/qadevOOo/runner/util/compare/GraphicalComparator.java
new file mode 100644
index 000000000000..71109e984188
--- /dev/null
+++ b/qadevOOo/runner/util/compare/GraphicalComparator.java
@@ -0,0 +1,260 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package util.compare;
+
+import convwatch.GraphicalDifferenceCheck;
+import convwatch.GraphicalTestArguments;
+import convwatch.DirectoryHelper;
+import convwatch.FileHelper;
+
+import lib.TestParameters;
+import java.io.File;
+import java.io.FileFilter;
+import java.io.IOException;
+
+import util.compare.DocComparator;
+import convwatch.ConvWatchException;
+
+// -----------------------------------------------------------------------------
+class GraphicalComparator implements DocComparator
+{
+ GraphicalTestArguments m_aArguments;
+
+ protected GraphicalComparator(TestParameters aParams)
+ {
+ m_aArguments = new GraphicalTestArguments(aParams);
+ }
+
+ /**
+ * @return an instance of this object, but only it's interface
+ */
+ static DocComparator getInstance(TestParameters aParams)
+ {
+ // setting the default test parameter
+ // TEST aParams
+ GraphicalComparator a = new GraphicalComparator(aParams);
+ return a;
+ }
+
+ /**
+ * return a (FileFilter) function, which returns true, if the filename is a '*.prn' file
+ */
+ FileFilter getTrueIfPRNFile_FileFilter()
+ {
+ FileFilter aFileFilter = new FileFilter()
+ {
+ public boolean accept( File pathname )
+ {
+ if (pathname.getName().endsWith(".prn"))
+ {
+ return true;
+ }
+ return false;
+ }
+ };
+ return aFileFilter;
+ }
+
+ /**
+ * build a new file from _sEntry by
+ * replacing the path equals to _sInputPath with _sReferencePath and replace it's suffix by _sNewSuffix.
+ * If _sInputPath is empty, replace the whole path by _sReferencePath.
+ */
+ protected String createSpecialFile(String _sEntry, String _sInputPath, String _sReferencePath, String _sNewSuffix)
+ {
+ String fs = System.getProperty("file.separator");
+ String sNewSubDir = "";
+ if (_sInputPath.length() > 0)
+ {
+ sNewSubDir = FileHelper.removeFirstDirectorysAndBasenameFrom(_sEntry, _sInputPath);
+ }
+ String sNameNoSuffix = FileHelper.getNameNoSuffix(FileHelper.getBasename(_sEntry));
+
+ // add the sub path to the difference path
+ String sNewReferencePath;
+ if (sNewSubDir.length() > 0)
+ {
+ sNewReferencePath = _sReferencePath + fs + sNewSubDir;
+ }
+ else
+ {
+ sNewReferencePath = _sReferencePath;
+ }
+ // add the difference name
+ sNewReferencePath += fs + sNameNoSuffix + _sNewSuffix;
+ return sNewReferencePath;
+ }
+
+ boolean isReferenceOrDiffExistent(String _sNewSuffix)
+ {
+ boolean isExistent = false;
+
+ // LLA? What if sReferencePath is a directory, but directory is empty? is the result then true or false;
+
+ // wir muessen durch den InputPath durch und dann fuer jedes Dokument prufen, ob im angegebenen ReferencePath eine Reference existiert.
+ String sInputPath = m_aArguments.getInputPath();
+ if (FileHelper.isDir(sInputPath))
+ {
+ Object[] aList = DirectoryHelper.traverse(sInputPath, FileHelper.getFileFilter(), m_aArguments.includeSubDirectories());
+ for (int i=0;i<aList.length;i++)
+ {
+ // get document + path
+ String sEntry = (String)aList[i];
+ String sNewReferencePath = createSpecialFile(sEntry, sInputPath, m_aArguments.getReferencePath(), _sNewSuffix);
+ // split path from document path which only is equal to sInputPath (sub path)
+ if (FileHelper.exists(sNewReferencePath))
+ {
+ isExistent = true;
+ }
+ }
+ }
+ else
+ {
+ // sInputPath is a file
+ String sNewReferencePath = createSpecialFile(sInputPath, "", m_aArguments.getReferencePath(), _sNewSuffix);
+ if (FileHelper.exists(sNewReferencePath))
+ {
+ isExistent = true;
+ }
+ }
+ return isExistent;
+ }
+
+ /**
+ * REFERENCE_PATH must set to directory/file, where the reference (*.prn files) (should) exist
+ */
+ public boolean isReferenceExistent()
+ {
+ return isReferenceOrDiffExistent(".prn");
+ }
+
+ /**
+ * INPUT_PATH must set, to directory/file, where the documents exist.
+ * REFERENCE_PATH must set to directory/file, where the created references (*.prn files) will create.
+ */
+ public void createReference() throws IOException
+ {
+ // woher kommt das TestDocument
+ // INPUT_PATH
+ // wohin
+ // REFERENCE_PATH
+ // mit was (Reference Application)
+ // AppExecutionCmd
+ try
+ {
+ String referenceInputPath = null;
+ if(m_aArguments.getReferenceInputPath() == null)
+ {
+ GraphicalDifferenceCheck.createReferences(m_aArguments.getInputPath(), m_aArguments.getReferencePath(), m_aArguments);
+ }
+ else
+ {
+ referenceInputPath = m_aArguments.getReferenceInputPath();
+ GraphicalDifferenceCheck.createReferences(referenceInputPath, m_aArguments.getReferencePath(), m_aArguments);
+ }
+ }
+ catch (ConvWatchException e)
+ {
+ // wrap it to IOException
+ throw new java.io.IOException(e.getMessage());
+ }
+ }
+
+ /**
+ * INPUT_PATH must set, to directory/file, where the documents exist.
+ * REFERENCE_PATH must set to directory/file, where the created references (*.prn files) will create.
+ * OUTPUT_PATH must set to a directory, there the whole ouptut will create
+ */
+ public boolean compare() throws IOException
+ {
+ try
+ {
+ if (FileHelper.isDebugEnabled())
+ {
+ System.err.println(" Inputpath: '" + m_aArguments.getInputPath() + "'");
+ System.err.println(" Outputpath: '" + m_aArguments.getOutputPath() + "'");
+ System.err.println("Referencepath: '" + m_aArguments.getReferencePath() + "'");
+ }
+ return GraphicalDifferenceCheck.check(m_aArguments.getInputPath(), m_aArguments.getOutputPath(), m_aArguments.getReferencePath(), m_aArguments);
+ }
+ catch(ConvWatchException e)
+ {
+ // wrap it to IOException
+ if (FileHelper.isDebugEnabled())
+ {
+ System.err.println("Exception caught");
+ System.err.println(" Inputpath: '" + m_aArguments.getInputPath() + "'");
+ System.err.println(" Outputpath: '" + m_aArguments.getOutputPath() + "'");
+ System.err.println("Referencepath: '" + m_aArguments.getReferencePath() + "'");
+ }
+ throw new java.io.IOException(e.getMessage());
+ }
+ }
+
+ /**
+ *
+ * INPUT_PATH must set to the original documents the directory structure is taken to see if the references exist in the DIFF_PATH
+ * DIFF_PATH must set to the diff references
+ */
+ public boolean isDiffReferenceExistent() throws IOException
+ {
+ return isReferenceOrDiffExistent(".prn.diff0001.jpg");
+ }
+
+ /**
+ * INPUT_PATH must set, to directory/file, where the documents exist.
+ * REFERENCE_PATH must set to directory/file, where the created references (*.prn files) exists.
+ * OUTPUT_PATH must set to a directory, where the whole ouptut will create. Here the diffReference will create.
+ * At the momemt it's not possible to say only where the diffreferences will create.
+ */
+ public void createDiffReference() throws IOException
+ {
+ // this is the same like compareDiff(), but trash the result.
+ compareDiff();
+ }
+
+ /**
+ * INPUT_PATH must set, to directory/file, where the documents exist.
+ * REFERENCE_PATH must set to directory/file, where the created references (*.prn files) exists.
+ * OUTPUT_PATH must set to a directory, where the whole ouptut will create.
+ * DIFF_PATH must set to a directory, where the older difference references exist, it's possible to set this to the same as REFERENCE_PATH
+ * but this is not the default and will not automatically set.
+ */
+ public boolean compareDiff() throws IOException
+ {
+ try
+ {
+ return GraphicalDifferenceCheck.check(m_aArguments.getInputPath(), m_aArguments.getOutputPath(), m_aArguments.getReferencePath(), m_aArguments.getDiffPath(), m_aArguments);
+ }
+ catch(ConvWatchException e)
+ {
+ // wrap it to IOException
+ throw new java.io.IOException(e.getMessage());
+ }
+ }
+
+}
diff --git a/qadevOOo/runner/util/compare/PDFComparator.java b/qadevOOo/runner/util/compare/PDFComparator.java
new file mode 100644
index 000000000000..fb49b0db40dd
--- /dev/null
+++ b/qadevOOo/runner/util/compare/PDFComparator.java
@@ -0,0 +1,62 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package util.compare;
+
+import util.compare.DocComparator;
+import lib.TestParameters;
+import util.compare.GraphicalComparator;
+
+class PDFComparator extends GraphicalComparator implements DocComparator
+{
+ protected PDFComparator(TestParameters aParams)
+ {
+ super(aParams);
+ }
+
+ static DocComparator getInstance(TestParameters aParams)
+ {
+ aParams.put(convwatch.PropertyName.DOC_COMPARATOR_REFERENCE_TYPE, "pdf");
+ PDFComparator a = new PDFComparator(aParams);
+ return a;
+ }
+
+ // all in GraphicalComparator implemented.
+ // public boolean isReferenceExistent() throws IOException;
+ //
+ // public void createReference() throws IOException;
+ //
+ // public boolean compare() throws IOException;
+ //
+ //
+ // public boolean isDiffReferenceExistent() throws IOException;
+ //
+ // public void createDiffReference() throws IOException;
+ //
+ // public boolean compareDiff() throws IOException;
+}
+
diff --git a/qadevOOo/runner/util/compare/XMLComparator.java b/qadevOOo/runner/util/compare/XMLComparator.java
new file mode 100644
index 000000000000..470dbaa3ada1
--- /dev/null
+++ b/qadevOOo/runner/util/compare/XMLComparator.java
@@ -0,0 +1,58 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package util.compare;
+
+//import java.io.IOException;
+//import util.compare.DocComparator;
+//import lib.TestParameters;
+
+/**
+ * This Interface isn't ready yet.
+ *
+ */
+/*
+class XMLComparator implements DocComparator
+{
+ static DocComparator getInstance(TestParameters aParams)
+ {
+ return null;
+ }
+ public boolean isReferenceExistent() throws IOException;
+
+ public void createReference() throws IOException;
+
+ public boolean compare() throws IOException;
+
+
+ public boolean isDiffReferenceExistent() throws IOException;
+
+ public void createDiffReference() throws IOException;
+
+ public boolean compareDiff() throws IOException;
+}
+*/
diff --git a/qadevOOo/runner/util/compare/makefile.mk b/qadevOOo/runner/util/compare/makefile.mk
new file mode 100644
index 000000000000..2983e8aa581b
--- /dev/null
+++ b/qadevOOo/runner/util/compare/makefile.mk
@@ -0,0 +1,54 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+PRJ=..$/..$/..
+
+PRJNAME = OOoRunner
+PACKAGE = util.compare
+TARGET = runner_util_compare
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+# --- Files --------------------------------------------------------
+
+JARFILES = ridl.jar unoil.jar jurt.jar juh.jar java_uno.jar
+JAVAFILES = \
+ DocComparatorFactory.java \
+ DocComparator.java \
+ GraphicalComparator.java \
+ PDFComparator.java
+
+# doesn't implement yet.
+# PDFComparator.java \
+# XMLComparator.java
+
+JAVACLASSFILES= $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class)
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
diff --git a/qadevOOo/runner/util/db/DataSource.java b/qadevOOo/runner/util/db/DataSource.java
new file mode 100644
index 000000000000..60c613edd854
--- /dev/null
+++ b/qadevOOo/runner/util/db/DataSource.java
@@ -0,0 +1,163 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ */
+
+package util.db;
+
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.container.NoSuchElementException;
+import com.sun.star.frame.XModel;
+import com.sun.star.frame.XStorable;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.sdb.XDocumentDataSource;
+import com.sun.star.sdb.XOfficeDatabaseDocument;
+import com.sun.star.sdbc.XDataSource;
+import com.sun.star.uno.Exception;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XNamingService;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import lib.StatusException;
+
+/** wraps a com.sun.star.sdb.DataSource
+ *
+ * @author fs93730
+ */
+public class DataSource
+{
+ protected DataSource( XMultiServiceFactory _orb, DataSourceDescriptor _descriptor )
+ {
+ m_orb = _orb;
+ try
+ {
+ m_dataSource = (XDataSource)UnoRuntime.queryInterface( XDataSource.class,
+ m_orb.createInstance( "com.sun.star.sdb.DataSource" ) );
+ m_properties = (XPropertySet)UnoRuntime.queryInterface( XPropertySet.class,
+ m_dataSource );
+
+ Object[] descriptorProperties = new Object[] {
+ _descriptor.Name, _descriptor.URL, _descriptor.Info, _descriptor.User, _descriptor.Password,
+ _descriptor.IsPasswordRequired };
+ String[] propertyNames = new String[] {
+ "Name", "URL", "Info", "User", "Password", "IsPasswordRequired" };
+ for ( int i=0; i < descriptorProperties.length; ++i )
+ if ( descriptorProperties[i] != null )
+ m_properties.setPropertyValue( propertyNames[i], descriptorProperties[i] );
+ }
+ catch ( Exception e )
+ {
+ throw new StatusException( "could not create/fill a css.sdb.DataSource object", e );
+ }
+ }
+
+ public XDataSource getDataSource()
+ {
+ return m_dataSource;
+ }
+
+ /**
+ * retrieves the css.sdb.OfficeDatabaseDocument associated with the data source
+ * @return
+ */
+ public DatabaseDocument getDatabaseDocument()
+ {
+ synchronized ( this )
+ {
+ if ( m_document == null )
+ m_document = new DatabaseDocument( m_orb, this );
+ }
+ return m_document;
+ }
+
+ public void revokeRegistration()
+ {
+ String dataSourceName = "";
+ try
+ {
+ dataSourceName = (String)m_properties.getPropertyValue( "Name" );
+ XNamingService dbContext = (XNamingService)UnoRuntime.queryInterface( XNamingService.class,
+ m_orb.createInstance( "com.sun.star.sdb.DatabaseContext" ) );
+ dbContext.revokeObject( dataSourceName );
+ }
+ catch ( Exception e )
+ {
+ throw new StatusException( "DataSource.revokeRegistration: could not revoke the object (" + dataSourceName + ")", e );
+ }
+ }
+
+ public void registerAs( final String _registrationName, final boolean _revokeIfRegistered )
+ {
+ String doing = null;
+ try
+ {
+ doing = "creating database context";
+ XNamingService dbContext = UnoRuntime.queryInterface( XNamingService.class,
+ m_orb.createInstance( "com.sun.star.sdb.DatabaseContext" ) );
+
+ if ( _revokeIfRegistered )
+ {
+ doing = "revoking previously registered data source";
+ try
+ {
+ dbContext.revokeObject( _registrationName );
+ }
+ catch( NoSuchElementException e )
+ { /* allowed here */ }
+ }
+
+ // if the document associated with the database document has not yet been saved, then we need to do so
+ DatabaseDocument doc = getDatabaseDocument();
+ String docURL = doc.getURL();
+ if ( docURL.length() == 0 )
+ {
+ final java.io.File tempFile = java.io.File.createTempFile( _registrationName + "_", ".odb" );
+ if ( tempFile.exists() )
+ // we did not really want to create that file, we just wanted its local name, but
+ // createTempFile actually creates it => throw it away
+ // (This is necessary since some JVM/platform combinations seem to actually lock the file)
+ tempFile.delete();
+ String localPart = tempFile.toURI().toURL().toString();
+ localPart = localPart.substring( localPart.lastIndexOf( '/' ) + 1 );
+ docURL = util.utils.getOfficeTemp( m_orb ) + localPart;
+ doing = "storing database document to temporary location (" + docURL + ")";
+ doc.storeAsURL( docURL );
+ }
+
+ // register the data soource
+ doing = "registering the data source at the database context";
+ dbContext.registerObject( _registrationName, m_dataSource );
+ }
+ catch( final java.lang.Exception e )
+ {
+ throw new StatusException( "DataSource.registerAs: error during " + doing, e );
+ }
+ }
+
+ private XMultiServiceFactory m_orb = null;
+ private XDataSource m_dataSource = null;
+ private XPropertySet m_properties = null;
+ private DatabaseDocument m_document = null;
+}
diff --git a/qadevOOo/runner/util/db/DataSourceDescriptor.java b/qadevOOo/runner/util/db/DataSourceDescriptor.java
new file mode 100644
index 000000000000..9faeeb3f51e0
--- /dev/null
+++ b/qadevOOo/runner/util/db/DataSourceDescriptor.java
@@ -0,0 +1,74 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ */
+
+package util.db;
+
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.lang.XMultiServiceFactory;
+
+/** a descriptor for creating a com.sun.star.sdb.DataSource
+ *
+ * @author fs93730
+ */
+public class DataSourceDescriptor
+{
+ /**
+ * Representation of <code>'Name'</code> property.
+ */
+ public String Name = null ;
+ /**
+ * Representation of <code>'URL'</code> property.
+ */
+ public String URL = null ;
+ /**
+ * Representation of <code>'Info'</code> property.
+ */
+ public PropertyValue[] Info = null ;
+ /**
+ * Representation of <code>'User'</code> property.
+ */
+ public String User = null ;
+ /**
+ * Representation of <code>'Password'</code> property.
+ */
+ public String Password = null ;
+ /**
+ * Representation of <code>'IsPasswordRequired'</code> property.
+ */
+ public Boolean IsPasswordRequired = null ;
+
+ public DataSourceDescriptor( XMultiServiceFactory _orb )
+ {
+ m_orb = _orb;
+ }
+
+ public DataSource createDataSource()
+ {
+ return new DataSource( m_orb, this );
+ }
+
+ private XMultiServiceFactory m_orb = null;
+}
diff --git a/qadevOOo/runner/util/db/DatabaseDocument.java b/qadevOOo/runner/util/db/DatabaseDocument.java
new file mode 100644
index 000000000000..9022315fbfa4
--- /dev/null
+++ b/qadevOOo/runner/util/db/DatabaseDocument.java
@@ -0,0 +1,90 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ */
+
+package util.db;
+
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.frame.XModel;
+import com.sun.star.frame.XStorable;
+import com.sun.star.io.IOException;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.sdb.XDocumentDataSource;
+import com.sun.star.sdb.XOfficeDatabaseDocument;
+import com.sun.star.uno.UnoRuntime;
+
+/**
+ * encapsulates a css.sdb.DatabaseDocument
+ */
+public class DatabaseDocument
+{
+ protected DatabaseDocument( final XMultiServiceFactory _orb, final DataSource _dataSource )
+ {
+ m_orb = _orb;
+ m_dataSource = _dataSource;
+
+ XDocumentDataSource docDataSource = (XDocumentDataSource)UnoRuntime.queryInterface(
+ XDocumentDataSource.class, m_dataSource.getDataSource() );
+ m_databaseDocument = (XOfficeDatabaseDocument)UnoRuntime.queryInterface(XOfficeDatabaseDocument.class,
+ docDataSource.getDatabaseDocument() );
+
+ m_model = (XModel)UnoRuntime.queryInterface( XModel.class, m_databaseDocument );
+ m_storeDoc = (XStorable)UnoRuntime.queryInterface( XStorable.class, m_databaseDocument );
+ }
+
+ public DataSource getDataSource()
+ {
+ return m_dataSource;
+ }
+
+ public XOfficeDatabaseDocument getDatabaseDocument()
+ {
+ return m_databaseDocument;
+ }
+
+ /**
+ * passes through to XModel.getURL.
+ */
+ public String getURL()
+ {
+ return m_model.getURL();
+ }
+
+ /**
+ * simplified version (taking no arguments except the target URL) of XStorage.storeAsURL
+ * @param _url
+ * specifies the location to where to store the document
+ */
+ public void storeAsURL( final String _url ) throws IOException
+ {
+ m_storeDoc.storeAsURL( _url, new PropertyValue[] { } );
+ }
+
+ private XMultiServiceFactory m_orb;
+ private DataSource m_dataSource;
+ private XOfficeDatabaseDocument m_databaseDocument;
+ private XModel m_model;
+ private XStorable m_storeDoc;
+}
diff --git a/qadevOOo/runner/util/dbg.java b/qadevOOo/runner/util/dbg.java
new file mode 100644
index 000000000000..259500fe0c8f
--- /dev/null
+++ b/qadevOOo/runner/util/dbg.java
@@ -0,0 +1,347 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package util;
+
+import com.sun.star.uno.XInterface;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.Type;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.beans.XPropertySetInfo;
+import com.sun.star.beans.Property;
+import com.sun.star.beans.PropertyAttribute;
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.lang.XTypeProvider;
+import com.sun.star.lang.XServiceInfo;
+import java.io.PrintWriter;
+import java.lang.reflect.Method;
+
+/**
+ * This class accumulates all kinds of methods for accessing debug information
+ * from UNO implementations.
+ */
+public class dbg {
+
+ /**
+ * Prints information about the supported interfaces of an implementation
+ * to standard out.
+ * @param xTarget The implementation which should be analysed.
+ * @see com.sun.star.uno.XInterface
+ */
+ public static void printInterfaces(XInterface xTarget) {
+ printInterfaces(xTarget, false);
+ }
+
+ /**
+ * Prints information about the supported interfaces of an implementation
+ * to standard out. Extended information can be printed.
+ * @param xTarget The implementation which should be analysed.
+ * @param extendedInfo Should extended information be printed?
+ * @see com.sun.star.uno.XInterface
+ */
+ public static void printInterfaces(XInterface xTarget,
+ boolean extendedInfo){
+ Type[] types = getInterfaceTypes(xTarget);
+ if( null != types ) {
+ int nLen = types.length;
+ for( int i = 0; i < nLen ; i++ ) {
+ System.out.println(types[i].getTypeName());
+ if (extendedInfo) {
+ printInterfaceInfo(types[i]);
+ System.out.println();
+ }
+ }
+ }
+ }
+
+ /**
+ * Returns all interface types of an implementation as a type array.
+ * @param xTarget The implementation which should be analyzed.
+ * @return An array with all interface types; null if there are none.
+ * @see com.sun.star.uno.XInterface
+ */
+ public static Type[] getInterfaceTypes(XInterface xTarget) {
+ Type[] types = null;
+ XTypeProvider xTypeProvider = (XTypeProvider)
+ UnoRuntime.queryInterface( XTypeProvider.class, xTarget);
+ if( xTypeProvider != null )
+ types = xTypeProvider.getTypes();
+ return types;
+ }
+
+ /**
+ * Returns true if a specified target implements the interface with the
+ * given name. Note that the comparison is not case sensitive.
+ * @param xTarget The implementation which should be analysed.
+ * @param ifcName The name of the interface that is tested. The name can
+ * be full qualified, such as 'com.sun.star.io.XInputStream', or only
+ * consist of the interface name, such as 'XText'.
+ * @return True, if xTarget implements the interface named ifcType
+ * @see com.sun.star.uno.XInterface
+ */
+ public static boolean implementsInterface(
+ XInterface xTarget, String ifcName) {
+ Type[] types = getInterfaceTypes(xTarget);
+ if( null != types ) {
+ int nLen = types.length;
+ for( int i = 0; i < nLen ; i++ ) {
+ if(types[i].getTypeName().toLowerCase().endsWith(
+ ifcName.toLowerCase()))
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Prints information about an interface type.
+ *
+ * @param aType The type of the given interface.
+ * @see com.sun.star.uno.Type
+ */
+ public static void printInterfaceInfo(Type aType) {
+ try {
+ Class zClass = aType.getZClass();
+ Method[] methods = zClass.getDeclaredMethods();
+ for (int i=0; i<methods.length; i++) {
+ System.out.println("\t" + methods[i].getReturnType().getName()
+ + " " + methods[i].getName() + "()");
+ }
+ }
+ catch (Exception ex) {
+ System.out.println("Exception occured while printing InterfaceInfo");
+ ex.printStackTrace();
+ }
+ }
+
+ /**
+ * Prints a string array to standard out.
+ *
+ * @param entries : The array to be printed.
+ */
+ public static void printArray( String [] entries ) {
+ for ( int i=0; i< entries.length;i++ ) {
+ System.out.println(entries[i]);
+ }
+ }
+
+ /**
+ * Print all information about the property <code>name</code> from
+ * the property set <code>PS</code> to standard out.
+ * @param PS The property set which should contain a property called
+ * <code>name</code>.
+ * @param name The name of the property.
+ * @see com.sun.star.beans.XPropertySet
+ */
+ public static void printPropertyInfo(XPropertySet PS, String name) {
+ printPropertyInfo(PS, name, new PrintWriter(System.out)) ;
+ }
+
+ /**
+ * Print all information about the property <code>name</code> from
+ * the property set <code>PS</code> to a print writer.
+ * @param PS The property set which should contain a property called
+ * <code>name</code>.
+ * @param name The name of the property.
+ * @param out The print writer which is used as output.
+ * @see com.sun.star.beans.XPropertySet
+ */
+ public static void printPropertyInfo(XPropertySet PS, String name,
+ PrintWriter out) {
+ try {
+ XPropertySetInfo PSI = PS.getPropertySetInfo();
+ Property[] props = PSI.getProperties();
+ Property prop = PSI.getPropertyByName(name);
+ out.println("Property name is " + prop.Name);
+ out.println("Property handle is " + prop.Handle);
+ out.println("Property type is " + prop.Type.getTypeName());
+ out.println("Property current value is " +
+ PS.getPropertyValue(name));
+ out.println("Attributes :");
+ short attr = prop.Attributes;
+
+ if ((attr & PropertyAttribute.BOUND) != 0)
+ out.println("\t-BOUND");
+
+ if ((attr & PropertyAttribute.CONSTRAINED) != 0)
+ out.println("\t-CONSTRAINED");
+
+ if ((attr & PropertyAttribute.MAYBEAMBIGUOUS) != 0)
+ out.println("\t-MAYBEAMBIGUOUS");
+
+ if ((attr & PropertyAttribute.MAYBEDEFAULT) != 0)
+ out.println("\t-MAYBEDEFAULT");
+
+ if ((attr & PropertyAttribute.MAYBEVOID) != 0)
+ out.println("\t-MAYBEVOID");
+
+ if ((attr & PropertyAttribute.READONLY) != 0)
+ out.println("\t-READONLY");
+
+ if ((attr & PropertyAttribute.REMOVEABLE) != 0)
+ out.println("\t-REMOVEABLE");
+
+ if ((attr & PropertyAttribute.TRANSIENT) != 0)
+ out.println("\t-TRANSIENT");
+ } catch(com.sun.star.uno.Exception e) {
+ out.println("Exception!!!!");
+ e.printStackTrace(out);
+ }
+ }
+
+ /**
+ * Print the names and the values of a sequnze of <code>PropertyValue</code>
+ * to to standard out.
+ * @param ps The property which should displayed
+ * @see com.sun.star.beans.PropertyValue
+ */
+
+ public static void printProperyValueSequenzePairs(PropertyValue[] ps){
+ for( int i = 0; i < ps.length; i++){
+ printProperyValuePairs(ps[i], new PrintWriter(System.out));
+ }
+ }
+
+ /**
+ * Print the names and the values of a sequenze of <code>PropertyValue</code>
+ * to a print writer.
+ * @param ps The property which should displayed
+ * @param out The print writer which is used as output.
+ * @see com.sun.star.beans.PropertyValue
+ */
+ public static void printProperyValueSequenzePairs(PropertyValue[] ps, PrintWriter out){
+ for( int i = 0; i < ps.length; i++){
+ printProperyValuePairs(ps[i], out);
+ }
+ }
+
+ /**
+ * Print the name and the value of a <code>PropertyValue</code> to to standard out.
+ * @param ps The property which should displayed
+ * @see com.sun.star.beans.PropertyValue
+ */
+ public static void printProperyValuePairs(PropertyValue ps){
+ printProperyValuePairs(ps, new PrintWriter(System.out));
+ }
+
+ /**
+ * Print the name and the value of a <code>PropertyValue</code> to a print writer.
+ * @param ps The property which should displayed
+ * @param out The print writer which is used as output.
+ * @see com.sun.star.beans.PropertyValue
+ */
+ public static void printProperyValuePairs(PropertyValue ps, PrintWriter out){
+
+ if (ps.Value instanceof String[] ){
+ String[] values = (String[]) ps.Value;
+ String oneValue = "value is an empty String[]";
+ if (values.length > 0){
+ oneValue = "['";
+ for( int i=0; i < values.length; i++){
+ oneValue += values[i];
+ if (i+1 < values.length) oneValue += "';'";
+ }
+ oneValue += "']";
+ }
+ out.println("--------");
+ out.println(" Name: '" + ps.Name + "' contains String[]:");
+ out.println(oneValue);
+ out.println("--------");
+
+ } else if (ps.Value instanceof PropertyValue){
+ out.println("--------");
+ out.println(" Name: '" + ps.Name + "' contains PropertyValue:");
+ printProperyValuePairs((PropertyValue)ps.Value, out);
+ out.println("--------");
+
+ } else if (ps.Value instanceof PropertyValue[]){
+ out.println("--------");
+ out.println(" Name: '" + ps.Name + "' contains PropertyValue[]:");
+ printProperyValueSequenzePairs((PropertyValue[])ps.Value, out);
+ out.println("--------");
+
+ } else {
+ out.println("Name: '" + ps.Name + "' Value: '" + ps.Value.toString() + "'");
+ }
+ }
+
+ /**
+ * Print the names of all properties inside this property set
+ * @param ps The property set which is printed.
+ * @see com.sun.star.beans.XPropertySet
+ */
+ public static void printPropertiesNames(XPropertySet ps) {
+ XPropertySetInfo psi = ps.getPropertySetInfo();
+ Property[] props = psi.getProperties();
+ for (int i = 0; i < props.length; i++)
+ System.out.println(i + ". " + props[i].Name);
+ }
+
+ /**
+ * Print the supported services of a UNO object.
+ * @param aObject A UNO object.
+ */
+ public static void getSuppServices (Object aObject) {
+ XServiceInfo xSI = (XServiceInfo)
+ UnoRuntime.queryInterface(XServiceInfo.class,aObject);
+ printArray(xSI.getSupportedServiceNames());
+ String str="Therein not Supported Service";
+ boolean notSupportedServices = false;
+ for (int i=0;i<xSI.getSupportedServiceNames().length;i++) {
+ if (! xSI.supportsService(xSI.getSupportedServiceNames()[i])) {
+ notSupportedServices = true;
+ str+="\n" + xSI.getSupportedServiceNames()[i];
+ }
+ }
+ if (notSupportedServices)
+ System.out.println(str);
+ }
+
+ /**
+ * Get the unique implementation id of a UNO object.
+ * @param xTarget An implementation of a UNO object.
+ * @return The implementation id.
+ */
+ public static String getImplID( XInterface xTarget ) {
+ String str = "";
+ XTypeProvider xTypeProvider = (XTypeProvider)
+ UnoRuntime.queryInterface( XTypeProvider.class, xTarget);
+ if( xTypeProvider != null ) {
+ byte[] id = xTypeProvider.getImplementationId();
+ str = "ImplementationID: ";
+ for (int i=0; i<id.length;i++) {
+ Byte b = new Byte(id[i]);
+ str += b.intValue();
+ }
+ } else {
+ str = "No Implementation ID available";
+ }
+ return str;
+ }
+
+
+}
diff --git a/qadevOOo/runner/util/makefile.mk b/qadevOOo/runner/util/makefile.mk
new file mode 100644
index 000000000000..7b4d72385e24
--- /dev/null
+++ b/qadevOOo/runner/util/makefile.mk
@@ -0,0 +1,87 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..
+
+PRJNAME = OOoRunner
+PACKAGE = util
+TARGET = runner_util
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+# --- Files --------------------------------------------------------
+
+JARFILES = ridl.jar jurt.jar unoil.jar
+
+JAVAFILES = AccessibilityTools.java \
+ BasicMacroTools.java \
+ BookmarkDsc.java \
+ ControlDsc.java \
+ dbg.java \
+ DBTools.java \
+ DefaultDsc.java \
+ DesktopTools.java \
+ DrawTools.java \
+ DynamicClassLoader.java \
+ FootnoteDsc.java \
+ FormTools.java \
+ FrameDsc.java \
+ InstCreator.java \
+ InstDescr.java \
+ ParagraphDsc.java \
+ ReferenceMarkDsc.java \
+ RegistryTools.java \
+ ShapeDsc.java \
+ SOfficeFactory.java \
+ StyleFamilyDsc.java \
+ PropertyName.java \
+ SysUtils.java \
+ TableDsc.java \
+ TextSectionDsc.java \
+ XLayerImpl.java \
+ XLayerHandlerImpl.java \
+ XSchemaHandlerImpl.java \
+ UITools.java \
+ utils.java \
+ ValueChanger.java \
+ ValueComparer.java \
+ WaitUnreachable.java \
+ WriterTools.java \
+ XInstCreator.java \
+ XMLTools.java
+
+JAVACLASSFILES= $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class)
+
+# --- Targets ------------------------------------------------------
+
+
+.INCLUDE : target.mk
+
+TST:
+ @echo $(JAVACLASSFILES)
diff --git a/qadevOOo/runner/util/utils.java b/qadevOOo/runner/util/utils.java
new file mode 100644
index 000000000000..3f882f10fafb
--- /dev/null
+++ b/qadevOOo/runner/util/utils.java
@@ -0,0 +1,1020 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package util;
+
+import com.sun.star.frame.XController;
+import com.sun.star.frame.XDispatch;
+import com.sun.star.frame.XDispatchProvider;
+import com.sun.star.frame.XModel;
+import com.sun.star.lang.XComponent;
+import java.lang.System;
+import java.util.StringTokenizer;
+import java.io.*;
+import java.util.ArrayList;
+import java.io.RandomAccessFile;
+import java.net.Socket;
+import java.net.ServerSocket;
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.beans.Property;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.ucb.InteractiveAugmentedIOException;
+import com.sun.star.ucb.XSimpleFileAccess;
+import com.sun.star.lang.XServiceInfo;
+
+import com.sun.star.util.URL;
+import com.sun.star.util.XURLTransformer;
+
+import com.sun.star.uno.AnyConverter;
+import com.sun.star.uno.Type;
+import com.sun.star.uno.XComponentContext;
+import com.sun.star.util.XMacroExpander;
+import java.text.DecimalFormat;
+import java.util.Calendar;
+
+import java.util.Collections;
+import java.util.GregorianCalendar;
+
+public class utils {
+
+ /**
+ *
+ * This method adds the DOCPTH to a given file
+ *
+ * @param sDocName the file which should be completed to the test doc path
+ * @return $TESTDOCPATH/sDocName
+ */
+ public static String getFullTestDocName(String sDocName) {
+ String docpth = System.getProperty("DOCPTH");
+ if (docpth.endsWith("\\") || docpth.endsWith("/")) {
+ docpth = docpth.substring(0, docpth.length() - 1);
+ }
+
+ System.out.println("docpth:" + docpth);
+
+ String pthSep = System.getProperty("file.separator");
+
+ if (docpth.equals("unknown")) {
+ System.out.println("try to get tDoc from $SRC_ROOT/qadevOOo");
+ String srcRoot = System.getProperty(PropertyName.SRC_ROOT);
+ if (srcRoot != null) {
+ File srcR = new File(srcRoot);
+ String[] list = srcR.list(new FilenameFilter() {
+
+ public boolean accept(File dir, String name) {
+ return name.startsWith("qadevOOo");
+ }
+ });
+
+ if (list[0] != null) {
+ String tDoc = srcRoot.concat(pthSep).concat(list[0]).concat(pthSep).concat("testdocs");
+
+ if (new File(tDoc).exists()) {
+ docpth = tDoc;
+ }
+ }
+ }
+ }
+
+ if (docpth.startsWith("http:")) {
+ return docpth + "/" + sDocName;
+ }
+ String testdocPth = "";
+
+ if (docpth.equals("unknown")) {
+ System.out.println("try to get tDoc from OBJDSCS");
+ String objdscPth = System.getProperty("OBJDSCS");
+ if (objdscPth != null) {
+ int i = objdscPth.indexOf("objdsc");
+ String arcPth = objdscPth.substring(0, i - 1);
+ testdocPth = arcPth + pthSep + "doc" + pthSep + "java" +
+ pthSep + "testdocs" + pthSep + sDocName;
+ }
+ } else {
+ testdocPth = docpth + pthSep + sDocName;
+ }
+ return testdocPth;
+ }
+
+ /**
+ *
+ * This method adds the DOCPTH to a given file
+ * and changes the format to an file URL
+ *
+ */
+ public static String getFullTestURL(String sDocName) {
+ String fullDocPath = getFullTestDocName(sDocName);
+ if (fullDocPath.startsWith("http:")) {
+ return fullDocPath;
+ }
+ if (fullDocPath.startsWith("file:")) {
+ return fullDocPath;
+ }
+ String prefix = null;
+
+ // Windows: \\\\margritte\\qaapi\\workspace\\qadev\\testdocs/emptyChart.sds
+ if (fullDocPath.startsWith("\\\\")) {
+ prefix = "file:";
+ }
+
+ fullDocPath = fullDocPath.replace('\\', '/');
+ if (prefix == null) {
+ if (fullDocPath.startsWith("//")) {
+ prefix = "file:/";
+ } else if (fullDocPath.startsWith("/")) {
+ prefix = "file://";
+ } else {
+ prefix = "file:///";
+ }
+ }
+ if (!fullDocPath.endsWith("/")) {
+ File aFile = new File(fullDocPath);
+ if (aFile.isDirectory()) {
+ fullDocPath += "/";
+ }
+ }
+ String fulldocURL = prefix + fullDocPath;
+ return fulldocURL;
+ }
+
+ /**
+ *
+ * This method changes a given URL to a valid file URL
+ *
+ */
+ public static String getFullURL(String sDocName) {
+ String fullDocPath = sDocName;
+ fullDocPath = fullDocPath.replace('\\', '/');
+
+ if (fullDocPath.startsWith("http:")) {
+ return fullDocPath;
+ }
+ if (fullDocPath.startsWith("ftp:")) {
+ return fullDocPath;
+ }
+ String prefix = "";
+ if (!fullDocPath.startsWith("file:///")) {
+ if (fullDocPath.startsWith("//")) {
+ prefix = "file:";
+ } else {
+ if (fullDocPath.startsWith("/")) {
+ prefix = "file://";
+// if (helper.OSHelper.isLinuxIntel())
+// {
+// prefix = "file:/";
+// }
+ }
+ else
+ {
+ prefix = "file:///";
+ }
+ }
+ }
+ if (!fullDocPath.endsWith("/")) {
+ File aFile = new File(fullDocPath);
+ if (aFile.isDirectory()) {
+ fullDocPath += "/";
+ }
+ }
+ String fulldocURL = prefix + fullDocPath;
+
+ return fulldocURL;
+ }
+
+ /**
+ *
+ * This method creates folders needed
+ *
+ */
+ public static void make_Directories(String first, String path) {
+ String already_done = null;
+ String fs = System.getProperty("file.separator");
+ StringTokenizer path_tokenizer = new StringTokenizer(path, fs, false);
+ already_done = first;
+ while (path_tokenizer.hasMoreTokens()) {
+ String part = path_tokenizer.nextToken();
+ File new_dir = new File(already_done + File.separatorChar + part);
+ already_done = new_dir.toString();
+ //create the directory
+ new_dir.mkdirs();
+ }
+ return;
+ }
+
+ /**
+ *
+ * This method get the version for a given TestBase/platform combination
+ *
+ */
+ public static String getVersion(String aFile, String aPlatform, String aTestbase) {
+ if ((aFile == null) || (aPlatform == null) || (aTestbase == null)) {
+ return "/";
+ }
+
+ File the_file = new File(aFile);
+ try {
+ RandomAccessFile raf = new RandomAccessFile(the_file, "r");
+ String res = "";
+ while (!res.equals("[" + aTestbase.toUpperCase() + "]")) {
+ res = raf.readLine();
+ }
+ res = "=/";
+ while ((!res.startsWith(aPlatform)) || (res.startsWith("["))) {
+ res = raf.readLine();
+ }
+ raf.close();
+ if (res.startsWith("[")) {
+ res = "/";
+ }
+ return res.substring(res.indexOf("=") + 1);
+
+ } catch (Exception e) {
+ System.out.println("Couldn't find version");
+ return "/";
+ }
+ }
+
+ /**
+ *
+ * This method get's the user dir of the connected office
+ *
+ */
+ public static String getOfficeUserPath(XMultiServiceFactory msf) {
+ String userPath = null;
+
+ // get a folder wich is located in the user dir
+ try {
+ userPath = (String) getOfficeSettingsValue(msf, "UserConfig");
+ } catch (Exception e) {
+ System.out.println("Couldn't get Office User Path");
+ e.printStackTrace();
+ }
+
+ // strip the returned folder to the user dir
+ if (userPath.charAt(userPath.length() - 1) == '/') {
+ userPath = userPath.substring(0, userPath.length() - 1);
+ }
+ int index = userPath.lastIndexOf('/');
+ if (index != -1) {
+ userPath = userPath.substring(0, index);
+ }
+
+ return userPath;
+ }
+
+ /**
+ * In the office there are some sttetings available. This function
+ * returns the value of the given setting name. For Example the setting name "Temp"
+ * "Temp" returns the temp folder of the office instance.
+ * @param msf a XMultiServiceFactory
+ * @param setting the name of the setting the value should be returned.
+ * For example "Temp" reutrns the temp folder of the current office instance.
+ * @see com.sun.star.util.PathSettings
+ * @return the value as String
+ */
+ public static String getOfficeSettingsValue(XMultiServiceFactory msf, String setting) {
+
+ String settingPath = null;
+ try {
+ Object settings = msf.createInstance("com.sun.star.comp.framework.PathSettings");
+ XPropertySet pthSettings = null;
+ try {
+ pthSettings = (XPropertySet) AnyConverter.toObject(
+ new Type(XPropertySet.class), settings);
+ } catch (com.sun.star.lang.IllegalArgumentException iae) {
+ System.out.println("### couldn't get Office Settings");
+ }
+ settingPath = (String) pthSettings.getPropertyValue(setting);
+
+ } catch (Exception e) {
+ System.out.println("Couldn't get stting value for " + setting);
+ e.printStackTrace();
+ }
+ return settingPath;
+ }
+
+ public static void setOfficeSettingsValue(XMultiServiceFactory msf, String setting, String value) {
+
+ String settingPath = null;
+ try {
+ Object settings = msf.createInstance("com.sun.star.comp.framework.PathSettings");
+ XPropertySet pthSettings = null;
+ try {
+ pthSettings = (XPropertySet) AnyConverter.toObject(
+ new Type(XPropertySet.class), settings);
+ } catch (com.sun.star.lang.IllegalArgumentException iae) {
+ System.out.println("### couldn't get Office Settings");
+ }
+ pthSettings.setPropertyValue(setting, value);
+
+ } catch (Exception e) {
+ System.out.println("Couldn't set '" + setting + "' to value '" + value + "'");
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * This method returns the temp dicrectory of the user.
+ * Since Java 1.4 it is not possible to read environment variables. To workaround
+ * this, the Java parameter -D could be used.
+ */
+ public static String getUsersTempDir() {
+ String tempDir = System.getProperty("my.temp");
+ if (tempDir == null) {
+ tempDir = System.getProperty("my.tmp");
+ if (tempDir == null) {
+ tempDir = System.getProperty("java.io.tmpdir");
+ }
+ }
+ // remove ending file separator
+ if (tempDir.endsWith(System.getProperty("file.separator"))) {
+ tempDir = tempDir.substring(0, tempDir.length() - 1);
+ }
+
+ return tempDir;
+ }
+
+ /**
+ *
+ * This method get's the temp dir of the connected office
+ *
+ */
+ public static String getOfficeTemp(XMultiServiceFactory msf) {
+ String url = getOfficeUserPath(msf) + "/test-temp/";
+ try {
+ new File(new URI(url)).mkdir();
+ } catch (URISyntaxException e) {
+ throw new RuntimeException(e);
+ }
+ return url;
+ }
+
+ /**
+ * Gets StarOffice temp directory without 'file:///' prefix.
+ * For example is usefull for Registry URL specifying.
+ * @msf Office factory for accessing its settings.
+ * @return SOffice temporary directory in form for example
+ * 'd:/Office60/user/temp/'.
+ */
+ public static String getOfficeTempDir(XMultiServiceFactory msf) {
+
+ String dir = getOfficeTemp(msf);
+
+ int idx = dir.indexOf("file:///");
+
+ if (idx < 0) {
+ return dir;
+ }
+
+ dir = dir.substring("file:///".length());
+
+ idx = dir.indexOf(":");
+
+ // is the last character a '/' or a '\'?
+ boolean lastCharSet = dir.endsWith("/") || dir.endsWith("\\");
+
+ if (idx < 0) { // linux or solaris
+ dir = "/" + dir;
+ dir += lastCharSet ? "" : "/";
+ } else { // windows
+ dir += lastCharSet ? "" : "\\";
+ }
+
+ return dir;
+ }
+
+ /**
+ * Gets StarOffice temp directory without 'file:///' prefix.
+ * and System dependend file separator
+ */
+ public static String getOfficeTempDirSys(XMultiServiceFactory msf) {
+
+ String dir = getOfficeTemp(msf);
+ String sysDir = "";
+
+ int idx = dir.indexOf("file://");
+
+ // remove leading 'file://'
+ if (idx < 0) {
+ sysDir = dir;
+ } else {
+ sysDir = dir.substring("file://".length());
+ }
+
+ // append '/' if not there (e.g. linux)
+ if (sysDir.charAt(sysDir.length() - 1) != '/') {
+ sysDir += "/";
+ }
+
+ // remove leading '/' and replace others with '\' on windows machines
+ if (sysDir.indexOf(":") != -1) {
+ sysDir = sysDir.substring(1);
+ sysDir = sysDir.replace('/', '\\');
+ }
+ return sysDir;
+ }
+
+ /**
+ * converts a fileURL to a system URL
+ * @param a file URL
+ * @return a system URL
+ */
+ public static String getSystemURL(String fileURL) {
+ String sysDir = "";
+
+ int idx = fileURL.indexOf("file://");
+
+ // remove leading 'file://'
+ if (idx < 0) {
+ sysDir = fileURL;
+ } else {
+ sysDir = fileURL.substring("file://".length());
+ }
+
+ // remove leading '/' and replace others with '\' on windows machines
+ if (sysDir.indexOf(":") != -1) {
+ sysDir = sysDir.substring(1);
+ sysDir = sysDir.replace('/', '\\');
+ }
+ return sysDir;
+ }
+
+ /**
+ * This method check via Office the existance of the given file URL
+ * @param msf the multiservice factory
+ * @param fileURL the file which existance should be checked
+ * @return true if the file exists, else false
+ */
+ public static boolean fileExists(XMultiServiceFactory msf, String fileURL) {
+ boolean exists = false;
+ try {
+
+ Object fileacc = msf.createInstance("com.sun.star.comp.ucb.SimpleFileAccess");
+ XSimpleFileAccess simpleAccess = (XSimpleFileAccess) UnoRuntime.queryInterface(XSimpleFileAccess.class,
+ fileacc);
+ if (simpleAccess.exists(fileURL)) {
+ exists = true;
+ }
+
+ } catch (Exception e) {
+ System.out.println("Couldn't access file '" + fileURL + "'");
+ e.printStackTrace();
+ exists = false;
+ }
+ return exists;
+ }
+
+ /**
+ * This method deletes via office the given file URL. It checks the existance
+ * of <CODE>fileURL</CODE>. If exists it will be deletet.
+ * @param msf the multiservice factory
+ * @param fileURL the file to delete
+ * @return true if the file could be deletet or the file does not exist
+ */
+ public static boolean deleteFile(XMultiServiceFactory xMsf, String fileURL) {
+ boolean delete = true;
+ try {
+
+ Object fileacc = xMsf.createInstance("com.sun.star.comp.ucb.SimpleFileAccess");
+ XSimpleFileAccess simpleAccess = (XSimpleFileAccess) UnoRuntime.queryInterface(XSimpleFileAccess.class,
+ fileacc);
+ if (simpleAccess.exists(fileURL)) {
+ simpleAccess.kill(fileURL);
+ }
+
+ } catch (Exception e) {
+ System.out.println("Couldn't delete file '" + fileURL + "'");
+ e.printStackTrace();
+ delete = false;
+ }
+ return delete;
+ }
+
+ /**
+ * This method copies via office a given file to a new one
+ * @param msf the multi service factory
+ * @param oldF the source file
+ * @param newF the destination file
+ * @return true at success
+ */
+ public static boolean copyFile(XMultiServiceFactory xMsf, String source, String destinaion) {
+ boolean res = false;
+ try {
+ Object fileacc = xMsf.createInstance("com.sun.star.comp.ucb.SimpleFileAccess");
+ XSimpleFileAccess simpleAccess = (XSimpleFileAccess) UnoRuntime.queryInterface(XSimpleFileAccess.class,
+ fileacc);
+ if (!simpleAccess.exists(destinaion)) {
+ simpleAccess.copy(source, destinaion);
+ }
+
+ res = true;
+ } catch (Exception e) {
+ System.out.println("Couldn't copy file '" + source + "' -> '" + destinaion + "'");
+ e.printStackTrace();
+ res = false;
+ }
+ return res;
+ }
+
+ private static void overwriteFile_impl(
+ XMultiServiceFactory xMsf, String oldF, String newF)
+ throws InteractiveAugmentedIOException
+ {
+ try {
+ Object fileacc = xMsf.createInstance("com.sun.star.comp.ucb.SimpleFileAccess");
+
+ XSimpleFileAccess simpleAccess = (XSimpleFileAccess) UnoRuntime.queryInterface(XSimpleFileAccess.class,
+ fileacc);
+ if (simpleAccess.exists(newF)) {
+ simpleAccess.kill(newF);
+ }
+ simpleAccess.copy(oldF, newF);
+ } catch (InteractiveAugmentedIOException e) {
+ throw e;
+ } catch (com.sun.star.uno.Exception e) {
+ System.out.println("Couldn't copy " + oldF + " to " + newF + ":");
+ e.printStackTrace();
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
+ * Copies file to a new location using OpenOffice.org features. If the target
+ * file already exists, the file is deleted.
+ *
+ * @returns <code>true</code> if the file was successfully copied,
+ * <code>false</code> if some errors occured (e.g. file is locked, used
+ * by another process).
+ */
+ public static boolean tryOverwriteFile(
+ XMultiServiceFactory xMsf, String oldF, String newF)
+ {
+ try {
+ overwriteFile_impl(xMsf, oldF, newF);
+ } catch (InteractiveAugmentedIOException e) {
+ return false;
+ }
+ return true;
+ }
+
+ public static void doOverwriteFile(
+ XMultiServiceFactory xMsf, String oldF, String newF)
+ {
+ try {
+ overwriteFile_impl(xMsf, oldF, newF);
+ } catch (InteractiveAugmentedIOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public static boolean hasPropertyByName(XPropertySet props, String aName) {
+ Property[] list = props.getPropertySetInfo().getProperties();
+ boolean res = false;
+ for (int i = 0; i < list.length; i++) {
+ String the_name = list[i].Name;
+ if (aName.equals(the_name)) {
+ res = true;
+ }
+ }
+ return res;
+ }
+
+ /**
+ *
+ * This method returns the implementation name of a given object
+ *
+ */
+ public static String getImplName(Object aObject) {
+ String res = "Error getting Implementation name";
+ try {
+ XServiceInfo xSI = (XServiceInfo) UnoRuntime.queryInterface(XServiceInfo.class, aObject);
+ res = xSI.getImplementationName();
+ } catch (Exception e) {
+ res = "Error getting Implementation name ( " + e + " )";
+ }
+
+ return res;
+ }
+
+ /**
+ *
+ * This method checks if an Object is void
+ *
+ */
+ public static boolean isVoid(Object aObject) {
+ if (aObject instanceof com.sun.star.uno.Any) {
+ com.sun.star.uno.Any oAny = (com.sun.star.uno.Any) aObject;
+ return (oAny.getType().getTypeName().equals("void"));
+ } else {
+ return false;
+ }
+
+ }
+
+ /**
+ *
+ * This method replaces a substring with another
+ *
+ */
+ public static String replacePart(String all, String toReplace, String replacement) {
+ return replaceAll13(all, toReplace, replacement);
+ }
+
+ /**
+ * Scan localhost for the next free port-number from a starting port
+ * on. If the starting port is smaller than 1024, port number starts with
+ * 10000 as default, because numbers < 1024 are never free on unix machines.
+ * @param startPort The port where scanning starts.
+ * @return The next free port.
+ */
+ public static int getNextFreePort(int startPort) {
+ if (startPort < 1024) {
+ startPort = 10000;
+ }
+ for (int port = startPort; port < 65536; port++) {
+ System.out.println("Scan port " + port);
+ try {
+ // first trying to establish a server-socket on localhost
+ // fails if there is already a server running
+ ServerSocket sSock = new ServerSocket(port);
+ sSock.close();
+ } catch (IOException e) {
+ System.out.println(" -> server: occupied port " + port);
+ continue;
+ }
+ try {
+ // now trying to establish a client-socket
+ // fails if there is no server on any connectable machine
+ Socket sock = new Socket("localhost", port);
+ System.out.println(" -> socket: occupied port: " + port);
+ } catch (IOException e) {
+ System.out.println(" -> free port");
+ return port;
+ }
+ }
+ return 65535;
+ }
+
+ public static URL parseURL(XMultiServiceFactory xMSF, String url) {
+ URL[] rUrl = new URL[1];
+ rUrl[0] = new URL();
+ rUrl[0].Complete = url;
+
+ XURLTransformer xTrans = null;
+ try {
+ Object inst = xMSF.createInstance("com.sun.star.util.URLTransformer");
+ xTrans = (XURLTransformer) UnoRuntime.queryInterface(XURLTransformer.class, inst);
+ } catch (com.sun.star.uno.Exception e) {
+ }
+
+ xTrans.parseStrict(rUrl);
+
+ return rUrl[0];
+ }
+
+ public static String getOfficeURL(XMultiServiceFactory msf) {
+ try {
+ Object settings = msf.createInstance("com.sun.star.util.PathSettings");
+ XPropertySet settingProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, settings);
+ String path = (String) settingProps.getPropertyValue("Module");
+ return path;
+ } catch (Exception e) {
+ System.out.println("Couldn't get Office Settings ");
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ /** returns the path to the office binary folder
+ *
+ * @param msf The XMultiSeriveFactory
+ * @return the path to the office binrary or an empty string on any error
+ */
+ public static String getOfficeBinPath(XMultiServiceFactory msf) {
+ String sysBinDir = "";
+ try {
+ sysBinDir = utils.getSystemURL(utils.expandMacro(msf, "$SYSBINDIR"));
+ } catch (java.lang.Exception e) {
+ }
+
+ return sysBinDir;
+ }
+
+ /**
+ * Get an array of all property names from the property set. With the include
+ * and exclude parameters the properties can be filtered. <br>
+ * Set excludePropertyAttribute = 0 and includePropertyAttribute = 0
+ * to include all and exclude none.
+ * @param props The instance of XPropertySet
+ * @param includePropertyAttribute Properties without these attributes are filtered and will not be returned.
+ * @param excludePropertyAttribute Properties with these attributes are filtered and will not be returned.
+ * @return A String array with all property names.
+ * @see com.sun.star.beans.XPropertySet
+ * @see com.sun.star.beans.Property
+ * @see com.sun.star.beans.PropertyAttribute
+ */
+ public static String[] getFilteredPropertyNames(XPropertySet props, short includePropertyAttribute,
+ short excludePropertyAttribute) {
+ Property[] the_props = props.getPropertySetInfo().getProperties();
+ ArrayList l = new ArrayList();
+ for (int i = 0; i < the_props.length; i++) {
+ boolean exclude = ((the_props[i].Attributes & excludePropertyAttribute) != 0);
+ boolean include = (includePropertyAttribute == 0) ||
+ ((the_props[i].Attributes & includePropertyAttribute) != 0);
+ if (include && !exclude) {
+ l.add(the_props[i].Name);
+ }
+ }
+ Collections.sort(l);
+ String[] names = new String[l.size()];
+ names = (String[]) l.toArray(names);
+ return names;
+ }
+
+ /** Causes the thread to sleep some time.
+ * It can be used f.e. like:
+ * util.utils.shortWait(tParam.getInt("ShortWait"));
+ */
+ public static void shortWait(int milliseconds) {
+ try {
+ Thread.currentThread().sleep(milliseconds);
+ } catch (InterruptedException e) {
+ System.out.println("While waiting :" + e);
+ }
+ }
+
+ /**
+ * Validate the AppExecutionCommand. Returned is an error message, starting
+ * with "Error:", or a warning, if the command might work.
+ * @param appExecCommand The application execution command that is checked.
+ * @param os The operating system where the check runs.
+ * @return The error message, or OK, if no error was detected.
+ */
+ public static String validateAppExecutionCommand(String appExecCommand, String os) {
+ String errorMessage = "OK";
+ appExecCommand = replaceAll13(appExecCommand, "\"", "");
+ appExecCommand = replaceAll13(appExecCommand, "'", "");
+ StringTokenizer commandTokens = new StringTokenizer(appExecCommand, " \t");
+ String officeExecutable = "";
+ String officeExecCommand = "soffice";
+ // is there a 'soffice' in the command? 2do: eliminate case sensitivity on windows
+ int index = -1;
+ while (commandTokens.hasMoreTokens() && index == -1) {
+ officeExecutable += commandTokens.nextToken() + " ";
+ index = officeExecutable.indexOf(officeExecCommand);
+ }
+ if (index == -1) {
+ errorMessage = "Error: Your 'AppExecutionCommand' parameter does not " +
+ "contain '" + officeExecCommand + "'.";
+ } else {
+ // does the directory exist?
+ officeExecutable = officeExecutable.trim();
+ String officePath = officeExecutable.substring(0, index);
+ File f = new File(officePath);
+ if (!f.exists() || !f.isDirectory()) {
+ errorMessage = "Error: Your 'AppExecutionCommand' parameter does not " +
+ "point to a valid system directory: " + officePath;
+ } else {
+ // is it an office installation?
+ f = new File(officeExecutable);
+ // one try for windows platform can't be wrong...
+ if (!f.exists() || !f.isFile()) {
+ f = new File(officeExecutable + ".exe");
+ }
+ if (!f.exists() || !f.isFile()) {
+ errorMessage = "Error: Your 'AppExecutionCommand' parameter does not " +
+ "point to a valid office installation.";
+ } else {
+ // do we have the accept parameter?
+ boolean gotNoAccept = true;
+ while (commandTokens.hasMoreElements()) {
+ String officeParam = commandTokens.nextToken();
+ if (officeParam.indexOf("-accept=") != -1) {
+ gotNoAccept = false;
+ errorMessage = validateConnectString(officeParam, true);
+ }
+ }
+ if (gotNoAccept) {
+ errorMessage = "Error: Your 'AppExecutionCommand' parameter does not " +
+ "contain a '-accept' parameter for connecting the office.";
+ }
+ }
+ }
+ }
+ return errorMessage;
+ }
+
+ /**
+ * Validate the connection string. Returned is an error message, starting
+ * with "Error:", or a warning, if the command might work.
+ * @param connectString The connection string that is checked.
+ * @param checkAppExecutionCommand If the AppExecutionCommand is checked, the error messages willbe different.
+ * @return The error message, or OK, if no error was detected.
+ */
+ public static String validateConnectString(String connectString, boolean checkAppExecutionCommand) {
+ String acceptPrefix = "";
+ if (checkAppExecutionCommand) {
+ acceptPrefix = "-accept=";
+ }
+
+ String errorMessage = "OK";
+ // a warning, if an unknown connection method is used
+ if (connectString.indexOf("socket") != -1) {
+ if (connectString.indexOf(acceptPrefix + "socket,host=") == -1 ||
+ connectString.indexOf("port=") == -1) {
+ if (checkAppExecutionCommand) {
+ errorMessage = "Error: The '-accept' parameter contains a syntax error: It should be like: '-accept=socket,host=localhost,port=8100;urp;";
+ } else {
+ errorMessage = "Error: The 'ConnectionString' parameter contains a syntax error: It should be like: 'socket,host=localhost,port=8100'";
+ }
+ }
+ } else if (connectString.indexOf("pipe") != -1) {
+ if (connectString.indexOf(acceptPrefix + "pipe,name=") == -1) {
+ if (checkAppExecutionCommand) {
+ errorMessage = "Error: The '-accept' parameter contains a syntax error: It should be like: '-accept=pipe,name=myuniquename;urp;'";
+ } else {
+ errorMessage = "Error: The 'ConnectionString' parameter contains a syntax error: It should be like: 'pipe,name=myuniquename'";
+ }
+ }
+ } else {
+ if (checkAppExecutionCommand) {
+ errorMessage = "Warning: The '-accept' parameter contains an unknown connection method.";
+ } else {
+ errorMessage = "Warning: The 'ConnectionString' parameter contains an unknown connection method.";
+ }
+ }
+ return errorMessage;
+ }
+
+ /**
+ * String.replaceAll() ist available since Java 1.4 but the runner must be buldabale with Java 1.3
+ * @param originalString
+ * @param searchString
+ * @param replaceString
+ * @return modified string
+ */
+ public static String replaceAll13(String originalString, String searchString, String replaceString) {
+
+ StringBuffer changeStringBuffer = new StringBuffer(originalString);
+ int searchLength = searchString.length();
+ int replaceLength = replaceString.length();
+ int index = originalString.indexOf(searchString);
+ while (index != -1) {
+ changeStringBuffer = changeStringBuffer.replace(index, index + searchLength, replaceString);
+ originalString = changeStringBuffer.toString();
+ index = originalString.indexOf(searchString, index + replaceLength);
+ }
+ return originalString;
+ }
+
+ /**
+ * expand macrofied strings like <CODE>${$ORIGIN/bootstrap.ini:UserInstallation}</CODE> or
+ * <CODE>$_OS</CODE>
+ * @param xMSF the MultiServiceFactory
+ * @param expand the string to expand
+ * @throws java.lang.Exception was thrown on any exception
+ * @return return the expanded string
+ * @see com.sun.star.util.theMacroExpander
+ */
+ public static String expandMacro(XMultiServiceFactory xMSF, String expand) throws java.lang.Exception {
+ try {
+ XPropertySet xPS = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xMSF);
+ XComponentContext xContext = (XComponentContext) UnoRuntime.queryInterface(XComponentContext.class,
+ xPS.getPropertyValue("DefaultContext"));
+ XMacroExpander xME = (XMacroExpander) UnoRuntime.queryInterface(XMacroExpander.class,
+ xContext.getValueByName("/singletons/com.sun.star.util.theMacroExpander"));
+ return xME.expandMacros(expand);
+ } catch (Exception e) {
+ throw new Exception("could not expand macro: " + e.toString(), e);
+ }
+
+ }
+
+ /**
+ * returns the platform of the office.<br>
+ * Since the runner and the office could run on different platform this function delivers the
+ * platform the office is running.
+ * @param xMSF the XMultiServiceFactory
+ * @return unxsols, unxsoli, unxlngi, wntmsci
+ */
+ public static String getOfficeOS(XMultiServiceFactory xMSF) {
+ String platform = "unknown";
+
+ try {
+ String theOS = expandMacro(xMSF, "$_OS");
+
+ if (theOS.equals("Windows")) {
+ platform = "wntmsci";
+ } else if (theOS.equals("Linux")) {
+ platform = "unxlngi";
+ } else {
+ if (theOS.equals("Solaris")) {
+ String theArch = expandMacro(xMSF, "$_ARCH");
+ if (theArch.equals("SPARC")) {
+ platform = "unxsols";
+ } else if (theArch.equals("x86")) {
+ platform = "unxsoli";
+ }
+ }
+ }
+ } catch (Exception ex) {
+ }
+ return platform;
+ }
+
+ /**
+ * dispatches given <CODE>URL</CODE> to the document <CODE>XComponent</CODE>
+ * @param xMSF the <CODE>XMultiServiceFactory</CODE>
+ * @param xDoc the document where to dispatch
+ * @param URL the <CODE>URL</CODE> to dispatch
+ * @throws java.lang.Exception throws <CODE>java.lang.Exception</CODE> on any error
+ */
+ public static void dispatchURL(XMultiServiceFactory xMSF, XComponent xDoc, String URL) throws java.lang.Exception {
+ XModel aModel = (XModel) UnoRuntime.queryInterface(XModel.class, xDoc);
+
+ XController xCont = aModel.getCurrentController();
+
+ dispatchURL(xMSF, xCont, URL);
+
+ }
+
+ /**
+ * dispatches given <CODE>URL</CODE> to the <CODE>XController</CODE>
+ * @param xMSF the <CODE>XMultiServiceFactory</CODE>
+ * @param xComp the <CODE>XController</CODE> to query for a XDispatchProvider
+ * @param URL the <CODE>URL</CODE> to dispatch
+ * @throws java.lang.Exception throws <CODE>java.lang.Exception</CODE> on any error
+ */
+ public static void dispatchURL(XMultiServiceFactory xMSF, XController xCont, String URL) throws java.lang.Exception {
+ try {
+
+ XDispatchProvider xDispProv = (XDispatchProvider) UnoRuntime.queryInterface(XDispatchProvider.class, xCont);
+
+ XURLTransformer xParser = (com.sun.star.util.XURLTransformer) UnoRuntime.queryInterface(
+ XURLTransformer.class,
+ xMSF.createInstance("com.sun.star.util.URLTransformer"));
+
+ // Because it's an in/out parameter we must use an array of URL objects.
+ URL[] aParseURL = new URL[1];
+ aParseURL[0] = new URL();
+ aParseURL[0].Complete = URL;
+ xParser.parseStrict(aParseURL);
+
+ URL aURL = aParseURL[0];
+
+ XDispatch xDispatcher = xDispProv.queryDispatch(aURL, "", 0);
+ xDispatcher.dispatch(aURL, null);
+
+ utils.shortWait(3000);
+
+ } catch (Exception e) {
+ throw new Exception("ERROR: could not dispatch URL '" + URL + "': " + e.toString());
+ }
+ }
+
+ /** returns a String which contains the current date and time<br>
+ * format: [DD.MM.YYYY - HH:MM:SS::mm]
+ *
+ ** @return a String which contains the current date and time
+ */
+ public static String getDateTime() {
+
+ Calendar cal = new GregorianCalendar();
+ DecimalFormat dfmt = new DecimalFormat("00");
+ String dateTime = dfmt.format(cal.get(Calendar.DAY_OF_MONTH)) + "." +
+ dfmt.format(cal.get(Calendar.MONTH) + 1) + "." +
+ dfmt.format(cal.get(Calendar.YEAR)) + " - " +
+ dfmt.format(cal.get(Calendar.HOUR_OF_DAY)) + ":" +
+ dfmt.format(cal.get(Calendar.MINUTE)) + ":" +
+ dfmt.format(cal.get(Calendar.SECOND)) + "," +
+ dfmt.format(cal.get(Calendar.MILLISECOND));
+ return "[" + dateTime + "]";
+ }
+}