1*40df464eSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*40df464eSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*40df464eSAndrew Rist * or more contributor license agreements. See the NOTICE file
5*40df464eSAndrew Rist * distributed with this work for additional information
6*40df464eSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*40df464eSAndrew Rist * to you under the Apache License, Version 2.0 (the
8*40df464eSAndrew Rist * "License"); you may not use this file except in compliance
9*40df464eSAndrew Rist * with the License. You may obtain a copy of the License at
10*40df464eSAndrew Rist *
11*40df464eSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*40df464eSAndrew Rist *
13*40df464eSAndrew Rist * Unless required by applicable law or agreed to in writing,
14*40df464eSAndrew Rist * software distributed under the License is distributed on an
15*40df464eSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*40df464eSAndrew Rist * KIND, either express or implied. See the License for the
17*40df464eSAndrew Rist * specific language governing permissions and limitations
18*40df464eSAndrew Rist * under the License.
19*40df464eSAndrew Rist *
20*40df464eSAndrew Rist *************************************************************/
21*40df464eSAndrew Rist
22*40df464eSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir #include "HistoryOptTest.hxx"
25cdf0e10cSrcweir // #include "AccessibilityOptTest.hxx"
26cdf0e10cSrcweir // #include "PrintOptTest.hxx"
27cdf0e10cSrcweir #include "UserOptTest.hxx"
28cdf0e10cSrcweir
29cdf0e10cSrcweir #include <com/sun/star/uno/XComponentContext.hpp>
30cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp>
31cdf0e10cSrcweir #include <com/sun/star/task/XJob.hpp>
32cdf0e10cSrcweir #include <com/sun/star/beans/NamedValue.hpp>
33cdf0e10cSrcweir
34cdf0e10cSrcweir #include <sal/config.h>
35cdf0e10cSrcweir #include <rtl/ustring.hxx>
36cdf0e10cSrcweir #include <cppuhelper/implbase2.hxx>
37cdf0e10cSrcweir #include <cppuhelper/implementationentry.hxx>
38cdf0e10cSrcweir
39cdf0e10cSrcweir //=============================================================================
40cdf0e10cSrcweir namespace css = ::com::sun::star;
41cdf0e10cSrcweir
42cdf0e10cSrcweir namespace svl{
43cdf0e10cSrcweir
44cdf0e10cSrcweir //=============================================================================
45cdf0e10cSrcweir static const ::rtl::OUString PROP_TEST = ::rtl::OUString::createFromAscii("Test");
46cdf0e10cSrcweir static const ::rtl::OUString TEST_PICKLIST = ::rtl::OUString::createFromAscii("checkPicklist");
47cdf0e10cSrcweir static const ::rtl::OUString TEST_URLHISTORY = ::rtl::OUString::createFromAscii("checkURLHistory");
48cdf0e10cSrcweir static const ::rtl::OUString TEST_HELPBOOKMARKS = ::rtl::OUString::createFromAscii("checkHelpBookmarks");
49cdf0e10cSrcweir // static const ::rtl::OUString TEST_ACCESSIBILITYOPTIONS = ::rtl::OUString::createFromAscii("checkAccessibilityOptions");
50cdf0e10cSrcweir // static const ::rtl::OUString TEST_PRINTOPTIONS = ::rtl::OUString::createFromAscii("checkPrintOptions");
51cdf0e10cSrcweir static const ::rtl::OUString TEST_USEROPTIONS = ::rtl::OUString::createFromAscii("checkUserOptions");
52cdf0e10cSrcweir
53cdf0e10cSrcweir //=============================================================================
54cdf0e10cSrcweir class ConfigItemTest : public ::cppu::WeakImplHelper2< css::task::XJob ,
55cdf0e10cSrcweir css::lang::XServiceInfo >
56cdf0e10cSrcweir {
57cdf0e10cSrcweir //-------------------------------------------------------------------------
58cdf0e10cSrcweir // interface
59cdf0e10cSrcweir public:
60cdf0e10cSrcweir explicit ConfigItemTest(const css::uno::Reference< css::uno::XComponentContext >& xContext);
61cdf0e10cSrcweir
62cdf0e10cSrcweir // css::task::XJob
63cdf0e10cSrcweir virtual css::uno::Any SAL_CALL execute(const css::uno::Sequence< css::beans::NamedValue >& lArguments)
64cdf0e10cSrcweir throw (css::uno::RuntimeException ,
65cdf0e10cSrcweir css::lang::IllegalArgumentException,
66cdf0e10cSrcweir css::uno::Exception );
67cdf0e10cSrcweir
68cdf0e10cSrcweir // css::lang::XServiceInfo
69cdf0e10cSrcweir virtual ::rtl::OUString SAL_CALL getImplementationName()
70cdf0e10cSrcweir throw (css::uno::RuntimeException);
71cdf0e10cSrcweir
72cdf0e10cSrcweir virtual ::sal_Bool SAL_CALL supportsService(const ::rtl::OUString& sServiceName)
73cdf0e10cSrcweir throw (css::uno::RuntimeException);
74cdf0e10cSrcweir
75cdf0e10cSrcweir virtual css::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
76cdf0e10cSrcweir throw (css::uno::RuntimeException);
77cdf0e10cSrcweir
78cdf0e10cSrcweir //-------------------------------------------------------------------------
79cdf0e10cSrcweir // internal
80cdf0e10cSrcweir private:
81cdf0e10cSrcweir ConfigItemTest(ConfigItemTest &); // not defined
~ConfigItemTest()82cdf0e10cSrcweir virtual ~ConfigItemTest() {}
83cdf0e10cSrcweir void operator=(ConfigItemTest &); // not defined
84cdf0e10cSrcweir
85cdf0e10cSrcweir //-------------------------------------------------------------------------
86cdf0e10cSrcweir // helper for registration !
87cdf0e10cSrcweir public:
88cdf0e10cSrcweir static ::rtl::OUString SAL_CALL st_getImplementationName();
89cdf0e10cSrcweir static css::uno::Sequence< ::rtl::OUString > SAL_CALL st_getSupportedServiceNames();
90cdf0e10cSrcweir static css::uno::Reference< css::uno::XInterface > SAL_CALL st_create(const css::uno::Reference< css::uno::XComponentContext >& XContext);
91cdf0e10cSrcweir
92cdf0e10cSrcweir //-------------------------------------------------------------------------
93cdf0e10cSrcweir // member
94cdf0e10cSrcweir private:
95cdf0e10cSrcweir css::uno::Reference< css::uno::XComponentContext > m_xContext;
96cdf0e10cSrcweir };
97cdf0e10cSrcweir
98cdf0e10cSrcweir //=============================================================================
ConfigItemTest(const css::uno::Reference<css::uno::XComponentContext> & xContext)99cdf0e10cSrcweir ConfigItemTest::ConfigItemTest(const css::uno::Reference< css::uno::XComponentContext >& xContext)
100cdf0e10cSrcweir : m_xContext(xContext)
101cdf0e10cSrcweir {}
102cdf0e10cSrcweir
103cdf0e10cSrcweir //=============================================================================
104cdf0e10cSrcweir // css::task::XJob
execute(const css::uno::Sequence<css::beans::NamedValue> & lArguments)105cdf0e10cSrcweir css::uno::Any SAL_CALL ConfigItemTest::execute(const css::uno::Sequence< css::beans::NamedValue >& lArguments)
106cdf0e10cSrcweir throw (css::uno::RuntimeException ,
107cdf0e10cSrcweir css::lang::IllegalArgumentException,
108cdf0e10cSrcweir css::uno::Exception )
109cdf0e10cSrcweir {
110cdf0e10cSrcweir ::rtl::OUString sTest;
111cdf0e10cSrcweir ::sal_Int32 i = 0;
112cdf0e10cSrcweir ::sal_Int32 c = lArguments.getLength();
113cdf0e10cSrcweir for (i=0; i<c; ++i)
114cdf0e10cSrcweir {
115cdf0e10cSrcweir const css::beans::NamedValue& rArg = lArguments[0];
116cdf0e10cSrcweir if (rArg.Name.equals(PROP_TEST))
117cdf0e10cSrcweir rArg.Value >>= sTest;
118cdf0e10cSrcweir }
119cdf0e10cSrcweir
120cdf0e10cSrcweir if (sTest.equals(TEST_PICKLIST))
121cdf0e10cSrcweir {
122cdf0e10cSrcweir HistoryOptTest aOptTest;
123cdf0e10cSrcweir aOptTest.checkPicklist();
124cdf0e10cSrcweir }
125cdf0e10cSrcweir else if (sTest.equals(TEST_URLHISTORY))
126cdf0e10cSrcweir {
127cdf0e10cSrcweir HistoryOptTest aOptTest;
128cdf0e10cSrcweir aOptTest.checkURLHistory();
129cdf0e10cSrcweir }
130cdf0e10cSrcweir else if (sTest.equals(TEST_HELPBOOKMARKS))
131cdf0e10cSrcweir {
132cdf0e10cSrcweir HistoryOptTest aOptTest;
133cdf0e10cSrcweir aOptTest.checkHelpBookmarks();
134cdf0e10cSrcweir }
135cdf0e10cSrcweir // else if (sTest.equals(TEST_ACCESSIBILITYOPTIONS))
136cdf0e10cSrcweir // {
137cdf0e10cSrcweir // AccessibilityOptTest aOptTest;
138cdf0e10cSrcweir // aOptTest.impl_checkAccessibilityOptions();
139cdf0e10cSrcweir // }
140cdf0e10cSrcweir // else if (sTest.equals(TEST_PRINTOPTIONS))
141cdf0e10cSrcweir // {
142cdf0e10cSrcweir // PrintOptTest aOptTest;
143cdf0e10cSrcweir // aOptTest.impl_checkPrint();
144cdf0e10cSrcweir // }
145cdf0e10cSrcweir else if (sTest.equals(TEST_USEROPTIONS))
146cdf0e10cSrcweir {
147cdf0e10cSrcweir UserOptTest aOptTest;
148cdf0e10cSrcweir aOptTest.impl_checkUserData();
149cdf0e10cSrcweir }
150cdf0e10cSrcweir
151cdf0e10cSrcweir return css::uno::Any();
152cdf0e10cSrcweir }
153cdf0e10cSrcweir
154cdf0e10cSrcweir //=============================================================================
155cdf0e10cSrcweir // com::sun::star::uno::XServiceInfo
getImplementationName()156cdf0e10cSrcweir ::rtl::OUString SAL_CALL ConfigItemTest::getImplementationName()
157cdf0e10cSrcweir throw (css::uno::RuntimeException)
158cdf0e10cSrcweir {
159cdf0e10cSrcweir return ConfigItemTest::st_getImplementationName();
160cdf0e10cSrcweir }
161cdf0e10cSrcweir
162cdf0e10cSrcweir //=============================================================================
163cdf0e10cSrcweir // com::sun::star::uno::XServiceInfo
supportsService(const::rtl::OUString & sServiceName)164cdf0e10cSrcweir ::sal_Bool SAL_CALL ConfigItemTest::supportsService(const ::rtl::OUString& sServiceName)
165cdf0e10cSrcweir throw (css::uno::RuntimeException)
166cdf0e10cSrcweir {
167cdf0e10cSrcweir css::uno::Sequence< ::rtl::OUString > lServiceNames = ConfigItemTest::st_getSupportedServiceNames();
168cdf0e10cSrcweir for (::sal_Int32 i = 0; i < lServiceNames.getLength(); ++i)
169cdf0e10cSrcweir {
170cdf0e10cSrcweir if (lServiceNames[i].equals(sServiceName))
171cdf0e10cSrcweir return sal_True;
172cdf0e10cSrcweir }
173cdf0e10cSrcweir return sal_False;
174cdf0e10cSrcweir }
175cdf0e10cSrcweir
176cdf0e10cSrcweir //=============================================================================
177cdf0e10cSrcweir // com::sun::star::uno::XServiceInfo
getSupportedServiceNames()178cdf0e10cSrcweir css::uno::Sequence< ::rtl::OUString > SAL_CALL ConfigItemTest::getSupportedServiceNames()
179cdf0e10cSrcweir throw (css::uno::RuntimeException)
180cdf0e10cSrcweir {
181cdf0e10cSrcweir return ConfigItemTest::st_getSupportedServiceNames();
182cdf0e10cSrcweir }
183cdf0e10cSrcweir
184cdf0e10cSrcweir //=============================================================================
st_getImplementationName()185cdf0e10cSrcweir ::rtl::OUString SAL_CALL ConfigItemTest::st_getImplementationName()
186cdf0e10cSrcweir {
187cdf0e10cSrcweir return ::rtl::OUString::createFromAscii("com.sun.star.comp.svl.ConfigItemTest");
188cdf0e10cSrcweir }
189cdf0e10cSrcweir
190cdf0e10cSrcweir //=============================================================================
st_getSupportedServiceNames()191cdf0e10cSrcweir css::uno::Sequence< ::rtl::OUString > SAL_CALL ConfigItemTest::st_getSupportedServiceNames()
192cdf0e10cSrcweir {
193cdf0e10cSrcweir css::uno::Sequence< ::rtl::OUString > lServices(1);
194cdf0e10cSrcweir lServices[0] = ::rtl::OUString::createFromAscii("com.sun.star.test.ConfigItems");
195cdf0e10cSrcweir return lServices;
196cdf0e10cSrcweir }
197cdf0e10cSrcweir
198cdf0e10cSrcweir //=============================================================================
st_create(const css::uno::Reference<css::uno::XComponentContext> & xContext)199cdf0e10cSrcweir css::uno::Reference< css::uno::XInterface > SAL_CALL ConfigItemTest::st_create(const css::uno::Reference< css::uno::XComponentContext >& xContext)
200cdf0e10cSrcweir {
201cdf0e10cSrcweir ConfigItemTest* pObject = new ConfigItemTest(xContext);
202cdf0e10cSrcweir css::uno::Reference< css::uno::XInterface > xObject (static_cast< ::cppu::OWeakObject* >(pObject));
203cdf0e10cSrcweir return xObject;
204cdf0e10cSrcweir }
205cdf0e10cSrcweir
206cdf0e10cSrcweir } // namespace svl
207cdf0e10cSrcweir
208cdf0e10cSrcweir //=============================================================================
209cdf0e10cSrcweir static ::cppu::ImplementationEntry const lRegEntries[] =
210cdf0e10cSrcweir {
211cdf0e10cSrcweir {
212cdf0e10cSrcweir &::svl::ConfigItemTest::st_create,
213cdf0e10cSrcweir &::svl::ConfigItemTest::st_getImplementationName,
214cdf0e10cSrcweir &::svl::ConfigItemTest::st_getSupportedServiceNames,
215cdf0e10cSrcweir &::cppu::createSingleComponentFactory, 0, 0
216cdf0e10cSrcweir },
217cdf0e10cSrcweir
218cdf0e10cSrcweir { 0, 0, 0, 0, 0, 0 }
219cdf0e10cSrcweir };
220cdf0e10cSrcweir
221cdf0e10cSrcweir //=============================================================================
component_getImplementationEnvironment(const char ** pEnvTypeName,uno_Environment **)222cdf0e10cSrcweir extern "C" void SAL_CALL component_getImplementationEnvironment(const char** pEnvTypeName,
223cdf0e10cSrcweir uno_Environment** )
224cdf0e10cSrcweir {
225cdf0e10cSrcweir *pEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
226cdf0e10cSrcweir }
227cdf0e10cSrcweir
228cdf0e10cSrcweir //=============================================================================
component_getFactory(const char * sImplName,void * pServiceManager,void * pRegistryKey)229cdf0e10cSrcweir extern "C" void * SAL_CALL component_getFactory(const char* sImplName ,
230cdf0e10cSrcweir void* pServiceManager,
231cdf0e10cSrcweir void* pRegistryKey )
232cdf0e10cSrcweir {
233cdf0e10cSrcweir return ::cppu::component_getFactoryHelper(sImplName, pServiceManager, pRegistryKey, lRegEntries);
234cdf0e10cSrcweir }
235cdf0e10cSrcweir
236cdf0e10cSrcweir //=============================================================================
component_writeInfo(void * pServiceManager,void * pRegistryKey)237cdf0e10cSrcweir extern "C" sal_Bool SAL_CALL component_writeInfo(void* pServiceManager,
238cdf0e10cSrcweir void* pRegistryKey )
239cdf0e10cSrcweir {
240cdf0e10cSrcweir return ::cppu::component_writeInfoHelper(pServiceManager, pRegistryKey, lRegEntries);
241cdf0e10cSrcweir }
242