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 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_svtools.hxx" 26 27 #include "hatchwindowfactory.hxx" 28 #include "hatchwindow.hxx" 29 #include "cppuhelper/factory.hxx" 30 #include <vcl/svapp.hxx> 31 32 #include "documentcloser.hxx" 33 34 using namespace ::com::sun::star; 35 36 //------------------------------------------------------------------------- 37 uno::Sequence< ::rtl::OUString > SAL_CALL OHatchWindowFactory::impl_staticGetSupportedServiceNames() 38 { 39 uno::Sequence< ::rtl::OUString > aRet(2); 40 aRet[0] = ::rtl::OUString::createFromAscii("com.sun.star.embed.HatchWindowFactory"); 41 aRet[1] = ::rtl::OUString::createFromAscii("com.sun.star.comp.embed.HatchWindowFactory"); 42 return aRet; 43 } 44 45 //------------------------------------------------------------------------- 46 ::rtl::OUString SAL_CALL OHatchWindowFactory::impl_staticGetImplementationName() 47 { 48 return ::rtl::OUString::createFromAscii("com.sun.star.comp.embed.HatchWindowFactory"); 49 } 50 51 //------------------------------------------------------------------------- 52 uno::Reference< uno::XInterface > SAL_CALL OHatchWindowFactory::impl_staticCreateSelfInstance( 53 const uno::Reference< lang::XMultiServiceFactory >& xServiceManager ) 54 { 55 return uno::Reference< uno::XInterface >( *new OHatchWindowFactory( xServiceManager ) ); 56 } 57 58 59 //------------------------------------------------------------------------- 60 uno::Reference< embed::XHatchWindow > SAL_CALL OHatchWindowFactory::createHatchWindowInstance( 61 const uno::Reference< awt::XWindowPeer >& xParent, 62 const awt::Rectangle& aBounds, 63 const awt::Size& aHandlerSize ) 64 { 65 if ( !xParent.is() ) 66 throw lang::IllegalArgumentException(); // TODO 67 68 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 69 VCLXHatchWindow* pResult = new VCLXHatchWindow(); 70 pResult->initializeWindow( xParent, aBounds, aHandlerSize ); 71 return uno::Reference< embed::XHatchWindow >( static_cast< embed::XHatchWindow* >( pResult ) ); 72 } 73 74 //------------------------------------------------------------------------- 75 ::rtl::OUString SAL_CALL OHatchWindowFactory::getImplementationName() 76 { 77 return impl_staticGetImplementationName(); 78 } 79 80 //------------------------------------------------------------------------- 81 sal_Bool SAL_CALL OHatchWindowFactory::supportsService( const ::rtl::OUString& ServiceName ) 82 { 83 uno::Sequence< ::rtl::OUString > aSeq = impl_staticGetSupportedServiceNames(); 84 85 for ( sal_Int32 nInd = 0; nInd < aSeq.getLength(); nInd++ ) 86 if ( ServiceName.compareTo( aSeq[nInd] ) == 0 ) 87 return sal_True; 88 89 return sal_False; 90 } 91 92 //------------------------------------------------------------------------- 93 uno::Sequence< ::rtl::OUString > SAL_CALL OHatchWindowFactory::getSupportedServiceNames() 94 { 95 return impl_staticGetSupportedServiceNames(); 96 } 97 98 //------------------------------------------------------------------------- 99 100 extern "C" 101 { 102 103 SAL_DLLPUBLIC_EXPORT void SAL_CALL component_getImplementationEnvironment ( 104 const sal_Char ** ppEnvTypeName, uno_Environment ** /* ppEnv */) 105 { 106 *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; 107 } 108 109 SAL_DLLPUBLIC_EXPORT void * SAL_CALL component_getFactory ( 110 const sal_Char * pImplementationName, void * pServiceManager, void * /* pRegistryKey */) 111 { 112 void * pResult = 0; 113 if (pServiceManager) 114 { 115 uno::Reference< lang::XSingleServiceFactory > xFactory; 116 if (OHatchWindowFactory::impl_staticGetImplementationName().compareToAscii (pImplementationName ) == 0) 117 { 118 xFactory = cppu::createOneInstanceFactory( 119 reinterpret_cast< lang::XMultiServiceFactory* >(pServiceManager), 120 OHatchWindowFactory::impl_staticGetImplementationName(), 121 OHatchWindowFactory::impl_staticCreateSelfInstance, 122 OHatchWindowFactory::impl_staticGetSupportedServiceNames()); 123 } 124 else if (ODocumentCloser::impl_staticGetImplementationName().compareToAscii (pImplementationName ) == 0) 125 { 126 xFactory = cppu::createSingleFactory( 127 reinterpret_cast< lang::XMultiServiceFactory* >( pServiceManager ), 128 ODocumentCloser::impl_staticGetImplementationName(), 129 ODocumentCloser::impl_staticCreateSelfInstance, 130 ODocumentCloser::impl_staticGetSupportedServiceNames() ); 131 } 132 133 if (xFactory.is()) 134 { 135 xFactory->acquire(); 136 pResult = xFactory.get(); 137 } 138 } 139 return pResult; 140 } 141 142 } // extern "C" 143