merge the formfield patch from ooo-build
[ooovba.git] / ure / source / uretest / cppserver.cc
blob2c96b8a0cfe78ea1eba7aac3d0c884c9fe7c5913
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: cppserver.cc,v $
10 * $Revision: 1.3 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #include "sal/config.h"
33 #include <new>
35 #include "com/sun/star/uno/Exception.hpp"
36 #include "com/sun/star/uno/Reference.hxx"
37 #include "com/sun/star/uno/RuntimeException.hpp"
38 #include "com/sun/star/uno/Sequence.hxx"
39 #include "com/sun/star/uno/XComponentContext.hpp"
40 #include "com/sun/star/uno/XInterface.hpp"
41 #include "cppuhelper/factory.hxx"
42 #include "cppuhelper/implbase1.hxx"
43 #include "cppuhelper/implementationentry.hxx"
44 #include "cppuhelper/weak.hxx"
45 #include "rtl/ustring.h"
46 #include "rtl/ustring.hxx"
47 #include "sal/types.h"
48 #include "uno/environment.h"
49 #include "uno/lbnames.h"
51 #include "test/types/Data.hpp"
52 #include "test/types/XServer.hpp"
54 namespace css = ::com::sun::star;
56 namespace {
58 class Service: public ::cppu::WeakImplHelper1< ::test::types::XServer > {
59 public:
60 Service() {}
62 virtual ::test::types::Data SAL_CALL getData()
63 throw (::css::uno::RuntimeException)
65 return ::test::types::Data(
66 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Hello")), 42);
69 private:
70 Service(Service &); // not defined
71 void operator =(Service &); // not defined
73 virtual ~Service() {}
76 namespace CppServer {
78 ::css::uno::Reference< ::css::uno::XInterface > create(
79 ::css::uno::Reference< ::css::uno::XComponentContext > const &)
80 SAL_THROW((::css::uno::Exception))
82 try {
83 return static_cast< ::cppu::OWeakObject * >(new Service);
84 } catch (::std::bad_alloc &) {
85 throw ::css::uno::RuntimeException(
86 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("std::bad_alloc")),
87 ::css::uno::Reference< ::css::uno::XInterface >());
91 ::rtl::OUString getImplementationName() {
92 return ::rtl::OUString(
93 RTL_CONSTASCII_USTRINGPARAM("test.cpp.cppserver.Component"));
96 ::css::uno::Sequence< ::rtl::OUString > getSupportedServiceNames() {
97 return ::css::uno::Sequence< ::rtl::OUString >();
102 ::cppu::ImplementationEntry entries[] = {
103 { CppServer::create, CppServer::getImplementationName,
104 CppServer::getSupportedServiceNames, ::cppu::createSingleComponentFactory,
105 0, 0 },
106 { 0, 0, 0, 0, 0, 0 } };
110 extern "C" ::sal_Bool SAL_CALL component_writeInfo(
111 void * serviceManager, void * registryKey)
113 return ::cppu::component_writeInfoHelper(
114 serviceManager, registryKey, entries);
117 extern "C" void * SAL_CALL component_getFactory(
118 char const * implName, void * serviceManager, void * registryKey)
120 return ::cppu::component_getFactoryHelper(
121 implName, serviceManager, registryKey, entries);
124 extern "C" void SAL_CALL component_getImplementationEnvironment(
125 char const ** envTypeName, ::uno_Environment **)
127 *envTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;