diff options
author | sb <sb@openoffice.org> | 2010-10-21 11:50:04 +0200 |
---|---|---|
committer | sb <sb@openoffice.org> | 2010-10-21 11:50:04 +0200 |
commit | 9d792efeb631f24f8864d2f9541afd25422e85c2 (patch) | |
tree | eba7d8786a06e1590dfaca8415b912202662cdab /desktop/test | |
parent | sb131: #i114962# fix component factory so it can be live deployed (diff) | |
download | core-9d792efeb631f24f8864d2f9541afd25422e85c2.tar.gz core-9d792efeb631f24f8864d2f9541afd25422e85c2.zip |
sb131: #i114962# also test singletons in passive.oxt
Diffstat (limited to 'desktop/test')
-rw-r--r-- | desktop/test/deployment/passive/Dispatch.java (renamed from desktop/test/deployment/passive/Service.java) | 41 | ||||
-rw-r--r-- | desktop/test/deployment/passive/Provider.java | 81 | ||||
-rw-r--r-- | desktop/test/deployment/passive/Services.java | 49 | ||||
-rw-r--r-- | desktop/test/deployment/passive/makefile.mk | 2 | ||||
-rw-r--r-- | desktop/test/deployment/passive/manifest.mf | 2 | ||||
-rw-r--r-- | desktop/test/deployment/passive/passive_java.component | 4 | ||||
-rw-r--r-- | desktop/test/deployment/passive/passive_native.component | 4 | ||||
-rw-r--r-- | desktop/test/deployment/passive/passive_native.cxx | 139 | ||||
-rw-r--r-- | desktop/test/deployment/passive/passive_python.component | 4 | ||||
-rw-r--r-- | desktop/test/deployment/passive/passive_python.py | 43 |
10 files changed, 291 insertions, 78 deletions
diff --git a/desktop/test/deployment/passive/Service.java b/desktop/test/deployment/passive/Dispatch.java index d4f2d52f1da0..295f34d599da 100644 --- a/desktop/test/deployment/passive/Service.java +++ b/desktop/test/deployment/passive/Dispatch.java @@ -34,52 +34,32 @@ import com.sun.star.beans.PropertyValue; import com.sun.star.frame.DispatchDescriptor; import com.sun.star.frame.XDesktop; import com.sun.star.frame.XDispatch; -import com.sun.star.frame.XDispatchProvider; import com.sun.star.frame.XStatusListener; import com.sun.star.lang.WrappedTargetRuntimeException; import com.sun.star.lang.XComponent; import com.sun.star.lang.XMultiComponentFactory; import com.sun.star.lang.XServiceInfo; -import com.sun.star.lang.XSingleComponentFactory; -import com.sun.star.lib.uno.helper.Factory; import com.sun.star.lib.uno.helper.WeakBase; import com.sun.star.uno.UnoRuntime; import com.sun.star.uno.XComponentContext; import com.sun.star.util.URL; -public final class Service extends WeakBase - implements XServiceInfo, XDispatchProvider, XDispatch +public final class Dispatch extends WeakBase implements XServiceInfo, XDispatch { - public Service(XComponentContext context) { + public Dispatch(XComponentContext context) { this.context = context; } public String getImplementationName() { return implementationName; } public boolean supportsService(String ServiceName) { - return ServiceName.equals(getSupportedServiceNames()[0]); //TODO + return false; //TODO } public String[] getSupportedServiceNames() { return serviceNames; } - public XDispatch queryDispatch( - URL URL, String TargetFrameName, int SearchFlags) - { - return this; - } - - public XDispatch[] queryDispatches(DispatchDescriptor[] Requests) { - XDispatch[] s = new XDispatch[Requests.length]; - for (int i = 0; i < s.length; ++i) { - s[i] = queryDispatch( - Requests[i].FeatureURL, Requests[i].FrameName, - Requests[i].SearchFlags); - } - return s; - } - public void dispatch(URL URL, PropertyValue[] Arguments) { try { XMultiComponentFactory smgr = UnoRuntime.queryInterface( @@ -112,19 +92,10 @@ public final class Service extends WeakBase public void removeStatusListener(XStatusListener Control, URL URL) {} - public static XSingleComponentFactory __getComponentFactory( - String implementation) - { - return implementation.equals(implementationName) - ? Factory.createComponentFactory(Service.class, serviceNames) - : null; - } - private final XComponentContext context; - private static final String implementationName = - "com.sun.star.comp.test.deployment.passive_java"; + static final String implementationName = + "com.sun.star.comp.test.deployment.passive_java_singleton"; - private static final String[] serviceNames = new String[] { - "com.sun.star.test.deployment.passive_java" }; + static final String[] serviceNames = new String[0]; } diff --git a/desktop/test/deployment/passive/Provider.java b/desktop/test/deployment/passive/Provider.java new file mode 100644 index 000000000000..6f74ed9eb89e --- /dev/null +++ b/desktop/test/deployment/passive/Provider.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 com.sun.star.comp.test.deployment.passive_java; + +import com.sun.star.frame.DispatchDescriptor; +import com.sun.star.frame.XDispatch; +import com.sun.star.frame.XDispatchProvider; +import com.sun.star.lang.XServiceInfo; +import com.sun.star.lib.uno.helper.WeakBase; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XComponentContext; +import com.sun.star.util.URL; + +public final class Provider extends WeakBase + implements XServiceInfo, XDispatchProvider +{ + public Provider(XComponentContext context) { + this.context = context; + } + + public String getImplementationName() { return implementationName; } + + public boolean supportsService(String ServiceName) { + return ServiceName.equals(getSupportedServiceNames()[0]); //TODO + } + + public String[] getSupportedServiceNames() { + return serviceNames; + } + + public XDispatch queryDispatch( + URL URL, String TargetFrameName, int SearchFlags) + { + return UnoRuntime.queryInterface( + XDispatch.class, + context.getValueByName( + "/singletons/" + + "com.sun.star.test.deployment.passive_java_singleton")); + } + + public XDispatch[] queryDispatches(DispatchDescriptor[] Requests) { + XDispatch[] s = new XDispatch[Requests.length]; + for (int i = 0; i < s.length; ++i) { + s[i] = queryDispatch( + Requests[i].FeatureURL, Requests[i].FrameName, + Requests[i].SearchFlags); + } + return s; + } + + private final XComponentContext context; + + static final String implementationName = + "com.sun.star.comp.test.deployment.passive_java"; + + static final String[] serviceNames = new String[] { + "com.sun.star.test.deployment.passive_java" }; +} diff --git a/desktop/test/deployment/passive/Services.java b/desktop/test/deployment/passive/Services.java new file mode 100644 index 000000000000..799df3e70222 --- /dev/null +++ b/desktop/test/deployment/passive/Services.java @@ -0,0 +1,49 @@ +/************************************************************************* +* 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 com.sun.star.comp.test.deployment.passive_java; + +import com.sun.star.lang.XSingleComponentFactory; +import com.sun.star.lib.uno.helper.Factory; + +public final class Services { + private Services() {} + + public static XSingleComponentFactory __getComponentFactory( + String implementation) + { + if (implementation.equals(Dispatch.implementationName)) { + return Factory.createComponentFactory( + Dispatch.class, Dispatch.implementationName, + Dispatch.serviceNames); + } else if (implementation.equals(Provider.implementationName)) { + return Factory.createComponentFactory( + Provider.class, Provider.implementationName, + Provider.serviceNames); + } else { + return null; + } + } +} diff --git a/desktop/test/deployment/passive/makefile.mk b/desktop/test/deployment/passive/makefile.mk index deadd782dd60..2d75d1d253d4 100644 --- a/desktop/test/deployment/passive/makefile.mk +++ b/desktop/test/deployment/passive/makefile.mk @@ -32,7 +32,7 @@ TARGET = test_deployment_passive ENABLE_EXCEPTIONS = TRUE PACKAGE = com/sun/star/comp/test/deployment/passive_java -JAVAFILES = Service.java +JAVAFILES = Dispatch.java Provider.java Services.java JARFILES = juh.jar ridl.jar unoil.jar my_components = passive_native passive_java passive_python diff --git a/desktop/test/deployment/passive/manifest.mf b/desktop/test/deployment/passive/manifest.mf index 5ad70357a1d2..45a04bf263dc 100644 --- a/desktop/test/deployment/passive/manifest.mf +++ b/desktop/test/deployment/passive/manifest.mf @@ -1,3 +1,3 @@ Sealed: true -RegistrationClassName: com.sun.star.comp.test.deployment.passive_java.Service +RegistrationClassName: com.sun.star.comp.test.deployment.passive_java.Services UNO-Type-Path: diff --git a/desktop/test/deployment/passive/passive_java.component b/desktop/test/deployment/passive/passive_java.component index dfc55a5b8c36..74be57177dfe 100644 --- a/desktop/test/deployment/passive/passive_java.component +++ b/desktop/test/deployment/passive/passive_java.component @@ -31,4 +31,8 @@ <implementation name="com.sun.star.comp.test.deployment.passive_java"> <service name="com.sun.star.test.deployment.passive_java"/> </implementation> + <implementation + name="com.sun.star.comp.test.deployment.passive_java_singleton"> + <singleton name="com.sun.star.test.deployment.passive_java_singleton"/> + </implementation> </component> diff --git a/desktop/test/deployment/passive/passive_native.component b/desktop/test/deployment/passive/passive_native.component index 7b0c314628a6..c14fd7ff0062 100644 --- a/desktop/test/deployment/passive/passive_native.component +++ b/desktop/test/deployment/passive/passive_native.component @@ -31,4 +31,8 @@ <implementation name="com.sun.star.comp.test.deployment.passive_native"> <service name="com.sun.star.test.deployment.passive_native"/> </implementation> + <implementation + name="com.sun.star.comp.test.deployment.passive_native_singleton"> + <singleton name="com.sun.star.test.deployment.passive_native_singleton"/> + </implementation> </component> diff --git a/desktop/test/deployment/passive/passive_native.cxx b/desktop/test/deployment/passive/passive_native.cxx index 66a49251d81c..39101257ad67 100644 --- a/desktop/test/deployment/passive/passive_native.cxx +++ b/desktop/test/deployment/passive/passive_native.cxx @@ -44,6 +44,7 @@ #include "com/sun/star/lang/XComponent.hpp" #include "com/sun/star/lang/XMultiComponentFactory.hpp" #include "com/sun/star/lang/XServiceInfo.hpp" +#include "com/sun/star/uno/DeploymentException.hpp" #include "com/sun/star/uno/Exception.hpp" #include "com/sun/star/uno/Reference.hxx" #include "com/sun/star/uno/RuntimeException.hpp" @@ -52,7 +53,7 @@ #include "com/sun/star/uno/XInterface.hpp" #include "com/sun/star/util/URL.hpp" #include "cppuhelper/factory.hxx" -#include "cppuhelper/implbase3.hxx" +#include "cppuhelper/implbase2.hxx" #include "cppuhelper/implementationentry.hxx" #include "cppuhelper/weak.hxx" #include "osl/diagnose.h" @@ -65,17 +66,16 @@ namespace { namespace css = com::sun::star; -class Service: - public cppu::WeakImplHelper3< - css::lang::XServiceInfo, css::frame::XDispatchProvider, - css::frame::XDispatch >, +class Provider: + public cppu::WeakImplHelper2< + css::lang::XServiceInfo, css::frame::XDispatchProvider >, private boost::noncopyable { public: static css::uno::Reference< css::uno::XInterface > SAL_CALL static_create( css::uno::Reference< css::uno::XComponentContext > const & xContext) SAL_THROW((css::uno::Exception)) - { return static_cast< cppu::OWeakObject * >(new Service(xContext)); } + { return static_cast< cppu::OWeakObject * >(new Provider(xContext)); } static rtl::OUString SAL_CALL static_getImplementationName(); @@ -83,10 +83,11 @@ public: static_getSupportedServiceNames(); private: - Service(css::uno::Reference< css::uno::XComponentContext > const & context): + Provider( + css::uno::Reference< css::uno::XComponentContext > const & context): context_(context) { OSL_ASSERT(context.is()); } - virtual ~Service() {} + virtual ~Provider() {} virtual rtl::OUString SAL_CALL getImplementationName() throw (css::uno::RuntimeException) @@ -102,49 +103,56 @@ private: virtual css::uno::Reference< css::frame::XDispatch > SAL_CALL queryDispatch( css::util::URL const &, rtl::OUString const &, sal_Int32) - throw (css::uno::RuntimeException) - { return this; } + throw (css::uno::RuntimeException); virtual css::uno::Sequence< css::uno::Reference< css::frame::XDispatch > > SAL_CALL queryDispatches( css::uno::Sequence< css::frame::DispatchDescriptor > const & Requests) throw (css::uno::RuntimeException); - virtual void SAL_CALL dispatch( - css::util::URL const &, - css::uno::Sequence< css::beans::PropertyValue > const &) - throw (css::uno::RuntimeException); - - virtual void SAL_CALL addStatusListener( - css::uno::Reference< css::frame::XStatusListener > const &, - css::util::URL const &) - throw (css::uno::RuntimeException) - {} - - virtual void SAL_CALL removeStatusListener( - css::uno::Reference< css::frame::XStatusListener > const &, - css::util::URL const &) - throw (css::uno::RuntimeException) - {} - css::uno::Reference< css::uno::XComponentContext > context_; }; -rtl::OUString Service::static_getImplementationName() { +rtl::OUString Provider::static_getImplementationName() { return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.test.deployment.passive_native")); } -css::uno::Sequence< rtl::OUString > Service::static_getSupportedServiceNames() { +css::uno::Sequence< rtl::OUString > Provider::static_getSupportedServiceNames() +{ rtl::OUString name( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.test.deployment.passive_native")); return css::uno::Sequence< rtl::OUString >(&name, 1); } +css::uno::Reference< css::frame::XDispatch > Provider::queryDispatch( + css::util::URL const &, rtl::OUString const &, sal_Int32) + throw (css::uno::RuntimeException) +{ + css::uno::Reference< css::frame::XDispatch > dispatch; + if (!(context_->getValueByName( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "/singletons/com.sun.star.test.deployment." + "passive_native_singleton"))) >>= + dispatch) || + !dispatch.is()) + { + throw css::uno::DeploymentException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "component context fails to supply singleton" + " com.sun.star.test.deployment.passive_native_singleton of" + " type com.sun.star.frame.XDispatch")), + context_); + } + return dispatch; +} + css::uno::Sequence< css::uno::Reference< css::frame::XDispatch > > -Service::queryDispatches( +Provider::queryDispatches( css::uno::Sequence< css::frame::DispatchDescriptor > const & Requests) throw (css::uno::RuntimeException) { @@ -158,7 +166,69 @@ Service::queryDispatches( return s; } -void Service::dispatch( +class Dispatch: + public cppu::WeakImplHelper2< + css::lang::XServiceInfo, css::frame::XDispatch >, + private boost::noncopyable +{ +public: + static css::uno::Reference< css::uno::XInterface > SAL_CALL static_create( + css::uno::Reference< css::uno::XComponentContext > const & xContext) + SAL_THROW((css::uno::Exception)) + { return static_cast< cppu::OWeakObject * >(new Dispatch(xContext)); } + + static rtl::OUString SAL_CALL static_getImplementationName(); + + static css::uno::Sequence< rtl::OUString > SAL_CALL + static_getSupportedServiceNames() + { return css::uno::Sequence< rtl::OUString >(); } + +private: + Dispatch( + css::uno::Reference< css::uno::XComponentContext > const & context): + context_(context) { OSL_ASSERT(context.is()); } + + virtual ~Dispatch() {} + + virtual rtl::OUString SAL_CALL getImplementationName() + throw (css::uno::RuntimeException) + { return static_getImplementationName(); } + + virtual sal_Bool SAL_CALL supportsService(rtl::OUString const &) + throw (css::uno::RuntimeException) + { return false; } //TODO + + virtual css::uno::Sequence< rtl::OUString > SAL_CALL + getSupportedServiceNames() throw (css::uno::RuntimeException) + { return static_getSupportedServiceNames(); } + + virtual void SAL_CALL dispatch( + css::util::URL const &, + css::uno::Sequence< css::beans::PropertyValue > const &) + throw (css::uno::RuntimeException); + + virtual void SAL_CALL addStatusListener( + css::uno::Reference< css::frame::XStatusListener > const &, + css::util::URL const &) + throw (css::uno::RuntimeException) + {} + + virtual void SAL_CALL removeStatusListener( + css::uno::Reference< css::frame::XStatusListener > const &, + css::util::URL const &) + throw (css::uno::RuntimeException) + {} + + css::uno::Reference< css::uno::XComponentContext > context_; +}; + +rtl::OUString Dispatch::static_getImplementationName() { + return rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.comp.test.deployment.passive_native_singleton")); +} + +void Dispatch::dispatch( css::util::URL const &, css::uno::Sequence< css::beans::PropertyValue > const &) throw (css::uno::RuntimeException) @@ -194,8 +264,11 @@ void Service::dispatch( } static cppu::ImplementationEntry const services[] = { - { &Service::static_create, &Service::static_getImplementationName, - &Service::static_getSupportedServiceNames, + { &Provider::static_create, &Provider::static_getImplementationName, + &Provider::static_getSupportedServiceNames, + &cppu::createSingleComponentFactory, 0, 0 }, + { &Dispatch::static_create, &Dispatch::static_getImplementationName, + &Dispatch::static_getSupportedServiceNames, &cppu::createSingleComponentFactory, 0, 0 }, { 0, 0, 0, 0, 0, 0 } }; diff --git a/desktop/test/deployment/passive/passive_python.component b/desktop/test/deployment/passive/passive_python.component index 3a0bea4b5296..ea7a1992b534 100644 --- a/desktop/test/deployment/passive/passive_python.component +++ b/desktop/test/deployment/passive/passive_python.component @@ -31,4 +31,8 @@ <implementation name="com.sun.star.comp.test.deployment.passive_python"> <service name="com.sun.star.test.deployment.passive_python"/> </implementation> + <implementation + name="com.sun.star.comp.test.deployment.passive_python_singleton"> + <singleton name="com.sun.star.test.deployment.passive_python_singleton"/> + </implementation> </component> diff --git a/desktop/test/deployment/passive/passive_python.py b/desktop/test/deployment/passive/passive_python.py index 183cbdc899c3..dda68cccdb2f 100644 --- a/desktop/test/deployment/passive/passive_python.py +++ b/desktop/test/deployment/passive/passive_python.py @@ -33,24 +33,49 @@ from com.sun.star.awt.MessageBoxButtons import BUTTONS_OK from com.sun.star.frame import XDispatch, XDispatchProvider from com.sun.star.lang import XServiceInfo -implementationName = "com.sun.star.comp.test.deployment.passive_python" -serviceNames = ("com.sun.star.test.deployment.passive_python",) +class Provider(unohelper.Base, XServiceInfo, XDispatchProvider): + implementationName = "com.sun.star.comp.test.deployment.passive_python" + + serviceNames = ("com.sun.star.test.deployment.passive_python",) -class Service(unohelper.Base, XServiceInfo, XDispatchProvider, XDispatch): def __init__(self, context): self.context = context def getImplementationName(self): - return implementationName + return self.implementationName def supportsService(self, ServiceName): - return ServiceName in serviceNames + return ServiceName in self.serviceNames def getSupportedServiceNames(self): - return serviceNames + return self.serviceNames def queryDispatch(self, URL, TargetFrame, SearchFlags): - return self + return self.context.getValueByName( \ + "/singletons/com.sun.star.test.deployment.passive_python_singleton") + + def queryDispatches(self, Requests): + tuple( \ + self.queryDispatch(i.FeatureURL, i.FrameName, i.SearchFlags) \ + for i in Requests) + +class Dispatch(unohelper.Base, XServiceInfo, XDispatch): + implementationName = \ + "com.sun.star.comp.test.deployment.passive_python_singleton" + + serviceNames = () + + def __init__(self, context): + self.context = context + + def getImplementationName(self): + return self.implementationName + + def supportsService(self, ServiceName): + return ServiceName in self.serviceNames + + def getSupportedServiceNames(self): + return self.serviceNames def dispatch(self, URL, Arguments): smgr = self.context.getServiceManager() @@ -71,4 +96,6 @@ class Service(unohelper.Base, XServiceInfo, XDispatchProvider, XDispatch): g_ImplementationHelper = unohelper.ImplementationHelper() g_ImplementationHelper.addImplementation( \ - Service, implementationName, serviceNames,) + Provider, Provider.implementationName, Provider.serviceNames) +g_ImplementationHelper.addImplementation( \ + Dispatch, Dispatch.implementationName, Dispatch.serviceNames) |