summaryrefslogtreecommitdiffstats
path: root/qadevOOo/tests/java/mod/_fwl
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 16:51:28 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 16:51:28 +0000
commit940b4d1848e8c70ab7642901a68594e8016caffc (patch)
treeeb72f344ee6c3d9b80a7ecc079ea79e9fba8676d /qadevOOo/tests/java/mod/_fwl
parentInitial commit. (diff)
downloadlibreoffice-940b4d1848e8c70ab7642901a68594e8016caffc.tar.xz
libreoffice-940b4d1848e8c70ab7642901a68594e8016caffc.zip
Adding upstream version 1:7.0.4.upstream/1%7.0.4upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'qadevOOo/tests/java/mod/_fwl')
-rw-r--r--qadevOOo/tests/java/mod/_fwl/ContentHandlerFactory.java93
-rw-r--r--qadevOOo/tests/java/mod/_fwl/FilterFactory.java160
-rw-r--r--qadevOOo/tests/java/mod/_fwl/FrameLoaderFactory.java87
-rw-r--r--qadevOOo/tests/java/mod/_fwl/PathSettings.java138
-rw-r--r--qadevOOo/tests/java/mod/_fwl/SubstituteVariables.java68
-rw-r--r--qadevOOo/tests/java/mod/_fwl/TypeDetection.java152
6 files changed, 698 insertions, 0 deletions
diff --git a/qadevOOo/tests/java/mod/_fwl/ContentHandlerFactory.java b/qadevOOo/tests/java/mod/_fwl/ContentHandlerFactory.java
new file mode 100644
index 000000000..41cbd39ab
--- /dev/null
+++ b/qadevOOo/tests/java/mod/_fwl/ContentHandlerFactory.java
@@ -0,0 +1,93 @@
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+package mod._fwl;
+
+import com.sun.star.beans.NamedValue;
+import java.io.PrintWriter;
+
+import lib.TestCase;
+import lib.TestEnvironment;
+import lib.TestParameters;
+import util.utils;
+
+import com.sun.star.container.XNameAccess;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XInterface;
+
+/**
+ * Test for object which is represented by service
+ * <code>com.sun.star.frame.FrameLoaderFactory</code>. <p>
+ *
+ * Object implements the following interfaces :
+ * <ul>
+ * <li> <code>com::sun::star::container::XNameAccess</code></li>
+ * <li> <code>com::sun::star::container::XElementAccess</code></li>
+ * <li> <code>com::sun::star::lang::XMultiServiceFactory</code></li>
+ * </ul> <p>
+ *
+ * @see com.sun.star.container.XNameAccess
+ * @see com.sun.star.container.XElementAccess
+ * @see com.sun.star.lang.XMultiServiceFactory
+ * @see ifc.container._XNameAccess
+ * @see ifc.container._XElementAccess
+ * @see ifc.lang._XMultiServiceFactory
+ */
+public class ContentHandlerFactory extends TestCase {
+
+ /**
+ * Creating a TestEnvironment for the interfaces to be tested.
+ * Creates an instance of the service
+ * <code>com.sun.star.frame.ContentHandlerFactory</code>. <p>
+ */
+ @Override
+ protected TestEnvironment createTestEnvironment
+ (TestParameters Param, PrintWriter log) throws Exception {
+ XInterface oObj = null;
+ Object oInterface = null ;
+
+ //now get the OButtonControl
+ oInterface = Param.getMSF().createInstance
+ ("com.sun.star.frame.ContentHandlerFactory") ;
+
+ oObj = (XInterface) oInterface ;
+ log.println("ImplName: "+utils.getImplName(oObj));
+
+ log.println( "creating a new environment for object" );
+ TestEnvironment tEnv = new TestEnvironment( oObj );
+
+ XNameAccess xNA = UnoRuntime.queryInterface
+ (XNameAccess.class, oObj);
+ tEnv.addObjRelation("XMSF.serviceNames", xNA.getElementNames());
+ xNA.getElementNames();
+
+ // com.sun.star.container.XContainerQuery
+ NamedValue[] querySequenze = new NamedValue[1];
+ NamedValue query = new NamedValue();
+ query.Name = "Name";
+ query.Value = "com.sun.star.comp.framework.SoundHandler";
+ querySequenze[0] = query;
+
+ tEnv.addObjRelation("XContainerQuery.createSubSetEnumerationByProperties",
+ querySequenze);
+
+ return tEnv;
+ } // finish method getTestEnvironment
+
+}
+
diff --git a/qadevOOo/tests/java/mod/_fwl/FilterFactory.java b/qadevOOo/tests/java/mod/_fwl/FilterFactory.java
new file mode 100644
index 000000000..1ed9869b1
--- /dev/null
+++ b/qadevOOo/tests/java/mod/_fwl/FilterFactory.java
@@ -0,0 +1,160 @@
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+package mod._fwl;
+
+import java.io.PrintWriter;
+import java.util.ArrayList;
+
+import lib.TestCase;
+import lib.TestEnvironment;
+import lib.TestParameters;
+import util.utils;
+
+import com.sun.star.beans.NamedValue;
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.container.XNameAccess;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XInterface;
+
+/**
+ * Test for object which is represented by service
+ * <code>com.sun.star.comp.framework.FilterFactory</code>. <p>
+ *
+ * Object implements the following interfaces :
+ * <ul>
+ * <li> <code>com::sun::star::container::XNameAccess</code></li>
+ * <li> <code>com::sun::star::container::XElementAccess</code></li>
+ * <li> <code>com::sun::star::lang::XMultiServiceFactory</code></li>
+ * </ul> <p>
+ *
+ * @see com.sun.star.container.XNameAccess
+ * @see com.sun.star.container.XElementAccess
+ * @see com.sun.star.lang.XMultiServiceFactory
+ * @see ifc.container._XNameAccess
+ * @see ifc.container._XElementAccess
+ * @see ifc.lang._XMultiServiceFactory
+ */
+public class FilterFactory extends TestCase {
+
+ /**
+ * Creating a TestEnvironment for the interfaces to be tested.
+ * Creates an instance of the service
+ * <code>com.sun.star.comp.framework.FilterFactory</code>.
+ * Prepares relation for
+ * <code>XMultiServiceFactory.createInstanceWithArguments</code> method
+ * test. Only filters which have their service names can be instantiated
+ * in some reasons (?). For instantiation used filter type as service
+ * name and its name as a parameter. <p>
+ */
+ @Override
+ protected TestEnvironment createTestEnvironment
+ (TestParameters Param, PrintWriter log) throws Exception {
+ Object oInterface = Param.getMSF().createInstance
+ ("com.sun.star.document.FilterFactory") ;
+ XInterface oObj = (XInterface) oInterface ;
+ log.println("ImplName: "+utils.getImplName(oObj));
+
+ log.println( "creating a new environment for object" );
+ TestEnvironment tEnv = new TestEnvironment( oObj );
+
+ XNameAccess xNA = UnoRuntime.queryInterface
+ (XNameAccess.class, oObj);
+ String[] filterNames = xNA.getElementNames();
+
+ // XNameContainer; XNameReplace
+ String filterName = filterNames[0];
+ Object[] instance = (Object[]) xNA.getByName(filterName);
+
+ log.println("adding INSTANCE 1 as obj relation to environment");
+
+ log.println("fill property 'TemplateName' with 'INSTANCE1'");
+ setPropertyValueValue((PropertyValue[])instance, "TemplateName", "INSTANCE1");
+ tEnv.addObjRelation("INSTANCE" +1, instance);
+
+
+ // XMSF
+ ArrayList<String> vFTypes = new ArrayList<String>();
+ ArrayList<Object[]> vFArgs = new ArrayList<Object[]>();
+ for (int i = 0; i < filterNames.length; i++) {
+ PropertyValue[] filterProps = null;
+ System.out.println(filterNames[i]);
+ filterProps = (PropertyValue[])
+ xNA.getByName(filterNames[i]);
+ String filterImpl = (String) getPropertyValueValue
+ (filterProps, "FilterService");
+ if (filterImpl != null && filterImpl.length() > 0) {
+ String filterType = (String) getPropertyValueValue
+ (filterProps, "Type");
+ vFTypes.add(filterType);
+ PropertyValue prop = new PropertyValue();
+ prop.Name = "FilterName";
+ prop.Value = filterNames[i];
+ vFArgs.add(new Object[] {prop});
+
+ log.println("Found filter '" + filterNames[i] + "', type: " +
+ filterType + ", service name: '" + filterImpl + "'");
+ }
+ }
+
+ tEnv.addObjRelation("XMSF.serviceNamesWithArgs",
+ vFTypes.toArray(new String[vFTypes.size()]));
+ tEnv.addObjRelation("XMSF.Args",
+ vFArgs.toArray(new Object[vFArgs.size()][]));
+
+ // com.sun.star.container.XContainerQuery
+ NamedValue[] querySequenze = new NamedValue[1];
+ NamedValue query = new NamedValue();
+ query.Name = "Name";
+ query.Value = "Rich Text Format";
+ querySequenze[0] = query;
+
+ tEnv.addObjRelation("XContainerQuery.createSubSetEnumerationByProperties",
+ querySequenze);
+
+
+ return tEnv;
+ } // finish method getTestEnvironment
+
+ protected Object getPropertyValueValue(PropertyValue[] props, String pName) {
+ int i = 0;
+ while (i < props.length && !props[i].Name.equals(pName)) {
+ i++;
+ }
+ return i < props.length ? props[i].Value : null;
+
+ }
+
+ protected void setPropertyValueValue(PropertyValue[] props, String pName, Object pValue) {
+ int i = 0;
+ while (i < props.length && !props[i].Name.equals(pName)) {
+ i++;
+ }
+ props[i].Value = pValue;
+ }
+
+ protected PropertyValue getPropertyValue(PropertyValue[] props, String pName) {
+ int i = 0;
+ while (i < props.length && !props[i].Name.equals(pName)) {
+ i++;
+ }
+ return i < props.length ? props[i] : null;
+
+ }
+}
+
diff --git a/qadevOOo/tests/java/mod/_fwl/FrameLoaderFactory.java b/qadevOOo/tests/java/mod/_fwl/FrameLoaderFactory.java
new file mode 100644
index 000000000..5beaebdb5
--- /dev/null
+++ b/qadevOOo/tests/java/mod/_fwl/FrameLoaderFactory.java
@@ -0,0 +1,87 @@
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+package mod._fwl;
+
+import com.sun.star.beans.NamedValue;
+import java.io.PrintWriter;
+
+import lib.TestCase;
+import lib.TestEnvironment;
+import lib.TestParameters;
+import util.utils;
+
+import com.sun.star.container.XNameAccess;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XInterface;
+
+/**
+ * Test for object which is represented by service
+ * <code>com.sun.star.frame.FrameLoaderFactory</code>. <p>
+ *
+ * Object implements the following interfaces :
+ * <ul>
+ * <li> <code>com::sun::star::container::XNameAccess</code></li>
+ * <li> <code>com::sun::star::container::XElementAccess</code></li>
+ * <li> <code>com::sun::star::lang::XMultiServiceFactory</code></li>
+ * </ul> <p>
+ *
+ * @see com.sun.star.container.XNameAccess
+ * @see com.sun.star.container.XElementAccess
+ * @see com.sun.star.lang.XMultiServiceFactory
+ * @see ifc.container._XNameAccess
+ * @see ifc.container._XElementAccess
+ * @see ifc.lang._XMultiServiceFactory
+ */
+public class FrameLoaderFactory extends TestCase {
+
+ /**
+ * Creating a TestEnvironment for the interfaces to be tested.
+ * Creates an instance of the service
+ * <code>com.sun.star.frame.FrameLoaderFactory</code>. <p>
+ */
+ @Override
+ protected TestEnvironment createTestEnvironment
+ (TestParameters Param, PrintWriter log) throws Exception {
+ Object oInterface = Param.getMSF().createInstance
+ ("com.sun.star.frame.FrameLoaderFactory") ;
+ XInterface oObj = (XInterface) oInterface ;
+ log.println("ImplName: "+utils.getImplName(oObj));
+
+ log.println( "creating a new environment for object" );
+ TestEnvironment tEnv = new TestEnvironment( oObj );
+
+ XNameAccess xNA = UnoRuntime.queryInterface
+ (XNameAccess.class, oObj);
+ tEnv.addObjRelation("XMSF.serviceNames", xNA.getElementNames());
+
+ // com.sun.star.container.XContainerQuery
+ NamedValue[] querySequenze = new NamedValue[1];
+ NamedValue query = new NamedValue();
+ query.Name = "Name";
+ query.Value = "com.sun.star.frame.Bibliography";
+ querySequenze[0] = query;
+
+ tEnv.addObjRelation("XContainerQuery.createSubSetEnumerationByProperties",
+ querySequenze);
+
+ return tEnv;
+ } // finish method getTestEnvironment
+
+}
+
diff --git a/qadevOOo/tests/java/mod/_fwl/PathSettings.java b/qadevOOo/tests/java/mod/_fwl/PathSettings.java
new file mode 100644
index 000000000..8e05a6bfb
--- /dev/null
+++ b/qadevOOo/tests/java/mod/_fwl/PathSettings.java
@@ -0,0 +1,138 @@
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+package mod._fwl;
+
+import com.sun.star.beans.NamedValue;
+import com.sun.star.beans.Property;
+import com.sun.star.beans.PropertyVetoException;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.beans.XPropertySetInfo;
+import com.sun.star.lang.IllegalArgumentException;
+import com.sun.star.lang.WrappedTargetException;
+import com.sun.star.uno.UnoRuntime;
+import java.io.PrintWriter;
+import java.util.HashSet;
+import java.util.Set;
+
+import lib.TestCase;
+import lib.TestEnvironment;
+import lib.TestParameters;
+import util.utils;
+
+import com.sun.star.uno.XInterface;
+
+/**
+ * Test for object which is represented by service
+ * <code>com.sun.star.comp.framework.PathSettings</code>. <p>
+ *
+ * Object implements the following interfaces :
+ * <ul>
+ * <li> <code>com::sun::star::beans::XFastPropertySet</code></li>
+ * <li> <code>com::sun::star::util::PathSettings</code></li>
+ * <li> <code>com::sun::star::beans::XPropertySet</code></li>
+ * <li> <code>com::sun::star::beans::XMultiPropertySet</code></li>
+ * </ul> <p>
+ *
+ * @see com.sun.star.beans.XFastPropertySet
+ * @see com.sun.star.util.PathSettings
+ * @see com.sun.star.beans.XPropertySet
+ * @see com.sun.star.beans.XMultiPropertySet
+ * @see ifc.beans._XFastPropertySet
+ * @see ifc.util._PathSettings
+ * @see ifc.beans._XPropertySet
+ * @see ifc.beans._XMultiPropertySet
+ */
+public class PathSettings extends TestCase {
+
+ private static NamedValue[] m_Properties;
+ private static XPropertySet xPS;
+
+ /**
+ * restores the old values of the path settings
+ * @param tParam the test parameter
+ * @param log the log writer
+ */
+ @Override
+ protected void cleanup(TestParameters tParam, PrintWriter log) {
+ log.println("restore old values of path settings...");
+
+ for (int i=0; i < m_Properties.length; i++){
+ try{
+
+ xPS.setPropertyValue(m_Properties[i].Name, m_Properties[i].Value);
+
+ } catch (com.sun.star.beans.UnknownPropertyException e){
+ } catch (PropertyVetoException e){
+ } catch (IllegalArgumentException e){
+ } catch (WrappedTargetException e){
+ }
+ }
+ }
+ /**
+ * Creating a TestEnvironment for the interfaces to be tested.
+ * Creates an instance of the service
+ * <code>com.sun.star.comp.framework.PathSettings</code>.
+ */
+ @Override
+ protected TestEnvironment createTestEnvironment
+ (TestParameters Param, PrintWriter log) throws Exception {
+ XInterface oObj = null;
+ //now get the OButtonControl
+ Object oInterface = Param.getMSF().createInstance
+ ("com.sun.star.comp.framework.PathSettings") ;
+
+ oObj = (XInterface) oInterface ;
+ log.println("ImplName: "+utils.getImplName(oObj));
+
+ log.println( "creating a new environment for object" );
+ TestEnvironment tEnv = new TestEnvironment( oObj );
+
+ Set<String> exclProps = new HashSet<String>();
+ exclProps.add("UIConfig");
+ tEnv.addObjRelation("XFastPropertySet.ExcludeProps", exclProps);
+ tEnv.addObjRelation("XMultiPropertySet.ExcludeProps", exclProps);
+
+ saveAllPropertyValues(oObj);
+
+ return tEnv;
+ } // finish method getTestEnvironment
+
+ private void saveAllPropertyValues(XInterface oObj){
+
+ xPS = UnoRuntime.queryInterface(
+ XPropertySet.class, oObj);
+
+ XPropertySetInfo xPSI = xPS.getPropertySetInfo();
+
+ Property[] allProperties = xPSI.getProperties();
+ m_Properties = new NamedValue[allProperties.length];
+
+ for (int i=0; i < allProperties.length; i++){
+ try{
+ m_Properties[i] = new NamedValue(allProperties[i].Name,
+ xPS.getPropertyValue(allProperties[i].Name));
+
+ } catch (com.sun.star.beans.UnknownPropertyException e){
+ } catch (WrappedTargetException e){
+ }
+ }
+ }
+
+}
+
diff --git a/qadevOOo/tests/java/mod/_fwl/SubstituteVariables.java b/qadevOOo/tests/java/mod/_fwl/SubstituteVariables.java
new file mode 100644
index 000000000..f55b33a45
--- /dev/null
+++ b/qadevOOo/tests/java/mod/_fwl/SubstituteVariables.java
@@ -0,0 +1,68 @@
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+package mod._fwl;
+
+import java.io.PrintWriter;
+
+import lib.TestCase;
+import lib.TestEnvironment;
+import lib.TestParameters;
+import util.utils;
+
+import com.sun.star.uno.XInterface;
+
+/**
+ * Test for object which is represented by service
+ * <code>com.sun.star.frame.FrameLoaderFactory</code>. <p>
+ *
+ * Object implements the following interfaces :
+ * <ul>
+ * <li> <code>com::sun::star::container::XNameAccess</code></li>
+ * <li> <code>com::sun::star::container::XElementAccess</code></li>
+ * <li> <code>com::sun::star::lang::XMultiServiceFactory</code></li>
+ * </ul> <p>
+ *
+ * @see com.sun.star.util.XStringSubstitution
+ * @see ifc.util._XStringSubstitution
+ */
+public class SubstituteVariables extends TestCase {
+
+ /**
+ * Creating a TestEnvironment for the interfaces to be tested.
+ * Creates an instance of the service
+ * <code>com.sun.star.util.PathSubstitution</code>. <p>
+ */
+ @Override
+ protected TestEnvironment createTestEnvironment
+ (TestParameters Param, PrintWriter log) throws Exception {
+ //now get the OButtonControl
+ Object oInterface = Param.getMSF().createInstance
+ ("com.sun.star.util.PathSubstitution") ;
+ XInterface oObj = (XInterface) oInterface ;
+ log.println("ImplName: "+utils.getImplName(oObj));
+
+ log.println( "creating a new environment for object" );
+ TestEnvironment tEnv = new TestEnvironment( oObj );
+
+
+ return tEnv;
+ } // finish method getTestEnvironment
+
+}
+
diff --git a/qadevOOo/tests/java/mod/_fwl/TypeDetection.java b/qadevOOo/tests/java/mod/_fwl/TypeDetection.java
new file mode 100644
index 000000000..74af3b352
--- /dev/null
+++ b/qadevOOo/tests/java/mod/_fwl/TypeDetection.java
@@ -0,0 +1,152 @@
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+package mod._fwl;
+
+import com.sun.star.beans.NamedValue;
+import com.sun.star.container.XNameAccess;
+import java.io.PrintWriter;
+
+import lib.TestCase;
+import lib.TestEnvironment;
+import lib.TestParameters;
+import util.utils;
+
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XInterface;
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.frame.XStorable;
+import com.sun.star.text.XTextContent;
+import com.sun.star.text.XTextDocument;
+import util.SOfficeFactory;
+
+/**
+ * Test for object which is represented by service
+ * <code>com.sun.star.document.TypeDetection</code>. <p>
+ *
+ * Object implements the following interfaces :
+ * <ul>
+ * <li> <code>com::sun::star::container::XContainerQuery</code></li>
+ * <li> <code>com::sun::star::container::XElementAccess</code></li>
+ * <li> <code>com::sun::star::container::XNameAccess</code></li>
+ * <li> <code>com::sun::star::container::XNameContainer</code></li>
+ * <li> <code>com::sun::star::container::XNameReplace</code></li>
+ * <li> <code>com::sun::star::document::XTypeDetection</code></li>
+ * <li> <code>com::sun::star::util::XFlushable</code></li>
+ * </ul> <p>
+ *
+ * @see com.sun.star.container.XContainerQuery
+ * @see com.sun.star.container.XElementAccess
+ * @see com.sun.star.container.XNameAccess
+ * @see com.sun.star.container.XNameContainer
+ * @see com.sun.star.container.XNameReplace
+ * @see com.sun.star.document.XTypeDetection
+ * @see com.sun.star.util.XFlushable
+ * @see ifc.container._XContainerQuery
+ * @see ifc.container._XElementAccess
+ * @see ifc.container._XNameAccess
+ * @see ifc.container._XNameContainer
+ * @see ifc.container._XNameReplace
+ * @see ifc.document._XTypeDetection
+ * @see ifc.util._XFlushable
+ */
+public class TypeDetection extends TestCase {
+
+ /**
+ * Disposes text document.
+ */
+ @Override
+ protected void cleanup( TestParameters tParam, PrintWriter log ) {
+ log.println( " disposing xTextDoc " );
+ util.DesktopTools.closeDoc(xTextDoc);
+ }
+
+ XTextDocument xTextDoc = null;
+
+ /**
+ * Creating a TestEnvironment for the interfaces to be tested.
+ * Creates an instance of the service
+ * <code>com.sun.star.document.TypeDetection</code>. <p>
+ */
+ @Override
+ protected TestEnvironment createTestEnvironment
+ (TestParameters Param, PrintWriter log) throws Exception {
+ XInterface oObj = null;
+ Object oInterface = null ;
+
+ oInterface = Param.getMSF().createInstance
+ ("com.sun.star.document.TypeDetection") ;
+
+ oObj = (XInterface) oInterface ;
+ log.println("ImplName: "+utils.getImplName(oObj));
+
+ log.println( "creating a new environment for object" );
+ TestEnvironment tEnv = new TestEnvironment( oObj );
+
+ XNameAccess xNA = UnoRuntime.queryInterface
+ (XNameAccess.class, oObj);
+ String[] elementNames = xNA.getElementNames();
+ String elementName = elementNames[0];
+ Object[] instance = null;
+ instance = (Object[]) xNA.getByName(elementName);
+
+ log.println("adding INSTANCE 1 as obj relation to environment");
+
+ setPropertyValueValue((PropertyValue[])instance, "Preferred", "INSTANCE1");
+ tEnv.addObjRelation("INSTANCE" +1, instance);
+
+ // com.sun.star.container.XContainerQuery
+ NamedValue[] querySequenze = new NamedValue[1];
+ NamedValue query = new NamedValue();
+ query.Name = "Name";
+ query.Value = "generic_Text";
+ querySequenze[0] = query;
+
+
+ log.println("create text document with bookmarks");
+ SOfficeFactory SOF = SOfficeFactory.getFactory( Param.getMSF() );
+ String fileURL = null;
+ xTextDoc = SOF.createTextDoc( null );
+ XInterface xBookMark = SOfficeFactory.createBookmark( xTextDoc );
+ SOfficeFactory.insertTextContent( xTextDoc, (XTextContent) xBookMark );
+
+ fileURL = utils.getOfficeTemp(Param.getMSF() );
+ fileURL = fileURL + "bookmarks.oot";
+
+ XStorable store = UnoRuntime.queryInterface(XStorable.class, xTextDoc);
+ System.out.println(fileURL);
+ store.storeToURL(fileURL, new PropertyValue[0]);
+
+ tEnv.addObjRelation("XContainerQuery.createSubSetEnumerationByProperties",
+ querySequenze);
+ tEnv.addObjRelation("XTypeDetection.bookmarkDoc", fileURL+"#bookmark");
+
+ return tEnv;
+ } // finish method getTestEnvironment
+
+
+ protected void setPropertyValueValue(PropertyValue[] props, String pName, Object pValue) {
+ int i = 0;
+ while (i < props.length && !props[i].Name.equals(pName)) {
+ i++;
+ }
+ props[i].Value = pValue;
+ }
+
+}
+