summaryrefslogtreecommitdiff
path: root/qadevOOo/runner
diff options
context:
space:
mode:
authorKurt Zenker <kz@openoffice.org>2005-11-02 16:44:20 +0000
committerKurt Zenker <kz@openoffice.org>2005-11-02 16:44:20 +0000
commit5f942c35bba220c281b2e9e939a84c1307a2b5e8 (patch)
treef9f45f86e3a2c8b5300d0f3fe5fc1dd64a74b046 /qadevOOo/runner
parent57a363d19bc8c42281e24c193b10086592737592 (diff)
INTEGRATION: CWS qadev24 (1.3.16); FILE MERGED
2005/09/19 21:48:54 cn 1.3.16.3: RESYNC: (1.3-1.4); FILE MERGED 2005/08/19 13:58:42 cn 1.3.16.2: #i46734# new function 'bringWindowToFromt()' 2005/07/20 09:10:52 cn 1.3.16.1: #i52213# add dockStylist()
Diffstat (limited to 'qadevOOo/runner')
-rw-r--r--qadevOOo/runner/util/DesktopTools.java116
1 files changed, 108 insertions, 8 deletions
diff --git a/qadevOOo/runner/util/DesktopTools.java b/qadevOOo/runner/util/DesktopTools.java
index 6e2da8bba46b..52b89cc73d13 100644
--- a/qadevOOo/runner/util/DesktopTools.java
+++ b/qadevOOo/runner/util/DesktopTools.java
@@ -4,9 +4,9 @@
*
* $RCSfile: DesktopTools.java,v $
*
- * $Revision: 1.4 $
+ * $Revision: 1.5 $
*
- * last change: $Author: rt $ $Date: 2005-09-08 17:32:37 $
+ * last change: $Author: kz $ $Date: 2005-11-02 17:44:20 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
@@ -34,20 +34,31 @@
************************************************************************/
package util;
+import com.sun.star.awt.XTopWindow;
+import com.sun.star.beans.PropertyState;
import com.sun.star.beans.PropertyValue;
+import com.sun.star.beans.XPropertySet;
import com.sun.star.container.XEnumeration;
import com.sun.star.container.XEnumerationAccess;
+import com.sun.star.container.XNameAccess;
+import com.sun.star.container.XNameContainer;
+import com.sun.star.container.XNameReplace;
import com.sun.star.frame.XComponentLoader;
import com.sun.star.frame.XDesktop;
+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.lang.XSingleServiceFactory;
import com.sun.star.uno.UnoRuntime;
// access the implementations via names
import com.sun.star.uno.XInterface;
+import com.sun.star.util.XChangesBatch;
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;
@@ -91,6 +102,8 @@ public class DesktopTools {
/**
* 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(
@@ -98,8 +111,10 @@ public class DesktopTools {
return xDesktop.getComponents().createEnumeration();
}
- /*
+ /**
* returns an object arrary of all open documents
+ * @param xMSF the MultiServiceFactory
+ * @return returns an Array of document kinds like ["swriter"]
*/
public static Object[] getAllOpenDocuments(XMultiServiceFactory xMSF) {
Vector components = new Vector();
@@ -121,6 +136,11 @@ public class DesktopTools {
return components.toArray();
}
+ /**
+ * returns the kind of the document like "swriter"
+ * @param xComponent the document to check
+ * @return the kind of the document like "swriter"
+ */
public static String getDocumentType(XComponent xComponent) {
XServiceInfo sInfo = (XServiceInfo)UnoRuntime.queryInterface(
XServiceInfo.class, xComponent);
@@ -144,9 +164,11 @@ public class DesktopTools {
/**
* Opens a new document of a given kind
* with arguments
- * @param xMSF the MultiServiceFactory
* @return the XComponent Interface of the document
- */
+ * @param kind the kind of document to open like "swriter"
+ * @param Args some arguments to the new document
+ * @param xMSF the MultiServiceFactory
+ */
public static XComponent openNewDoc(XMultiServiceFactory xMSF, String kind,
PropertyValue[] Args) {
XComponent oDoc = null;
@@ -165,9 +187,11 @@ public class DesktopTools {
/**
* loads a document of from a given url
* with arguments
- * @param xMSF the MultiServiceFactory
* @return the XComponent Interface of the document
- */
+ * @param url the URL to load
+ * @param Args the arguments to the document to load
+ * @param xMSF the MultiServiceFactory
+ */
public static XComponent loadDoc(XMultiServiceFactory xMSF, String url,
PropertyValue[] Args) {
XComponent oDoc = null;
@@ -184,7 +208,7 @@ public class DesktopTools {
/**
* closes a given document
- * @param DocumentToClose
+ * @param DocumentToClose the document to close
*/
public static void closeDoc(XInterface DocumentToClose) {
String kd = System.getProperty("KeepDocument");
@@ -210,4 +234,80 @@ public class DesktopTools {
System.out.println("Couldn't close document");
}
}
+
+ /**
+ * 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();
+ }
+ }
+
+ /**
+ * 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 bringWindowToFromt(XModel xModel){
+ XTopWindow xTopWindow =
+ (XTopWindow) UnoRuntime.queryInterface(
+ XTopWindow.class,
+ xModel.getCurrentController().getFrame().getContainerWindow());
+
+ xTopWindow.toFront();
+ }
} \ No newline at end of file