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