summaryrefslogtreecommitdiffstats
path: root/extensions/qa/integration
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:06:44 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:06:44 +0000
commited5640d8b587fbcfed7dd7967f3de04b37a76f26 (patch)
tree7a5f7c6c9d02226d7471cb3cc8fbbf631b415303 /extensions/qa/integration
parentInitial commit. (diff)
downloadlibreoffice-ed5640d8b587fbcfed7dd7967f3de04b37a76f26.tar.xz
libreoffice-ed5640d8b587fbcfed7dd7967f3de04b37a76f26.zip
Adding upstream version 4:7.4.7.upstream/4%7.4.7upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'extensions/qa/integration')
-rw-r--r--extensions/qa/integration/extensions/ComponentFactory.java93
-rw-r--r--extensions/qa/integration/extensions/ConsoleWait.java120
-rw-r--r--extensions/qa/integration/extensions/Frame.java215
-rw-r--r--extensions/qa/integration/extensions/HelpTextProvider.java58
-rw-r--r--extensions/qa/integration/extensions/MethodHandler.java217
-rw-r--r--extensions/qa/integration/extensions/ObjectInspector.java159
-rw-r--r--extensions/qa/integration/extensions/ServicesHandler.java212
-rw-r--r--extensions/qa/integration/extensions/extensions_complex.sce1
-rw-r--r--extensions/qa/integration/extensions/makefile.mk74
9 files changed, 1149 insertions, 0 deletions
diff --git a/extensions/qa/integration/extensions/ComponentFactory.java b/extensions/qa/integration/extensions/ComponentFactory.java
new file mode 100644
index 000000000..ec848c4df
--- /dev/null
+++ b/extensions/qa/integration/extensions/ComponentFactory.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 integration.extensions;
+
+import com.sun.star.uno.XComponentContext;
+import com.sun.star.lang.XSingleComponentFactory;
+import java.lang.reflect.Constructor;
+
+public class ComponentFactory implements XSingleComponentFactory
+{
+ private final Class m_handlerClass;
+ private Constructor m_defaultConstructor;
+ private Constructor m_initConstructor;
+
+ public ComponentFactory( Class _handlerClass )
+ {
+ m_handlerClass = _handlerClass;
+
+ Class objectArrayClass = null;
+ try
+ {
+ objectArrayClass = Class.forName("[Ljava.lang.Object;");
+ }
+ catch ( java.lang.ClassNotFoundException e ) { }
+
+ Constructor ctors[] = _handlerClass.getConstructors();
+ for ( int i = 0; i < ctors.length; ++i)
+ {
+ Class ctorParams[] = ctors[i].getParameterTypes();
+ if ( ( ctorParams.length == 1 ) && ( ctorParams[0].equals( XComponentContext.class ) ) )
+ m_defaultConstructor = ctors[i];
+ if ( ( ctorParams.length == 2 )
+ && ( ctorParams[0].equals( XComponentContext.class ) )
+ && ( ctorParams[1].equals( objectArrayClass ) )
+ )
+ m_initConstructor = ctors[i];
+ }
+ if ( m_defaultConstructor == null )
+ throw new java.lang.IllegalArgumentException();
+ }
+
+ private Object ipml_createInstance( Constructor _ctor, Object[] _arguments )
+ {
+ Object newInstance = null;
+ try
+ {
+ newInstance = _ctor.newInstance( _arguments );
+ }
+ catch( InstantiationException e )
+ {
+ System.err.println( "InstantiationException: Could not instantiate an instance of " + m_handlerClass.getName() );
+ }
+ catch( IllegalAccessException e )
+ {
+ System.err.println( "IllegalAccessException: Could not instantiate an instance of " + m_handlerClass.getName() );
+ }
+ catch( java.lang.reflect.InvocationTargetException e )
+ {
+ System.err.println( "InvocationTargetException: Could not instantiate an instance of " + m_handlerClass.getName() );
+ }
+ return newInstance;
+ }
+
+ public Object createInstanceWithArgumentsAndContext(Object[] _arguments, XComponentContext _componentContext) throws com.sun.star.uno.Exception
+ {
+ if ( m_initConstructor != null )
+ return ipml_createInstance( m_initConstructor, new Object[] { _componentContext, _arguments } );
+ else
+ return createInstanceWithContext( _componentContext );
+ }
+
+ public Object createInstanceWithContext(XComponentContext _componentContext) throws com.sun.star.uno.Exception
+ {
+ return ipml_createInstance( m_defaultConstructor, new Object[] { _componentContext } );
+ }
+}
+
diff --git a/extensions/qa/integration/extensions/ConsoleWait.java b/extensions/qa/integration/extensions/ConsoleWait.java
new file mode 100644
index 000000000..34fdaa7c0
--- /dev/null
+++ b/extensions/qa/integration/extensions/ConsoleWait.java
@@ -0,0 +1,120 @@
+/*
+ * 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 integration.extensions;
+
+import com.sun.star.uno.*;
+import com.sun.star.lang.XComponent;
+
+public class ConsoleWait implements com.sun.star.lang.XEventListener
+{
+ private final Object m_disposable;
+
+ /** a helper class which waits for a console ENTER key event in a dedicated thread,
+ and notifies a ConsoleWait object if this event happened
+ */
+ private class WaitForEnter extends java.lang.Thread
+ {
+ private final ConsoleWait m_toNotify;
+ private boolean m_done;
+
+ public WaitForEnter( ConsoleWait _toNotify )
+ {
+ m_toNotify = _toNotify;
+ m_done = false;
+ }
+
+ public boolean isDone()
+ {
+ return m_done;
+ }
+
+ @Override
+ public void run()
+ {
+ try
+ {
+ System.out.println( "\npress enter to exit" );
+ System.in.read();
+
+ m_done = true;
+ // notify that the user pressed the key
+ synchronized ( m_toNotify )
+ {
+ m_toNotify.notify();
+ }
+ }
+ catch( java.lang.Exception e )
+ {
+ // not really interested in
+ System.err.println( e );
+ }
+ }
+ }
+
+ /** creates a ConsoleWait instance
+ * @param _disposable
+ * a component whose disposal should be monitored. When this component dies,
+ * the ConsoleWait also returns from a waitForConsole call, even if the user
+ * did not yet press the enter key
+ */
+ public ConsoleWait( Object _disposable )
+ {
+ m_disposable = _disposable;
+ XComponent component = UnoRuntime.queryInterface( XComponent.class, _disposable );
+ if ( component != null )
+ component.addEventListener( this );
+ }
+
+ /** waits for the user to press the ENTER key (on the console where she started the java program)
+ or the disposable component to be closed by the user.
+ @return
+ TRUE if the user pressed a key on the console, FALSE if she closed the document
+ */
+ public boolean waitForUserInput() throws java.lang.Exception
+ {
+ synchronized (this)
+ {
+ WaitForEnter keyWaiter = new WaitForEnter( this );
+ keyWaiter.start();
+ wait();
+
+ // if the waiter thread is done, the user pressed enter
+ boolean bKeyPressed = keyWaiter.isDone();
+ if ( !bKeyPressed )
+ keyWaiter.interrupt();
+
+ return bKeyPressed;
+ }
+ }
+
+ /* ------------------------------------------------------------------ */
+ /* XEventListener overridables */
+ /* ------------------------------------------------------------------ */
+ public void disposing( com.sun.star.lang.EventObject eventObject )
+ {
+ if ( eventObject.Source.equals( m_disposable ) )
+ {
+ // notify ourself that we can stop waiting for user input
+ synchronized (this)
+ {
+ notify();
+ }
+ }
+ }
+}
diff --git a/extensions/qa/integration/extensions/Frame.java b/extensions/qa/integration/extensions/Frame.java
new file mode 100644
index 000000000..15f26de74
--- /dev/null
+++ b/extensions/qa/integration/extensions/Frame.java
@@ -0,0 +1,215 @@
+/*
+ * 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 integration.extensions;
+
+import com.sun.star.uno.*;
+import com.sun.star.frame.*;
+import com.sun.star.task.XStatusIndicatorFactory;
+import com.sun.star.util.XCloseable;
+
+/**
+ * wraps the com.sun.star.frame.Frame service
+ */
+public class Frame implements XDispatchProvider,
+ XDispatchProviderInterception,
+ XFramesSupplier,
+ XStatusIndicatorFactory,
+ XCloseable
+{
+ private XFrame m_frame;
+ private XDispatchProvider m_dispatchProvider;
+ private XDispatchProviderInterception m_dispatchProviderInterception;
+ private XFramesSupplier m_framesSupplier;
+ private XStatusIndicatorFactory m_statusIndicatorFactory;
+ private XCloseable m_closeable;
+
+ /** Creates a new instance of Frame */
+ public Frame( Object _frameComponent )
+ {
+ if ( _frameComponent != null )
+ {
+ m_frame = UnoRuntime.queryInterface( XFrame.class, _frameComponent );
+ m_dispatchProvider = UnoRuntime.queryInterface( XDispatchProvider.class, _frameComponent );
+ m_dispatchProviderInterception = UnoRuntime.queryInterface( XDispatchProviderInterception.class, _frameComponent );
+ m_framesSupplier = UnoRuntime.queryInterface( XFramesSupplier.class, _frameComponent );
+ m_statusIndicatorFactory = UnoRuntime.queryInterface( XStatusIndicatorFactory.class, _frameComponent );
+ m_closeable = UnoRuntime.queryInterface( XCloseable.class, _frameComponent );
+ }
+ }
+
+ public XFrame getXFrame()
+ {
+ return m_frame;
+ }
+
+ public void activate()
+ {
+ m_frame.activate();
+ }
+
+ public void addEventListener(com.sun.star.lang.XEventListener _eventListener)
+ {
+ m_frame.addEventListener( _eventListener );
+ }
+
+ public void addFrameActionListener(XFrameActionListener _frameActionListener)
+ {
+ m_frame.addFrameActionListener( _frameActionListener );
+ }
+
+ public void contextChanged()
+ {
+ m_frame.contextChanged();
+ }
+
+ public com.sun.star.task.XStatusIndicator createStatusIndicator()
+ {
+ return m_statusIndicatorFactory.createStatusIndicator();
+ }
+
+ public void deactivate()
+ {
+ m_frame.deactivate();
+ }
+
+ public void dispose()
+ {
+ m_frame.dispose();
+ }
+
+ public XFrame findFrame(String str, int param)
+ {
+ return m_frame.findFrame( str, param );
+ }
+
+ public XFrame getActiveFrame()
+ {
+ return m_framesSupplier.getActiveFrame();
+ }
+
+ public com.sun.star.awt.XWindow getComponentWindow()
+ {
+ return m_frame.getComponentWindow();
+ }
+
+ public com.sun.star.awt.XWindow getContainerWindow()
+ {
+ return m_frame.getContainerWindow();
+ }
+
+ public XController getController()
+ {
+ return m_frame.getController();
+ }
+
+ public XFramesSupplier getCreator()
+ {
+ return m_frame.getCreator();
+ }
+
+ public XFrames getFrames()
+ {
+ return m_framesSupplier.getFrames();
+ }
+
+ public String getName()
+ {
+ return m_frame.getName();
+ }
+
+ public void initialize(com.sun.star.awt.XWindow _window)
+ {
+ m_frame.initialize( _window );
+ }
+
+ public boolean isActive()
+ {
+ return m_frame.isActive();
+ }
+
+ public boolean isTop()
+ {
+ return m_frame.isTop();
+ }
+
+ public XDispatch queryDispatch(com.sun.star.util.URL _url, String _str, int _param)
+ {
+ return m_dispatchProvider.queryDispatch( _url, _str, _param );
+ }
+
+ public XDispatch[] queryDispatches(DispatchDescriptor[] dispatchDescriptor)
+ {
+ return m_dispatchProvider.queryDispatches( dispatchDescriptor );
+ }
+
+ public void registerDispatchProviderInterceptor(XDispatchProviderInterceptor _dispatchProviderInterceptor)
+ {
+ m_dispatchProviderInterception.registerDispatchProviderInterceptor( _dispatchProviderInterceptor );
+ }
+
+ public void releaseDispatchProviderInterceptor(XDispatchProviderInterceptor _dispatchProviderInterceptor)
+ {
+ m_dispatchProviderInterception.releaseDispatchProviderInterceptor( _dispatchProviderInterceptor );
+ }
+
+ public void removeEventListener(com.sun.star.lang.XEventListener _eventListener)
+ {
+ m_frame.removeEventListener( _eventListener );
+ }
+
+ public void removeFrameActionListener(XFrameActionListener _frameActionListener)
+ {
+ m_frame.removeFrameActionListener( _frameActionListener );
+ }
+
+ public void setActiveFrame(XFrame _frame)
+ {
+ m_framesSupplier.setActiveFrame( _frame );
+ }
+
+ public boolean setComponent(com.sun.star.awt.XWindow _window, XController _controller)
+ {
+ return m_frame.setComponent( _window, _controller );
+ }
+
+ public void setCreator(XFramesSupplier _framesSupplier)
+ {
+ m_frame.setCreator( _framesSupplier );
+ }
+
+ public void setName(String str)
+ {
+ m_frame.setName( str );
+ }
+
+ public void close(boolean _deliverOwnership) throws com.sun.star.util.CloseVetoException
+ {
+ m_closeable.close( _deliverOwnership );
+ }
+
+ public void removeCloseListener(com.sun.star.util.XCloseListener _closeListener)
+ {
+ m_closeable.removeCloseListener( _closeListener );
+ }
+
+ public void addCloseListener(com.sun.star.util.XCloseListener _closeListener)
+ {
+ m_closeable.addCloseListener( _closeListener );
+ }
+}
diff --git a/extensions/qa/integration/extensions/HelpTextProvider.java b/extensions/qa/integration/extensions/HelpTextProvider.java
new file mode 100644
index 000000000..8bd6596bc
--- /dev/null
+++ b/extensions/qa/integration/extensions/HelpTextProvider.java
@@ -0,0 +1,58 @@
+/*
+ * 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 integration.extensions;
+
+import com.sun.star.inspection.XObjectInspectorUI;
+import com.sun.star.inspection.XPropertyControl;
+import com.sun.star.inspection.XPropertyControlObserver;
+import com.sun.star.lang.NoSupportException;
+
+/** displays help text for the currently selected method
+ */
+public class HelpTextProvider implements XPropertyControlObserver
+{
+ private final XObjectInspectorUI m_inspectorUI;
+
+ /**
+ * Creates a new instance of HelpTextProvider
+ */
+ public HelpTextProvider( XObjectInspectorUI _inspectorUI )
+ {
+ m_inspectorUI = _inspectorUI;
+ m_inspectorUI.registerControlObserver( this );
+ }
+
+ public void focusGained( XPropertyControl _propertyControl )
+ {
+ try
+ {
+ String helpText = "here could be the help for:\n";
+ helpText += _propertyControl.getValue().toString();
+ m_inspectorUI.setHelpSectionText( helpText );
+ }
+ catch (NoSupportException ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+
+ public void valueChanged( XPropertyControl _propertyControl )
+ {
+ // not interested in
+ }
+}
diff --git a/extensions/qa/integration/extensions/MethodHandler.java b/extensions/qa/integration/extensions/MethodHandler.java
new file mode 100644
index 000000000..ffc81c5f5
--- /dev/null
+++ b/extensions/qa/integration/extensions/MethodHandler.java
@@ -0,0 +1,217 @@
+/*
+ * 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 integration.extensions;
+
+import com.sun.star.uno.*;
+import com.sun.star.beans.*;
+import com.sun.star.reflection.*;
+import com.sun.star.inspection.*;
+
+public class MethodHandler implements XPropertyHandler
+{
+ private XIntrospection m_introspection;
+ private XIdlMethod[] m_methods;
+ private java.util.HashMap<String,XIdlMethod> m_methodsHash;
+
+ /** Creates a new instance of MethodHandler */
+ public MethodHandler( XComponentContext _context )
+ {
+ m_methodsHash = new java.util.HashMap<String,XIdlMethod>();
+
+ try
+ {
+ m_introspection = UnoRuntime.queryInterface( XIntrospection.class,
+ _context.getServiceManager().createInstanceWithContext( "com.sun.star.beans.Introspection", _context )
+ );
+ }
+ catch( com.sun.star.uno.Exception e )
+ {
+ System.err.println( "MethodHandler: could not create an Introspection service, not much functionality will be available." );
+ }
+ }
+
+
+
+ public void actuatingPropertyChanged(String _propertyName, Object _newValue, Object _oldValue, com.sun.star.inspection.XObjectInspectorUI _objectInspectorUI, boolean _firstTimeInit) throws com.sun.star.lang.NullPointerException
+ {
+ // not interested in
+ }
+
+ public void addEventListener(com.sun.star.lang.XEventListener _eventListener)
+ {
+ // ignoring this
+ }
+
+ public void addPropertyChangeListener(com.sun.star.beans.XPropertyChangeListener _propertyChangeListener) throws com.sun.star.lang.NullPointerException
+ {
+ // ignoring this
+ }
+
+ public Object convertToControlValue(String _propertyName, Object _propertyValue, com.sun.star.uno.Type type) throws com.sun.star.beans.UnknownPropertyException
+ {
+ return _propertyValue;
+ }
+
+ public Object convertToPropertyValue(String _propertyName, Object _controlValue) throws com.sun.star.beans.UnknownPropertyException
+ {
+ return _controlValue;
+ }
+
+ public com.sun.star.inspection.LineDescriptor describePropertyLine(String _propertyName, com.sun.star.inspection.XPropertyControlFactory _propertyControlFactory) throws com.sun.star.beans.UnknownPropertyException, com.sun.star.lang.NullPointerException
+ {
+ com.sun.star.inspection.LineDescriptor descriptor = new com.sun.star.inspection.LineDescriptor();
+
+ descriptor = new LineDescriptor();
+ descriptor.Category = "Methods";
+ descriptor.DisplayName = "has method";
+ descriptor.HasPrimaryButton = descriptor.HasSecondaryButton = false;
+ descriptor.IndentLevel = 0;
+ try
+ {
+ XPropertyControl control = UnoRuntime.queryInterface(
+ XPropertyControl.class, _propertyControlFactory.createPropertyControl(
+ PropertyControlType.TextField, true ) );
+
+ descriptor.Control = control;
+ }
+ catch( com.sun.star.lang.IllegalArgumentException e )
+ {
+ }
+ return descriptor;
+ }
+
+ public void dispose()
+ {
+ // nothing to do
+ }
+
+ public String[] getActuatingProperties()
+ {
+ // none
+ return new String[] { };
+ }
+
+ public com.sun.star.beans.PropertyState getPropertyState(String _propertyName) throws com.sun.star.beans.UnknownPropertyException
+ {
+ return com.sun.star.beans.PropertyState.DIRECT_VALUE;
+ }
+
+ public Object getPropertyValue(String _propertyName) throws com.sun.star.beans.UnknownPropertyException
+ {
+ XIdlMethod method = impl_getMethod( _propertyName );
+
+ String signature = "";
+ signature += method.getReturnType().getName();
+ signature += " ";
+ signature += method.getName();
+
+ signature += "(";
+
+ XIdlClass[] parameterTypes = method.getParameterTypes();
+ for ( int param = 0; param<parameterTypes.length; ++param )
+ {
+ signature += ( param == 0 ) ? " " : ", ";
+ signature += parameterTypes[param].getName();
+ }
+
+ signature += " )";
+ return signature;
+ }
+
+ public String[] getSupersededProperties()
+ {
+ return new String[] { };
+ }
+
+ public com.sun.star.beans.Property[] getSupportedProperties()
+ {
+ Property[] properties = new Property[] { };
+ if ( m_methods != null )
+ {
+ properties = new Property[ m_methods.length ];
+ for ( int i=0; i<m_methods.length; ++i )
+ {
+ properties[i] = new Property( m_methods[i].getName(), 0, new Type( String.class ), (short)0 );
+ m_methodsHash.put( m_methods[i].getName(), m_methods[i] );
+ }
+ }
+ return properties;
+ }
+
+ public void inspect(Object _component) throws com.sun.star.lang.NullPointerException
+ {
+ if ( m_introspection == null )
+ return;
+
+ m_methods = null;
+ m_methodsHash = new java.util.HashMap<String,XIdlMethod>();
+
+ XIntrospectionAccess introspectionAccess = m_introspection.inspect( _component );
+ if ( introspectionAccess == null )
+ return;
+
+ m_methods = introspectionAccess.getMethods( MethodConcept.ALL );
+ }
+
+ public boolean isComposable(String _propertyName) throws com.sun.star.beans.UnknownPropertyException
+ {
+ return true;
+ }
+
+ public com.sun.star.inspection.InteractiveSelectionResult onInteractivePropertySelection(String str, boolean param, Object[] obj, com.sun.star.inspection.XObjectInspectorUI xObjectInspectorUI) throws com.sun.star.beans.UnknownPropertyException, com.sun.star.lang.NullPointerException
+ {
+ return InteractiveSelectionResult.Cancelled;
+ }
+
+ public void removeEventListener(com.sun.star.lang.XEventListener _eventListener)
+ {
+ // ignoring this
+ }
+
+ public void removePropertyChangeListener(com.sun.star.beans.XPropertyChangeListener _propertyChangeListener)
+ {
+ // ignoring this
+ }
+
+ public void setPropertyValue(String str, Object obj) throws com.sun.star.beans.UnknownPropertyException
+ {
+ // we declared our properties as readonly
+ throw new java.lang.RuntimeException();
+ }
+
+ public boolean suspend(boolean param)
+ {
+ return true;
+ }
+
+ /** returns the descriptor for the method with the given name
+ * @param _propertyName
+ * the name of the method whose descriptor should be obtained
+ * @throws com.sun.star.beans.UnknownPropertyException
+ * if we don't have a method hash, or the given property name does not denote a method of our inspectee
+ */
+ private XIdlMethod impl_getMethod( String _methodName ) throws UnknownPropertyException
+ {
+ XIdlMethod method = m_methodsHash.get( _methodName );
+ if ( method == null )
+ throw new com.sun.star.beans.UnknownPropertyException();
+
+ return method;
+ }
+}
diff --git a/extensions/qa/integration/extensions/ObjectInspector.java b/extensions/qa/integration/extensions/ObjectInspector.java
new file mode 100644
index 000000000..2b2fa4e0a
--- /dev/null
+++ b/extensions/qa/integration/extensions/ObjectInspector.java
@@ -0,0 +1,159 @@
+/*
+ * 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 integration.extensions;
+
+import com.sun.star.uno.XComponentContext;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.lang.XMultiServiceFactory;
+
+import com.sun.star.frame.*;
+import com.sun.star.inspection.*;
+import com.sun.star.beans.*;
+
+public class ObjectInspector extends complexlib.ComplexTestCase
+{
+ private XComponentContext m_context;
+ private XMultiServiceFactory m_orb;
+ private Frame m_desktop;
+
+ static final private String m_inspectorFrameName = "ObjectInspector";
+
+ /* ------------------------------------------------------------------ */
+ @Override
+ public String[] getTestMethodNames()
+ {
+ return new String[] {
+ "interactiveObjectInspector"
+ };
+ }
+
+ /* ------------------------------------------------------------------ */
+ @Override
+ public String getTestObjectName()
+ {
+ return "Test Skeleton";
+ }
+
+ /* ------------------------------------------------------------------ */
+ public void before() throws com.sun.star.uno.Exception, java.lang.Exception
+ {
+ m_orb = param.getMSF();
+ m_context = UnoRuntime.queryInterface( XComponentContext.class,
+ UnoRuntime.queryInterface( XPropertySet.class, m_orb ).getPropertyValue( "DefaultContext" ) );
+ m_desktop = new Frame( m_orb.createInstance( "com.sun.star.frame.Desktop" ) );
+ }
+
+ /* ------------------------------------------------------------------ */
+ public void after() throws java.lang.Exception
+ {
+ closeExistentInspector();
+ }
+
+ /* ------------------------------------------------------------------ */
+ public void interactiveObjectInspector() throws com.sun.star.uno.Exception, java.lang.Exception
+ {
+ closeExistentInspector();
+
+ // the to-be-inspected object
+ XFrame inspectee = m_desktop.getActiveFrame();
+
+ // the inspector
+ XObjectInspector inspector = createObjectInspector();
+
+ // do inspect
+ inspector.inspect( new Object[] { inspectee } );
+
+ ConsoleWait keyWaiter = new ConsoleWait( inspector );
+ keyWaiter.waitForUserInput();
+ }
+
+ /* ------------------------------------------------------------------ */
+ private XObjectInspector createObjectInspector() throws com.sun.star.uno.Exception
+ {
+ com.sun.star.awt.XWindow floatingWindow = createFloatingWindow();
+
+ Frame inspectorFrame = new Frame( m_orb.createInstance( "com.sun.star.frame.Frame" ) );
+ inspectorFrame.setName( m_inspectorFrameName );
+ inspectorFrame.initialize( floatingWindow );
+ m_desktop.getFrames().append( inspectorFrame.getXFrame() );
+
+ // handler factories:
+ Object[] handlerFactories = new Object[] {
+ "com.sun.star.inspection.GenericPropertyHandler",
+ new ComponentFactory( ServicesHandler.class ),
+ new ComponentFactory( MethodHandler.class )
+ };
+ // a model
+ XObjectInspectorModel model = ObjectInspectorModel.createWithHandlerFactoriesAndHelpSection(
+ m_context, handlerFactories, 4, 4 );
+
+ // create the ObjectInspector
+ XObjectInspector inspector = com.sun.star.inspection.ObjectInspector.createWithModel(
+ m_context, model );
+
+ // add an observer which will emit help texts
+ new HelpTextProvider( inspector.getInspectorUI() );
+
+ // plug it into the frame
+ inspector.attachFrame( inspectorFrame.getXFrame() );
+
+ // make the window visible
+ floatingWindow.setVisible( true );
+
+ // outta here
+ return inspector;
+ }
+
+ /* ------------------------------------------------------------------ */
+ private void closeExistentInspector()
+ {
+ Frame existentInspectorFrame = new Frame( m_desktop.findFrame( m_inspectorFrameName, 255 ) );
+ try
+ {
+ existentInspectorFrame.close( true );
+ }
+ catch( com.sun.star.util.CloseVetoException e )
+ {
+ failed( "could not close the existent inspector frame" );
+ }
+ }
+
+ /* ------------------------------------------------------------------ */
+ private com.sun.star.awt.XWindow createFloatingWindow() throws com.sun.star.uno.Exception
+ {
+ com.sun.star.awt.XToolkit toolkit = UnoRuntime.queryInterface(
+ com.sun.star.awt.XToolkit.class, m_orb.createInstance( "com.sun.star.awt.Toolkit" ) );
+
+ com.sun.star.awt.WindowDescriptor windowDescriptor = new com.sun.star.awt.WindowDescriptor();
+ windowDescriptor.Type = com.sun.star.awt.WindowClass.TOP;
+ windowDescriptor.WindowServiceName = "modelessdialog"; // "floatingwindow" would need a parent
+ windowDescriptor.ParentIndex = -1;
+ //windowDescriptor.Parent = null;
+
+ windowDescriptor.Bounds = new com.sun.star.awt.Rectangle( 500, 100, 400, 600 );
+ windowDescriptor.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;
+
+ return UnoRuntime.queryInterface( com.sun.star.awt.XWindow.class,
+ toolkit.createWindow( windowDescriptor ) );
+ }
+}
diff --git a/extensions/qa/integration/extensions/ServicesHandler.java b/extensions/qa/integration/extensions/ServicesHandler.java
new file mode 100644
index 000000000..c84e128e8
--- /dev/null
+++ b/extensions/qa/integration/extensions/ServicesHandler.java
@@ -0,0 +1,212 @@
+/*
+ * 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 integration.extensions;
+
+import com.sun.star.uno.*;
+import com.sun.star.beans.*;
+import com.sun.star.inspection.*;
+import com.sun.star.frame.*;
+import com.sun.star.lang.XServiceInfo;
+
+public class ServicesHandler implements XPropertyHandler
+{
+ private final XComponentContext m_context;
+ private String[] m_supportedServices;
+
+ private static class ClickHandler implements com.sun.star.awt.XActionListener
+ {
+ XComponentContext m_context;
+ private final String m_serviceName;
+
+ public ClickHandler( XComponentContext _context, String _serviceName )
+ {
+ m_context = _context;
+ m_serviceName = _serviceName;
+ }
+
+ public void disposing(com.sun.star.lang.EventObject eventObject)
+ {
+ // not interested in
+ }
+
+ public void actionPerformed(com.sun.star.awt.ActionEvent actionEvent)
+ {
+ try
+ {
+ // translate the service name into a URL to dispatch
+ String documentationURL = "https://api.libreoffice.org/docs/common/ref/" + m_serviceName.replace('.','/') + ".html";
+ System.out.println( documentationURL );
+
+ // the OpenHyperlink command, to be dispatched to the Desktop
+ com.sun.star.util.URL dispatchURL[] = { new com.sun.star.util.URL() };
+ dispatchURL[0].Complete = ".uno:OpenHyperlink";
+ com.sun.star.util.XURLTransformer transformer = UnoRuntime.queryInterface(
+ com.sun.star.util.XURLTransformer.class,
+ m_context.getServiceManager().createInstanceWithContext( "com.sun.star.util.URLTransformer", m_context ) );
+ transformer.parseStrict( dispatchURL );
+
+ // the dispatcher for the OpenHyperlink command
+ Frame desktop = new Frame(
+ m_context.getServiceManager().createInstanceWithContext( "com.sun.star.frame.Desktop", m_context ) );
+ XDispatch dispatcher = desktop.queryDispatch(dispatchURL[0],"",0);
+
+ // the arguments for the OpenHyperlink command
+ PropertyValue dispatchArgs[] = new PropertyValue[] { new PropertyValue() };
+ dispatchArgs[0].Name = "URL";
+ dispatchArgs[0].Value = documentationURL;
+
+ dispatcher.dispatch(dispatchURL[0], dispatchArgs );
+ }
+ catch( com.sun.star.uno.Exception e )
+ {
+ e.printStackTrace( System.err );
+ }
+ }
+ }
+
+ /** Creates a new instance of ServicesHandler */
+ public ServicesHandler( XComponentContext _context )
+ {
+ m_context = _context;
+ m_supportedServices = new String[] { };
+ }
+
+ public void actuatingPropertyChanged(String _propertyName, Object _newValue, Object _oldValue, com.sun.star.inspection.XObjectInspectorUI _objectInspectorUI, boolean _firstTimeInit) throws com.sun.star.lang.NullPointerException
+ {
+ // not interested in
+ }
+
+ public void addEventListener(com.sun.star.lang.XEventListener _eventListener)
+ {
+ // ignoring this
+ }
+
+ public void addPropertyChangeListener(com.sun.star.beans.XPropertyChangeListener _propertyChangeListener) throws com.sun.star.lang.NullPointerException
+ {
+ // ignoring this
+ }
+
+ public Object convertToControlValue(String _propertyName, Object _propertyValue, com.sun.star.uno.Type type) throws com.sun.star.beans.UnknownPropertyException
+ {
+ return _propertyValue;
+ }
+
+ public Object convertToPropertyValue(String _propertyName, Object _controlValue) throws com.sun.star.beans.UnknownPropertyException
+ {
+ return _controlValue;
+ }
+
+ public com.sun.star.inspection.LineDescriptor describePropertyLine(String _propertyName, com.sun.star.inspection.XPropertyControlFactory _propertyControlFactory) throws com.sun.star.beans.UnknownPropertyException, com.sun.star.lang.NullPointerException
+ {
+ com.sun.star.inspection.LineDescriptor descriptor = new com.sun.star.inspection.LineDescriptor();
+
+ descriptor = new LineDescriptor();
+ descriptor.Category = "Services";
+ descriptor.DisplayName = "supports service";
+ descriptor.HasPrimaryButton = descriptor.HasSecondaryButton = false;
+ descriptor.IndentLevel = 0;
+ try
+ {
+ XHyperlinkControl hyperlinkControl = UnoRuntime.queryInterface(
+ XHyperlinkControl.class, _propertyControlFactory.createPropertyControl( PropertyControlType.HyperlinkField, true ) );
+ hyperlinkControl.addActionListener( new ClickHandler( m_context, _propertyName ) );
+
+ descriptor.Control = hyperlinkControl;
+ }
+ catch( com.sun.star.lang.IllegalArgumentException e )
+ {
+ }
+ return descriptor;
+ }
+
+ public void dispose()
+ {
+ // nothing to do
+ }
+
+ public String[] getActuatingProperties()
+ {
+ // none
+ return new String[] { };
+ }
+
+ public com.sun.star.beans.PropertyState getPropertyState(String _propertyName) throws com.sun.star.beans.UnknownPropertyException
+ {
+ return com.sun.star.beans.PropertyState.DIRECT_VALUE;
+ }
+
+ public Object getPropertyValue(String _propertyName) throws com.sun.star.beans.UnknownPropertyException
+ {
+ return _propertyName;
+ }
+
+ public String[] getSupersededProperties()
+ {
+ return new String[] { "SupportedServiceNames" };
+ // we're used in conjunction with a GenericPropertyHandler, which (via inspection) finds
+ // a property SupportedServiceNames, resulting from the XServiceInfo.getSupportedServiceNames
+ // method. Since we handle those ourself, we supersede them.
+ }
+
+ public com.sun.star.beans.Property[] getSupportedProperties()
+ {
+ Property[] properties = new Property[ m_supportedServices.length ];
+ for ( int i=0; i<m_supportedServices.length; ++i )
+ properties[i] = new Property( m_supportedServices[i], 0, new Type( String.class ), (short)0 );
+ return properties;
+ }
+
+ public void inspect(Object _component) throws com.sun.star.lang.NullPointerException
+ {
+ XServiceInfo serviceInfo = UnoRuntime.queryInterface( XServiceInfo.class, _component );
+ if ( serviceInfo != null )
+ m_supportedServices = serviceInfo.getSupportedServiceNames();
+ }
+
+ public boolean isComposable(String _propertyName) throws com.sun.star.beans.UnknownPropertyException
+ {
+ return true;
+ }
+
+ public com.sun.star.inspection.InteractiveSelectionResult onInteractivePropertySelection(String str, boolean param, Object[] obj, com.sun.star.inspection.XObjectInspectorUI xObjectInspectorUI) throws com.sun.star.beans.UnknownPropertyException, com.sun.star.lang.NullPointerException
+ {
+ return InteractiveSelectionResult.Cancelled;
+ }
+
+ public void removeEventListener(com.sun.star.lang.XEventListener _eventListener)
+ {
+ // ignoring this
+ }
+
+ public void removePropertyChangeListener(com.sun.star.beans.XPropertyChangeListener _propertyChangeListener)
+ {
+ // ignoring this
+ }
+
+ public void setPropertyValue(String str, Object obj) throws com.sun.star.beans.UnknownPropertyException
+ {
+ // we declared our properties as readonly
+ throw new java.lang.RuntimeException();
+ }
+
+ public boolean suspend(boolean param)
+ {
+ return true;
+ }
+}
diff --git a/extensions/qa/integration/extensions/extensions_complex.sce b/extensions/qa/integration/extensions/extensions_complex.sce
new file mode 100644
index 000000000..563376c72
--- /dev/null
+++ b/extensions/qa/integration/extensions/extensions_complex.sce
@@ -0,0 +1 @@
+#-o integration.extensions.ObjectInspector \ No newline at end of file
diff --git a/extensions/qa/integration/extensions/makefile.mk b/extensions/qa/integration/extensions/makefile.mk
new file mode 100644
index 000000000..ca524e0eb
--- /dev/null
+++ b/extensions/qa/integration/extensions/makefile.mk
@@ -0,0 +1,74 @@
+#
+# 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 .
+#
+
+PRJ = ..$/..$/..
+TARGET = ExtensionsIntegrationTests
+PRJNAME = extensions
+PACKAGE = integration$/$(PRJNAME)
+
+# --- Settings -----------------------------------------------------
+.INCLUDE: settings.mk
+
+
+#----- compile .java files -----------------------------------------
+
+JARFILES = ridl.jar unoil.jar jurt.jar juh.jar java_uno.jar OOoRunner.jar
+JAVAFILES := $(shell @$(FIND) .$/*.java)
+JAVACLASSFILES := $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class)
+
+#----- make a jar from compiled files ------------------------------
+
+MAXLINELENGTH = 100000
+
+JARCLASSDIRS = $(PACKAGE)
+JARTARGET = $(TARGET).jar
+JARCOMPRESS = TRUE
+
+# --- Runner Settings ----------------------------------------------
+
+# create connection string for OOoRunner
+.IF "$(RUNNER_CONNECTION_STRING)" == ""
+ .IF "$(OOO_RUNNER_PORT)" == ""
+ OOO_RUNNER_PORT=8100
+ .ENDIF
+ .IF "$(OOO_RUNNER_HOST)" == ""
+ OOO_RUNNER_HOST=localhost
+ .ENDIF
+ RUNNER_CONNECTION_STRING=socket,host=$(OOO_RUNNER_HOST),port=$(OOO_RUNNER_PORT)
+.ENDIF
+
+# classpath and argument list
+RUNNER_CLASSPATH = -cp $(CLASSPATH)$(LIBO_PATH_SEPARATOR)$(SOLARBINDIR)$/OOoRunner.jar$(LIBO_PATH_SEPARATOR)$(CLASSPATH)$(LIBO_PATH_SEPARATOR)$(SOLARBINDIR)$/ConnectivityTools.jar
+RUNNER_ARGS = org.openoffice.Runner -TestBase java_complex -cs $(RUNNER_CONNECTION_STRING)
+
+# --- Targets ------------------------------------------------------
+
+.IF "$(depend)" == ""
+ALL : ALLTAR
+.ELSE
+ALL: ALLDEP
+.ENDIF
+
+.INCLUDE : target.mk
+
+run:
+ +java $(RUNNER_CLASSPATH) $(RUNNER_ARGS) -sce extensions_complex.sce
+
+run_%:
+ +java $(RUNNER_CLASSPATH) $(RUNNER_ARGS) -o integration.$(PRJNAME).$(@:s/run_//)
+