xref: /trunk/main/svl/qa/complex/ConfigItems/helper/ConfigItemTest.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir #include "HistoryOptTest.hxx"
29*cdf0e10cSrcweir // #include "AccessibilityOptTest.hxx"
30*cdf0e10cSrcweir // #include "PrintOptTest.hxx"
31*cdf0e10cSrcweir #include "UserOptTest.hxx"
32*cdf0e10cSrcweir 
33*cdf0e10cSrcweir #include <com/sun/star/uno/XComponentContext.hpp>
34*cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp>
35*cdf0e10cSrcweir #include <com/sun/star/task/XJob.hpp>
36*cdf0e10cSrcweir #include <com/sun/star/beans/NamedValue.hpp>
37*cdf0e10cSrcweir 
38*cdf0e10cSrcweir #include <sal/config.h>
39*cdf0e10cSrcweir #include <rtl/ustring.hxx>
40*cdf0e10cSrcweir #include <cppuhelper/implbase2.hxx>
41*cdf0e10cSrcweir #include <cppuhelper/implementationentry.hxx>
42*cdf0e10cSrcweir 
43*cdf0e10cSrcweir //=============================================================================
44*cdf0e10cSrcweir namespace css = ::com::sun::star;
45*cdf0e10cSrcweir 
46*cdf0e10cSrcweir namespace svl{
47*cdf0e10cSrcweir 
48*cdf0e10cSrcweir //=============================================================================
49*cdf0e10cSrcweir static const ::rtl::OUString PROP_TEST                  = ::rtl::OUString::createFromAscii("Test");
50*cdf0e10cSrcweir static const ::rtl::OUString TEST_PICKLIST              = ::rtl::OUString::createFromAscii("checkPicklist");
51*cdf0e10cSrcweir static const ::rtl::OUString TEST_URLHISTORY            = ::rtl::OUString::createFromAscii("checkURLHistory");
52*cdf0e10cSrcweir static const ::rtl::OUString TEST_HELPBOOKMARKS         = ::rtl::OUString::createFromAscii("checkHelpBookmarks");
53*cdf0e10cSrcweir // static const ::rtl::OUString TEST_ACCESSIBILITYOPTIONS  = ::rtl::OUString::createFromAscii("checkAccessibilityOptions");
54*cdf0e10cSrcweir // static const ::rtl::OUString TEST_PRINTOPTIONS          = ::rtl::OUString::createFromAscii("checkPrintOptions");
55*cdf0e10cSrcweir static const ::rtl::OUString TEST_USEROPTIONS           = ::rtl::OUString::createFromAscii("checkUserOptions");
56*cdf0e10cSrcweir 
57*cdf0e10cSrcweir //=============================================================================
58*cdf0e10cSrcweir class ConfigItemTest : public ::cppu::WeakImplHelper2< css::task::XJob         ,
59*cdf0e10cSrcweir                                                         css::lang::XServiceInfo >
60*cdf0e10cSrcweir {
61*cdf0e10cSrcweir     //-------------------------------------------------------------------------
62*cdf0e10cSrcweir     // interface
63*cdf0e10cSrcweir     public:
64*cdf0e10cSrcweir         explicit ConfigItemTest(const css::uno::Reference< css::uno::XComponentContext >& xContext);
65*cdf0e10cSrcweir 
66*cdf0e10cSrcweir         // css::task::XJob
67*cdf0e10cSrcweir         virtual css::uno::Any SAL_CALL execute(const css::uno::Sequence< css::beans::NamedValue >& lArguments)
68*cdf0e10cSrcweir             throw (css::uno::RuntimeException         ,
69*cdf0e10cSrcweir                    css::lang::IllegalArgumentException,
70*cdf0e10cSrcweir                    css::uno::Exception                );
71*cdf0e10cSrcweir 
72*cdf0e10cSrcweir         // css::lang::XServiceInfo
73*cdf0e10cSrcweir         virtual ::rtl::OUString SAL_CALL getImplementationName()
74*cdf0e10cSrcweir             throw (css::uno::RuntimeException);
75*cdf0e10cSrcweir 
76*cdf0e10cSrcweir         virtual ::sal_Bool SAL_CALL supportsService(const ::rtl::OUString& sServiceName)
77*cdf0e10cSrcweir             throw (css::uno::RuntimeException);
78*cdf0e10cSrcweir 
79*cdf0e10cSrcweir         virtual css::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
80*cdf0e10cSrcweir             throw (css::uno::RuntimeException);
81*cdf0e10cSrcweir 
82*cdf0e10cSrcweir     //-------------------------------------------------------------------------
83*cdf0e10cSrcweir     // internal
84*cdf0e10cSrcweir     private:
85*cdf0e10cSrcweir         ConfigItemTest(ConfigItemTest &); // not defined
86*cdf0e10cSrcweir         virtual ~ConfigItemTest() {}
87*cdf0e10cSrcweir         void operator=(ConfigItemTest &); // not defined
88*cdf0e10cSrcweir 
89*cdf0e10cSrcweir     //-------------------------------------------------------------------------
90*cdf0e10cSrcweir     // helper for registration !
91*cdf0e10cSrcweir     public:
92*cdf0e10cSrcweir         static ::rtl::OUString SAL_CALL st_getImplementationName();
93*cdf0e10cSrcweir         static css::uno::Sequence< ::rtl::OUString > SAL_CALL st_getSupportedServiceNames();
94*cdf0e10cSrcweir         static css::uno::Reference< css::uno::XInterface > SAL_CALL st_create(const css::uno::Reference< css::uno::XComponentContext >& XContext);
95*cdf0e10cSrcweir 
96*cdf0e10cSrcweir     //-------------------------------------------------------------------------
97*cdf0e10cSrcweir     // member
98*cdf0e10cSrcweir     private:
99*cdf0e10cSrcweir         css::uno::Reference< css::uno::XComponentContext >  m_xContext;
100*cdf0e10cSrcweir };
101*cdf0e10cSrcweir 
102*cdf0e10cSrcweir //=============================================================================
103*cdf0e10cSrcweir ConfigItemTest::ConfigItemTest(const css::uno::Reference< css::uno::XComponentContext >& xContext)
104*cdf0e10cSrcweir     : m_xContext(xContext)
105*cdf0e10cSrcweir {}
106*cdf0e10cSrcweir 
107*cdf0e10cSrcweir //=============================================================================
108*cdf0e10cSrcweir // css::task::XJob
109*cdf0e10cSrcweir css::uno::Any SAL_CALL ConfigItemTest::execute(const css::uno::Sequence< css::beans::NamedValue >& lArguments)
110*cdf0e10cSrcweir     throw (css::uno::RuntimeException         ,
111*cdf0e10cSrcweir            css::lang::IllegalArgumentException,
112*cdf0e10cSrcweir            css::uno::Exception                )
113*cdf0e10cSrcweir {
114*cdf0e10cSrcweir     ::rtl::OUString sTest;
115*cdf0e10cSrcweir     ::sal_Int32     i    = 0;
116*cdf0e10cSrcweir     ::sal_Int32     c    = lArguments.getLength();
117*cdf0e10cSrcweir     for (i=0; i<c; ++i)
118*cdf0e10cSrcweir     {
119*cdf0e10cSrcweir         const css::beans::NamedValue& rArg = lArguments[0];
120*cdf0e10cSrcweir         if (rArg.Name.equals(PROP_TEST))
121*cdf0e10cSrcweir             rArg.Value >>= sTest;
122*cdf0e10cSrcweir     }
123*cdf0e10cSrcweir 
124*cdf0e10cSrcweir     if (sTest.equals(TEST_PICKLIST))
125*cdf0e10cSrcweir     {
126*cdf0e10cSrcweir         HistoryOptTest aOptTest;
127*cdf0e10cSrcweir         aOptTest.checkPicklist();
128*cdf0e10cSrcweir     }
129*cdf0e10cSrcweir     else if (sTest.equals(TEST_URLHISTORY))
130*cdf0e10cSrcweir     {
131*cdf0e10cSrcweir         HistoryOptTest aOptTest;
132*cdf0e10cSrcweir         aOptTest.checkURLHistory();
133*cdf0e10cSrcweir     }
134*cdf0e10cSrcweir     else if (sTest.equals(TEST_HELPBOOKMARKS))
135*cdf0e10cSrcweir     {
136*cdf0e10cSrcweir         HistoryOptTest aOptTest;
137*cdf0e10cSrcweir         aOptTest.checkHelpBookmarks();
138*cdf0e10cSrcweir     }
139*cdf0e10cSrcweir //  else if (sTest.equals(TEST_ACCESSIBILITYOPTIONS))
140*cdf0e10cSrcweir //  {
141*cdf0e10cSrcweir //      AccessibilityOptTest aOptTest;
142*cdf0e10cSrcweir //      aOptTest.impl_checkAccessibilityOptions();
143*cdf0e10cSrcweir //  }
144*cdf0e10cSrcweir //  else if (sTest.equals(TEST_PRINTOPTIONS))
145*cdf0e10cSrcweir //  {
146*cdf0e10cSrcweir //         PrintOptTest aOptTest;
147*cdf0e10cSrcweir //         aOptTest.impl_checkPrint();
148*cdf0e10cSrcweir //  }
149*cdf0e10cSrcweir     else if (sTest.equals(TEST_USEROPTIONS))
150*cdf0e10cSrcweir     {
151*cdf0e10cSrcweir         UserOptTest aOptTest;
152*cdf0e10cSrcweir         aOptTest.impl_checkUserData();
153*cdf0e10cSrcweir     }
154*cdf0e10cSrcweir 
155*cdf0e10cSrcweir     return css::uno::Any();
156*cdf0e10cSrcweir }
157*cdf0e10cSrcweir 
158*cdf0e10cSrcweir //=============================================================================
159*cdf0e10cSrcweir // com::sun::star::uno::XServiceInfo
160*cdf0e10cSrcweir ::rtl::OUString SAL_CALL ConfigItemTest::getImplementationName()
161*cdf0e10cSrcweir     throw (css::uno::RuntimeException)
162*cdf0e10cSrcweir {
163*cdf0e10cSrcweir     return ConfigItemTest::st_getImplementationName();
164*cdf0e10cSrcweir }
165*cdf0e10cSrcweir 
166*cdf0e10cSrcweir //=============================================================================
167*cdf0e10cSrcweir // com::sun::star::uno::XServiceInfo
168*cdf0e10cSrcweir ::sal_Bool SAL_CALL ConfigItemTest::supportsService(const ::rtl::OUString& sServiceName)
169*cdf0e10cSrcweir     throw (css::uno::RuntimeException)
170*cdf0e10cSrcweir {
171*cdf0e10cSrcweir     css::uno::Sequence< ::rtl::OUString > lServiceNames = ConfigItemTest::st_getSupportedServiceNames();
172*cdf0e10cSrcweir     for (::sal_Int32 i = 0; i < lServiceNames.getLength(); ++i)
173*cdf0e10cSrcweir     {
174*cdf0e10cSrcweir         if (lServiceNames[i].equals(sServiceName))
175*cdf0e10cSrcweir             return sal_True;
176*cdf0e10cSrcweir     }
177*cdf0e10cSrcweir     return sal_False;
178*cdf0e10cSrcweir }
179*cdf0e10cSrcweir 
180*cdf0e10cSrcweir //=============================================================================
181*cdf0e10cSrcweir // com::sun::star::uno::XServiceInfo
182*cdf0e10cSrcweir css::uno::Sequence< ::rtl::OUString > SAL_CALL ConfigItemTest::getSupportedServiceNames()
183*cdf0e10cSrcweir     throw (css::uno::RuntimeException)
184*cdf0e10cSrcweir {
185*cdf0e10cSrcweir     return ConfigItemTest::st_getSupportedServiceNames();
186*cdf0e10cSrcweir }
187*cdf0e10cSrcweir 
188*cdf0e10cSrcweir //=============================================================================
189*cdf0e10cSrcweir ::rtl::OUString SAL_CALL ConfigItemTest::st_getImplementationName()
190*cdf0e10cSrcweir {
191*cdf0e10cSrcweir     return ::rtl::OUString::createFromAscii("com.sun.star.comp.svl.ConfigItemTest");
192*cdf0e10cSrcweir }
193*cdf0e10cSrcweir 
194*cdf0e10cSrcweir //=============================================================================
195*cdf0e10cSrcweir css::uno::Sequence< ::rtl::OUString > SAL_CALL ConfigItemTest::st_getSupportedServiceNames()
196*cdf0e10cSrcweir {
197*cdf0e10cSrcweir     css::uno::Sequence< ::rtl::OUString > lServices(1);
198*cdf0e10cSrcweir     lServices[0] = ::rtl::OUString::createFromAscii("com.sun.star.test.ConfigItems");
199*cdf0e10cSrcweir     return lServices;
200*cdf0e10cSrcweir }
201*cdf0e10cSrcweir 
202*cdf0e10cSrcweir //=============================================================================
203*cdf0e10cSrcweir css::uno::Reference< css::uno::XInterface > SAL_CALL ConfigItemTest::st_create(const css::uno::Reference< css::uno::XComponentContext >& xContext)
204*cdf0e10cSrcweir {
205*cdf0e10cSrcweir     ConfigItemTest*                            pObject = new ConfigItemTest(xContext);
206*cdf0e10cSrcweir     css::uno::Reference< css::uno::XInterface > xObject (static_cast< ::cppu::OWeakObject* >(pObject));
207*cdf0e10cSrcweir     return xObject;
208*cdf0e10cSrcweir }
209*cdf0e10cSrcweir 
210*cdf0e10cSrcweir } // namespace svl
211*cdf0e10cSrcweir 
212*cdf0e10cSrcweir //=============================================================================
213*cdf0e10cSrcweir static ::cppu::ImplementationEntry const lRegEntries[] =
214*cdf0e10cSrcweir {
215*cdf0e10cSrcweir     {
216*cdf0e10cSrcweir         &::svl::ConfigItemTest::st_create,
217*cdf0e10cSrcweir         &::svl::ConfigItemTest::st_getImplementationName,
218*cdf0e10cSrcweir         &::svl::ConfigItemTest::st_getSupportedServiceNames,
219*cdf0e10cSrcweir         &::cppu::createSingleComponentFactory, 0, 0
220*cdf0e10cSrcweir     },
221*cdf0e10cSrcweir 
222*cdf0e10cSrcweir     { 0, 0, 0, 0, 0, 0 }
223*cdf0e10cSrcweir };
224*cdf0e10cSrcweir 
225*cdf0e10cSrcweir //=============================================================================
226*cdf0e10cSrcweir extern "C" void SAL_CALL component_getImplementationEnvironment(const char**            pEnvTypeName,
227*cdf0e10cSrcweir                                                                       uno_Environment**             )
228*cdf0e10cSrcweir {
229*cdf0e10cSrcweir     *pEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
230*cdf0e10cSrcweir }
231*cdf0e10cSrcweir 
232*cdf0e10cSrcweir //=============================================================================
233*cdf0e10cSrcweir extern "C" void * SAL_CALL component_getFactory(const char* sImplName      ,
234*cdf0e10cSrcweir                                                       void* pServiceManager,
235*cdf0e10cSrcweir                                                       void* pRegistryKey   )
236*cdf0e10cSrcweir {
237*cdf0e10cSrcweir     return ::cppu::component_getFactoryHelper(sImplName, pServiceManager, pRegistryKey, lRegEntries);
238*cdf0e10cSrcweir }
239*cdf0e10cSrcweir 
240*cdf0e10cSrcweir //=============================================================================
241*cdf0e10cSrcweir extern "C" sal_Bool SAL_CALL component_writeInfo(void* pServiceManager,
242*cdf0e10cSrcweir                                                  void* pRegistryKey   )
243*cdf0e10cSrcweir {
244*cdf0e10cSrcweir     return ::cppu::component_writeInfoHelper(pServiceManager, pRegistryKey, lRegEntries);
245*cdf0e10cSrcweir }
246