1 /*************************************************************************
3 * OpenOffice.org - a multi-platform office productivity suite
5 * $RCSfile: ConfigItemTest.cxx,v $
9 * last change: $Author: as $ $Date: 2008/03/19 11:09:23 $
11 * The Contents of this file are made available subject to
12 * the terms of GNU Lesser General Public License Version 2.1.
15 * GNU Lesser General Public License Version 2.1
16 * =============================================
17 * Copyright 2005 by Sun Microsystems, Inc.
18 * 901 San Antonio Road, Palo Alto, CA 94303, USA
20 * This library is free software; you can redistribute it and/or
21 * modify it under the terms of the GNU Lesser General Public
22 * License version 2.1, as published by the Free Software Foundation.
24 * This library is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
27 * Lesser General Public License for more details.
29 * You should have received a copy of the GNU Lesser General Public
30 * License along with this library; if not, write to the Free Software
31 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
34 ************************************************************************/
36 #include "HistoryOptTest.hxx"
37 #include "AccessibilityOptTest.hxx"
38 #include "PrintOptTest.hxx"
39 #include "UserOptTest.hxx"
41 #include <com/sun/star/uno/XComponentContext.hpp>
42 #include <com/sun/star/lang/XServiceInfo.hpp>
43 #include <com/sun/star/task/XJob.hpp>
44 #include <com/sun/star/beans/NamedValue.hpp>
46 #include <sal/config.h>
47 #include <rtl/ustring.hxx>
48 #include <cppuhelper/implbase2.hxx>
49 #include <cppuhelper/implementationentry.hxx>
51 //=============================================================================
52 namespace css
= ::com::sun::star
;
56 //=============================================================================
57 static const ::rtl::OUString PROP_TEST
= ::rtl::OUString::createFromAscii("Test");
58 static const ::rtl::OUString TEST_PICKLIST
= ::rtl::OUString::createFromAscii("checkPicklist");
59 static const ::rtl::OUString TEST_URLHISTORY
= ::rtl::OUString::createFromAscii("checkURLHistory");
60 static const ::rtl::OUString TEST_HELPBOOKMARKS
= ::rtl::OUString::createFromAscii("checkHelpBookmarks");
61 static const ::rtl::OUString TEST_ACCESSIBILITYOPTIONS
= ::rtl::OUString::createFromAscii("checkAccessibilityOptions");
62 static const ::rtl::OUString TEST_PRINTOPTIONS
= ::rtl::OUString::createFromAscii("checkPrintOptions");
63 static const ::rtl::OUString TEST_USEROPTIONS
= ::rtl::OUString::createFromAscii("checkUserOptions");
65 //=============================================================================
66 class ConfigItemTest
: public ::cppu::WeakImplHelper2
< css::task::XJob
,
67 css::lang::XServiceInfo
>
69 //-------------------------------------------------------------------------
72 explicit ConfigItemTest(const css::uno::Reference
< css::uno::XComponentContext
>& xContext
);
75 virtual css::uno::Any SAL_CALL
execute(const css::uno::Sequence
< css::beans::NamedValue
>& lArguments
)
76 throw (css::uno::RuntimeException
,
77 css::lang::IllegalArgumentException
,
78 css::uno::Exception
);
80 // css::lang::XServiceInfo
81 virtual ::rtl::OUString SAL_CALL
getImplementationName()
82 throw (css::uno::RuntimeException
);
84 virtual ::sal_Bool SAL_CALL
supportsService(const ::rtl::OUString
& sServiceName
)
85 throw (css::uno::RuntimeException
);
87 virtual css::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getSupportedServiceNames()
88 throw (css::uno::RuntimeException
);
90 //-------------------------------------------------------------------------
93 ConfigItemTest(ConfigItemTest
&); // not defined
94 virtual ~ConfigItemTest() {}
95 void operator=(ConfigItemTest
&); // not defined
97 //-------------------------------------------------------------------------
98 // helper for registration !
100 static ::rtl::OUString SAL_CALL
st_getImplementationName();
101 static css::uno::Sequence
< ::rtl::OUString
> SAL_CALL
st_getSupportedServiceNames();
102 static css::uno::Reference
< css::uno::XInterface
> SAL_CALL
st_create(const css::uno::Reference
< css::uno::XComponentContext
>& XContext
);
104 //-------------------------------------------------------------------------
107 css::uno::Reference
< css::uno::XComponentContext
> m_xContext
;
110 //=============================================================================
111 ConfigItemTest::ConfigItemTest(const css::uno::Reference
< css::uno::XComponentContext
>& xContext
)
112 : m_xContext(xContext
)
115 //=============================================================================
117 css::uno::Any SAL_CALL
ConfigItemTest::execute(const css::uno::Sequence
< css::beans::NamedValue
>& lArguments
)
118 throw (css::uno::RuntimeException
,
119 css::lang::IllegalArgumentException
,
120 css::uno::Exception
)
122 ::rtl::OUString sTest
;
124 ::sal_Int32 c
= lArguments
.getLength();
127 const css::beans::NamedValue
& rArg
= lArguments
[0];
128 if (rArg
.Name
.equals(PROP_TEST
))
129 rArg
.Value
>>= sTest
;
132 if (sTest
.equals(TEST_PICKLIST
))
134 HistoryOptTest aOptTest
;
135 aOptTest
.checkPicklist();
137 else if (sTest
.equals(TEST_URLHISTORY
))
139 HistoryOptTest aOptTest
;
140 aOptTest
.checkURLHistory();
142 else if (sTest
.equals(TEST_HELPBOOKMARKS
))
144 HistoryOptTest aOptTest
;
145 aOptTest
.checkHelpBookmarks();
147 else if (sTest
.equals(TEST_ACCESSIBILITYOPTIONS
))
149 AccessibilityOptTest aOptTest
;
150 aOptTest
.impl_checkAccessibilityOptions();
152 else if (sTest
.equals(TEST_PRINTOPTIONS
))
154 PrintOptTest aOptTest
;
155 aOptTest
.impl_checkPrint();
157 else if (sTest
.equals(TEST_USEROPTIONS
))
159 UserOptTest aOptTest
;
160 aOptTest
.impl_checkUserData();
163 return css::uno::Any();
166 //=============================================================================
167 // com::sun::star::uno::XServiceInfo
168 ::rtl::OUString SAL_CALL
ConfigItemTest::getImplementationName()
169 throw (css::uno::RuntimeException
)
171 return ConfigItemTest::st_getImplementationName();
174 //=============================================================================
175 // com::sun::star::uno::XServiceInfo
176 ::sal_Bool SAL_CALL
ConfigItemTest::supportsService(const ::rtl::OUString
& sServiceName
)
177 throw (css::uno::RuntimeException
)
179 css::uno::Sequence
< ::rtl::OUString
> lServiceNames
= ConfigItemTest::st_getSupportedServiceNames();
180 for (::sal_Int32 i
= 0; i
< lServiceNames
.getLength(); ++i
)
182 if (lServiceNames
[i
].equals(sServiceName
))
188 //=============================================================================
189 // com::sun::star::uno::XServiceInfo
190 css::uno::Sequence
< ::rtl::OUString
> SAL_CALL
ConfigItemTest::getSupportedServiceNames()
191 throw (css::uno::RuntimeException
)
193 return ConfigItemTest::st_getSupportedServiceNames();
196 //=============================================================================
197 ::rtl::OUString SAL_CALL
ConfigItemTest::st_getImplementationName()
199 return ::rtl::OUString::createFromAscii("com.sun.star.comp.svtools.ConfigItemTest");
202 //=============================================================================
203 css::uno::Sequence
< ::rtl::OUString
> SAL_CALL
ConfigItemTest::st_getSupportedServiceNames()
205 css::uno::Sequence
< ::rtl::OUString
> lServices(1);
206 lServices
[0] = ::rtl::OUString::createFromAscii("com.sun.star.test.ConfigItems");
210 //=============================================================================
211 css::uno::Reference
< css::uno::XInterface
> SAL_CALL
ConfigItemTest::st_create(const css::uno::Reference
< css::uno::XComponentContext
>& xContext
)
213 ConfigItemTest
* pObject
= new ConfigItemTest(xContext
);
214 css::uno::Reference
< css::uno::XInterface
> xObject (static_cast< ::cppu::OWeakObject
* >(pObject
));
218 } // namespace svtools
220 //=============================================================================
221 static ::cppu::ImplementationEntry
const lRegEntries
[] =
224 &::svtools::ConfigItemTest::st_create
,
225 &::svtools::ConfigItemTest::st_getImplementationName
,
226 &::svtools::ConfigItemTest::st_getSupportedServiceNames
,
227 &::cppu::createSingleComponentFactory
, 0, 0
233 //=============================================================================
234 extern "C" void SAL_CALL
component_getImplementationEnvironment(const char** pEnvTypeName
,
237 *pEnvTypeName
= CPPU_CURRENT_LANGUAGE_BINDING_NAME
;
240 //=============================================================================
241 extern "C" void * SAL_CALL
component_getFactory(const char* sImplName
,
242 void* pServiceManager
,
245 return ::cppu::component_getFactoryHelper(sImplName
, pServiceManager
, pRegistryKey
, lRegEntries
);
248 //=============================================================================
249 extern "C" sal_Bool SAL_CALL
component_writeInfo(void* pServiceManager
,
252 return ::cppu::component_writeInfoHelper(pServiceManager
, pRegistryKey
, lRegEntries
);