1*2722ceddSAndrew Rist /**************************************************************
2*2722ceddSAndrew Rist  *
3*2722ceddSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*2722ceddSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*2722ceddSAndrew Rist  * distributed with this work for additional information
6*2722ceddSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*2722ceddSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*2722ceddSAndrew Rist  * "License"); you may not use this file except in compliance
9*2722ceddSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*2722ceddSAndrew Rist  *
11*2722ceddSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*2722ceddSAndrew Rist  *
13*2722ceddSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*2722ceddSAndrew Rist  * software distributed under the License is distributed on an
15*2722ceddSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*2722ceddSAndrew Rist  * KIND, either express or implied.  See the License for the
17*2722ceddSAndrew Rist  * specific language governing permissions and limitations
18*2722ceddSAndrew Rist  * under the License.
19*2722ceddSAndrew Rist  *
20*2722ceddSAndrew Rist  *************************************************************/
21*2722ceddSAndrew Rist 
22*2722ceddSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #include "precompiled_desktop.hxx"
25cdf0e10cSrcweir #include "sal/config.h"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "boost/noncopyable.hpp"
28cdf0e10cSrcweir #include "com/sun/star/beans/PropertyValue.hpp"
29cdf0e10cSrcweir #include "com/sun/star/frame/DispatchDescriptor.hpp"
30cdf0e10cSrcweir #include "com/sun/star/frame/XDispatch.hpp"
31cdf0e10cSrcweir #include "com/sun/star/frame/XDispatchProvider.hpp"
32cdf0e10cSrcweir #include "com/sun/star/frame/XStatusListener.hpp"
33cdf0e10cSrcweir #include "com/sun/star/lang/XServiceInfo.hpp"
34cdf0e10cSrcweir #include "com/sun/star/uno/Exception.hpp"
35cdf0e10cSrcweir #include "com/sun/star/uno/Reference.hxx"
36cdf0e10cSrcweir #include "com/sun/star/uno/RuntimeException.hpp"
37cdf0e10cSrcweir #include "com/sun/star/uno/Sequence.hxx"
38cdf0e10cSrcweir #include "com/sun/star/uno/XComponentContext.hpp"
39cdf0e10cSrcweir #include "com/sun/star/uno/XInterface.hpp"
40cdf0e10cSrcweir #include "com/sun/star/util/URL.hpp"
41cdf0e10cSrcweir #include "cppuhelper/factory.hxx"
42cdf0e10cSrcweir #include "cppuhelper/implbase3.hxx"
43cdf0e10cSrcweir #include "cppuhelper/implementationentry.hxx"
44cdf0e10cSrcweir #include "cppuhelper/weak.hxx"
45cdf0e10cSrcweir #include "filter/msfilter/countryid.hxx"
46cdf0e10cSrcweir #include "osl/diagnose.h"
47cdf0e10cSrcweir #include "rtl/ustring.h"
48cdf0e10cSrcweir #include "rtl/ustring.hxx"
49cdf0e10cSrcweir #include "sal/types.h"
50cdf0e10cSrcweir #include "uno/lbnames.h"
51cdf0e10cSrcweir #include "vcl/svapp.hxx"
52cdf0e10cSrcweir 
53cdf0e10cSrcweir namespace {
54cdf0e10cSrcweir 
55cdf0e10cSrcweir namespace css = com::sun::star;
56cdf0e10cSrcweir 
57cdf0e10cSrcweir class Service:
58cdf0e10cSrcweir     public cppu::WeakImplHelper3<
59cdf0e10cSrcweir         css::lang::XServiceInfo, css::frame::XDispatchProvider,
60cdf0e10cSrcweir         css::frame::XDispatch >,
61cdf0e10cSrcweir     private boost::noncopyable
62cdf0e10cSrcweir {
63cdf0e10cSrcweir public:
static_create(css::uno::Reference<css::uno::XComponentContext> const &)64cdf0e10cSrcweir     static css::uno::Reference< css::uno::XInterface > SAL_CALL static_create(
65cdf0e10cSrcweir         css::uno::Reference< css::uno::XComponentContext > const &)
66cdf0e10cSrcweir         SAL_THROW((css::uno::Exception))
67cdf0e10cSrcweir     { return static_cast< cppu::OWeakObject * >(new Service); }
68cdf0e10cSrcweir 
69cdf0e10cSrcweir     static rtl::OUString SAL_CALL static_getImplementationName();
70cdf0e10cSrcweir 
71cdf0e10cSrcweir     static css::uno::Sequence< rtl::OUString > SAL_CALL
72cdf0e10cSrcweir     static_getSupportedServiceNames();
73cdf0e10cSrcweir 
74cdf0e10cSrcweir private:
Service()75cdf0e10cSrcweir     Service() {}
76cdf0e10cSrcweir 
~Service()77cdf0e10cSrcweir     virtual ~Service() {}
78cdf0e10cSrcweir 
getImplementationName()79cdf0e10cSrcweir     virtual rtl::OUString SAL_CALL getImplementationName()
80cdf0e10cSrcweir         throw (css::uno::RuntimeException)
81cdf0e10cSrcweir     { return static_getImplementationName(); }
82cdf0e10cSrcweir 
supportsService(rtl::OUString const & ServiceName)83cdf0e10cSrcweir     virtual sal_Bool SAL_CALL supportsService(rtl::OUString const & ServiceName)
84cdf0e10cSrcweir         throw (css::uno::RuntimeException)
85cdf0e10cSrcweir     { return ServiceName == getSupportedServiceNames()[0]; } //TODO
86cdf0e10cSrcweir 
87cdf0e10cSrcweir     virtual css::uno::Sequence< rtl::OUString > SAL_CALL
getSupportedServiceNames()88cdf0e10cSrcweir     getSupportedServiceNames() throw (css::uno::RuntimeException)
89cdf0e10cSrcweir     { return static_getSupportedServiceNames(); }
90cdf0e10cSrcweir 
queryDispatch(css::util::URL const &,rtl::OUString const &,sal_Int32)91cdf0e10cSrcweir     virtual css::uno::Reference< css::frame::XDispatch > SAL_CALL queryDispatch(
92cdf0e10cSrcweir         css::util::URL const &, rtl::OUString const &, sal_Int32)
93cdf0e10cSrcweir         throw (css::uno::RuntimeException)
94cdf0e10cSrcweir     { return this; }
95cdf0e10cSrcweir 
96cdf0e10cSrcweir     virtual css::uno::Sequence< css::uno::Reference< css::frame::XDispatch > >
97cdf0e10cSrcweir     SAL_CALL queryDispatches(
98cdf0e10cSrcweir         css::uno::Sequence< css::frame::DispatchDescriptor > const & Requests)
99cdf0e10cSrcweir         throw (css::uno::RuntimeException);
100cdf0e10cSrcweir 
101cdf0e10cSrcweir     virtual void SAL_CALL dispatch(
102cdf0e10cSrcweir         css::util::URL const &,
103cdf0e10cSrcweir         css::uno::Sequence< css::beans::PropertyValue > const &)
104cdf0e10cSrcweir         throw (css::uno::RuntimeException);
105cdf0e10cSrcweir 
addStatusListener(css::uno::Reference<css::frame::XStatusListener> const &,css::util::URL const &)106cdf0e10cSrcweir     virtual void SAL_CALL addStatusListener(
107cdf0e10cSrcweir         css::uno::Reference< css::frame::XStatusListener > const &,
108cdf0e10cSrcweir         css::util::URL const &)
109cdf0e10cSrcweir         throw (css::uno::RuntimeException)
110cdf0e10cSrcweir     {}
111cdf0e10cSrcweir 
removeStatusListener(css::uno::Reference<css::frame::XStatusListener> const &,css::util::URL const &)112cdf0e10cSrcweir     virtual void SAL_CALL removeStatusListener(
113cdf0e10cSrcweir         css::uno::Reference< css::frame::XStatusListener > const &,
114cdf0e10cSrcweir         css::util::URL const &)
115cdf0e10cSrcweir         throw (css::uno::RuntimeException)
116cdf0e10cSrcweir     {}
117cdf0e10cSrcweir };
118cdf0e10cSrcweir 
static_getImplementationName()119cdf0e10cSrcweir rtl::OUString Service::static_getImplementationName() {
120cdf0e10cSrcweir     return rtl::OUString(
121cdf0e10cSrcweir         RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.test.deployment.boxt"));
122cdf0e10cSrcweir }
123cdf0e10cSrcweir 
static_getSupportedServiceNames()124cdf0e10cSrcweir css::uno::Sequence< rtl::OUString > Service::static_getSupportedServiceNames() {
125cdf0e10cSrcweir     rtl::OUString name(
126cdf0e10cSrcweir         RTL_CONSTASCII_USTRINGPARAM("com.sun.star.test.deployment.boxt"));
127cdf0e10cSrcweir     return css::uno::Sequence< rtl::OUString >(&name, 1);
128cdf0e10cSrcweir }
129cdf0e10cSrcweir 
130cdf0e10cSrcweir css::uno::Sequence< css::uno::Reference< css::frame::XDispatch > >
queryDispatches(css::uno::Sequence<css::frame::DispatchDescriptor> const & Requests)131cdf0e10cSrcweir Service::queryDispatches(
132cdf0e10cSrcweir     css::uno::Sequence< css::frame::DispatchDescriptor > const & Requests)
133cdf0e10cSrcweir     throw (css::uno::RuntimeException)
134cdf0e10cSrcweir {
135cdf0e10cSrcweir     css::uno::Sequence< css::uno::Reference< css::frame::XDispatch > > s(
136cdf0e10cSrcweir         Requests.getLength());
137cdf0e10cSrcweir     for (sal_Int32 i = 0; i < s.getLength(); ++i) {
138cdf0e10cSrcweir         s[i] = queryDispatch(
139cdf0e10cSrcweir             Requests[i].FeatureURL, Requests[i].FrameName,
140cdf0e10cSrcweir             Requests[i].SearchFlags);
141cdf0e10cSrcweir     }
142cdf0e10cSrcweir     return s;
143cdf0e10cSrcweir }
144cdf0e10cSrcweir 
dispatch(css::util::URL const &,css::uno::Sequence<css::beans::PropertyValue> const &)145cdf0e10cSrcweir void Service::dispatch(
146cdf0e10cSrcweir     css::util::URL const &,
147cdf0e10cSrcweir     css::uno::Sequence< css::beans::PropertyValue > const &)
148cdf0e10cSrcweir     throw (css::uno::RuntimeException)
149cdf0e10cSrcweir {
150cdf0e10cSrcweir     msfilter::ConvertCountryToLanguage(msfilter::COUNTRY_DONTKNOW);
151cdf0e10cSrcweir         // link against some obscure library that is unlikely already loaded
152cdf0e10cSrcweir     Application::ShowNativeErrorBox(
153cdf0e10cSrcweir         rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("boxt")),
154cdf0e10cSrcweir         rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("test")));
155cdf0e10cSrcweir }
156cdf0e10cSrcweir 
157cdf0e10cSrcweir static cppu::ImplementationEntry const services[] = {
158cdf0e10cSrcweir     { &Service::static_create, &Service::static_getImplementationName,
159cdf0e10cSrcweir       &Service::static_getSupportedServiceNames,
160cdf0e10cSrcweir       &cppu::createSingleComponentFactory, 0, 0 },
161cdf0e10cSrcweir     { 0, 0, 0, 0, 0, 0 }
162cdf0e10cSrcweir };
163cdf0e10cSrcweir 
164cdf0e10cSrcweir }
165cdf0e10cSrcweir 
component_getFactory(char const * pImplName,void * pServiceManager,void * pRegistryKey)166cdf0e10cSrcweir extern "C" void * SAL_CALL component_getFactory(
167cdf0e10cSrcweir     char const * pImplName, void * pServiceManager, void * pRegistryKey)
168cdf0e10cSrcweir {
169cdf0e10cSrcweir     return cppu::component_getFactoryHelper(
170cdf0e10cSrcweir         pImplName, pServiceManager, pRegistryKey, services);
171cdf0e10cSrcweir }
172cdf0e10cSrcweir 
component_getImplementationEnvironment(char const ** ppEnvTypeName,uno_Environment **)173cdf0e10cSrcweir extern "C" void SAL_CALL component_getImplementationEnvironment(
174cdf0e10cSrcweir     char const ** ppEnvTypeName, uno_Environment **)
175cdf0e10cSrcweir {
176cdf0e10cSrcweir     *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
177cdf0e10cSrcweir }
178cdf0e10cSrcweir 
component_writeInfo(void * pServiceManager,void * pRegistryKey)179cdf0e10cSrcweir extern "C" sal_Bool SAL_CALL component_writeInfo(
180cdf0e10cSrcweir     void * pServiceManager, void * pRegistryKey)
181cdf0e10cSrcweir {
182cdf0e10cSrcweir     return component_writeInfoHelper(pServiceManager, pRegistryKey, services);
183cdf0e10cSrcweir }
184