Kaydet (Commit) 63cb9b5e authored tarafından Stephan Bergmann's avatar Stephan Bergmann

Clean up desktop/test/deployment/{active,passive}

Change-Id: I7f5bbbd1d8a2491c86c2875ae155ef4b10154377
üst f83cf4e4
...@@ -28,12 +28,13 @@ ...@@ -28,12 +28,13 @@
#include "sal/config.h" #include "sal/config.h"
#include <cassert>
#include "boost/noncopyable.hpp" #include "boost/noncopyable.hpp"
#include "com/sun/star/awt/MessageBoxButtons.hpp" #include "com/sun/star/awt/MessageBoxButtons.hpp"
#include "com/sun/star/awt/Rectangle.hpp" #include "com/sun/star/awt/Rectangle.hpp"
#include "com/sun/star/awt/XMessageBox.hpp"
#include "com/sun/star/awt/Toolkit.hpp" #include "com/sun/star/awt/Toolkit.hpp"
#include "com/sun/star/awt/XMessageBoxFactory.hpp" #include "com/sun/star/awt/XMessageBox.hpp"
#include "com/sun/star/awt/XWindowPeer.hpp" #include "com/sun/star/awt/XWindowPeer.hpp"
#include "com/sun/star/beans/PropertyValue.hpp" #include "com/sun/star/beans/PropertyValue.hpp"
#include "com/sun/star/frame/DispatchDescriptor.hpp" #include "com/sun/star/frame/DispatchDescriptor.hpp"
...@@ -43,7 +44,6 @@ ...@@ -43,7 +44,6 @@
#include "com/sun/star/frame/XFrame.hpp" #include "com/sun/star/frame/XFrame.hpp"
#include "com/sun/star/frame/XStatusListener.hpp" #include "com/sun/star/frame/XStatusListener.hpp"
#include "com/sun/star/lang/XComponent.hpp" #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/lang/XServiceInfo.hpp"
#include "com/sun/star/uno/DeploymentException.hpp" #include "com/sun/star/uno/DeploymentException.hpp"
#include "com/sun/star/uno/Exception.hpp" #include "com/sun/star/uno/Exception.hpp"
...@@ -56,9 +56,8 @@ ...@@ -56,9 +56,8 @@
#include "cppuhelper/factory.hxx" #include "cppuhelper/factory.hxx"
#include "cppuhelper/implbase2.hxx" #include "cppuhelper/implbase2.hxx"
#include "cppuhelper/implementationentry.hxx" #include "cppuhelper/implementationentry.hxx"
#include "cppuhelper/supportsservice.hxx"
#include "cppuhelper/weak.hxx" #include "cppuhelper/weak.hxx"
#include "osl/diagnose.h"
#include "rtl/ustring.h"
#include "rtl/ustring.hxx" #include "rtl/ustring.hxx"
#include "sal/types.h" #include "sal/types.h"
#include "uno/lbnames.h" #include "uno/lbnames.h"
...@@ -78,32 +77,32 @@ public: ...@@ -78,32 +77,32 @@ public:
SAL_THROW((css::uno::Exception)) SAL_THROW((css::uno::Exception))
{ return static_cast< cppu::OWeakObject * >(new Provider(xContext)); } { return static_cast< cppu::OWeakObject * >(new Provider(xContext)); }
static rtl::OUString SAL_CALL static_getImplementationName(); static OUString SAL_CALL static_getImplementationName();
static css::uno::Sequence< rtl::OUString > SAL_CALL static css::uno::Sequence< OUString > SAL_CALL
static_getSupportedServiceNames(); static_getSupportedServiceNames();
private: private:
Provider( Provider(
css::uno::Reference< css::uno::XComponentContext > const & context): css::uno::Reference< css::uno::XComponentContext > const & context):
context_(context) { OSL_ASSERT(context.is()); } context_(context) { assert(context.is()); }
virtual ~Provider() {} virtual ~Provider() {}
virtual rtl::OUString SAL_CALL getImplementationName() virtual OUString SAL_CALL getImplementationName()
throw (css::uno::RuntimeException) throw (css::uno::RuntimeException)
{ return static_getImplementationName(); } { return static_getImplementationName(); }
virtual sal_Bool SAL_CALL supportsService(rtl::OUString const & ServiceName) virtual sal_Bool SAL_CALL supportsService(OUString const & ServiceName)
throw (css::uno::RuntimeException) throw (css::uno::RuntimeException)
{ return ServiceName == getSupportedServiceNames()[0]; } //TODO { return cppu::supportsService(this, ServiceName); }
virtual css::uno::Sequence< rtl::OUString > SAL_CALL virtual css::uno::Sequence< OUString > SAL_CALL
getSupportedServiceNames() throw (css::uno::RuntimeException) getSupportedServiceNames() throw (css::uno::RuntimeException)
{ return static_getSupportedServiceNames(); } { return static_getSupportedServiceNames(); }
virtual css::uno::Reference< css::frame::XDispatch > SAL_CALL queryDispatch( virtual css::uno::Reference< css::frame::XDispatch > SAL_CALL queryDispatch(
css::util::URL const &, rtl::OUString const &, sal_Int32) css::util::URL const &, OUString const &, sal_Int32)
throw (css::uno::RuntimeException); throw (css::uno::RuntimeException);
virtual css::uno::Sequence< css::uno::Reference< css::frame::XDispatch > > virtual css::uno::Sequence< css::uno::Reference< css::frame::XDispatch > >
...@@ -114,39 +113,31 @@ private: ...@@ -114,39 +113,31 @@ private:
css::uno::Reference< css::uno::XComponentContext > context_; css::uno::Reference< css::uno::XComponentContext > context_;
}; };
rtl::OUString Provider::static_getImplementationName() { OUString Provider::static_getImplementationName() {
return rtl::OUString( return OUString("com.sun.star.comp.test.deployment.passive_native");
RTL_CONSTASCII_USTRINGPARAM(
"com.sun.star.comp.test.deployment.passive_native"));
} }
css::uno::Sequence< rtl::OUString > Provider::static_getSupportedServiceNames() css::uno::Sequence< OUString > Provider::static_getSupportedServiceNames()
{ {
rtl::OUString name( OUString name("com.sun.star.test.deployment.passive_native");
RTL_CONSTASCII_USTRINGPARAM( return css::uno::Sequence< OUString >(&name, 1);
"com.sun.star.test.deployment.passive_native"));
return css::uno::Sequence< rtl::OUString >(&name, 1);
} }
css::uno::Reference< css::frame::XDispatch > Provider::queryDispatch( css::uno::Reference< css::frame::XDispatch > Provider::queryDispatch(
css::util::URL const &, rtl::OUString const &, sal_Int32) css::util::URL const &, OUString const &, sal_Int32)
throw (css::uno::RuntimeException) throw (css::uno::RuntimeException)
{ {
css::uno::Reference< css::frame::XDispatch > dispatch; css::uno::Reference< css::frame::XDispatch > dispatch;
if (!(context_->getValueByName( if (!(context_->getValueByName(
rtl::OUString( "/singletons/com.sun.star.test.deployment."
RTL_CONSTASCII_USTRINGPARAM( "passive_native_singleton") >>=
"/singletons/com.sun.star.test.deployment."
"passive_native_singleton"))) >>=
dispatch) || dispatch) ||
!dispatch.is()) !dispatch.is())
{ {
throw css::uno::DeploymentException( throw css::uno::DeploymentException(
rtl::OUString( "component context fails to supply singleton"
RTL_CONSTASCII_USTRINGPARAM( " com.sun.star.test.deployment.passive_native_singleton of type"
"component context fails to supply singleton" " com.sun.star.frame.XDispatch",
" com.sun.star.test.deployment.passive_native_singleton of"
" type com.sun.star.frame.XDispatch")),
context_); context_);
} }
return dispatch; return dispatch;
...@@ -178,28 +169,28 @@ public: ...@@ -178,28 +169,28 @@ public:
SAL_THROW((css::uno::Exception)) SAL_THROW((css::uno::Exception))
{ return static_cast< cppu::OWeakObject * >(new Dispatch(xContext)); } { return static_cast< cppu::OWeakObject * >(new Dispatch(xContext)); }
static rtl::OUString SAL_CALL static_getImplementationName(); static OUString SAL_CALL static_getImplementationName();
static css::uno::Sequence< rtl::OUString > SAL_CALL static css::uno::Sequence< OUString > SAL_CALL
static_getSupportedServiceNames() static_getSupportedServiceNames()
{ return css::uno::Sequence< rtl::OUString >(); } { return css::uno::Sequence< OUString >(); }
private: private:
Dispatch( Dispatch(
css::uno::Reference< css::uno::XComponentContext > const & context): css::uno::Reference< css::uno::XComponentContext > const & context):
context_(context) { OSL_ASSERT(context.is()); } context_(context) { assert(context.is()); }
virtual ~Dispatch() {} virtual ~Dispatch() {}
virtual rtl::OUString SAL_CALL getImplementationName() virtual OUString SAL_CALL getImplementationName()
throw (css::uno::RuntimeException) throw (css::uno::RuntimeException)
{ return static_getImplementationName(); } { return static_getImplementationName(); }
virtual sal_Bool SAL_CALL supportsService(rtl::OUString const &) virtual sal_Bool SAL_CALL supportsService(OUString const & ServiceName)
throw (css::uno::RuntimeException) throw (css::uno::RuntimeException)
{ return false; } //TODO { return cppu::supportsService(this, ServiceName); }
virtual css::uno::Sequence< rtl::OUString > SAL_CALL virtual css::uno::Sequence< OUString > SAL_CALL
getSupportedServiceNames() throw (css::uno::RuntimeException) getSupportedServiceNames() throw (css::uno::RuntimeException)
{ return static_getSupportedServiceNames(); } { return static_getSupportedServiceNames(); }
...@@ -223,10 +214,9 @@ private: ...@@ -223,10 +214,9 @@ private:
css::uno::Reference< css::uno::XComponentContext > context_; css::uno::Reference< css::uno::XComponentContext > context_;
}; };
rtl::OUString Dispatch::static_getImplementationName() { OUString Dispatch::static_getImplementationName() {
return rtl::OUString( return OUString(
RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.test.deployment.passive_native_singleton");
"com.sun.star.comp.test.deployment.passive_native_singleton"));
} }
void Dispatch::dispatch( void Dispatch::dispatch(
...@@ -234,29 +224,19 @@ void Dispatch::dispatch( ...@@ -234,29 +224,19 @@ void Dispatch::dispatch(
css::uno::Sequence< css::beans::PropertyValue > const &) css::uno::Sequence< css::beans::PropertyValue > const &)
throw (css::uno::RuntimeException) throw (css::uno::RuntimeException)
{ {
css::uno::Reference< css::lang::XMultiComponentFactory > smgr(context_->getServiceManager(), css::uno::UNO_SET_THROW);
css::uno::Reference< css::awt::XToolkit > toolkit( css::awt::Toolkit::create(context_), css::uno::UNO_SET_THROW);
css::uno::Reference< css::awt::XMessageBox > box( css::uno::Reference< css::awt::XMessageBox > box(
css::uno::Reference< css::awt::XMessageBoxFactory >( css::awt::Toolkit::create(context_)->createMessageBox(
toolkit, css::uno::Reference< css::awt::XWindowPeer >(
css::uno::UNO_QUERY_THROW)->createMessageBox( css::uno::Reference< css::frame::XFrame >(
css::uno::Reference< css::awt::XWindowPeer >( css::uno::Reference< css::frame::XDesktop >(
css::uno::Reference< css::frame::XFrame >( (context_->getServiceManager()->
css::uno::Reference< css::frame::XDesktop >( createInstanceWithContext(
smgr->createInstanceWithContext( "com.sun.star.frame.Desktop", context_)),
rtl::OUString( css::uno::UNO_QUERY_THROW)->getCurrentFrame(),
RTL_CONSTASCII_USTRINGPARAM( css::uno::UNO_SET_THROW)->getComponentWindow(),
"com.sun.star.frame.Desktop")), css::uno::UNO_QUERY_THROW),
context_), css::awt::Rectangle(), "infobox",
css::uno::UNO_QUERY_THROW)->getCurrentFrame(), css::awt::MessageBoxButtons::BUTTONS_OK, "passive", "native"),
css::uno::UNO_SET_THROW)->getComponentWindow(),
css::uno::UNO_QUERY_THROW),
css::awt::Rectangle(),
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("infobox")),
css::awt::MessageBoxButtons::BUTTONS_OK,
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("passive")),
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("native"))),
css::uno::UNO_SET_THROW); css::uno::UNO_SET_THROW);
box->execute(); box->execute();
css::uno::Reference< css::lang::XComponent >( css::uno::Reference< css::lang::XComponent >(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment