diff options
Diffstat (limited to 'sfx2/qa/complex/DocHelper')
-rw-r--r-- | sfx2/qa/complex/DocHelper/DialogThread.java | 95 | ||||
-rw-r--r-- | sfx2/qa/complex/DocHelper/WriterHelper.java | 296 | ||||
-rw-r--r-- | sfx2/qa/complex/DocHelper/makefile.mk | 46 |
3 files changed, 0 insertions, 437 deletions
diff --git a/sfx2/qa/complex/DocHelper/DialogThread.java b/sfx2/qa/complex/DocHelper/DialogThread.java deleted file mode 100644 index 7151ccbb292d..000000000000 --- a/sfx2/qa/complex/DocHelper/DialogThread.java +++ /dev/null @@ -1,95 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -package complex.framework.DocHelper; - -import com.sun.star.beans.PropertyValue; -import com.sun.star.frame.XController; -import com.sun.star.frame.XDispatch; -import com.sun.star.frame.XDispatchProvider; -import com.sun.star.frame.XModel; -import com.sun.star.lang.XComponent; -import com.sun.star.lang.XMultiServiceFactory; -import com.sun.star.uno.UnoRuntime; -import com.sun.star.util.URL; -import com.sun.star.util.XURLTransformer; - -import java.lang.Thread; - - -/** - * This class opens a given dialog in a separate Thread by dispatching an url - * - */ -public class DialogThread extends Thread { - public XComponent m_xDoc = null; - public XMultiServiceFactory m_xMSF = null; - public String m_url = ""; - - public DialogThread(XComponent xDoc, XMultiServiceFactory msf, String url) { - this.m_xDoc = xDoc; - this.m_xMSF = msf; - this.m_url = url; - } - - public void run() { - XModel aModel = (XModel) UnoRuntime.queryInterface(XModel.class, - m_xDoc); - - XController xController = aModel.getCurrentController(); - - //Opening Dialog - try { - XDispatchProvider xDispProv = (XDispatchProvider) UnoRuntime.queryInterface( - XDispatchProvider.class, - xController.getFrame()); - XURLTransformer xParser = (com.sun.star.util.XURLTransformer) UnoRuntime.queryInterface( - XURLTransformer.class, - m_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 = m_url; - xParser.parseStrict(aParseURL); - - URL aURL = aParseURL[0]; - XDispatch xDispatcher = xDispProv.queryDispatch(aURL, "", com.sun.star.frame.FrameSearchFlag.SELF | - com.sun.star.frame.FrameSearchFlag.CHILDREN); - PropertyValue[] dispatchArguments = new PropertyValue[0]; - - if (xDispatcher != null) { - xDispatcher.dispatch(aURL, dispatchArguments); - } else { - System.out.println("xDispatcher is null"); - } - } catch (com.sun.star.uno.Exception e) { - System.out.println("Couldn't open dialog"); - } - } -}
\ No newline at end of file diff --git a/sfx2/qa/complex/DocHelper/WriterHelper.java b/sfx2/qa/complex/DocHelper/WriterHelper.java deleted file mode 100644 index b65e8e915423..000000000000 --- a/sfx2/qa/complex/DocHelper/WriterHelper.java +++ /dev/null @@ -1,296 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -package complex.framework.DocHelper; - -import com.sun.star.accessibility.AccessibleRole; -import com.sun.star.accessibility.XAccessible; -import com.sun.star.accessibility.XAccessibleAction; -import com.sun.star.accessibility.XAccessibleContext; -import com.sun.star.accessibility.XAccessibleSelection; -import com.sun.star.awt.XExtendedToolkit; -import com.sun.star.awt.XWindow; -import com.sun.star.frame.XDesktop; -import com.sun.star.lang.XComponent; -import com.sun.star.lang.XMultiServiceFactory; -import com.sun.star.text.XTextDocument; -import com.sun.star.uno.UnoRuntime; -import com.sun.star.util.XCloseable; - -import complex.framework.DocHelper.DialogThread; -import java.io.PrintWriter; - -import util.AccessibilityTools; -import util.WriterTools; - - -/** - * Methods to open Writer docs - * - */ -public class WriterHelper { - XMultiServiceFactory m_xMSF = null; - - /** Creates a new instance of WriterHelper - * @param m_xMSF The MultiServiceFactory gained from the office - */ - public WriterHelper(XMultiServiceFactory m_xMSF) { - this.m_xMSF = m_xMSF; - } - - /** Opens an empty document - * @return a reference to the opened document is returned - */ - public XTextDocument openEmptyDoc() { - return WriterTools.createTextDoc(m_xMSF); - } - - /** Closes a given XTextDocument - * @param xTextDoc the text document to be closed - * @return if an error occurs the errormessage is returned and an empty String if not - */ - public String closeDoc(XTextDocument xTextDoc) { - XCloseable closer = (XCloseable) UnoRuntime.queryInterface( - XCloseable.class, xTextDoc); - String err = ""; - - try { - closer.close(true); - } catch (com.sun.star.util.CloseVetoException e) { - err = "couldn't close document " + e; - } - - return err; - } - - /** a TextDocument is opened by pressing a button in a dialog given by uno-URL - * @param url the uno-URL of the dialog to be opened - * @param createButton the language dependend label of the button to be pressed - * @param destroyLocal if true the document that has been opened to dispatch the dialog is closed before the method returns, - * otherwise this document remains open - * @return returns the created Textdocument - */ - public XTextDocument openFromDialog(String url, String createButton, - boolean destroyLocal) { - XTextDocument xLocalDoc = WriterTools.createTextDoc(m_xMSF); - XComponent comp = (XComponent) UnoRuntime.queryInterface( - XComponent.class, xLocalDoc); - DialogThread diagThread = new DialogThread(comp, m_xMSF, url); - diagThread.start(); - shortWait(); - - if (createButton.length() > 1) { - XExtendedToolkit tk = getToolkit(); - AccessibilityTools at = new AccessibilityTools(); - Object atw = tk.getActiveTopWindow(); - - XWindow xWindow = (XWindow) UnoRuntime.queryInterface( - XWindow.class, atw); - - XAccessible xRoot = at.getAccessibleObject(xWindow); - XAccessibleContext buttonContext = at.getAccessibleObjectForRole( - xRoot, - AccessibleRole.PUSH_BUTTON, - createButton); - - XAccessibleAction buttonAction = (XAccessibleAction) UnoRuntime.queryInterface( - XAccessibleAction.class, - buttonContext); - - try { - System.out.println("Name: " + - buttonContext.getAccessibleName()); - buttonAction.doAccessibleAction(0); - } catch (com.sun.star.lang.IndexOutOfBoundsException e) { - System.out.println("Couldn't press button"); - } - - shortWait(); - } - - XDesktop xDesktop = getDesktop(); - - XTextDocument returnDoc = (XTextDocument) UnoRuntime.queryInterface( - XTextDocument.class, - xDesktop.getCurrentComponent()); - - if (destroyLocal) { - closeDoc(xLocalDoc); - } - - return returnDoc; - } - - public XTextDocument DocByAutopilot(XMultiServiceFactory msf, - int[] indexes, boolean destroyLocal, - String bName) { - XTextDocument xLocalDoc = WriterTools.createTextDoc(m_xMSF); - Object toolkit = null; - - try { - toolkit = msf.createInstance("com.sun.star.awt.Toolkit"); - } catch (com.sun.star.uno.Exception e) { - e.printStackTrace(); - } - - XExtendedToolkit tk = (XExtendedToolkit) UnoRuntime.queryInterface( - XExtendedToolkit.class, toolkit); - - shortWait(); - - AccessibilityTools at = new AccessibilityTools(); - - Object atw = tk.getActiveTopWindow(); - - XWindow xWindow = (XWindow) UnoRuntime.queryInterface(XWindow.class, - atw); - - XAccessible xRoot = at.getAccessibleObject(xWindow); - - XAccessibleContext ARoot = at.getAccessibleObjectForRole(xRoot, - AccessibleRole.MENU_BAR); - XAccessibleSelection sel = (XAccessibleSelection) UnoRuntime.queryInterface( - XAccessibleSelection.class, ARoot); - - for (int k = 0; k < indexes.length; k++) { - try { - sel.selectAccessibleChild(indexes[k]); - shortWait(); - ARoot = ARoot.getAccessibleChild(indexes[k]) - .getAccessibleContext(); - sel = (XAccessibleSelection) UnoRuntime.queryInterface( - XAccessibleSelection.class, ARoot); - } catch (com.sun.star.lang.IndexOutOfBoundsException e) { - } - } - - shortWait(); - - atw = tk.getActiveTopWindow(); - - xWindow = (XWindow) UnoRuntime.queryInterface(XWindow.class, atw); - - xRoot = at.getAccessibleObject(xWindow); - - //at.printAccessibleTree(new PrintWriter(System.out),xRoot); - - XAccessibleAction action = (XAccessibleAction) UnoRuntime.queryInterface( - XAccessibleAction.class, - at.getAccessibleObjectForRole(xRoot, - AccessibleRole.PUSH_BUTTON, - bName)); - - try { - action.doAccessibleAction(0); - } catch (com.sun.star.lang.IndexOutOfBoundsException e) { - } - - shortWait(); - - atw = tk.getActiveTopWindow(); - - xWindow = (XWindow) UnoRuntime.queryInterface(XWindow.class, atw); - - xRoot = at.getAccessibleObject(xWindow); - - at.printAccessibleTree(new PrintWriter(System.out),xRoot); - - action = (XAccessibleAction) UnoRuntime.queryInterface( - XAccessibleAction.class, - at.getAccessibleObjectForRole(xRoot, - AccessibleRole.PUSH_BUTTON, - "Yes")); - - try { - if (action != null) action.doAccessibleAction(0); - } catch (com.sun.star.lang.IndexOutOfBoundsException e) { - } - - shortWait(); - - XDesktop xDesktop = getDesktop(); - - XTextDocument returnDoc = (XTextDocument) UnoRuntime.queryInterface( - XTextDocument.class, - xDesktop.getCurrentComponent()); - - if (destroyLocal) { - closeDoc(xLocalDoc); - } - - return returnDoc; - } - - /** - * Sleeps for 2 sec. to allow StarOffice to react - */ - private void shortWait() { - try { - Thread.sleep(4000); - } catch (InterruptedException e) { - System.out.println("While waiting :" + e); - } - } - - /** creates an instance of com.sun.star.awt.Toolkit to query the XExtendedToolkit - * interface - * @return returns the gained XExtendedToolkit Interface - */ - public XExtendedToolkit getToolkit() { - Object toolkit = null; - - try { - toolkit = m_xMSF.createInstance("com.sun.star.awt.Toolkit"); - } catch (com.sun.star.uno.Exception e) { - System.out.println("Couldn't get toolkit"); - e.printStackTrace(); - } - - XExtendedToolkit tk = (XExtendedToolkit) UnoRuntime.queryInterface( - XExtendedToolkit.class, toolkit); - - return tk; - } - - /** creates an instance of com.sun.star.frame.Desktop to query the XDesktop interface - * @return returns the gained XDesktop interface - */ - protected XDesktop getDesktop() { - Object desk = null; - - try { - desk = m_xMSF.createInstance("com.sun.star.frame.Desktop"); - } catch (com.sun.star.uno.Exception e) { - System.out.println("Couldn't get desktop"); - e.printStackTrace(); - } - - XDesktop xDesktop = (XDesktop) UnoRuntime.queryInterface( - XDesktop.class, desk); - - return xDesktop; - } -}
\ No newline at end of file diff --git a/sfx2/qa/complex/DocHelper/makefile.mk b/sfx2/qa/complex/DocHelper/makefile.mk deleted file mode 100644 index 6b6ac9191cdb..000000000000 --- a/sfx2/qa/complex/DocHelper/makefile.mk +++ /dev/null @@ -1,46 +0,0 @@ -#************************************************************************* -# -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# Copyright 2000, 2010 Oracle and/or its affiliates. -# -# OpenOffice.org - a multi-platform office productivity suite -# -# This file is part of OpenOffice.org. -# -# OpenOffice.org is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License version 3 -# only, as published by the Free Software Foundation. -# -# OpenOffice.org is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License version 3 for more details -# (a copy is included in the LICENSE file that accompanied this code). -# -# You should have received a copy of the GNU Lesser General Public License -# version 3 along with OpenOffice.org. If not, see -# <http://www.openoffice.org/license.html> -# for a copy of the LGPLv3 License. -# -#************************************************************************* - -PRJ = ..$/..$/.. -TARGET = DocHelper -PRJNAME = $(TARGET) -PACKAGE = complex$/framework$/dochelper - -# --- Settings ----------------------------------------------------- -.INCLUDE: settings.mk - - -#----- compile .java files ----------------------------------------- - -JARFILES = ridl.jar unoil.jar jurt.jar juh.jar java_uno.jar OOoRunner.jar -JAVAFILES = DialogThread.java WriterHelper.java -JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class) - -# --- Targets ------------------------------------------------------ - -.INCLUDE : target.mk - |